// 2.
clazz = Class.forName( implementationName );
}
}
catch (java.net.MalformedURLException e) {
CannotActivateFactoryException cae = new CannotActivateFactoryException(
"Can not activate factory because " + e.toString() );
cae.fillInStackTrace();
throw cae;
}
catch (java.io.IOException e) {
CannotActivateFactoryException cae = new CannotActivateFactoryException(
"Can not activate factory because " + e.toString() );
cae.fillInStackTrace();
throw cae;
}
catch (java.lang.ClassNotFoundException e) {
CannotActivateFactoryException cae = new CannotActivateFactoryException(
"Can not activate factory because " + e.toString() );
cae.fillInStackTrace();
throw cae;
}
if (null == clazz)
{
CannotActivateFactoryException cae =
new CannotActivateFactoryException(
"Cannot determine activation class!" );
cae.fillInStackTrace();
throw cae;
}
Class[] paramTypes = {String.class, XMultiServiceFactory.class, XRegistryKey.class};
Object[] params = { implementationName, multiServiceFactory, xKey };
// try to get factory from implemetation class
// latest style: use the public static method __getComponentFactory
// - new style: use the public static method __getServiceFactory
// - old style: use the public static method getServiceFactory ( DEPRECATED )
Method compfac_method = null;
try
{
compfac_method = clazz.getMethod(
"__getComponentFactory", new Class [] { String.class } );
}
catch ( NoSuchMethodException noSuchMethodEx) {}
catch ( SecurityException secEx) {}
Method method = null;
if (null == compfac_method)
{
try {
method = clazz.getMethod("__getServiceFactory", paramTypes);
}
catch ( NoSuchMethodException noSuchMethodEx) {
method = null;
}
catch ( SecurityException secEx) {
method = null;
}
}
try {
if (null != compfac_method)
{
Object ret = compfac_method.invoke( clazz, new Object [] { implementationName } );
if (null == ret || !(ret instanceof XSingleComponentFactory))
{
throw new CannotActivateFactoryException(
"No factory object for " + implementationName );
}
return (XSingleComponentFactory)ret;
}
else
{
if ( method == null ) {
method = clazz.getMethod("getServiceFactory", paramTypes);
}
Object oRet = method.invoke(clazz, params);
if ( (oRet != null) && (oRet instanceof XSingleServiceFactory) ) {
returnObject = (XSingleServiceFactory) oRet;
}
}
}
catch ( NoSuchMethodException e) {
throw new CannotActivateFactoryException("Can not activate the factory for "
+ implementationName + " because " + e.toString() );
}
catch ( SecurityException e) {
throw new CannotActivateFactoryException("Can not activate the factory for "
+ implementationName + " because " + e.toString() );
}
catch ( IllegalAccessException e ) {
throw new CannotActivateFactoryException("Can not activate the factory for "
+ implementationName + " because " + e.toString() );
}
catch ( IllegalArgumentException e ) {
throw new CannotActivateFactoryException("Can not activate the factory for "
+ implementationName + " because " + e.toString() );
}
catch ( InvocationTargetException e ) {
throw new CannotActivateFactoryException("Can not activate the factory for "
+ implementationName + " because " + e.getTargetException().toString() );
}
return returnObject;
}