cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: WebServiceContext not injected in endpoint
Date Wed, 27 Feb 2008 16:10:53 GMT

This is one of the many issues with the ScopePolicy/factory stuff which 
is one of the reasons I eliminated the ScopePolicy stuff entirely from 
the 2.1/trunk codebase.   :-)

Is there any chance you could give the 2.1 snapshots a try?   Configuring 
your usecase will be SLIGHTLY different, but not by much:


org.apache.cxf.service.invoker.Factory factory = new
     org.apache.cxf.service.invoker.PerRequestFactory(GreeterImpl.class);
JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory);
.....

The newer Factory stuff, since it has access to the exchange at request 
time, can get the bus and thus get the resources properly injected.

That said, the resource injection isn't "free" so that will add a small 
amount of extra processing per request.   Thus, you might want to use 
the PooledFactory to maintain a pool of GreeterImpl objects or possibly 
a SessionFactory to create one per session (assuming your clients honor 
the session).

In anycase, with the 2.1 code the major bugs should be fixed and I'd LOVE 
to see someone else test it a bit to makre sure.   Basically, resources 
should get injected and the pooled stuff should actually work. 

Dan




On Wednesday 27 February 2008, Davide Gesino wrote:
> trying customizing the JAxWSMethodInvoker I have problems injecting
> the web service context with the @Resource annotation.
> Maybe there's something wrong in what I am doing, maybe it could be a
> bug.
>
> Assume you have a GreeterImpl endpoint with the web service context
> injected.
>
> Try the following:
>
> case 1
> ScopePolicy policy = ApplicationScopePolicy.instance();
> // trying with the following is the same:
> // ScopePolicy policy = RequestScopePolicy.instance();
> org.apache.cxf.common.util.factory.Factory factory= new
> LocalFactory(GreeterImpl.class);
> JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(fattorazza,
> policy);
>
> JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
> factoryBean.setAddress(address);
> factoryBean.setServiceBean(implementor);
> factoryBean.setInvoker(invoker);
> factoryBean.create();
>
> case 2
> Endpoint.publish(address,implementor);
>
> the endpoint
> public class GreeterImpl implements Greeter {
>
> 	@Resource
> 	private WebServiceContext context;
>
> public java.lang.String greetMe(java.lang.String requestType) {
>
>
> 		if (context != null) {
> 			// in case 1 it is null, in case 2 it is !=null
> 		}
>
>
> 		return "hello "+ requestType;
> }
>
> in case 1 the method invocation works fine, but the context is not
> injected, while in case 2 the context is injected.
>
> where is the fault?
>
> Davide



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Mime
View raw message