public Object run() throws ClassNotFoundException, InstantiationException, IllegalAccessException { return ProviderLocator.loadClass(finalClassName, this.getClass(), contextClassLoader).newInstance(); } });
public Object run() throws ClassNotFoundException, InstantiationException, IllegalAccessException { return ProviderLocator.loadClass(finalClassName, this.getClass(), contextClassLoader).newInstance(); } });
public Object run() throws Exception { factoryClassName[0] = System.getProperty(FACTORY_NAME); if (factoryClassName[0] == null) throw new ClassNotFoundException("Property " + FACTORY_NAME + " not set"); Thread currentThread = Thread.currentThread(); ClassLoader tccl = currentThread.getContextClassLoader(); return ProviderLocator.loadClass(factoryClassName[0], PolicyConfigurationFactory.class, tccl).newInstance(); } });
public Object run() throws Exception { factoryClassName[0] = System.getProperty(FACTORY_NAME); if (factoryClassName[0] == null) throw new ClassNotFoundException("Property " + FACTORY_NAME + " not set"); Thread currentThread = Thread.currentThread(); ClassLoader tccl = currentThread.getContextClassLoader(); return ProviderLocator.loadClass(factoryClassName[0], PolicyConfigurationFactory.class, tccl).newInstance(); } });
public MessagePolicy.ProtectionPolicy run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<? extends MessagePolicy.ProtectionPolicy> cl = ProviderLocator.loadClass(protectionPolicyType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.ProtectionPolicy.class); Constructor<? extends MessagePolicy.ProtectionPolicy> cnst = cl.getConstructor(); MessagePolicy.ProtectionPolicy target = cnst.newInstance(); return target; } });
public MessagePolicy.Target run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<? extends MessagePolicy.Target> cl = ProviderLocator.loadClass(targetType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.Target.class); Constructor<? extends MessagePolicy.Target> cnst = cl.getConstructor(); MessagePolicy.Target target = cnst.newInstance(); return target; } });
public AuthConfigProvider run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<? extends AuthConfigProvider> cl = ProviderLocator.loadClass(configProviderType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(AuthConfigProvider.class); Constructor<? extends AuthConfigProvider> cnst = cl.getConstructor(Map.class, AuthConfigFactory.class); return cnst.newInstance(configProviderType.getProperties(), authConfigFactory); } });
public T run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, AuthException { Class<? extends T> cl = (Class<? extends T>) ProviderLocator.loadClass(authModuleType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()); Constructor<? extends T> cnst = cl.getConstructor(); T authModule = cnst.newInstance(); Method m = cl.getMethod("initialize", MessagePolicy.class, MessagePolicy.class, CallbackHandler.class, Map.class); MessagePolicy reqPolicy = newMessagePolicy(authModuleType.getRequestPolicy()); MessagePolicy respPolicy = newMessagePolicy(authModuleType.getResponsePolicy()); m.invoke(authModule, reqPolicy, respPolicy, callbackHandler, authModuleType.getOptions()); return authModule; } });
private static Object newInstance(String className, ClassLoader classLoader) throws FactoryConfigurationError { try { return ProviderLocator.loadClass(className, FactoryLocator.class, classLoader).newInstance(); } catch (ClassNotFoundException x) { throw new FactoryConfigurationError("Requested factory " + className + " cannot be located. Classloader =" + classLoader.toString(), x); } catch (Exception x) { throw new FactoryConfigurationError("Requested factory " + className + " could not be instantiated: " + x, x); } } }
public Object run() { try { return ProviderLocator.loadClass(iClassName, FactoryFinder.class, iClassLoader).newInstance(); } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + iClassName + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + iClassName + " could not be instantiated: " + x, x); } } });
public synchronized DataContentHandler createDataContentHandler(String mimeType) { CommandInfo info = getCommand(mimeType, "content-handler"); if (info == null) { return null; } ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = getClass().getClassLoader(); } try { return (DataContentHandler) ProviderLocator.loadClass(info.getCommandClass(), this.getClass(), cl).newInstance(); } catch (ClassNotFoundException e) { return null; } catch (IllegalAccessException e) { return null; } catch (InstantiationException e) { return null; } }
private static Object newInstance(String className, ClassLoader classLoader) throws FactoryConfigurationError { try { return ProviderLocator.loadClass(className, FactoryLocator.class, classLoader).newInstance(); } catch (ClassNotFoundException x) { throw new FactoryConfigurationError("Requested factory " + className + " cannot be located. Classloader =" + classLoader.toString(), x); } catch (Exception x) { throw new FactoryConfigurationError("Requested factory " + className + " could not be instantiated: " + x, x); } } }
public synchronized DataContentHandler createDataContentHandler(String mimeType) { CommandInfo info = getCommand(mimeType, "content-handler"); if (info == null) { return null; } ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = getClass().getClassLoader(); } try { return (DataContentHandler) ProviderLocator.loadClass(info.getCommandClass(), this.getClass(), cl).newInstance(); } catch (ClassNotFoundException e) { return null; } catch (IllegalAccessException e) { return null; } catch (InstantiationException e) { return null; } }
public static ConnectionFactory newInstance() throws JAXRException { String className = System.getProperty("javax.xml.registry.ConnectionFactoryClass", "org.apache.ws.scout.registry.ConnectionFactoryImpl"); ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ConnectionFactory.class.getClassLoader(); } try { Class factoryClass = ProviderLocator.loadClass(className, ConnectionFactory.class, cl); return (ConnectionFactory) factoryClass.newInstance(); } catch (ClassNotFoundException e) { throw new JAXRException("Unable to load JAXR ConnectionFactoryClass: " + className, e); } catch (InstantiationException e) { throw new JAXRException("Unable to instantiate JAXR ConnectionFactoryClass: " + className, e); } catch (IllegalAccessException e) { throw new JAXRException("Unable to instantiate JAXR ConnectionFactoryClass: " + className, e); } } }
public static ConnectionFactory newInstance() throws JAXRException { String className = System.getProperty("javax.xml.registry.ConnectionFactoryClass", "org.apache.ws.scout.registry.ConnectionFactoryImpl"); ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ConnectionFactory.class.getClassLoader(); } try { Class factoryClass = ProviderLocator.loadClass(className, ConnectionFactory.class, cl); return (ConnectionFactory) factoryClass.newInstance(); } catch (ClassNotFoundException e) { throw new JAXRException("Unable to load JAXR ConnectionFactoryClass: " + className, e); } catch (InstantiationException e) { throw new JAXRException("Unable to instantiate JAXR ConnectionFactoryClass: " + className, e); } catch (IllegalAccessException e) { throw new JAXRException("Unable to instantiate JAXR ConnectionFactoryClass: " + className, e); } } }
/** * Create an instance of a class using the specified * <code>ClassLoader</code>, or if that fails from the * <code>ClassLoader</code> that loaded this class. * * @param className the name of the class to instantiate * @param classLoader a <code>ClassLoader</code> to load the class from * * @return a new <code>Object</code> that is an instance of the class of * the given name from the given class loader * @throws ConfigurationError if the class could not be found or * instantiated */ private static Object newInstance(String className, ClassLoader classLoader) throws ConfigurationError { try { return ProviderLocator.loadClass(className, FactoryFinder.class, classLoader).newInstance(); } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + className + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + className + " could not be instantiated: " + x, x); } }
private static EntityManagerFactory createFactory(String providerName, String persistenceUnitName, Map properties) throws PersistenceException { Class<?> providerClass; // get our class loader ClassLoader cl = PrivClassLoader.get(null); if (cl == null) cl = PrivClassLoader.get(Persistence.class); try { providerClass = ProviderLocator.loadClass(providerName, Persistence.class, cl); } catch (Exception e) { throw new PersistenceException("Invalid or inaccessible explicit provider class: " + providerName, e); } try { PersistenceProvider provider = (PersistenceProvider) providerClass.newInstance(); return provider.createEntityManagerFactory(persistenceUnitName, properties); } catch (Exception e) { throw new PersistenceException("Explicit error returned from provider: " + providerName + " for PU: " + persistenceUnitName, e); } }
private static EntityManagerFactory createFactory(String providerName, String persistenceUnitName, Map properties) throws PersistenceException { Class<?> providerClass; // get our class loader ClassLoader cl = PrivClassLoader.get(null); if (cl == null) cl = PrivClassLoader.get(Persistence.class); try { providerClass = ProviderLocator.loadClass(providerName, Persistence.class, cl); } catch (Exception e) { throw new PersistenceException("Invalid or inaccessible explicit provider class: " + providerName, e); } try { PersistenceProvider provider = (PersistenceProvider) providerClass.newInstance(); return provider.createEntityManagerFactory(persistenceUnitName, properties); } catch (Exception e) { throw new PersistenceException("Explicit error returned from provider: " + providerName + " for PU: " + persistenceUnitName, e); } }
private static EntityManagerFactory createFactory(String providerName, String persistenceUnitName, Map properties) throws PersistenceException { Class<?> providerClass; // get our class loader ClassLoader cl = PrivClassLoader.get(null); if (cl == null) cl = PrivClassLoader.get(Persistence.class); try { providerClass = ProviderLocator.loadClass(providerName, Persistence.class, cl); } catch (Exception e) { throw new PersistenceException("Invalid or inaccessible explicit provider class: " + providerName, e); } try { PersistenceProvider provider = (PersistenceProvider) providerClass.newInstance(); return provider.createEntityManagerFactory(persistenceUnitName, properties); } catch (Exception e) { throw new PersistenceException("Explicit error returned from provider: " + providerName + " for PU: " + persistenceUnitName, e); } }
private static EntityManagerFactory createFactory(String providerName, String persistenceUnitName, Map properties) throws PersistenceException { Class<?> providerClass; // get our class loader ClassLoader cl = PrivClassLoader.get(null); if (cl == null) cl = PrivClassLoader.get(Persistence.class); try { providerClass = ProviderLocator.loadClass(providerName, Persistence.class, cl); } catch (Exception e) { throw new PersistenceException("Invalid or inaccessible explicit provider class: " + providerName, e); } try { PersistenceProvider provider = (PersistenceProvider) providerClass.newInstance(); return provider.createEntityManagerFactory(persistenceUnitName, properties); } catch (Exception e) { throw new PersistenceException("Explicit error returned from provider: " + providerName + " for PU: " + persistenceUnitName, e); } }