You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by lm...@apache.org on 2010/07/27 22:47:12 UTC
svn commit: r979862 [7/19] - in /cxf/sandbox/oauth_1.0a: ./ api/
api/src/main/java/org/apache/cxf/ api/src/main/java/org/apache/cxf/endpoint/
api/src/main/java/org/apache/cxf/phase/
api/src/main/java/org/apache/cxf/ws/addressing/ api/src/main/java/org/...
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java Tue Jul 27 20:46:55 2010
@@ -19,6 +19,7 @@
package org.apache.cxf.jaxws.spi;
+import java.lang.reflect.Method;
import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -42,6 +43,7 @@ import org.w3c.dom.Element;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.common.WSDLConstants;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxws.EndpointImpl;
@@ -54,8 +56,31 @@ import org.apache.cxf.wsdl.WSDLManager;
public class ProviderImpl extends javax.xml.ws.spi.Provider {
public static final String JAXWS_PROVIDER = ProviderImpl.class.getName();
- private static final Logger LOG = LogUtils.getL7dLogger(ProviderImpl.class);
+ protected static final Logger LOG = LogUtils.getL7dLogger(ProviderImpl.class);
private static JAXBContext jaxbContext;
+ private static final boolean JAXWS_22;
+ static {
+ boolean b = false;
+ try {
+ //JAX-WS 2.2 would have the HttpContext class in the classloader
+ Class<?> cls = ClassLoaderUtils.loadClass("javax.xml.ws.spi.http.HttpContext",
+ ProviderImpl.class);
+ //In addition to that, the Endpoint class we pick up on the classloader
+ //should have a publish method that uses it. Otherwise, we MAY be
+ //be getting the HttpContext from the 2.2 jaxws-api jar, but the Endpoint
+ //class from the 2.1 JRE
+ Method m = Endpoint.class.getMethod("publish", cls);
+ b = m != null;
+ } catch (Throwable ex) {
+ b = false;
+ }
+ JAXWS_22 = b;
+ }
+
+
+ public static boolean isJaxWs22() {
+ return JAXWS_22;
+ }
@Override
public ServiceDelegate createServiceDelegate(URL url, QName qname, Class cls) {
@@ -77,6 +102,13 @@ public class ProviderImpl extends javax.
serviceName, serviceClass, features);
}
+
+ protected EndpointImpl createEndpointImpl(Bus bus,
+ String bindingId,
+ Object implementor,
+ WebServiceFeature ... features) {
+ return new EndpointImpl(bus, implementor, bindingId, features);
+ }
@Override
public Endpoint createEndpoint(String bindingId, Object implementor) {
@@ -84,7 +116,7 @@ public class ProviderImpl extends javax.
Endpoint ep = null;
if (EndpointUtils.isValidImplementor(implementor)) {
Bus bus = BusFactory.getThreadDefaultBus();
- ep = new EndpointImpl(bus, implementor, bindingId);
+ ep = createEndpointImpl(bus, bindingId, implementor);
return ep;
} else {
throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
@@ -97,7 +129,7 @@ public class ProviderImpl extends javax.
EndpointImpl ep = null;
if (EndpointUtils.isValidImplementor(implementor)) {
Bus bus = BusFactory.getThreadDefaultBus();
- ep = new EndpointImpl(bus, implementor, bindingId, features);
+ ep = createEndpointImpl(bus, bindingId, implementor, features);
return ep;
} else {
throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
@@ -290,11 +322,4 @@ public class ProviderImpl extends javax.
}
return jaxbContext;
}
- /*
- //new in 2.2, but introduces a new class not found in 2.1
- public Endpoint createEndpoint(String bindingId, Class<?> implementorClass,
- Invoker invoker, WebServiceFeature ... features) {
- //TODO - JAXWS 2.2
- }
- */
}
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java Tue Jul 27 20:46:55 2010
@@ -37,6 +37,7 @@ import org.apache.cxf.configuration.spri
import org.apache.cxf.configuration.spring.BusWiringType;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.spi.ProviderImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
@@ -48,12 +49,27 @@ import org.springframework.context.Appli
public class EndpointDefinitionParser extends AbstractBeanDefinitionParser {
-
+ private static final Class<?> EP_CLASS;
+ static {
+ Class<?> cls = SpringEndpointImpl.class;
+ try {
+ if (ProviderImpl.isJaxWs22()) {
+ cls = ClassLoaderUtils
+ .loadClass("org.apache.cxf.jaxws22.spring.JAXWS22SpringEndpointImpl",
+ EndpointDefinitionParser.class);
+ }
+ } catch (Throwable t) {
+ cls = SpringEndpointImpl.class;
+ }
+ EP_CLASS = cls;
+ }
+
+
private static final String IMPLEMENTOR = "implementor";
public EndpointDefinitionParser() {
super();
- setBeanClass(SpringEndpointImpl.class);
+ setBeanClass(EP_CLASS);
}
@Override
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java Tue Jul 27 20:46:55 2010
@@ -25,6 +25,8 @@ import java.util.List;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Binding;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.WebServiceFeature;
@@ -32,6 +34,7 @@ import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.MTOMFeature;
import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.w3c.dom.Element;
@@ -70,7 +73,10 @@ import org.apache.cxf.service.model.Bind
import org.apache.cxf.service.model.DescriptionInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.apache.cxf.ws.addressing.JAXWSAConstants;
+import org.apache.cxf.ws.addressing.Names;
+import org.apache.cxf.ws.addressing.VersionTransformer;
import org.apache.cxf.ws.addressing.WSAddressingFeature;
import org.apache.cxf.ws.policy.PolicyConstants;
import org.apache.cxf.wsdl.WSDLManager;
@@ -195,6 +201,28 @@ public class JaxWsEndpointImpl extends E
}
addAddressingFeature(feature);
}
+ extractWsdlEprs(endpoint);
+ }
+
+ private void extractWsdlEprs(EndpointInfo endpoint) {
+ //parse the EPR in wsdl
+ List<ExtensibilityElement> portExtensors = endpoint.getExtensors(ExtensibilityElement.class);
+ if (portExtensors != null) {
+ Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator();
+ QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference");
+ while (extensionElements.hasNext()) {
+ ExtensibilityElement ext = (ExtensibilityElement)extensionElements.next();
+ if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) {
+ DOMSource domSource = new DOMSource(((UnknownExtensibilityElement)ext).getElement());
+ W3CEndpointReference w3cEPR = new W3CEndpointReference(domSource);
+ EndpointReferenceType ref = VersionTransformer.convertToInternal(w3cEPR);
+ endpoint.getTarget().setMetadata(ref.getMetadata());
+ endpoint.getTarget().setReferenceParameters(ref.getReferenceParameters());
+ endpoint.getTarget().getOtherAttributes().putAll(ref.getOtherAttributes());
+ }
+
+ }
+ }
}
private boolean hasUsingAddressing(List<ExtensibilityElement> exts) {
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java Tue Jul 27 20:46:55 2010
@@ -301,9 +301,26 @@ public class JaxWsImplementorInfo {
}
}
}
- wsProviderAnnotation = implementorClass.getAnnotation(WebServiceProvider.class);
+
+ wsProviderAnnotation = getWebServiceProviderAnnotation(implementorClass);
}
+ private static WebServiceProvider getWebServiceProviderAnnotation(Class<?> cls) {
+ if (cls == null) {
+ return null;
+ }
+ WebServiceProvider ann = cls.getAnnotation(WebServiceProvider.class);
+ if (null != ann) {
+ return ann;
+ }
+ for (Class<?> inf : cls.getInterfaces()) {
+ if (null != inf.getAnnotation(WebServiceProvider.class)) {
+ return inf.getAnnotation(WebServiceProvider.class);
+ }
+ }
+ return getWebServiceProviderAnnotation(cls.getSuperclass());
+ }
+
public boolean isWebServiceProvider() {
return Provider.class.isAssignableFrom(implementorClass);
}
@@ -321,22 +338,28 @@ public class JaxWsImplementorInfo {
}
public Class<?> getProviderParameterType() {
- // The Provider Implementor inherits out of Provider<T>
- Class<?> c = implementorClass;
+ return doGetProviderParameterType(implementorClass);
+ }
+
+ private static Class<?> doGetProviderParameterType(Class<?> c) {
while (c != null) {
Type intfTypes[] = c.getGenericInterfaces();
for (Type t : intfTypes) {
Class<?> clazz = JAXBEncoderDecoder.getClassFromType(t);
- if (Provider.class == clazz) {
- Type paramTypes[] = ((ParameterizedType)t).getActualTypeArguments();
- return JAXBEncoderDecoder.getClassFromType(paramTypes[0]);
+ if (Provider.class.isAssignableFrom(clazz)) {
+ if (Provider.class == clazz) {
+ Type paramTypes[] = ((ParameterizedType)t).getActualTypeArguments();
+ return JAXBEncoderDecoder.getClassFromType(paramTypes[0]);
+ } else {
+ return doGetProviderParameterType(clazz);
+ }
}
}
c = c.getSuperclass();
}
return null;
}
-
+
public String getBindingType() {
BindingType bType = implementorClass.getAnnotation(BindingType.class);
if (bType != null) {
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Tue Jul 27 20:46:55 2010
@@ -41,6 +41,7 @@ import javax.xml.ws.Action;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.BindingType;
import javax.xml.ws.FaultAction;
+import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.WebFault;
import javax.xml.ws.WebServiceFeature;
@@ -269,10 +270,11 @@ public class JaxWsServiceFactoryBean ext
}
protected void initializeWSDLOperationsForProvider() {
- Type[] genericInterfaces = getServiceClass().getGenericInterfaces();
- ParameterizedType pt = (ParameterizedType)genericInterfaces[0];
- Class c = (Class)pt.getActualTypeArguments()[0];
-
+ Class c = getProviderParameterType(getServiceClass());
+ if (c == null) {
+ throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
+ }
+
if (getEndpointInfo() == null
&& isFromWsdl()) {
//most likely, they specified a WSDL, but for some reason
@@ -367,6 +369,24 @@ public class JaxWsServiceFactoryBean ext
}
+ protected Class<?> getProviderParameterType(Class<?> cls) {
+ if (cls == null) {
+ return null;
+ }
+ Type[] genericInterfaces = cls.getGenericInterfaces();
+ for (Type type : genericInterfaces) {
+ if (type instanceof ParameterizedType) {
+ Class<?> rawCls = (Class<?>)((ParameterizedType)type).getRawType();
+ if (Provider.class == rawCls) {
+ return (Class<?>)((ParameterizedType)type).getActualTypeArguments()[0];
+ }
+ } else if (type instanceof Class && Provider.class.isAssignableFrom((Class)type)) {
+ return getProviderParameterType((Class)type);
+ }
+ }
+ return getProviderParameterType(cls.getSuperclass());
+ }
+
void initializeWrapping(OperationInfo o, Method selected) {
Class responseWrapper = getResponseWrapper(selected);
if (responseWrapper != null) {
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties Tue Jul 27 20:46:55 2010
@@ -19,6 +19,7 @@
#
#
SEI_LOAD_FAILURE_EXC = Failed to load service endpoint interface.
+INVALID_PROVIDER_EXC = {0} is not a valid JAXWS Provider.
SEI_LOAD_FAILURE_MSG = Could not load Webservice SEI
SEI_WITHOUT_WEBSERVICE_ANNOTATION_EXC = Service endpoint interface does not have a @WebService annotation.
ILLEGAL_ATTRIBUTE_IN_SEI_ANNOTATION_EXC = Attributes portName, serviceName and endpointInterface are not allowed in the @WebService annotation of an SEI.
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java Tue Jul 27 20:46:55 2010
@@ -160,4 +160,29 @@ public class JaxWsServerFactoryBeanTest
doc,
XPathConstants.NODE);
}
+
+ @Test
+ public void testPostConstructCalled() throws Exception {
+ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+ factory.setServiceClass(Hello.class);
+ Hello bean = new Hello();
+ factory.setServiceBean(bean);
+ String address = "http://localhost:9001/jaxwstest";
+ factory.setAddress(address);
+ factory.create();
+ assertTrue("PostConstruct is not called", bean.isPostConstructCalled());
+ }
+
+ @Test
+ public void testPostConstructBlocked() throws Exception {
+ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+ factory.setServiceClass(Hello.class);
+ Hello bean = new Hello();
+ factory.setServiceBean(bean);
+ String address = "http://localhost:9001/jaxwstest";
+ factory.setAddress(address);
+ factory.setBlockPostConstruct(true);
+ factory.create();
+ assertFalse("PostConstruct is called", bean.isPostConstructCalled());
+ }
}
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java Tue Jul 27 20:46:55 2010
@@ -21,12 +21,26 @@ package org.apache.cxf.jaxws.service;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.PostConstruct;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Hello {
+ private boolean postConstructCalled;
+
+ @PostConstruct
+ @WebMethod(exclude = true)
+ public void init() {
+ postConstructCalled = true;
+ }
+
+ @WebMethod(exclude = true)
+ public boolean isPostConstructCalled() {
+ return postConstructCalled;
+ }
+
@WebMethod
public String sayHi(String text) {
return text;
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/js/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/js/pom.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/js/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/js/pom.xml Tue Jul 27 20:46:55 2010
@@ -82,7 +82,7 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.1_spec</artifactId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
</dependency>
</dependencies>
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties Tue Jul 27 20:46:55 2010
@@ -19,4 +19,4 @@
#
#
COULD.NOT.RESOLVE.BINDING=Could not resolve a binding for {0}
-ERROR_READING_SCHEMA=There was an error reading the schema {0}.
\ No newline at end of file
+
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java Tue Jul 27 20:46:55 2010
@@ -176,10 +176,7 @@ public class DefaultServiceConfiguration
@Override
public Boolean hasOutMessage(Method m) {
- if (m.getReturnType().getClass().equals(void.class) && m.getExceptionTypes().length == 0) {
- return false;
- }
- return true;
+ return Boolean.TRUE;
}
@Override
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Tue Jul 27 20:46:55 2010
@@ -19,7 +19,6 @@
package org.apache.cxf.service.factory;
-import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
@@ -49,15 +48,14 @@ import java.util.logging.Logger;
import javax.wsdl.Operation;
import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlMimeType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
-import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.DOMError;
import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.Document;
import org.apache.cxf.BusException;
import org.apache.cxf.binding.BindingFactoryManager;
@@ -70,7 +68,6 @@ import org.apache.cxf.common.util.String
import org.apache.cxf.common.xmlschema.SchemaCollection;
import org.apache.cxf.common.xmlschema.XmlSchemaUtils;
import org.apache.cxf.common.xmlschema.XmlSchemaValidationManager;
-import org.apache.cxf.databinding.AbstractDataBinding;
import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.databinding.source.mime.MimeAttribute;
import org.apache.cxf.databinding.source.mime.MimeSerializer;
@@ -83,14 +80,12 @@ import org.apache.cxf.frontend.FaultInfo
import org.apache.cxf.frontend.MethodDispatcher;
import org.apache.cxf.frontend.SimpleMethodDispatcher;
import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.MethodComparator;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.FaultOutInterceptor;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.resource.URIResolver;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.ServiceImpl;
import org.apache.cxf.service.ServiceModelSchemaValidator;
@@ -120,11 +115,12 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaObjectTable;
import org.apache.ws.commons.schema.XmlSchemaSequence;
-
import org.apache.ws.commons.schema.XmlSchemaType;
import org.apache.ws.commons.schema.constants.Constants;
import org.apache.ws.commons.schema.utils.NamespaceMap;
+
+
/**
* Introspects a class and builds a {@link Service} from it. If a WSDL URL is
* specified, a Service model will be directly from the WSDL and then metadata
@@ -181,7 +177,6 @@ public class ReflectionServiceFactoryBea
private Map<Method, Boolean> isRpcCache = new HashMap<Method, Boolean>();
private String styleCache;
private Boolean defWrappedCache;
- private List<String> schemaLocations;
public ReflectionServiceFactoryBean() {
getServiceConfigurations().add(0, new DefaultServiceConfiguration());
@@ -229,39 +224,6 @@ public class ReflectionServiceFactoryBea
}
retVal = db;
}
- if (retVal instanceof AbstractDataBinding && schemaLocations != null) {
- ResourceManager rr = getBus().getExtension(ResourceManager.class);
-
- List<DOMSource> schemas = new ArrayList<DOMSource>();
- for (String l : schemaLocations) {
- URL url = rr.resolveResource(l, URL.class);
-
- if (url == null) {
- URIResolver res;
- try {
- res = new URIResolver(l);
- } catch (IOException e) {
- throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e);
- }
-
- if (!res.isResolved()) {
- throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l));
- }
- url = res.getURL();
- }
-
- Document d;
- try {
- d = DOMUtils.readXml(url.openStream());
- } catch (Exception e) {
- throw new ServiceConstructionException(
- new Message("ERROR_READING_SCHEMA", LOG, l), e);
- }
- schemas.add(new DOMSource(d, url.toString()));
- }
-
- ((AbstractDataBinding)retVal).setSchemas(schemas);
- }
return retVal;
}
public void reset() {
@@ -1432,6 +1394,9 @@ public class ReflectionServiceFactoryBea
if (anno instanceof XmlJavaTypeAdapter) {
map.put(XmlJavaTypeAdapter.class, true);
}
+ if (anno instanceof XmlElementWrapper) {
+ map.put(XmlElementWrapper.class, true);
+ }
}
}
return map;
Modified: cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties (original)
+++ cxf/sandbox/oauth_1.0a/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties Tue Jul 27 20:46:55 2010
@@ -33,4 +33,4 @@ INTRACTABLE_PART= Message part {0} of Me
JAXWS_ANNOTATION_FOUND=A JAX-WS Annotation was found on {0} while using the Simple frontend. For better results, use the JAX-WS frontend.
XSD_VALIDATION_ERROR= Error in W3C XML Schema associated with service: {0}
COULD_NOT_UNWRAP=Could not unwrap Operation {0} to match method "{1}"
-INVALID_SCHEMA_URL=Could not load schema {0}
\ No newline at end of file
+
Modified: cxf/sandbox/oauth_1.0a/rt/javascript/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/javascript/pom.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/javascript/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/javascript/pom.xml Tue Jul 27 20:46:55 2010
@@ -88,8 +88,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
Modified: cxf/sandbox/oauth_1.0a/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml Tue Jul 27 20:46:55 2010
@@ -41,17 +41,17 @@
<httpj:engine-factory bus="cxf">
<httpj:engine port="8808">
<httpj:handlers>
- <bean class="org.mortbay.jetty.handler.ContextHandler">
+ <bean class="org.eclipse.jetty.server.handler.ContextHandler">
<property name="contextPath" value="/" />
<property name="handler">
- <bean class="org.mortbay.jetty.handler.ResourceHandler">
+ <bean class="org.eclipse.jetty.server.handler.ResourceHandler">
<property name="baseResource">
- <bean class="org.mortbay.resource.FileResource">
+ <bean class="org.eclipse.jetty.util.resource.FileResource">
<constructor-arg value="${staticResourceURL}" />
</bean>
</property>
<property name="mimeTypes">
- <bean class="org.mortbay.jetty.MimeTypes">
+ <bean class="org.eclipse.jetty.http.MimeTypes">
<property name="mimeMap">
<map>
<entry key="html"><value>text/html; charset="utf-8"</value></entry>
@@ -62,7 +62,7 @@
</bean>
</property>
</bean>
- <bean class="org.mortbay.jetty.handler.DefaultHandler" />
+ <bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
</httpj:handlers>
</httpj:engine>
</httpj:engine-factory>
Modified: cxf/sandbox/oauth_1.0a/rt/testsupport/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/testsupport/pom.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/testsupport/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/testsupport/pom.xml Tue Jul 27 20:46:55 2010
@@ -74,7 +74,7 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.1_spec</artifactId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/pom.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/pom.xml Tue Jul 27 20:46:55 2010
@@ -53,13 +53,13 @@
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-management</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
<optional>true</optional>
</dependency>
@@ -69,8 +69,8 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <groupId>${servlet-api.group}</groupId>
+ <artifactId>${servlet-api.artifact}</artifactId>
</dependency>
<dependency>
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java Tue Jul 27 20:46:55 2010
@@ -18,7 +18,7 @@
*/
package org.apache.cxf.transport.http_jetty;
-import org.mortbay.jetty.AbstractConnector;
+import org.eclipse.jetty.server.AbstractConnector;
/**
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextInspector.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextInspector.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextInspector.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextInspector.java Tue Jul 27 20:46:55 2010
@@ -19,7 +19,7 @@
package org.apache.cxf.transport.http_jetty;
import org.apache.cxf.endpoint.ContextInspector;
-import org.mortbay.jetty.handler.ContextHandler;
+import org.eclipse.jetty.server.handler.ContextHandler;
public class JettyContextInspector implements ContextInspector {
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Tue Jul 27 20:46:55 2010
@@ -34,7 +34,6 @@ import org.apache.cxf.BusFactory;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.configuration.security.CertificateConstraintsType;
-import org.apache.cxf.continuations.ContinuationInfo;
import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.continuations.SuspendedInvocationException;
import org.apache.cxf.interceptor.Fault;
@@ -46,15 +45,12 @@ import org.apache.cxf.service.model.Endp
import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.apache.cxf.transport.http.HTTPSession;
import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
-import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationWrapper;
import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
import org.apache.cxf.transports.http.QueryHandler;
import org.apache.cxf.transports.http.QueryHandlerRegistry;
import org.apache.cxf.transports.http.StemMatchingQueryHandler;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.Request;
-import org.mortbay.util.ajax.Continuation;
-import org.mortbay.util.ajax.ContinuationSupport;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
public class JettyHTTPDestination extends AbstractHTTPDestination {
@@ -162,8 +158,7 @@ public class JettyHTTPDestination extend
try {
url = new URL(endpointInfo.getAddress());
} catch (Exception e) {
- throw new Fault(new org.apache.cxf.common.i18n.Message("START_UP_SERVER_FAILED_MSG",
- LOG, e.getMessage()), e);
+ throw new Fault(e);
}
engine.addServant(url,
new JettyHTTPHandler(this, contextMatchOnExact()));
@@ -220,6 +215,14 @@ public class JettyHTTPDestination extend
Request baseRequest = (req instanceof Request)
? (Request)req : HttpConnection.getCurrentConnection().getRequest();
+ if (!"HEAD".equals(req.getMethod())) {
+ //bug in Jetty with persistent connections that if a HEAD is
+ //sent, a _head flag is never reset
+ HttpConnection c = baseRequest.getConnection();
+ if (c != null) {
+ c.getGenerator().setHead(false);
+ }
+ }
if (getServer().isSetRedirectURL()) {
resp.sendRedirect(getServer().getRedirectURL());
resp.flushBuffer();
@@ -295,11 +298,6 @@ public class JettyHTTPDestination extend
if (inMessage == null) {
inMessage = new MessageImpl();
- if (engine.getContinuationsEnabled()) {
- inMessage.put(ContinuationProvider.class.getName(),
- new JettyContinuationProvider(req, inMessage));
- }
-
setupMessage(inMessage, context, req, resp);
((MessageImpl)inMessage).setDestination(this);
@@ -313,17 +311,11 @@ public class JettyHTTPDestination extend
incomingObserver.onMessage(inMessage);
resp.flushBuffer();
baseRequest.setHandled(true);
- JettyContinuationProvider p = (JettyContinuationProvider)inMessage
- .get(ContinuationProvider.class.getName());
- if (p != null) {
- //make sure the continuation is stripped down
- JettyContinuationWrapper c = p.getContinuation(false);
- if (c != null) {
- c.done();
- }
- }
} catch (SuspendedInvocationException ex) {
- throw ex.getRuntimeException();
+ if (ex.getRuntimeException() != null) {
+ throw ex.getRuntimeException();
+ }
+ //else nothing to do
} catch (Fault ex) {
Throwable cause = ex.getCause();
if (cause instanceof RuntimeException) {
@@ -340,38 +332,6 @@ public class JettyHTTPDestination extend
}
}
- protected Message retrieveFromContinuation(HttpServletRequest req) {
- Message m = null;
-
- if (!engine.getContinuationsEnabled()) {
- return null;
- }
-
- Continuation cont = ContinuationSupport.getContinuation(req, null);
- synchronized (cont) {
- Object o = cont.getObject();
- if (o instanceof ContinuationInfo) {
- ContinuationInfo ci = (ContinuationInfo)o;
- m = ci.getMessage();
-
- // now that we got the message we don't need ContinuationInfo
- // as we don't know how continuation was suspended, by jetty wrapper
- // or directly in which (latter) case we need to ensure that an original user object
- // if any, need to be restored
- cont.setObject(ci.getUserObject());
- }
- if (m == null && (cont.isPending() || cont.isResumed())) {
- String message = "No message for existing continuation, status : "
- + (cont.isPending() ? "Pending" : "Resumed");
- if (!(o instanceof ContinuationInfo)) {
- message += ", ContinuationInfo object is unavailable";
- }
- LOG.warning(message);
- }
- }
- return m;
- }
-
@Override
public void shutdown() {
transportFactory.removeDestination(endpointInfo);
@@ -386,4 +346,16 @@ public class JettyHTTPDestination extend
private String getStem(String baseURI) {
return baseURI.substring(0, baseURI.lastIndexOf("/"));
}
+
+ protected Message retrieveFromContinuation(HttpServletRequest req) {
+ return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
+ }
+ protected void setupContinuation(Message inMessage,
+ final HttpServletRequest req,
+ final HttpServletResponse resp) {
+ if (engine.getContinuationsEnabled()) {
+ inMessage.put(ContinuationProvider.class.getName(),
+ new JettyContinuationProvider(req, resp, inMessage));
+ }
+ }
}
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java Tue Jul 27 20:46:55 2010
@@ -21,10 +21,12 @@ package org.apache.cxf.transport.http_je
import java.io.IOException;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.mortbay.jetty.handler.AbstractHandler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.AbstractHandler;
public class JettyHTTPHandler extends AbstractHandler {
private String urlName;
@@ -59,17 +61,18 @@ public class JettyHTTPHandler extends Ab
return target.startsWith(pathString);
}
- public void handle(String target, HttpServletRequest req,
- HttpServletResponse resp, int dispatch) throws IOException {
+ public void handle(String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
if (contextMatchExact) {
if (target.equals(urlName)) {
- jettyHTTPDestination.doService(servletContext, req, resp);
+ jettyHTTPDestination.doService(servletContext, request, response);
}
} else {
if (target.equals(urlName) || checkContextPath(target)) {
- jettyHTTPDestination.doService(servletContext, req, resp);
+ jettyHTTPDestination.doService(servletContext, request, response);
}
}
+
}
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java Tue Jul 27 20:46:55 2010
@@ -21,7 +21,6 @@ package org.apache.cxf.transport.http_je
import java.io.IOException;
import java.net.URL;
-
import java.security.GeneralSecurityException;
import java.util.List;
import java.util.logging.Level;
@@ -38,21 +37,23 @@ import org.apache.cxf.configuration.jsse
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.transport.HttpUriMapper;
import org.apache.cxf.transport.https_jetty.JettySslConnectorFactory;
-import org.mortbay.component.Container;
-import org.mortbay.jetty.AbstractConnector;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.handler.DefaultHandler;
-import org.mortbay.jetty.handler.HandlerList;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.HashSessionIdManager;
-import org.mortbay.jetty.servlet.HashSessionManager;
-import org.mortbay.jetty.servlet.SessionHandler;
-import org.mortbay.thread.QueuedThreadPool;
+import org.eclipse.jetty.server.AbstractConnector;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.handler.DefaultHandler;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.session.HashSessionIdManager;
+import org.eclipse.jetty.server.session.HashSessionManager;
+import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.component.Container;
+import org.eclipse.jetty.util.thread.OldQueuedThreadPool;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
/**
@@ -292,7 +293,6 @@ public class JettyHTTPServerEngine
* @param url the URL associated with the servant
* @param handler notified on incoming HTTP requests
*/
- @SuppressWarnings("deprecation")
public synchronized void addServant(URL url, JettyHTTPHandler handler) {
if (server == null) {
DefaultHandler defaultHandler = null;
@@ -314,52 +314,72 @@ public class JettyHTTPServerEngine
LOG.finer("connector.port: " + connector.getPort());
}
}
- server.addConnector(connector);
+
+ server.addConnector(connector);
+ /*
+ * The server may have no handler, it might have a collection handler,
+ * it might have a one-shot. We need to add one or more of ours.
+ *
+ */
+ int numberOfHandlers = 1;
+ if (handlers != null) {
+ numberOfHandlers += handlers.size();
+ }
+ Handler existingHandler = server.getHandler();
+
+ HandlerCollection handlerCollection = null;
+ boolean existingHandlerCollection = existingHandler instanceof HandlerCollection;
+ if (existingHandlerCollection) {
+ handlerCollection = (HandlerCollection) existingHandler;
+ }
+
+ if (!existingHandlerCollection
+ &&
+ (existingHandler != null || numberOfHandlers > 1)) {
+ handlerCollection = new HandlerCollection();
+ if (existingHandler != null) {
+ handlerCollection.addHandler(existingHandler);
+ }
+ server.setHandler(handlerCollection);
+ }
+
+ /*
+ * At this point, the server's handler is a collection. It was either
+ * one to start, or it is now one containing only the single handler
+ * that was there to begin with.
+ */
+
if (handlers != null && handlers.size() > 0) {
- HandlerList handlerList = new HandlerList();
for (Handler h : handlers) {
- // filting the jetty default handler
- // which should not be added at this point
+ // Filtering out the jetty default handler
+ // which should not be added at this point.
if (h instanceof DefaultHandler) {
defaultHandler = (DefaultHandler) h;
} else {
- handlerList.addHandler(h);
+ handlerCollection.addHandler(h);
}
}
- server.addHandler(handlerList);
}
contexts = new ContextHandlerCollection();
- server.addHandler(contexts);
- if (defaultHandler != null) {
- server.addHandler(defaultHandler);
+ /*
+ * handlerCollection may be null here if is only one handler to deal with.
+ * Which in turn implies that there can't be a 'defaultHander' to deal with.
+ */
+ if (handlerCollection != null) {
+ handlerCollection.addHandler(contexts);
+ if (defaultHandler != null) {
+ handlerCollection.addHandler(defaultHandler);
+ }
+ } else {
+ server.setHandler(contexts);
}
+
try {
setReuseAddress(connector);
+ setupThreadPool();
server.start();
-
- AbstractConnector aconn = (AbstractConnector) connector;
- if (isSetThreadingParameters()) {
- if (aconn.getThreadPool() instanceof org.mortbay.thread.BoundedThreadPool) {
- org.mortbay.thread.BoundedThreadPool pool
- = (org.mortbay.thread.BoundedThreadPool)aconn.getThreadPool();
- if (getThreadingParameters().isSetMinThreads()) {
- pool.setMinThreads(getThreadingParameters().getMinThreads());
- }
- if (getThreadingParameters().isSetMaxThreads()) {
- pool.setMaxThreads(getThreadingParameters().getMaxThreads());
- }
- } else if (aconn.getThreadPool() instanceof QueuedThreadPool) {
- QueuedThreadPool pool = (QueuedThreadPool)aconn.getThreadPool();
- if (getThreadingParameters().isSetMinThreads()) {
- pool.setMinThreads(getThreadingParameters().getMinThreads());
- }
- if (getThreadingParameters().isSetMaxThreads()) {
- pool.setMaxThreads(getThreadingParameters().getMaxThreads());
- }
- }
- }
} catch (Exception e) {
- LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[] {e.getMessage()});
+ LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[] {e.getMessage(), port});
//problem starting server
try {
server.stop();
@@ -368,22 +388,27 @@ public class JettyHTTPServerEngine
//ignore - probably wasn't fully started anyway
}
server = null;
- throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage()), e);
+ throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage(), port), e);
}
}
String contextName = HttpUriMapper.getContextName(url.getPath());
ContextHandler context = new ContextHandler();
context.setContextPath(contextName);
-
- // bind the jetty http handler with the context handler
- context.setHandler(handler);
- if (isSessionSupport) {
+ // bind the jetty http handler with the context handler
+ if (isSessionSupport) {
+ // If we have sessions, we need two handlers.
HashSessionManager sessionManager = new HashSessionManager();
SessionHandler sessionHandler = new SessionHandler(sessionManager);
HashSessionIdManager idManager = new HashSessionIdManager();
- sessionManager.setIdManager(idManager);
- context.addHandler(sessionHandler);
+ sessionManager.setIdManager(idManager);
+ HandlerCollection hc = new HandlerCollection();
+ hc.addHandler(handler);
+ hc.addHandler(sessionHandler);
+ context.setHandler(hc);
+ } else {
+ // otherwise, just the one.
+ context.setHandler(handler);
}
contexts.addHandler(context);
@@ -405,6 +430,34 @@ public class JettyHTTPServerEngine
++servantCount;
}
+ protected void setupThreadPool() {
+ AbstractConnector aconn = (AbstractConnector) connector;
+ if (isSetThreadingParameters()) {
+ ThreadPool pool = aconn.getThreadPool();
+ if (pool == null) {
+ pool = new QueuedThreadPool();
+ aconn.setThreadPool(pool);
+ }
+ if (pool instanceof OldQueuedThreadPool) {
+ OldQueuedThreadPool pl = (OldQueuedThreadPool)pool;
+ if (getThreadingParameters().isSetMinThreads()) {
+ pl.setMinThreads(getThreadingParameters().getMinThreads());
+ }
+ if (getThreadingParameters().isSetMaxThreads()) {
+ pl.setMaxThreads(getThreadingParameters().getMaxThreads());
+ }
+ } else if (pool instanceof QueuedThreadPool) {
+ QueuedThreadPool pl = (QueuedThreadPool)pool;
+ if (getThreadingParameters().isSetMinThreads()) {
+ pl.setMinThreads(getThreadingParameters().getMinThreads());
+ }
+ if (getThreadingParameters().isSetMaxThreads()) {
+ pl.setMaxThreads(getThreadingParameters().getMaxThreads());
+ }
+ }
+ }
+ }
+
private void setReuseAddress(Connector conn) throws IOException {
if (conn instanceof AbstractConnector) {
((AbstractConnector)conn).setReuseAddress(isReuseAddress());
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Tue Jul 27 20:46:55 2010
@@ -37,7 +37,7 @@ import org.apache.cxf.common.classloader
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.management.InstrumentationManager;
-import org.mortbay.component.Container;
+import org.eclipse.jetty.util.component.Container;
/**
@@ -290,7 +290,7 @@ public class JettyHTTPServerEngineFactor
MBeanServer mbs = bus.getExtension(InstrumentationManager.class).getMBeanServer();
if (mbs != null) {
try {
- Class<?> cls = ClassLoaderUtils.loadClass("org.mortbay.management.MBeanContainer",
+ Class<?> cls = ClassLoaderUtils.loadClass("org.eclipse.jetty.jmx.MBeanContainer",
getClass());
mBeanContainer = (Container.Listener) cls.
@@ -300,7 +300,7 @@ public class JettyHTTPServerEngineFactor
} catch (Throwable ex) {
//ignore - just won't instrument jetty. Probably don't have the
//jetty-management jar available
- LOG.info("Could not load or start org.mortbay.management.MBeanContainer. "
+ LOG.info("Could not load or start org.eclipse.management.MBeanContainer. "
+ "Jetty JMX support will not be enabled: " + ex.getMessage());
}
}
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties Tue Jul 27 20:46:55 2010
@@ -18,7 +18,7 @@
# under the License.
#
#
-START_UP_SERVER_FAILED_MSG = Could not start Jetty server: {0}
+START_UP_SERVER_FAILED_MSG = Could not start Jetty server on port {1}: {0}
ADD_HANDLER_FAILED_MSG = Could not add cxf jetty handler to Jetty server: {0}
REMOVE_HANDLER_FAILED_MSG = Could not remove cxf jetty handler from Jetty server: {0}
CAN_NOT_FIND_HANDLER_MSG = Could not find the handler to remove for context url {0}
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ServerEngine.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ServerEngine.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ServerEngine.java Tue Jul 27 20:46:55 2010
@@ -21,7 +21,7 @@ package org.apache.cxf.transport.http_je
import java.net.URL;
-import org.mortbay.jetty.Handler;
+import org.eclipse.jetty.server.Handler;
public interface ServerEngine {
/**
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java Tue Jul 27 20:46:55 2010
@@ -20,6 +20,7 @@
package org.apache.cxf.transport.http_jetty.continuations;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.cxf.continuations.Continuation;
import org.apache.cxf.continuations.ContinuationProvider;
@@ -28,11 +29,15 @@ import org.apache.cxf.message.Message;
public class JettyContinuationProvider implements ContinuationProvider {
private HttpServletRequest request;
+ private HttpServletResponse response;
private Message inMessage;
private JettyContinuationWrapper wrapper;
- public JettyContinuationProvider(HttpServletRequest req, Message m) {
+ public JettyContinuationProvider(HttpServletRequest req,
+ HttpServletResponse resp,
+ Message m) {
request = req;
+ response = resp;
this.inMessage = m;
}
public Continuation getContinuation() {
@@ -43,7 +48,7 @@ public class JettyContinuationProvider i
return null;
}
if (wrapper == null && create) {
- wrapper = new JettyContinuationWrapper(request, inMessage);
+ wrapper = new JettyContinuationWrapper(request, response, inMessage);
}
return wrapper;
}
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java Tue Jul 27 20:46:55 2010
@@ -20,96 +20,75 @@
package org.apache.cxf.transport.http_jetty.continuations;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.cxf.continuations.Continuation;
-import org.apache.cxf.continuations.ContinuationInfo;
-import org.apache.cxf.continuations.SuspendedInvocationException;
import org.apache.cxf.message.Message;
-import org.mortbay.jetty.RetryRequest;
-import org.mortbay.util.ajax.ContinuationSupport;
-
-public class JettyContinuationWrapper implements Continuation {
-
- private org.mortbay.util.ajax.Continuation continuation;
- private Message message;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.eclipse.jetty.continuation.ContinuationListener;
+import org.eclipse.jetty.server.AsyncContext;
+import org.eclipse.jetty.server.Request;
+
+public class JettyContinuationWrapper implements Continuation, ContinuationListener {
+ boolean isNew;
+ boolean isResumed;
+ boolean isPending = true;
+ Object obj;
+ private Message message;
+ private AsyncContext context;
+ private final Request req;
- public JettyContinuationWrapper(HttpServletRequest request, Message m) {
- continuation = ContinuationSupport.getContinuation(request, null);
+ public JettyContinuationWrapper(HttpServletRequest request,
+ HttpServletResponse resp,
+ Message m) {
+ req = (Request)request;
message = m;
+ isNew = !req.isAsyncStarted();
+ if (isNew) {
+ req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
+ message.getExchange().getInMessage());
+ context = req.startAsync(req, resp);
+ context.addContinuationListener(this);
+ } else {
+ context = req.getAsyncContext();
+ }
}
public Object getObject() {
- Object o = continuation.getObject();
- if (o instanceof ContinuationInfo) {
- return ((ContinuationInfo)o).getUserObject();
- }
- return o;
+ return obj;
+ }
+ public void setObject(Object userObject) {
+ obj = userObject;
+ }
+
+ public void resume() {
+ isResumed = true;
+ context.dispatch();
}
public boolean isNew() {
- return continuation.isNew() || (!continuation.isPending() && !continuation.isResumed());
+ return isNew;
}
public boolean isPending() {
- return continuation.isPending();
+ return isPending;
}
public boolean isResumed() {
- return continuation.isResumed();
+ return isResumed;
}
public void reset() {
- continuation.reset();
}
- public void resume() {
- continuation.resume();
- }
-
- public void setObject(Object userObject) {
-
- ContinuationInfo ci = null;
- Message m = message;
- if (m != null && m.getExchange() != null && m.getExchange().getInMessage() != null) {
- m = m.getExchange().getInMessage();
- }
- Object obj = continuation.getObject();
- if (obj instanceof ContinuationInfo) {
- ci = (ContinuationInfo)obj;
- } else {
- ci = new ContinuationInfo(m);
- ci.setUserObject(obj);
- }
- if (message != userObject) {
- ci.setUserObject(userObject);
- }
- continuation.setObject(ci);
- }
public boolean suspend(long timeout) {
-
- Object obj = continuation.getObject();
- if (obj == null) {
- continuation.setObject(new ContinuationInfo(message));
- }
- try {
- return continuation.suspend(timeout);
- } catch (RetryRequest ex) {
- throw new SuspendedInvocationException(ex);
- }
+ context.setTimeout(timeout);
+ isNew = false;
+ throw new org.apache.cxf.continuations.SuspendedInvocationException();
}
- public void done() {
- ContinuationInfo ci = null;
- Object obj = continuation.getObject();
- if (obj instanceof ContinuationInfo) {
- ci = (ContinuationInfo)obj;
- continuation.setObject(ci.getUserObject());
- }
- continuation.reset();
- }
-
protected Message getMessage() {
Message m = message;
if (m != null && m.getExchange().getInMessage() != null) {
@@ -118,9 +97,14 @@ public class JettyContinuationWrapper im
return m;
}
- public org.mortbay.util.ajax.Continuation getContinuation() {
- return continuation;
+
+ public void onComplete(org.eclipse.jetty.continuation.Continuation continuation) {
+ getMessage().remove(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE);
+ isPending = false;
+ }
+
+ public void onTimeout(org.eclipse.jetty.continuation.Continuation continuation) {
+ context.dispatch();
}
-
}
Propchange: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettySpringTypesFactory.java
('svn:mergeinfo' removed)
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java Tue Jul 27 20:46:55 2010
@@ -37,7 +37,7 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.configuration.security.ClientAuthentication;
import org.apache.cxf.configuration.security.FiltersType;
import org.apache.cxf.transport.https.SSLUtils;
-import org.mortbay.jetty.security.SslSocketConnector;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
/**
* This class extends the Jetty SslSocketConnector, which allows
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java Tue Jul 27 20:46:55 2010
@@ -21,7 +21,7 @@ package org.apache.cxf.transport.https_j
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.transport.http_jetty.JettyConnectorFactory;
-import org.mortbay.jetty.AbstractConnector;
+import org.eclipse.jetty.server.AbstractConnector;
/**
* This class wraps the JettyConnectorFactory and will create
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java Tue Jul 27 20:46:55 2010
@@ -21,11 +21,13 @@ package org.apache.cxf.transport.http_je
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
+
+import org.eclipse.jetty.server.handler.ContextHandler;
+
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.mortbay.jetty.handler.ContextHandler;
public class JettyContextInspectorTest extends Assert {
private static final String CONTEXT_PATH = "/foo/bar";
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java Tue Jul 27 20:46:55 2010
@@ -43,7 +43,6 @@ import org.apache.cxf.bus.CXFBusImpl;
import org.apache.cxf.common.util.Base64Utility;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.security.AuthorizationPolicy;
-import org.apache.cxf.continuations.ContinuationInfo;
import org.apache.cxf.continuations.SuspendedInvocationException;
import org.apache.cxf.endpoint.EndpointResolverRegistry;
import org.apache.cxf.helpers.CastUtils;
@@ -59,6 +58,7 @@ import org.apache.cxf.transport.ConduitI
import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.apache.cxf.transports.http.QueryHandler;
import org.apache.cxf.transports.http.QueryHandlerRegistry;
import org.apache.cxf.transports.http.StemMatchingQueryHandler;
@@ -69,13 +69,12 @@ import org.apache.cxf.ws.addressing.JAXW
import org.apache.cxf.ws.policy.PolicyEngine;
import org.apache.cxf.wsdl.EndpointReferenceUtils;
import org.easymock.classextension.EasyMock;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
-import org.mortbay.jetty.HttpFields;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Response;
-import org.mortbay.util.ajax.Continuation;
public class JettyHTTPDestinationTest extends Assert {
protected static final String AUTH_HEADER = "Authorization";
@@ -202,56 +201,11 @@ public class JettyHTTPDestinationTest ex
}
}
- @Test
- public void testRetrieveFromContinuation() throws Exception {
-
- Continuation continuation = EasyMock.createMock(Continuation.class);
-
- Message m = new MessageImpl();
- ContinuationInfo ci = new ContinuationInfo(m);
- Object userObject = new Object();
- ci.setUserObject(userObject);
- continuation.getObject();
- EasyMock.expectLastCall().andReturn(ci);
- continuation.setObject(ci.getUserObject());
- EasyMock.expectLastCall();
- EasyMock.replay(continuation);
-
- HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);
- httpRequest.getAttribute("org.mortbay.jetty.ajax.Continuation");
- EasyMock.expectLastCall().andReturn(continuation);
- EasyMock.replay(httpRequest);
-
- ServiceInfo serviceInfo = new ServiceInfo();
- serviceInfo.setName(new QName("bla", "Service"));
- EndpointInfo ei = new EndpointInfo(serviceInfo, "");
- ei.setName(new QName("bla", "Port"));
-
- transportFactory = new JettyHTTPTransportFactory();
- transportFactory.setBus(new CXFBusImpl());
-
- TestJettyDestination testDestination =
- new TestJettyDestination(transportFactory.getBus(),
- transportFactory, ei);
- testDestination.finalizeConfig();
- Message mi = testDestination.retrieveFromContinuation(httpRequest);
- assertSame("Message is lost", m, mi);
- EasyMock.verify(continuation);
- EasyMock.reset(httpRequest);
- httpRequest.getAttribute("org.mortbay.jetty.ajax.Continuation");
- EasyMock.expectLastCall().andReturn(null);
- mi = testDestination.retrieveFromContinuation(httpRequest);
- assertNotSame("New message expected", m, mi);
- }
@Test
public void testContinuationsIgnored() throws Exception {
- Continuation continuation = EasyMock.createMock(Continuation.class);
HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);
- httpRequest.getAttribute("org.mortbay.jetty.ajax.Continuation");
- EasyMock.expectLastCall().andReturn(continuation);
- EasyMock.replay(httpRequest);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
@@ -720,8 +674,9 @@ public class JettyHTTPDestinationTest ex
request = EasyMock.createMock(Request.class);
response = EasyMock.createMock(Response.class);
request.getMethod();
- EasyMock.expectLastCall().andReturn(method);
-
+ EasyMock.expectLastCall().andReturn(method).atLeastOnce();
+ request.getConnection();
+ EasyMock.expectLastCall().andReturn(null).anyTimes();
if (setRedirectURL) {
policy.setRedirectURL(NOWHERE + "foo/bar");
@@ -739,7 +694,10 @@ public class JettyHTTPDestinationTest ex
if ("GET".equals(method) && "?wsdl".equals(query)) {
verifyGetWSDLQuery();
} else { // test for the post
- EasyMock.expect(request.getMethod()).andReturn(method);
+ EasyMock.expect(request.getAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE))
+ .andReturn(null);
+
+ //EasyMock.expect(request.getMethod()).andReturn(method);
EasyMock.expect(request.getInputStream()).andReturn(is);
EasyMock.expect(request.getContextPath()).andReturn("/bar");
EasyMock.expect(request.getPathInfo()).andReturn("/foo");
@@ -748,7 +706,7 @@ public class JettyHTTPDestinationTest ex
EasyMock.expect(request.getQueryString()).andReturn(query);
EasyMock.expect(request.getHeader("Accept")).andReturn("*/*");
EasyMock.expect(request.getContentType()).andReturn("text/xml charset=utf8").times(2);
- EasyMock.expect(request.getAttribute("org.mortbay.jetty.ajax.Continuation")).andReturn(null);
+ EasyMock.expect(request.getAttribute("org.eclipse.jetty.ajax.Continuation")).andReturn(null);
HttpFields httpFields = new HttpFields();
httpFields.add("content-type", "text/xml");
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java Tue Jul 27 20:46:55 2010
@@ -37,18 +37,21 @@ import org.apache.cxf.Bus;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.configuration.spring.ConfigurerImpl;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.management.InstrumentationManager;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
+
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
public class JettyHTTPServerEngineTest extends Assert {
@@ -181,8 +184,8 @@ public class JettyHTTPServerEngineTest e
assertEquals("The jetty http handler did not take effect", response, "string1string2");
engine.addServant(new URL(urlStr2), handler2);
- Set<ObjectName> s = ManagementFactory.getPlatformMBeanServer().
- queryNames(new ObjectName("org.mortbay.jetty:type=server,*"), null);
+ Set<ObjectName> s = CastUtils.cast(ManagementFactory.getPlatformMBeanServer().
+ queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
assertEquals("Could not find 1 Jetty Server: " + s, 1, s.size());
engine.removeServant(new URL(urlStr));
@@ -211,14 +214,14 @@ public class JettyHTTPServerEngineTest e
engine.addServant(new URL(urlStr), handler1);
- Set<ObjectName> s = ManagementFactory.getPlatformMBeanServer().
- queryNames(new ObjectName("org.mortbay.jetty:type=server,*"), null);
+ Set<ObjectName> s = CastUtils.cast(ManagementFactory.getPlatformMBeanServer().
+ queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
assertEquals("Could not find 1 Jetty Server: " + s, 1, s.size());
engine2.addServant(new URL(urlStr2), handler2);
- s = ManagementFactory.getPlatformMBeanServer().
- queryNames(new ObjectName("org.mortbay.jetty:type=server,*"), null);
+ s = CastUtils.cast(ManagementFactory.getPlatformMBeanServer().
+ queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
assertEquals("Could not find 2 Jetty Server: " + s, 2, s.size());
engine.removeServant(new URL(urlStr));
@@ -227,14 +230,14 @@ public class JettyHTTPServerEngineTest e
engine.shutdown();
- s = ManagementFactory.getPlatformMBeanServer().
- queryNames(new ObjectName("org.mortbay.jetty:type=server,*"), null);
+ s = CastUtils.cast(ManagementFactory.getPlatformMBeanServer().
+ queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
assertEquals("Could not find 2 Jetty Server: " + s, 1, s.size());
engine2.shutdown();
- s = ManagementFactory.getPlatformMBeanServer().
- queryNames(new ObjectName("org.mortbay.jetty:type=server,*"), null);
+ s = CastUtils.cast(ManagementFactory.getPlatformMBeanServer().
+ queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
assertEquals("Could not find 0 Jetty Server: " + s, 0, s.size());
factory.destroyForPort(9234);
@@ -286,6 +289,7 @@ public class JettyHTTPServerEngineTest e
// transport.http_jetty:type=jettyhttptesthandler,id=0)
// when running subsequent tests.
contextHandler = engine.getContextHandler(new URL(urlStr));
+ contextHandler.stop();
contextHandler.setHandler(handler2);
contextHandler.start();
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPTestHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPTestHandler.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPTestHandler.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPTestHandler.java Tue Jul 27 20:46:55 2010
@@ -21,9 +21,12 @@ package org.apache.cxf.transport.http_je
import java.io.IOException;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.server.Request;
+
public class JettyHTTPTestHandler extends JettyHTTPHandler {
private boolean contextMatchExact;
private String response;
@@ -34,8 +37,11 @@ public class JettyHTTPTestHandler extend
response = s;
}
- public void handle(String target, HttpServletRequest req,
- HttpServletResponse resp, int dispatch) throws IOException {
+ @Override
+ public void handle(String target,
+ Request baseRequest,
+ HttpServletRequest request,
+ HttpServletResponse resp) throws IOException, ServletException {
if (contextMatchExact) {
// just return the response for testing
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml Tue Jul 27 20:46:55 2010
@@ -40,7 +40,7 @@
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
<httpj:connector>
- <beans:bean class="org.mortbay.jetty.bio.SocketConnector">
+ <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">
<beans:property name = "port" value="1234" />
</beans:bean>
</httpj:connector>
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java Tue Jul 27 20:46:55 2010
@@ -135,8 +135,8 @@ public class ApplicationContextTest exte
assertTrue("The engine should support session manager", engine.isSessionSupport());
assertNotNull("The handlers should not be null", engine.getHandlers());
assertEquals(1, engine.getHandlers().size());
- assertTrue("The connector should be instance of org.mortbay.jetty.bio.SocketConnector",
- engine.getConnector() instanceof org.mortbay.jetty.bio.SocketConnector);
+ assertTrue("The connector should be instance of org.eclipse.jetty.server.bio.SocketConnector",
+ engine.getConnector() instanceof org.eclipse.jetty.server.bio.SocketConnector);
JettyHTTPDestination jd3 =
(JettyHTTPDestination)factory.getDestination(
Modified: cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml?rev=979862&r1=979861&r2=979862&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml Tue Jul 27 20:46:55 2010
@@ -84,12 +84,12 @@
<hj:threadingParameters minThreads="${engine.port.nine.one.minThreads}"
maxThreads="${engine.port.nine.one.maxThreads}"/>
<hj:connector>
- <beans:bean class="org.mortbay.jetty.bio.SocketConnector">
+ <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">
<beans:property name = "port" value="${engine.port.nine.one}" />
</beans:bean>
</hj:connector>
<hj:handlers>
- <beans:bean class="org.mortbay.jetty.handler.DefaultHandler"/>
+ <beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</hj:handlers>
<hj:sessionSupport>true</hj:sessionSupport>
</hj:engine>