Java Code Examples for org.apache.tomcat.util.IntrospectionUtils#setProperty()
The following examples show how to use
org.apache.tomcat.util.IntrospectionUtils#setProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetContextPropertiesRule.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Handle the beginning of an XML element. * * @param attributes The attributes of this element * * @exception Exception if a processing error occurs */ @Override public void begin(String namespace, String nameX, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } if ("path".equals(name) || "docBase".equals(name)) { continue; } String value = attributes.getValue(i); if (!digester.isFakeAttribute(digester.peek(), name) && !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) { digester.getLogger().warn("[SetContextPropertiesRule]{" + digester.getMatch() + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } }
Example 2
Source File: SetAllPropertiesRule.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Handle the beginning of an XML element. * * @param attributes The attributes of this element * * @exception Exception if a processing error occurs */ @Override public void begin(String namespace, String nameX, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if ( !excludes.containsKey(name)) { if (!digester.isFakeAttribute(digester.peek(), name) && !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) { digester.getLogger().warn("[SetAllPropertiesRule]{" + digester.getMatch() + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } } }
Example 3
Source File: FilterBase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void init(FilterConfig filterConfig) throws ServletException { Enumeration<String> paramNames = filterConfig.getInitParameterNames(); while (paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); if (!IntrospectionUtils.setProperty(this, paramName, filterConfig.getInitParameter(paramName))) { String msg = sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName()); if (isConfigProblemFatal()) { throw new ServletException(msg); } else { getLogger().warn(msg); } } } }
Example 4
Source File: SetContextPropertiesRule.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Handle the beginning of an XML element. * * @param attributes The attributes of this element * * @exception Exception if a processing error occurs */ @Override public void begin(String namespace, String nameX, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } if ("path".equals(name) || "docBase".equals(name)) { continue; } String value = attributes.getValue(i); if (!digester.isFakeAttribute(digester.peek(), name) && !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) { digester.getLogger().warn("[SetContextPropertiesRule]{" + digester.getMatch() + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } }
Example 5
Source File: SetAllPropertiesRule.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Handle the beginning of an XML element. * * @param attributes The attributes of this element * * @exception Exception if a processing error occurs */ @Override public void begin(String namespace, String nameX, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if ( !excludes.containsKey(name)) { if (!digester.isFakeAttribute(digester.peek(), name) && !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) { digester.getLogger().warn("[SetAllPropertiesRule]{" + digester.getMatch() + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } } }
Example 6
Source File: FilterBase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Iterates over the configuration parameters and either logs a warning, * or throws an exception for any parameter that does not have a matching * setter in this filter. * * @param filterConfig The configuration information associated with the * filter instance being initialised * * @throws ServletException if {@link #isConfigProblemFatal()} returns * {@code true} and a configured parameter does not * have a matching setter */ @Override public void init(FilterConfig filterConfig) throws ServletException { Enumeration<String> paramNames = filterConfig.getInitParameterNames(); while (paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); if (!IntrospectionUtils.setProperty(this, paramName, filterConfig.getInitParameter(paramName))) { String msg = sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName()); if (isConfigProblemFatal()) { throw new ServletException(msg); } else { getLogger().warn(msg); } } } }
Example 7
Source File: ConnectorMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Set the value of a specific attribute of this MBean. * * @param attribute The identification of the attribute to be set * and the new value * * @exception AttributeNotFoundException if this attribute is not * supported by this MBean * @exception MBeanException if the initializer of an object * throws an exception * @exception ReflectionException if a Java reflection exception * occurs when invoking the getter */ @Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (attribute == null) { throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute is null"), "Attribute is null"); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } Connector connector = doGetManagedResource(); IntrospectionUtils.setProperty(connector, name, String.valueOf(value)); }
Example 8
Source File: SetAllPropertiesRule.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Handle the beginning of an XML element. * * @param attributes The attributes of this element * * @exception Exception if a processing error occurs */ @Override public void begin(String namespace, String nameX, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if ( !excludes.containsKey(name)) { if (!digester.isFakeAttribute(digester.peek(), name) && !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) { digester.getLogger().warn("[SetAllPropertiesRule]{" + digester.getMatch() + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } } }
Example 9
Source File: SetPropertiesRule.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Process the beginning of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param theName the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list for this element */ @Override public void begin(String namespace, String theName, Attributes attributes) throws Exception { // Populate the corresponding properties of the top object Object top = digester.peek(); if (digester.log.isDebugEnabled()) { if (top != null) { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Set " + top.getClass().getName() + " properties"); } else { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Set NULL properties"); } } for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if (digester.log.isDebugEnabled()) { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "'"); } if (!digester.isFakeAttribute(top, name) && !IntrospectionUtils.setProperty(top, name, value) && digester.getRulesValidation()) { digester.log.warn("[SetPropertiesRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } }
Example 10
Source File: NioEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Generic properties, introspected */ @Override public boolean setProperty(String name, String value) { final String selectorPoolName = "selectorPool."; try { if (name.startsWith(selectorPoolName)) { return IntrospectionUtils.setProperty(selectorPool, name.substring(selectorPoolName.length()), value); } else { return super.setProperty(name, value); } }catch ( Exception x ) { log.error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); return false; } }
Example 11
Source File: NioEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Generic properties, introspected */ @Override public boolean setProperty(String name, String value) { final String selectorPoolName = "selectorPool."; try { if (name.startsWith(selectorPoolName)) { return IntrospectionUtils.setProperty(selectorPool, name.substring(selectorPoolName.length()), value); } else { return super.setProperty(name, value); } }catch ( Exception x ) { log.error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); return false; } }
Example 12
Source File: Connector.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Set a configured property. */ public boolean setProperty(String name, String value) { String repl = name; if (replacements.get(name) != null) { repl = replacements.get(name); } return IntrospectionUtils.setProperty(protocolHandler, repl, value); }
Example 13
Source File: Connector.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Set a property on the protocol handler. * * @param name the property name * @param value the property value * @return <code>true</code> if the property was successfully set */ public boolean setProperty(String name, String value) { String repl = name; if (replacements.get(name) != null) { repl = replacements.get(name); } return IntrospectionUtils.setProperty(protocolHandler, repl, value); }
Example 14
Source File: AbstractEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public boolean setProperty(String name, String value) { setAttribute(name, value); final String socketName = "socket."; try { if (name.startsWith(socketName)) { return IntrospectionUtils.setProperty(socketProperties, name.substring(socketName.length()), value); } else { return IntrospectionUtils.setProperty(this,name,value,false); } }catch ( Exception x ) { getLog().error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); return false; } }
Example 15
Source File: NioEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Generic properties, introspected */ @Override public boolean setProperty(String name, String value) { final String selectorPoolName = "selectorPool."; try { if (name.startsWith(selectorPoolName)) { return IntrospectionUtils.setProperty(selectorPool, name.substring(selectorPoolName.length()), value); } else { return super.setProperty(name, value); } }catch ( Exception x ) { log.error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); return false; } }
Example 16
Source File: SimpleTcpCluster.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * transfer properties from cluster configuration to subelement bean. * @param prefix * @param bean * @deprecated Unused - will be removed in Tomcat 8.0.x */ @Deprecated protected void transferProperty(String prefix, Object bean) { if (prefix != null) { for (Iterator<String> iter = getPropertyNames(); iter.hasNext();) { String pkey = iter.next(); if (pkey.startsWith(prefix)) { String key = pkey.substring(prefix.length() + 1); Object value = getProperty(pkey); IntrospectionUtils.setProperty(bean, key, value.toString()); } } } }
Example 17
Source File: AbstractEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
public boolean setProperty(String name, String value) { setAttribute(name, value); final String socketName = "socket."; try { if (name.startsWith(socketName)) { return IntrospectionUtils.setProperty(socketProperties, name.substring(socketName.length()), value); } else { return IntrospectionUtils.setProperty(this,name,value,false); } }catch ( Exception x ) { getLog().error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); return false; } }
Example 18
Source File: SetPropertyRule.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Process the beginning of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param theName the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list for this element * * @exception NoSuchMethodException if the bean does not * have a writable property of the specified name */ @Override public void begin(String namespace, String theName, Attributes attributes) throws Exception { // Identify the actual property name and value to be used String actualName = null; String actualValue = null; for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if (name.equals(this.name)) { actualName = value; } else if (name.equals(this.value)) { actualValue = value; } } // Get a reference to the top object Object top = digester.peek(); // Log some debugging information if (digester.log.isDebugEnabled()) { digester.log.debug("[SetPropertyRule]{" + digester.match + "} Set " + top.getClass().getName() + " property " + actualName + " to " + actualValue); } // Set the property (with conversion as necessary) if (!digester.isFakeAttribute(top, actualName) && !IntrospectionUtils.setProperty(top, actualName, actualValue) && digester.getRulesValidation()) { digester.log.warn("[SetPropertyRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } }
Example 19
Source File: SetPropertiesRule.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Process the beginning of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param theName the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list for this element */ @Override public void begin(String namespace, String theName, Attributes attributes) throws Exception { // Populate the corresponding properties of the top object Object top = digester.peek(); if (digester.log.isDebugEnabled()) { if (top != null) { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Set " + top.getClass().getName() + " properties"); } else { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Set NULL properties"); } } // set up variables for custom names mappings int attNamesLength = 0; if (attributeNames != null) { attNamesLength = attributeNames.length; } int propNamesLength = 0; if (propertyNames != null) { propNamesLength = propertyNames.length; } for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); // we'll now check for custom mappings for (int n = 0; n<attNamesLength; n++) { if (name.equals(attributeNames[n])) { if (n < propNamesLength) { // set this to value from list name = propertyNames[n]; } else { // set name to null // we'll check for this later name = null; } break; } } if (digester.log.isDebugEnabled()) { digester.log.debug("[SetPropertiesRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "'"); } if (!digester.isFakeAttribute(top, name) && !IntrospectionUtils.setProperty(top, name, value) && digester.getRulesValidation()) { digester.log.warn("[SetPropertiesRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } } }
Example 20
Source File: SetPropertyRule.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Process the beginning of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param theName the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list for this element * * @exception NoSuchMethodException if the bean does not * have a writable property of the specified name */ @Override public void begin(String namespace, String theName, Attributes attributes) throws Exception { // Identify the actual property name and value to be used String actualName = null; String actualValue = null; for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if ("".equals(name)) { name = attributes.getQName(i); } String value = attributes.getValue(i); if (name.equals(this.name)) { actualName = value; } else if (name.equals(this.value)) { actualValue = value; } } // Get a reference to the top object Object top = digester.peek(); // Log some debugging information if (digester.log.isDebugEnabled()) { digester.log.debug("[SetPropertyRule]{" + digester.match + "} Set " + top.getClass().getName() + " property " + actualName + " to " + actualValue); } // Set the property (with conversion as necessary) if (!digester.isFakeAttribute(top, actualName) && !IntrospectionUtils.setProperty(top, actualName, actualValue) && digester.getRulesValidation()) { digester.log.warn("[SetPropertyRule]{" + digester.match + "} Setting property '" + name + "' to '" + value + "' did not find a matching property."); } }