private static Object newInstance(String className, Deployment dep) { final ClassLoader tccl = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader(dep.getClassLoader()); Class<?> clazz = tccl.loadClass(className); return clazz.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } finally { SecurityActions.setContextClassLoader(tccl); } }
public Class<?> getTargetBeanClass() { Class<?> result = targetBeanClass; if (result == null) { synchronized (this) { result = targetBeanClass; if (result == null) { ClassLoader classLoader = service.getDeployment().getClassLoader(); try { targetBeanClass = classLoader.loadClass(targetBean); result = targetBeanClass; } catch (ClassNotFoundException ex) { throw new WSFDeploymentException(ex); } } } } return result; }
private static Invoker newInvokerInstance(String className, Deployment dep) { final ClassLoader tccl = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader(dep.getClassLoader()); @SuppressWarnings("unchecked") Class<Invoker> clazz = (Class<Invoker>)tccl.loadClass(className); final AnnotationsInfo ai = dep.getAttachment(AnnotationsInfo.class); if (ai != null && clazz.isAssignableFrom(JBossWSInvoker.class)) { Constructor<Invoker> constr = clazz.getConstructor(boolean.class); return constr.newInstance(ai.hasAnnotatedClasses(UseAsyncMethod.class.getName())); } else { return clazz.getDeclaredConstructor().newInstance(); } } catch (Exception e) { throw new RuntimeException(e); } finally { SecurityActions.setContextClassLoader(tccl); } }
private void setUserEndpointBus(final Deployment dep) { //first make sure the global default bus is built with visibility over client dependencies only final ClassLoader clientClassLoader = ProviderImpl.class.getClassLoader(); if (BusFactory.getDefaultBus(false) == null) { JBossWSBusFactory.getDefaultBus(clientClassLoader); } final ClassLoader cl = SecurityActions.getContextClassLoader(); try { //then set the TCCL to a delegate classloader adding jbws client integration to user deployment dependencies SecurityActions.setContextClassLoader(createDelegateClassLoader(clientClassLoader, dep.getClassLoader())); final Bus userBus = BusFactory.newInstance().createBus(); //finally, create a new Bus instance to be later assigned to the thread running the user endpoint business methods for (final Endpoint ep : dep.getService().getEndpoints()) { ep.addAttachment(Bus.class, userBus); } } finally { SecurityActions.setContextClassLoader(cl); } }
private void startDeploymentBus(final Deployment dep) { BusFactory.setThreadDefaultBus(null); ClassLoader origClassLoader = SecurityActions.getContextClassLoader(); try { final ArchiveDeployment aDep = (ArchiveDeployment) dep; final ResourceResolver deploymentResolver = aDep.getResourceResolver(); final org.apache.cxf.resource.ResourceResolver resolver = new JBossWSResourceResolver(deploymentResolver); //set the runtime classloader (pointing to the deployment unit) to allow CXF accessing to the classes; //use origClassLoader (which on AS7 is set to ASIL aggregation module's classloader by TCCLDeploymentProcessor) as //parent to make sure user provided libs in the deployment do no mess up the WS endpoint's deploy if they duplicates //libraries already available on the application server modules. SecurityActions.setContextClassLoader(new DelegateClassLoader(dep.getClassLoader(), origClassLoader)); DDBeans metadata = dep.getAttachment(DDBeans.class); BusHolder holder = new BusHolder(metadata); Configurer configurer = holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new WSDLFilePublisher(aDep), aDep); holder.configure(resolver, configurer, dep.getAttachment(JBossWebservicesMetaData.class), dep); dep.addAttachment(BusHolder.class, holder); } finally { BusFactory.setThreadDefaultBus(null); SecurityActions.setContextClassLoader(origClassLoader); } }
policySetsListener = new PolicySetsAnnotationListener(dep.getClassLoader()); bus.getExtension(FactoryBeanListenerManager.class).addListener(policySetsListener);