private Service getService(Provider provider, URLName name) throws NoSuchProviderException { try { if (name == null) { name = new URLName(provider.getProtocol(), null, -1, null, null, null); } ClassLoader cl = getClassLoader(); Class clazz = cl.loadClass(provider.getClassName()); Constructor ctr = clazz.getConstructor(PARAM_TYPES); return (Service) ctr.newInstance(new Object[]{this, name}); } catch (ClassNotFoundException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to load class for provider: " + provider).initCause(e); } catch (NoSuchMethodException e) { throw (NoSuchProviderException) new NoSuchProviderException("Provider class does not have a constructor(Session, URLName): " + provider).initCause(e); } catch (InstantiationException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to instantiate provider class: " + provider).initCause(e); } catch (IllegalAccessException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to instantiate provider class: " + provider).initCause(e); } catch (InvocationTargetException e) { throw (NoSuchProviderException) new NoSuchProviderException("Exception from constructor of provider class: " + provider).initCause(e.getCause()); } }
private Service getService(Provider provider, URLName name) throws NoSuchProviderException { try { if (name == null) { name = new URLName(provider.getProtocol(), null, -1, null, null, null); } ClassLoader cl = getClassLoader(); Class clazz = null; try { clazz = ProviderLocator.loadClass(provider.getClassName(), this.getClass(), cl); } catch (ClassNotFoundException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to load class for provider: " + provider).initCause(e); } Constructor ctr = clazz.getConstructor(PARAM_TYPES); return(Service) ctr.newInstance(new Object[]{this, name}); } catch (NoSuchMethodException e) { throw (NoSuchProviderException) new NoSuchProviderException("Provider class does not have a constructor(Session, URLName): " + provider).initCause(e); } catch (InstantiationException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to instantiate provider class: " + provider).initCause(e); } catch (IllegalAccessException e) { throw (NoSuchProviderException) new NoSuchProviderException("Unable to instantiate provider class: " + provider).initCause(e); } catch (InvocationTargetException e) { throw (NoSuchProviderException) new NoSuchProviderException("Exception from constructor of provider class: " + provider).initCause(e.getCause()); } }