Author: dkulp
Date: Thu Feb 28 10:58:19 2008
New Revision: 632089
URL: http://svn.apache.org/viewvc?rev=632089&view=rev
Log:
Fix problems with WebServiceContextResourceResolver not getting registered so
the Context isn't properly injected
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/PooledFactory.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextResourceResolver.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/PooledFactory.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/PooledFactory.java?rev=632089&r1=632088&r2=632089&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/PooledFactory.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/PooledFactory.java
Thu Feb 28 10:58:19 2008
@@ -86,15 +86,24 @@
/** [EMAIL PROTECTED]/
public Object create(Exchange ex) throws Throwable {
if (factory == null
- || ((count == max) && !createMore)) {
+ || ((count >= max) && !createMore)) {
return pool.take();
}
Object o = pool.poll();
if (o == null) {
- count++;
- return factory.create(ex);
+ return createObject(ex);
}
return o;
+ }
+ protected synchronized Object createObject(Exchange e) throws Throwable {
+ //recheck the count/max stuff now that we're in a sync block
+ if (factory == null
+ || ((count >= max) && !createMore)) {
+ return pool.take();
+ }
+
+ count++;
+ return factory.create(e);
}
/** [EMAIL PROTECTED]/
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextResourceResolver.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextResourceResolver.java?rev=632089&r1=632088&r2=632089&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextResourceResolver.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextResourceResolver.java
Thu Feb 28 10:58:19 2008
@@ -21,12 +21,29 @@
import java.io.InputStream;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import javax.xml.ws.WebServiceContext;
+import org.apache.cxf.Bus;
+import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
public class WebServiceContextResourceResolver implements ResourceResolver {
+
+ @Resource
+ Bus bus;
+
+ @PostConstruct
+ public void register() {
+ if (bus != null
+ && bus.getExtension(ResourceManager.class) != null) {
+ bus.getExtension(ResourceManager.class).addResourceResolver(this);
+ }
+ }
+
+
public final InputStream getAsStream(final String string) {
return null;
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=632089&r1=632088&r2=632089&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Thu Feb 28 10:58:19 2008
@@ -22,8 +22,10 @@
import java.util.List;
import java.util.Vector;
+import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceContext;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.systest.jaxws.types.Bar;
@@ -36,19 +38,31 @@
public class DocLitWrappedCodeFirstServiceImpl implements
DocLitWrappedCodeFirstService {
public static final String DATA[] = new String[] {"string1", "string2",
"string3"};
+ @Resource
+ WebServiceContext context;
+
public int thisShouldNotBeInTheWSDL(int i) {
return i;
}
public String[] arrayOutput() {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
return DATA;
}
public Vector<String> listOutput() {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
return new Vector<String>(Arrays.asList(DATA));
}
public String arrayInput(String[] inputs) {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
StringBuffer buf = new StringBuffer();
for (String s : inputs) {
buf.append(s);
@@ -57,11 +71,17 @@
}
public int[] echoIntArray(int[] ar, Exchange ex) {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
return ar;
}
public String listInput(List<String> inputs) {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
StringBuffer buf = new StringBuffer();
if (inputs != null) {
for (String s : inputs) {
@@ -72,6 +92,9 @@
}
public String multiListInput(List<String> inputs1, List<String> inputs2,
String x, int y) {
+ if (context == null) {
+ throw new RuntimeException("No CONTEXT!!!");
+ }
StringBuffer buf = new StringBuffer();
for (String s : inputs1) {
buf.append(s);
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java?rev=632089&r1=632088&r2=632089&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java
Thu Feb 28 10:58:19 2008
@@ -23,7 +23,12 @@
import org.apache.cxf.anonymous_complex_type.AnonymousComplexTypeImpl;
import org.apache.cxf.jaxb_element_test.JaxbElementTestImpl;
+import org.apache.cxf.jaxws.JAXWSMethodInvoker;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.ordered_param_holder.OrderedParamHolderImpl;
+import org.apache.cxf.service.invoker.Factory;
+import org.apache.cxf.service.invoker.PerRequestFactory;
+import org.apache.cxf.service.invoker.PooledFactory;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -38,8 +43,19 @@
"http://localhost:9003/DocLitBareCodeFirstService/";
protected void run() {
- Object implementor4 = new DocLitWrappedCodeFirstServiceImpl();
- Endpoint.publish(DOCLIT_CODEFIRST_URL, implementor4);
+
+ Factory factory = new
PerRequestFactory(DocLitWrappedCodeFirstServiceImpl.class);
+ factory = new PooledFactory(factory, 4);
+
+ JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory);
+ JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
+ factoryBean.setAddress(DOCLIT_CODEFIRST_URL);
+ factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
+ factoryBean.setInvoker(invoker);
+ factoryBean.create();
+
+ //Object implementor4 = new DocLitWrappedCodeFirstServiceImpl();
+ //Endpoint.publish(DOCLIT_CODEFIRST_URL, implementor4);
Object implementor7 = new DocLitBareCodeFirstServiceImpl();
Endpoint.publish(DOCLITBARE_CODEFIRST_URL, implementor7);