if (replacements.get(name) != null) {
repl = (String) replacements.get(name);
}
+ if (!IntrospectionUtils.setProperty(protocolHandler, repl, value)) {
+ log.warn("Property " + name + " not found on the protocol handler.");
+ }
+ }
+
+
+ /**
+ * Set a configured property.
+ */
+ public void setPropertyInternal(String name, String value) {
+ String repl = name;
+ if (replacements.get(name) != null) {
+ repl = (String) replacements.get(name);
+ }
IntrospectionUtils.setProperty(protocolHandler, repl, value);
}
public void setAllowTrace(boolean allowTrace) {
this.allowTrace = allowTrace;
- setProperty("allowTrace", String.valueOf(allowTrace));
+ setPropertyInternal("allowTrace", String.valueOf(allowTrace));
}
public void setEmptySessionPath(boolean emptySessionPath) {
this.emptySessionPath = emptySessionPath;
- setProperty("emptySessionPath", String.valueOf(emptySessionPath));
+ setPropertyInternal("emptySessionPath", String.valueOf(emptySessionPath));
}
public void setEnableLookups(boolean enableLookups) {
this.enableLookups = enableLookups;
- setProperty("enableLookups", String.valueOf(enableLookups));
+ setPropertyInternal("enableLookups", String.valueOf(enableLookups));
}
public void setMaxSavePostSize(int maxSavePostSize) {
this.maxSavePostSize = maxSavePostSize;
- setProperty("maxSavePostSize", String.valueOf(maxSavePostSize));
+ setPropertyInternal("maxSavePostSize", String.valueOf(maxSavePostSize));
}
public void setPort(int port) {
this.port = port;
- setProperty("port", String.valueOf(port));
+ setPropertyInternal("port", String.valueOf(port));
}
if(proxyName != null && proxyName.length() > 0) {
this.proxyName = proxyName;
- setProperty("proxyName", proxyName);
+ setPropertyInternal("proxyName", proxyName);
} else {
this.proxyName = null;
removeProperty("proxyName");
public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
- setProperty("proxyPort", String.valueOf(proxyPort));
+ setPropertyInternal("proxyPort", String.valueOf(proxyPort));
}
public void setRedirectPort(int redirectPort) {
this.redirectPort = redirectPort;
- setProperty("redirectPort", String.valueOf(redirectPort));
+ setPropertyInternal("redirectPort", String.valueOf(redirectPort));
}
public void setSecure(boolean secure) {
this.secure = secure;
- setProperty("secure", Boolean.toString(secure));
+ setPropertyInternal("secure", Boolean.toString(secure));
}
/**
public void setURIEncoding(String URIEncoding) {
this.URIEncoding = URIEncoding;
- setProperty("uRIEncoding", URIEncoding);
+ setPropertyInternal("uRIEncoding", URIEncoding);
}
public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI) {
this.useBodyEncodingForURI = useBodyEncodingForURI;
- setProperty
+ setPropertyInternal
("useBodyEncodingForURI", String.valueOf(useBodyEncodingForURI));
}
*/
public void setXpoweredBy(boolean xpoweredBy) {
this.xpoweredBy = xpoweredBy;
- setProperty("xpoweredBy", String.valueOf(xpoweredBy));
+ setPropertyInternal("xpoweredBy", String.valueOf(xpoweredBy));
}
/**
*/
public void setUseIPVHosts(boolean useIPVHosts) {
this.useIPVHosts = useIPVHosts;
- setProperty("useIPVHosts", String.valueOf(useIPVHosts));
+ setPropertyInternal("useIPVHosts", String.valueOf(useIPVHosts));
}
/**
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
import org.apache.catalina.Container;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
// Initialize the digester
Digester digester = new Digester();
digester.setValidating(false);
+ digester.setRulesValidation(true);
+ HashMap<Class, List<String>> fakeAttributes = new HashMap<Class, List<String>>();
+ ArrayList<String> attrs = new ArrayList<String>();
+ attrs.add("className");
+ fakeAttributes.put(Object.class, attrs);
+ digester.setFakeAttributes(fakeAttributes);
digester.setClassLoader(StandardServer.class.getClassLoader());
// Configure the actions we will be using
connector = new Connector();
connector.setScheme("https");
connector.setSecure(true);
- connector.setProperty("SSLEnabled","true");
+ connector.setPropertyInternal("SSLEnabled","true");
// FIXME !!!! SET SSL PROPERTIES
} else {
connector = new Connector(protocol);
name = attributes.getQName(i);
}
String value = attributes.getValue(i);
- if ( !excludes.containsKey(name))
- IntrospectionUtils.setProperty(digester.peek(), name, value);
+ 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.");
+ }
+ }
}
}
continue;
}
String value = attributes.getValue(i);
- IntrospectionUtils.setProperty(digester.peek(), name, value);
+ 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.");
+ }
}
}
/**
- * Set a property.
- */
- public void setProperty(String name, String value) {
- setAttribute(name, value);
- }
-
-
- /**
- * Get a property
- */
- public String getProperty(String name) {
- return (String) getAttribute(name);
- }
-
-
- /**
* The adapter, used to call the connector
*/
public void setAdapter(Adapter adapter) {
/**
- * Set a property.
- */
- public void setProperty(String name, String value) {
- setAttribute(name, value);
- }
-
-
- /**
- * Get a property
- */
- public String getProperty(String name) {
- return (String) getAttribute(name);
- }
-
-
- /**
* The adapter, used to call the connector
*/
public void setAdapter(Adapter adapter) {
}
/**
- * Set a property.
- */
- public void setProperty(String name, String value) {
- setAttribute(name, value);
- }
-
- /**
- * Get a property
- */
- public String getProperty(String name) {
- return (String)getAttribute(name);
- }
-
- /**
* The adapter, used to call the connector.
*/
protected Adapter adapter;
public void setRestrictedUserAgents(String valueS) { restrictedUserAgents = valueS; }
- public String getProtocol() {
- return getProperty("protocol");
- }
-
- public void setProtocol( String k ) {
- setSecure(true);
- setAttribute("protocol", k);
- }
+ protected String protocol = null;
+ public String getProtocol() { return protocol; }
+ public void setProtocol(String protocol) { setSecure(true); this.protocol = protocol; }
/**
* Maximum number of requests which can be performed over a keepalive
/**
- * Set a property.
- */
- public void setProperty(String name, String value) {
- setAttribute(name, value);
- }
-
- /**
- * Get a property
- */
- public String getProperty(String name) {
- return (String)getAttribute(name);
- }
-
- /**
* Pass config info
*/
public void setAttribute(String name, Object value) {
* int or boolean we'll convert value to the right type before) - that means
* you can have setDebug(1).
*/
- public static void setProperty(Object o, String name, String value) {
+ public static boolean setProperty(Object o, String name, String value) {
if (dbg > 1)
d("setProperty(" + o.getClass() + " " + name + "=" + value + ")");
&& "java.lang.String".equals(paramT[0].getName())) {
methods[i].invoke(o, new Object[] { value });
- return;
+ return true;
}
}
if (ok) {
methods[i].invoke(o, params);
- return;
+ return true;
}
}
params[0] = name;
params[1] = value;
setPropertyMethod.invoke(o, params);
+ return true;
}
} catch (IllegalArgumentException ex2) {
if (dbg > 1)
ie.printStackTrace();
}
+ return false;
}
public static Object getProperty(Object o, String name) {
protected boolean validating = false;
+
+ /**
+ * Warn on missing attributes and elements.
+ */
+ protected boolean rulesValidation = false;
+
+
+ /**
+ * Fake attributes map (attributes are often used for object creation).
+ */
+ protected Map<Class, List<String>> fakeAttributes = null;
+
+
/**
* The Log to which most logging calls will be made.
*/
/**
+ * Return the rules validation flag.
+ */
+ public boolean getRulesValidation() {
+
+ return (this.rulesValidation);
+
+ }
+
+
+ /**
+ * Set the rules validation flag. This must be called before
+ * <code>parse()</code> is called the first time.
+ *
+ * @param rulesValidation The new rules validation flag.
+ */
+ public void setRulesValidation(boolean rulesValidation) {
+
+ this.rulesValidation = rulesValidation;
+
+ }
+
+
+ /**
+ * Return the fake attributes list.
+ */
+ public Map<Class, List<String>> getFakeAttributes() {
+
+ return (this.fakeAttributes);
+
+ }
+
+
+ /**
+ * Determine if an attribute is a fake attribute.
+ */
+ public boolean isFakeAttribute(Object object, String name) {
+
+ if (fakeAttributes == null) {
+ return false;
+ }
+ List<String> result = fakeAttributes.get(object.getClass());
+ if (result == null) {
+ result = fakeAttributes.get(Object.class);
+ }
+ if (result == null) {
+ return false;
+ } else {
+ return result.contains(name);
+ }
+
+ }
+
+
+ /**
+ * Set the fake attributes.
+ *
+ * @param fakeAttributes The new fake attributes.
+ */
+ public void setFakeAttributes(Map<Class, List<String>> fakeAttributes) {
+
+ this.fakeAttributes = fakeAttributes;
+
+ }
+
+
+ /**
* Return the XMLReader to be used for parsing the input document.
*
* FIX ME: there is a bug in JAXP/XERCES that prevent the use of a
if (debug) {
log.debug(" No rules found matching '" + match + "'.");
}
+ if (rulesValidation) {
+ log.warn(" No rules found matching '" + match + "'.");
+ }
}
// Recover the body text from the surrounding element
"} Setting property '" + name + "' to '" +
value + "'");
}
- IntrospectionUtils.setProperty(top, name, 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.");
+ }
}
}
}
// Set the property (with conversion as necessary)
- // FIXME: Exception if property doesn't exist ?
- IntrospectionUtils.setProperty(top, actualName, actualValue);
+ 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.");
+ }
}