Methods Summary |
---|
protected abstract java.lang.Object | createFeatureFactory(java.lang.reflect.InvocationHandler handler)Get an instance of a pluggable feature factory. The method expects
a property object as parameter that has one property for every supported
pluggable feature. The property name is the name of the interface
(without package name) and property value is the fully qualified name of
the class that implements the interface. The implementing class must
have a default public constructor.
|
private java.lang.String | findFeatureFromMethod(java.lang.reflect.Method method)Find feature name from a method. For the interface
PluggableFeatureFactory, a feature name is name of the interface
defining the feature. The return type of any method in the interface
PluggableFeatureFactory is the interface defining the feature (Note
that the interface only contains getter methods). For example, if one
of the pluggable features is defined by the interface
com.sun.enterprise.server.pluggable.CoolStuff, the corresponding
feature name is CoolStuff.
Class returnType = method.getReturnType();
return Utils.getNQClassName(returnType);
|
protected abstract java.lang.String | getDefaultFeatureFactoryPropertyName()
|
public java.lang.Object | getInstance()Get an instance of a pluggable feature factory using the system
property com.sun.appserv.pluggable.features. The value of the system
property is expected to be the name of a class that extends
java.util.Properties and defines one property for every supported
pluggable feature. This method calls getInstance(String) if the
value of com.sun.appserv.pluggable.features is not null.
The property com.sun.appserv.pluggable.features is defined as a
constant in the interface PluggableFeatureFactory and the implementation
uses that (PluggableFeatureFactory.PLUGGABLE_FEATURES_PROPERTY_NAME)
String propClassName = System.getProperty(
getDefaultFeatureFactoryPropertyName());
return getInstance(propClassName);
|
public java.lang.Object | getInstance(java.lang.String propClassName)Get an instance of a pluggable feature factory using specified property
class name. The method expects name of a class that extends
java.util.Properties and has a default (null or no argument) constructor.
This method will create an instance of specified class and then
call getInstance(Properties). If an instance of specified class name can
not be created, the method logs the exception to the logger specified
by setLogger() method, or to System.err (if no logger was set).
if (propClassName == null) {
return null;
}
Properties props = null;
try {
props = (Properties)Class.forName(propClassName).newInstance();
} catch (Exception ex) {
String msg = "Error loading pluggable features class "
+ propClassName;
if (_logger != null) {
_logger.log(Level.WARNING, msg, ex);
} else {
System.err.println(msg + "\nStack Trace:");
ex.printStackTrace();
}
}
return getInstance(props);
|
public java.lang.Object | getInstance(java.util.Properties props)
if (props == null) {
return null;
}
_featureImplClasses = props;
return createFeatureFactory(this);
|
public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)Handle a invocation on a proxy object. This implementation looks for
a property key matching the return type of the method, then takes the
value of the property, assumes it to be a class name, assumes that the
class has a default public constructor and then creates an instance of
that class and returns it.
String featureName = findFeatureFromMethod(method);
String className = _featureImplClasses.getProperty(featureName);
Object featureImpl = Class.forName(className).newInstance();
return featureImpl;
|