private Timer getTimer() { synchronized (getTimerLock) { if (timer == null) { ClassLoader loader = null; try { loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( ConnectorRuntime.getRuntime().getConnectorClassLoader()); timer = new Timer("connector-timer-proxy", true); } finally { Thread.currentThread().setContextClassLoader(loader); } } } return timer; }
/** * Loads the class with the common class loader. * * @param the class name * @return the loaded class * @throws if the class is not found. * @see getClassLoader() */ public static Class loadClass(String className) throws ClassNotFoundException { try{ return getClassLoader().loadClass(className); }catch(Exception e){ //try loading the class using common classloader (connector classloader's parent chain has common classloader) return ConnectorRuntime.getRuntime().getConnectorClassLoader().loadClass(className); } } }
try { Method[] methods= ConnectorRuntime.getRuntime().getConnectorClassLoader().loadClass( connectionDefinitionClassName).getMethods(); for (int i= 0; i < methods.length; i++) {
private Validator getBeanValidator(String rarName) { Validator beanValidator = ConnectorRegistry.getInstance().getBeanValidator(rarName); ValidatorFactory validatorFactory = null; // this is needed in case of appclient/standalone client // and system-resource-adapters in server. if (beanValidator == null) { ClassLoader contextCL = null; try{ contextCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(ConnectorRuntime.getRuntime().getConnectorClassLoader()); validatorFactory = Validation.byDefaultProvider().configure().buildValidatorFactory(); beanValidator = validatorFactory.getValidator(); ConnectorRegistry.getInstance().addBeanValidator(rarName, beanValidator); }finally{ Thread.currentThread().setContextClassLoader(contextCL); } } return beanValidator; } }
/** * Check if the classname has been loaded and if it is a Driver or a * DataSource impl. * @param classname * @return */ private boolean isLoaded(String classname, String resType) { Class cls = null; try { //This will fail in case the driver is not in classpath. cls = ConnectorRuntime.getRuntime().getConnectorClassLoader().loadClass(classname); //Check shud be made here to look into the lib directory now to see // if there are any newly installed drivers. //If so, create a URLClassLoader and load the class with common //classloader as the parent. } catch (Exception ex) { cls = null; } catch (Throwable t) { cls = null; } return (isResType(cls, resType)); }
try { if(ConnectorsUtil.belongsToSystemRA(resourceAdapterName)){ ClassLoader classLoader = ConnectorRuntime.getRuntime().getConnectorClassLoader(); loadedClass = classLoader.loadClass(className); }else{
try { connectionDefinitionClass= ConnectorRuntime.getRuntime().getConnectorClassLoader().loadClass(connectionDefinitionClassName); Object obj= connectionDefinitionClass.newInstance(); for (Iterator iter= s.iterator(); iter.hasNext();) {