use of org.apache.cxf.resource.DefaultResourceManager in project camel by apache.
the class CxfEndpoint method setupHandlers.
protected void setupHandlers(ClientFactoryBean factoryBean, Client client) throws Exception {
if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) {
AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
Method m = factoryBean.getClass().getMethod("getServiceFactory");
JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) m.invoke(factoryBean);
@SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers);
chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), factoryBean.getBindingId()));
if (!chain.isEmpty()) {
ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
ResourceInjector injector = new ResourceInjector(resourceManager);
for (Handler<?> h : chain) {
if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
injector.inject(h, getServiceClass());
injector.construct(h, getServiceClass());
} else {
injector.inject(h);
injector.construct(h);
}
}
}
((JaxWsEndpointImpl) client.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
}
}
use of org.apache.cxf.resource.DefaultResourceManager in project tomee by apache.
the class PojoEndpoint method injectCxfResources.
private ResourceInjector injectCxfResources(final Object implementor) {
ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
final List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
if (!resourceManager.getResourceResolvers().contains(WEB_SERVICE_CONTEXT_RESOURCE_RESOLVER)) {
resourceManager.addResourceResolver(WEB_SERVICE_CONTEXT_RESOURCE_RESOLVER);
}
final ResourceInjector injector = new ResourceInjector(resourceManager);
injector.inject(implementor);
return injector;
}
use of org.apache.cxf.resource.DefaultResourceManager in project cxf by apache.
the class JaxWsServerFactoryBean method injectResources.
/**
* inject resources into servant. The resources are injected
* according to @Resource annotations. See JSR 250 for more
* information.
*/
/**
* @param instance
*/
protected void injectResources(Object instance) {
if (instance != null && !blockInjection) {
ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
ResourceInjector injector = new ResourceInjector(resourceManager);
if (Proxy.isProxyClass(instance.getClass()) && getServiceClass() != null) {
injector.inject(instance, getServiceClass());
if (!blockPostConstruct) {
injector.construct(instance, getServiceClass());
}
} else {
injector.inject(instance);
if (!blockPostConstruct) {
injector.construct(instance);
}
}
}
}
use of org.apache.cxf.resource.DefaultResourceManager in project cxf by apache.
the class ExtensionManagerTest method setUp.
@Before
public void setUp() {
ResourceResolver resolver = new SinglePropertyResolver(EXTENSIONMANAGER_TEST_RESOURECE_NAME, this);
ResourceManager rm = new DefaultResourceManager(resolver);
extensions = new HashMap<>();
extensions.put(Integer.class, Integer.valueOf(0));
manager = new ExtensionManagerImpl("test-extension.xml", Thread.currentThread().getContextClassLoader(), extensions, rm, null);
}
use of org.apache.cxf.resource.DefaultResourceManager in project cxf by apache.
the class JaxWsProxyFactoryBean method buildHandlerChain.
private void buildHandlerChain(JaxWsClientProxy cp) {
AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) getServiceFactory();
@SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers);
if (loadHandlers) {
chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), this.getBindingId()));
}
if (!chain.isEmpty()) {
ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
ResourceInjector injector = new ResourceInjector(resourceManager);
for (Handler<?> h : chain) {
if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
injector.inject(h, getServiceClass());
injector.construct(h, getServiceClass());
} else {
injector.inject(h);
injector.construct(h);
}
}
}
cp.getBinding().setHandlerChain(chain);
}
Aggregations