cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r821023 [1/2] - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/sr...
Date Fri, 02 Oct 2009 14:03:06 GMT
Author: sergeyb
Date: Fri Oct  2 14:03:05 2009
New Revision: 821023

URL: http://svn.apache.org/viewvc?rev=821023&view=rev
Log:
Merged revisions 821008 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r821008 | sergeyb | 2009-10-02 14:17:21 +0100 (Fri, 02 Oct 2009) | 1 line
  
  JAXRS : support for spring prototypes and injecting contexts into jaxrs filters
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
      - copied unchanged from r821008, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/
      - copied from r821008, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/TestBean.java
      - copied unchanged from r821008, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/TestBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/jaxb.index
      - copied unchanged from r821008, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/index/jaxb.index
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/SpringResourceFactoryTest.java
      - copied unchanged from r821008, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/SpringResourceFactoryTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers2.xml
      - copied unchanged from r821008, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers2.xml
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
      - copied unchanged from r821008, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface2.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
      - copied unchanged from r821008, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/LifecycleInterface.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisElementProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:821008

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java Fri Oct  2 14:03:05 2009
@@ -42,8 +42,16 @@
         return o.getClass();
     }
     
+    protected Class getRealClassFromClassInternal(Class cls) {
+        return cls;
+    }
+    
     
     public static Class getRealClass(Object o) {
         return HELPER.getRealClassInternal(o);
     }
+    
+    public static Class getRealClassFromClass(Class cls) {
+        return HELPER.getRealClassFromClassInternal(cls);
+    }
 }

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java Fri Oct  2 14:03:05 2009
@@ -31,6 +31,13 @@
         Class.forName("org.springframework.aop.framework.Advised");
     }
     
+    protected Class getRealClassFromClassInternal(Class cls) {
+        if (AopUtils.isCglibProxyClass(cls)) {
+            return getRealClassFromClassInternal(cls.getSuperclass());
+        }
+        return cls;
+    }
+    
     protected Class getRealClassInternal(Object o) {
         if (AopUtils.isAopProxy(o)) {
             Advised advised = (Advised)o;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Fri Oct  2 14:03:05 2009
@@ -38,6 +38,7 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.MethodInvocationInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
@@ -57,6 +58,8 @@
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSServiceFactoryBean.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSInvoker.class);
     private static final String SERVICE_LOADER_AS_CONTEXT = "org.apache.cxf.serviceloader-context";
+    private static final String SERVICE_OBJECT_SCOPE = "org.apache.cxf.service.scope";
+    private static final String REQUEST_SCOPE = "request";    
     
     public JAXRSInvoker() {
     }
@@ -73,8 +76,18 @@
             //      in the out interceptor instead of dealing with the contents list ?
             return new MessageContentsList(response);
         }
-        
-        return invoke(exchange, request, getServiceObject(exchange));
+        ResourceProvider provider = getResourceProvider(exchange);
+        Object serviceObject = getServiceObject(exchange);
+        try {
+            return invoke(exchange, request, serviceObject);
+        } finally {
+            if (!isServiceObjectRequestScope(exchange.getInMessage())) {
+                provider.releaseInstance(exchange.getInMessage(), serviceObject);
+            } else {
+                exchange.put(JAXRSUtils.ROOT_INSTANCE, serviceObject);
+                exchange.put(JAXRSUtils.ROOT_PROVIDER, provider);
+            }
+        }
     }
 
     @SuppressWarnings("unchecked")
@@ -208,6 +221,17 @@
         return Boolean.TRUE.equals(en) || "true".equals(en);
     }
     
+    private boolean isServiceObjectRequestScope(Message inMessage) {
+        Object scope = inMessage.getContextualProperty(SERVICE_OBJECT_SCOPE);
+        return REQUEST_SCOPE.equals(scope);
+    }
+    
+    private ResourceProvider getResourceProvider(Exchange exchange) {
+        OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
+        ClassResourceInfo cri = ori.getClassResourceInfo();
+        return cri.getResourceProvider();
+    }
+    
     public Object getServiceObject(Exchange exchange) {
         OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
         ClassResourceInfo cri = ori.getClassResourceInfo();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Fri Oct  2 14:03:05 2009
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,6 +31,7 @@
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
@@ -136,7 +138,7 @@
         extensionMappings = extMaps;
     }
     
-    public List<Class> getResourceClasses() {
+    public List<Class<?>> getResourceClasses() {
         return serviceFactory.getResourceClasses();
     }
     
@@ -169,6 +171,19 @@
     public void setResourceProvider(Class c, ResourceProvider rp) {
         resourceProviders.put(c, rp);
     }
+    
+    public void setResourceProvider(ResourceProvider rp) {
+        setResourceProviders(CastUtils.cast(Collections.singletonList(rp), ResourceProvider.class));
+    }
+    
+    
+    public void setResourceProviders(List<ResourceProvider> rps) {
+        for (ResourceProvider rp : rps) {
+            Class<?> c = rp.getResourceClass();
+            setServiceClass(c);
+            resourceProviders.put(c, rp);
+        }
+    }
 
     public void setInvoker(Invoker invoker) {
         serviceFactory.setInvoker(invoker);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java Fri Oct  2 14:03:05 2009
@@ -100,8 +100,8 @@
         this.invoker = invoker;
     }
 
-    public List<Class> getResourceClasses() {
-        List<Class> resourceClasses = new ArrayList<Class>();
+    public List<Class<?>> getResourceClasses() {
+        List<Class<?>> resourceClasses = new ArrayList<Class<?>>();
         for (ClassResourceInfo cri : classResourceInfos) {
             resourceClasses.add(cri.getResourceClass());
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java Fri Oct  2 14:03:05 2009
@@ -128,11 +128,11 @@
     
     public Client createWithValues(Object... varValues) {
         checkResources(false);
-        
+        ClassResourceInfo cri = null;
         try {
             Endpoint ep = createEndpoint();
             URI baseURI = URI.create(getAddress());
-            ClassResourceInfo cri = serviceFactory.getClassResourceInfo().get(0);
+            cri = serviceFactory.getClassResourceInfo().get(0);
             boolean isRoot = cri.getURITemplate() != null;
             ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, isRoot, inheritHeaders,
                                                             varValues);
@@ -149,6 +149,16 @@
                                                                 InvocationHandlerAware.class}, 
                                      proxyImpl);
             }
+        } catch (IllegalArgumentException ex) {
+            String message = ex.getLocalizedMessage();
+            if (cri != null) {
+                String expected = cri.getServiceClass().getSimpleName();
+                if ((expected + " is not an interface").equals(message)) {
+                    message += "; make sure CGLIB is on the classpath";
+                }
+            }
+            LOG.severe(ex.getClass().getName() + " : " + message);
+            throw ex;
         } catch (Exception ex) {
             LOG.severe(ex.getClass().getName() + " : " + ex.getLocalizedMessage());
             throw new RuntimeException(ex);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Fri Oct  2 14:03:05 2009
@@ -331,7 +331,7 @@
      * @param memberClass expected type of collection member class
      * @return typed collection
      */
-    public <T> Collection<T> postAndGetCollection(Object body, Class<T> memberClass) {
+    public <T> Collection<? extends T> postAndGetCollection(Object body, Class<T> memberClass) {
         return invokeAndGetCollection("POST", body, memberClass);
     }
     
@@ -341,7 +341,7 @@
      * @param memberClass expected type of collection member class
      * @return typed collection
      */
-    public <T> Collection<T> getCollection(Class<T> memberClass) {
+    public <T> Collection<? extends T> getCollection(Class<T> memberClass) {
         return invokeAndGetCollection("GET", null, memberClass);
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Fri Oct  2 14:03:05 2009
@@ -41,6 +41,7 @@
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -145,12 +146,14 @@
                     ori = JAXRSUtils.findTargetMethod(resource, 
                         values.getFirst(URITemplate.FINAL_MATCH_GROUP), httpMethod, values, 
                         requestContentType, acceptContentTypes, false);
-                    message.getExchange().put(OperationResourceInfo.class, ori);
+                    setMessageProperties(message, ori, values);
                 } catch (WebApplicationException ex) {
                     operChecked = true;
                 }
                 
             }
+            InjectionUtils.injectContextFields(sh.getProvider(), sh, message);
+            InjectionUtils.injectContextFields(sh.getProvider(), sh, message);
             Response response = sh.getProvider().handleRequest(message, resource);
             if (response != null) {
                 message.getExchange().put(Response.class, response);
@@ -172,8 +175,7 @@
             try {                
                 ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
                                             httpMethod, values, requestContentType, acceptContentTypes);
-                message.getExchange().put(OperationResourceInfo.class, ori);
-                message.put(URITemplate.TEMPLATE_PARAMETERS, values);
+                setMessageProperties(message, ori, values);
             } catch (WebApplicationException ex) {
                 if (ex.getResponse() != null && ex.getResponse().getStatus() == 405 
                     && "OPTIONS".equalsIgnoreCase(httpMethod)) {
@@ -193,14 +195,17 @@
         LOG.fine("Accept contentType is: " + acceptTypes);
         
         LOG.fine("Found operation: " + ori.getMethodToInvoke().getName());
-        
-        message.getExchange().put(OperationResourceInfo.class, ori);
-        message.put(JAXRSUtils.RELATIVE_PATH, values.getFirst(URITemplate.FINAL_MATCH_GROUP));
-        message.put(URITemplate.TEMPLATE_PARAMETERS, values);
+        setMessageProperties(message, ori, values);  
       
-        //2. Process parameters
+        //Process parameters
         List<Object> params = JAXRSUtils.processParameters(ori, values, message);
-
         message.setContent(List.class, params);
     }
+    
+    private void setMessageProperties(Message message, OperationResourceInfo ori, 
+                                      MultivaluedMap<String, String> values) {
+        message.getExchange().put(OperationResourceInfo.class, ori);
+        message.put(JAXRSUtils.RELATIVE_PATH, values.getFirst(URITemplate.FINAL_MATCH_GROUP));
+        message.put(URITemplate.TEMPLATE_PARAMETERS, values);
+    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Fri Oct  2 14:03:05 2009
@@ -47,6 +47,7 @@
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.ext.ResponseHandler;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
@@ -75,6 +76,16 @@
         try {
             processResponse(message);
         } finally {
+            Object rootInstance = message.getExchange().remove(JAXRSUtils.ROOT_INSTANCE);
+            Object rootProvider = message.getExchange().remove(JAXRSUtils.ROOT_PROVIDER);
+            if (rootInstance != null && rootProvider != null) {
+                try {
+                    ((ResourceProvider)rootProvider).releaseInstance(message, rootInstance);
+                } catch (Throwable tex) {
+                    LOG.warning("Exception occurred during releasing the service instance, "
+                                + tex.getMessage());
+                }
+            }
             ProviderFactory.getInstance(message).clearThreadLocalProxies();
             ClassResourceInfo cri =
                 (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
@@ -113,6 +124,10 @@
             List<ProviderInfo<ResponseHandler>> handlers = 
                 ProviderFactory.getInstance(message).getResponseHandlers();
             for (ProviderInfo<ResponseHandler> rh : handlers) {
+                InjectionUtils.injectContextFields(rh.getProvider(), rh, 
+                                                   message.getExchange().getInMessage());
+                InjectionUtils.injectContextFields(rh.getProvider(), rh, 
+                                                   message.getExchange().getInMessage());
                 Response r = rh.getProvider().handleResponse(message, ori, response);
                 if (r != null) {
                     response = r;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java Fri Oct  2 14:03:05 2009
@@ -19,24 +19,21 @@
 
 package org.apache.cxf.jaxrs.lifecycle;
 
-import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Type;
+import java.lang.reflect.Method;
 
 import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.utils.AnnotationUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 
 public class PerRequestResourceProvider implements ResourceProvider {
     private Constructor<?> c;
+    private Method postConstructMethod;
+    private Method preDestroyMethod;
    
     public PerRequestResourceProvider(Class<?> clazz) {
         c = ResourceUtils.findResourceConstructor(clazz, true);
@@ -44,6 +41,8 @@
             throw new RuntimeException("Resource class " + clazz
                                        + " has no valid constructor");
         }
+        postConstructMethod = ResourceUtils.findPostConstructMethod(clazz);
+        preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz);
     }
     
     public boolean isSingleton() {
@@ -54,34 +53,14 @@
         return createInstance(m);
     }
     
-    public Object getInstance() {  
-        if (c.getParameterTypes().length > 0) {
-            throw new RuntimeException("Resource class constructor has context parameters "
-                          + "but no request message is available");
-        }
-        return createInstance(null);
-    }
-    
-    @SuppressWarnings("unchecked")
+        
     protected Object createInstance(Message m) {
         
-        Class<?>[] params = c.getParameterTypes();
-        Annotation[][] anns = c.getParameterAnnotations();
-        Type[] genericTypes = c.getGenericParameterTypes();
-        MultivaluedMap<String, String> templateValues = 
-            (MultivaluedMap)m.get(URITemplate.TEMPLATE_PARAMETERS);
-        Object[] values = new Object[params.length];
-        for (int i = 0; i < params.length; i++) {
-            if (AnnotationUtils.isContextClass(params[i])) {
-                values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]);
-            } else {
-                Parameter p = ResourceUtils.getParameter(i, anns[i]);
-                values[i] = JAXRSUtils.createHttpParameterValue(
-                                p, params[i], genericTypes[i], m, templateValues, null);
-            }
-        }
+        Object[] values = ResourceUtils.createConstructorArguments(c, m);
         try {
-            return params.length > 0 ? c.newInstance(values) : c.newInstance(new Object[]{});
+            Object instance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[]{});
+            InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod);
+            return instance;
         } catch (InstantiationException ex) {
             String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated";
             throw new WebApplicationException(Response.serverError().entity(msg).build());
@@ -97,4 +76,14 @@
         }
         
     }
+
+    public void releaseInstance(Message m, Object o) {
+        InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod);
+    }
+
+    public Class<?> getResourceClass() {
+        return c.getDeclaringClass();
+    }
+    
+    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java Fri Oct  2 14:03:05 2009
@@ -23,7 +23,8 @@
 
 public interface ResourceProvider {
 
-    Object getInstance();
     Object getInstance(Message m);
+    void releaseInstance(Message m, Object o);
+    Class<?> getResourceClass();
     boolean isSingleton();
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java Fri Oct  2 14:03:05 2009
@@ -19,13 +19,24 @@
 
 package org.apache.cxf.jaxrs.lifecycle;
 
+import org.apache.cxf.common.util.ClassHelper;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 
 public class SingletonResourceProvider implements ResourceProvider {
     private Object resourceInstance;
     
-    public SingletonResourceProvider(Object o) { 
+    public SingletonResourceProvider(Object o, boolean callPostConstruct) {
         resourceInstance = o;
+        if (callPostConstruct) {
+            InjectionUtils.invokeLifeCycleMethod(o, 
+                ResourceUtils.findPostConstructMethod(ClassHelper.getRealClass(o)));
+        }
+    }
+    
+    public SingletonResourceProvider(Object o) { 
+        this(o, false);
     }
     
     public boolean isSingleton() {
@@ -36,7 +47,12 @@
         return resourceInstance;
     }
     
-    public Object getInstance() {
-        return resourceInstance;
+    public void releaseInstance(Message m, Object o) {
+        // TODO Auto-generated method stub
+    }
+    
+    public Class<?> getResourceClass() {
+        return ClassHelper.getRealClass(resourceInstance);
     }
+    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Fri Oct  2 14:03:05 2009
@@ -92,6 +92,11 @@
     private String collectionWrapperName;
     private Map<String, String> collectionWrapperMap;
     private List<String> jaxbElementClassNames;
+    private Map<String, Object> cProperties;
+    
+    public void setContextProperties(Map<String, Object> contextProperties) {
+        cProperties = contextProperties;
+    }
     
     public void setUnmarshallAsJaxbElement(boolean value) {
         unmarshalAsJaxbElement = value;
@@ -161,7 +166,8 @@
                 collectionContextClasses.add(CollectionWrapper.class);
                 collectionContextClasses.add(type);
             }
-            collectionContext = JAXBContext.newInstance(collectionContextClasses.toArray(new Class[]{}));
+            collectionContext = JAXBContext.newInstance(collectionContextClasses.toArray(new Class[]{}), 
+                                                        cProperties);
             return collectionContext;
         }
     }
@@ -315,7 +321,7 @@
         synchronized (classContexts) {
             JAXBContext context = classContexts.get(type);
             if (context == null) {
-                context = JAXBContext.newInstance(new Class[]{type});
+                context = JAXBContext.newInstance(new Class[]{type}, cProperties);
                 classContexts.put(type, context);
             }
             return context;
@@ -331,7 +337,7 @@
             JAXBContext context = packageContexts.get(packageName);
             if (context == null) {
                 try {
-                    context = JAXBContext.newInstance(packageName, type.getClassLoader());
+                    context = JAXBContext.newInstance(packageName, type.getClassLoader(), cProperties);
                     packageContexts.put(packageName, context);
                 } catch (JAXBException ex) {
                     LOG.fine("Error creating a JAXBContext using ObjectFactory : " 
@@ -351,7 +357,8 @@
             || JAXBElement.class.isAssignableFrom(type)
             || objectFactoryForClass(type)
             || (type != genericType && objectFactoryForType(genericType))
-            || adapterAvailable(type, anns);
+            || adapterAvailable(type, anns)
+            || type.getResource("jaxb.index") != null;
     
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Fri Oct  2 14:03:05 2009
@@ -258,18 +258,17 @@
     
     
     public List<ProviderInfo<RequestHandler>> getRequestHandlers() {
+        List<ProviderInfo<RequestHandler>> handlers = null;
         if (requestHandlers.size() == 0) {
-            return Collections.unmodifiableList(SHARED_FACTORY.requestHandlers);
+            handlers = SHARED_FACTORY.requestHandlers;
         } else {
-            List<ProviderInfo<RequestHandler>> handlers = 
-                new ArrayList<ProviderInfo<RequestHandler>>(SHARED_FACTORY.requestHandlers);
+            handlers = new ArrayList<ProviderInfo<RequestHandler>>(SHARED_FACTORY.requestHandlers);
             handlers.addAll(requestHandlers);
-            return handlers;
         }
+        return Collections.unmodifiableList(handlers);
     }
     
     public List<ProviderInfo<ResponseHandler>> getResponseHandlers() {
-        
         return Collections.unmodifiableList(responseHandlers);
     }
 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java Fri Oct  2 14:03:05 2009
@@ -54,6 +54,7 @@
     private static final String SERVICE_CLASSES_PARAM = "jaxrs.serviceClasses";
     private static final String PROVIDERS_PARAM = "jaxrs.providers";
     private static final String SERVICE_SCOPE_PARAM = "jaxrs.scope";
+    private static final String SCHEMAS_PARAM = "jaxrs.schemaLocations";
     private static final String SERVICE_SCOPE_SINGLETON = "singleton";
     private static final String SERVICE_SCOPE_REQUEST = "prototype";
     
@@ -81,6 +82,8 @@
             bean.setModelRef(modelRef.trim());
         }
         
+        setSchemasLocations(bean, servletConfig);
+        
         List<Class> resourceClasses = getServiceClasses(servletConfig, modelRef != null);
         Map<Class, ResourceProvider> resourceProviders = 
             getResourceProviders(servletConfig, resourceClasses);
@@ -95,6 +98,24 @@
         bean.create();
     }
 
+    protected void setSchemasLocations(JAXRSServerFactoryBean bean, ServletConfig servletConfig) {
+        String schemas = servletConfig.getInitParameter(SCHEMAS_PARAM);
+        if (schemas == null) {
+            return;
+        }
+        String[] locations = schemas.split(" ");
+        List<String> list = new ArrayList<String>();
+        for (String loc : locations) {
+            String theLoc = loc.trim();
+            if (theLoc.length() != 0) {
+                list.add(theLoc);
+            }
+        }
+        if (list.size() > 0) {
+            bean.setSchemaLocations(list);
+        }
+    }
+    
     protected List<Class> getServiceClasses(ServletConfig servletConfig,
                                             boolean modelAvailable) throws ServletException {
         String serviceBeans = servletConfig.getInitParameter(SERVICE_CLASSES_PARAM);
@@ -107,8 +128,9 @@
         String[] classNames = serviceBeans.split(" ");
         List<Class> resourceClasses = new ArrayList<Class>();
         for (String cName : classNames) {
-            if (cName.length() != 0) {
-                Class<?> cls = loadClass(cName);
+            String theName = cName.trim();
+            if (theName.length() != 0) {
+                Class<?> cls = loadClass(theName);
                 resourceClasses.add(cls);
             }
         }
@@ -126,8 +148,9 @@
         String[] classNames = providersList.split(" ");
         List<Object> providers = new ArrayList<Object>();
         for (String cName : classNames) {
-            if (cName.length() != 0) {
-                Class<?> cls = loadClass(cName);
+            String theName = cName.trim();
+            if (theName.length() != 0) {
+                Class<?> cls = loadClass(theName);
                 providers.add(createSingletonInstance(cls, servletConfig));
             }
         }
@@ -146,7 +169,7 @@
         for (Class c : resourceClasses) {
             map.put(c, isPrototype ? new PerRequestResourceProvider(c)
                                    : new SingletonResourceProvider(
-                                         createSingletonInstance(c, servletConfig)));
+                                         createSingletonInstance(c, servletConfig), true));
         }
         return map;
     }    
@@ -240,7 +263,7 @@
     
     private Class<?> loadClass(String cName, String classType) throws ServletException {
         try {
-            return ClassLoaderUtils.loadClass(cName.trim(), CXFNonSpringJaxrsServlet.class);
+            return ClassLoaderUtils.loadClass(cName, CXFNonSpringJaxrsServlet.class);
         } catch (ClassNotFoundException ex) {
             throw new ServletException("No " + classType + " class " + cName.trim() + " can be found", ex); 
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java Fri Oct  2 14:03:05 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs.spring;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -30,6 +31,7 @@
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.springframework.beans.BeansException;
@@ -44,7 +46,6 @@
 
 public class JAXRSServerFactoryBeanDefinitionParser extends AbstractBeanDefinitionParser {
     
-
     public JAXRSServerFactoryBeanDefinitionParser() {
         super();
         setBeanClass(SpringJAXRSServerFactoryBean.class);
@@ -52,9 +53,22 @@
     
     @Override
     protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String val) {
-        mapToProperty(bean, name, val);        
+        if ("beanNames".equals(name)) {
+            String[] values = val.split(" ");
+            List<SpringResourceFactory> tempFactories = new ArrayList<SpringResourceFactory>(values.length);
+            for (String v : values) {
+                String theValue = v.trim();
+                if (theValue.length() > 0) {
+                    tempFactories.add(new SpringResourceFactory(theValue));
+                }
+            }
+            bean.addPropertyValue("tempResourceProviders", tempFactories);
+        } else {
+            mapToProperty(bean, name, val);
+        }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element el, String name) {
         if ("properties".equals(name) 
@@ -77,6 +91,9 @@
             || "modelBeans".equals(name)) {
             List list = ctx.getDelegate().parseListElement(el, bean.getBeanDefinition());
             bean.addPropertyValue(name, list);
+        }  else if ("serviceFactories".equals(name)) {
+            List list = ctx.getDelegate().parseListElement(el, bean.getBeanDefinition());
+            bean.addPropertyValue("resourceProviders", list);
         } else if ("model".equals(name)) {
             List<UserResource> resources = ResourceUtils.getResourcesFromElement(el);
             bean.addPropertyValue("modelBeans", resources);
@@ -116,6 +133,8 @@
     
     public static class SpringJAXRSServerFactoryBean extends JAXRSServerFactoryBean implements
         ApplicationContextAware {
+        
+        private List<SpringResourceFactory> tempFactories;
 
         public SpringJAXRSServerFactoryBean() {
             super();
@@ -124,8 +143,23 @@
         public SpringJAXRSServerFactoryBean(JAXRSServiceFactoryBean sf) {
             super(sf);
         }
+        
+        public void setTempResourceProviders(List<SpringResourceFactory> providers) {
+            tempFactories = providers;
+        }
 
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (tempFactories != null) {
+                List<ResourceProvider> factories = new ArrayList<ResourceProvider>(
+                    tempFactories.size());
+                for (int i = 0; i < tempFactories.size(); i++) {
+                    SpringResourceFactory factory = tempFactories.get(i);
+                    factory.setApplicationContext(ctx);
+                    factories.add(factory);
+                }
+                tempFactories.clear();
+                super.setResourceProviders(factories);
+            }
             if (getBus() == null) {
                 Bus bus = BusFactory.getThreadDefaultBus();
                 BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
@@ -133,5 +167,4 @@
             }
         }
     }
-
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Fri Oct  2 14:03:05 2009
@@ -872,4 +872,21 @@
             return HttpUtils.urlDecode(value);
         }
     }
+    
+    public static void invokeLifeCycleMethod(Object instance, Method method) {
+        if (method != null) {
+            method = InjectionUtils.checkProxy(method, instance);
+            try {
+                method.invoke(instance, new Object[]{});
+            } catch (InvocationTargetException ex) {
+                String msg = "Method " + method.getName() + " can not be invoked"
+                    + " due to InvocationTargetException";
+                throw new WebApplicationException(Response.serverError().entity(msg).build());
+            } catch (IllegalAccessException ex) {
+                String msg = "Method " + method.getName() + " can not be invoked"
+                    + " due to IllegalAccessException";
+                throw new WebApplicationException(Response.serverError().entity(msg).build());
+            } 
+        }
+    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri Oct  2 14:03:05 2009
@@ -39,6 +39,7 @@
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
@@ -100,7 +101,8 @@
     public static final String RELATIVE_PATH = "relative.path";
     public static final String ROOT_RESOURCE_CLASS = "root.resource.class";
     public static final String IGNORE_MESSAGE_WRITERS = "ignore.message.writers";
-    
+    public static final String ROOT_INSTANCE = "service.root.instance";
+    public static final String ROOT_PROVIDER = "service.root.provider";
     
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSUtils.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSUtils.class);
@@ -218,6 +220,9 @@
                                                  String path, 
                                                  MultivaluedMap<String, String> values) {
         
+        LOG.fine(new org.apache.cxf.common.i18n.Message("START_CRI_MATCH", 
+                                                        BUNDLE, 
+                                                        path).toString());
         if (resources.size() == 1) { 
             return resources.get(0).getURITemplate().match(path, values)
                    ? resources.get(0) : null;
@@ -227,10 +232,20 @@
             new TreeMap<ClassResourceInfo, MultivaluedMap<String, String>>(
                 new ClassResourceInfoComparator());
         
-        for (ClassResourceInfo resource : resources) {
+        for (ClassResourceInfo cri : resources) {
             MultivaluedMap<String, String> map = new MetadataMap<String, String>();
-            if (resource.getURITemplate().match(path, map)) {
-                candidateList.put(resource, map);
+            if (cri.getURITemplate().match(path, map)) {
+                candidateList.put(cri, map);
+                LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_SELECTED_POSSIBLY", 
+                                                                BUNDLE, 
+                                                                cri.getServiceClass().getName(),
+                                                                path, 
+                                                                cri.getURITemplate().getValue()).toString());
+            } else {
+                LOG.fine(new org.apache.cxf.common.i18n.Message("NO_CRI_MATCH", 
+                                                                BUNDLE, 
+                                                                path,
+                                                                cri.getServiceClass().getName()).toString());
             }
         }
         
@@ -238,7 +253,12 @@
             Map.Entry<ClassResourceInfo, MultivaluedMap<String, String>> firstEntry = 
                 candidateList.entrySet().iterator().next();
             values.putAll(firstEntry.getValue());
-            return firstEntry.getKey();
+            ClassResourceInfo cri = firstEntry.getKey();
+            LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_SELECTED", 
+                                                         BUNDLE, 
+                                                         cri.getServiceClass().getName(),
+                                                         path, cri.getURITemplate().getValue()).toString());
+            return cri;
         }
         
         return null;
@@ -261,6 +281,14 @@
                                                          String requestContentType, 
                                                          List<MediaType> acceptContentTypes,
                                                          boolean logNow) {
+        if (LOG.isLoggable(Level.FINE)) {
+            org.apache.cxf.common.i18n.Message msg = 
+                new org.apache.cxf.common.i18n.Message("START_OPER_MATCH", 
+                                                       BUNDLE,
+                                                       resource.getServiceClass().getName());
+            LOG.fine(msg.toString());
+            
+        }
         SortedMap<OperationResourceInfo, MultivaluedMap<String, String>> candidateList = 
             new TreeMap<OperationResourceInfo, MultivaluedMap<String, String>>(
                 new OperationResourceInfoComparator());
@@ -278,8 +306,10 @@
                 URITemplate uriTemplate = ori.getURITemplate();
                 MultivaluedMap<String, String> map = new MetadataMap<String, String>(values);
                 if (uriTemplate != null && uriTemplate.match(path, map)) {
+                    boolean added = false;
                     if (ori.isSubResourceLocator()) {
                         candidateList.put(ori, map);
+                        added = true;
                     } else {
                         String finalGroup = map.getFirst(URITemplate.FINAL_MATCH_GROUP);
                         if (finalGroup == null || StringUtils.isEmpty(finalGroup)
@@ -290,14 +320,25 @@
                             boolean pMatched = matchProduceTypes(acceptType, ori);
                             if (mMatched && cMatched && pMatched) {
                                 subresourcesOnly = false;
-                                candidateList.put(ori, map);    
+                                candidateList.put(ori, map);
+                                added = true;
                             } else {
                                 methodMatched = mMatched ? methodMatched + 1 : methodMatched;
                                 produceMatched = pMatched ? produceMatched + 1 : produceMatched;
                                 consumeMatched = cMatched ? consumeMatched + 1 : consumeMatched;
+                                logNoMatchMessage(ori, path, httpMethod, requestType, acceptContentTypes);
                             }
+                        } else {
+                            logNoMatchMessage(ori, path, httpMethod, requestType, acceptContentTypes);
                         }
                     }
+                    if (added && LOG.isLoggable(Level.FINE)) {
+                        LOG.fine(new org.apache.cxf.common.i18n.Message("OPER_SELECTED_POSSIBLY", 
+                                  BUNDLE, 
+                                  ori.getMethodToInvoke().getName()).toString());
+                    }
+                } else {
+                    logNoMatchMessage(ori, path, httpMethod, requestType, acceptContentTypes);
                 }
             }
             if (!candidateList.isEmpty() && !subresourcesOnly) {
@@ -315,6 +356,9 @@
                          BUNDLE, resource.getServiceClass().getName(), 
                          ori.getMethodToInvoke().getName()).toString());
             }
+            LOG.fine(new org.apache.cxf.common.i18n.Message("OPER_SELECTED", 
+                           BUNDLE, ori.getMethodToInvoke().getName(), 
+                           resource.getServiceClass().getName()).toString());
             return ori;
         }
         
@@ -323,8 +367,9 @@
         String name = resource.isRoot() ? "NO_OP_EXC" : "NO_SUBRESOURCE_METHOD_FOUND";
         org.apache.cxf.common.i18n.Message errorMsg = 
             new org.apache.cxf.common.i18n.Message(name, 
-                                                   BUNDLE, 
+                                                   BUNDLE,
                                                    path,
+                                                   httpMethod,
                                                    requestType.toString(),
                                                    convertTypesToString(acceptContentTypes));
         if (!"OPTIONS".equalsIgnoreCase(httpMethod) && logNow) {
@@ -334,6 +379,26 @@
         throw new WebApplicationException(rb.build());
         
     }    
+    
+    private static void logNoMatchMessage(OperationResourceInfo ori, 
+        String path, String httpMethod, MediaType requestType, List<MediaType> acceptContentTypes) {
+        if (!LOG.isLoggable(Level.FINE)) {
+            return;
+        }
+        org.apache.cxf.common.i18n.Message errorMsg = 
+            new org.apache.cxf.common.i18n.Message("OPER_NO_MATCH", 
+                                                   BUNDLE,
+                                                   ori.getMethodToInvoke().getName(),
+                                                   path,
+                                                   ori.getURITemplate().getValue(),
+                                                   httpMethod,
+                                                   ori.getHttpMethod(),
+                                                   requestType.toString(),
+                                                   convertTypesToString(ori.getConsumeTypes()),
+                                                   convertTypesToString(acceptContentTypes),
+                                                   convertTypesToString(ori.getProduceTypes()));
+        LOG.fine(errorMsg.toString());
+    }
 
     public static ResponseBuilder createResponseBuilder(ClassResourceInfo cri, int status, boolean addAllow) {
         ResponseBuilder rb = Response.status(status);
@@ -622,8 +687,18 @@
                 HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
                 FormUtils.populateMapFromString(params, (String)body, decode, request);
             } else {
-                MultipartBody body = AttachmentUtils.getMultipartBody(mc);
-                FormUtils.populateMapFromMultipart(params, body, decode);
+                if (mt != null && "multipart".equalsIgnoreCase(mt.getType()) 
+                    && MediaType.MULTIPART_FORM_DATA_TYPE.isCompatible(mt)) {
+                    MultipartBody body = AttachmentUtils.getMultipartBody(mc);
+                    FormUtils.populateMapFromMultipart(params, body, decode);
+                } else {
+                    org.apache.cxf.common.i18n.Message errorMsg = 
+                        new org.apache.cxf.common.i18n.Message("WRONG_FORM_MEDIA_TYPE", 
+                                                               BUNDLE, 
+                                                               mt == null ? "*/*" : mt.toString());
+                    LOG.warning(errorMsg.toString());
+                    throw new WebApplicationException(415);
+                }
             }
         }
         

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties Fri Oct  2 14:03:05 2009
@@ -29,7 +29,15 @@
 CLASS_CONSTRUCTOR_FAILURE=Class {0} can not be instantiated using a constructor with a single String argument
 CLASS_VALUE_OF_FAILURE=Instance of class {0} can not be created using static valueOf(String) or fromString(String) methods
 WRONG_PARAMETER_TYPE=Parameter Class {0} has no constructor with single String parameter, static valueOf(String) or fromString(String) methods
-NO_MSG_READER =.No message body reader found for request class : {0}, ContentType : {1}.
-NO_SUBRESOURCE_METHOD_FOUND=No operation matching request path {0} is found on subresource, ContentType : {1}, Accept : {2}.
-NO_OP_EXC =.No operation matching request path {0} is found, ContentType : {1}, Accept : {2}.
+NO_MSG_READER=.No message body reader found for request class : {0}, ContentType : {1}.
+NO_SUBRESOURCE_METHOD_FOUND=No operation matching request path {0} is found on subresource, HTTP Method : {1}, ContentType : {2}, Accept : {3}.
+NO_OP_EXC=.No operation matching request path {0} is found, HTTP Method : {1}, ContentType : {2}, Accept : {3}.
+START_OPER_MATCH=Trying to select a resource operation on the resource class {0}
+START_CRI_MATCH=Trying to select a resource class {0}, request path : {1}
+OPER_SELECTED_POSSIBLY=Resource operation {0} may get selected
+OPER_SELECTED=Resource operation {0} on the resource class {1} has been selected
+CRI_SELECTED_POSSIBLY=Resource class {0} may get selected, request path : {0}, resource class @Path : {1}
+CRI_SELECTED=Resource class {0} has been selected, request path : {0}, resource class @Path : {1}
+OPER_NO_MATCH=No method match, method name : {0}, request path : {1}, method @Path : {2}, HTTP Method : {3}, method HTTP Method : {4}, ContentType : {5}, method @Consumes : {6}, Accept : {7}, method @Produces : {8}.
 MULTTIPART_ID_NOT_FOUND=No multipart with content id {0} found, request content type : {1}
+WRONG_FORM_MEDIA_TYPE=An application/x-www-form-urlencoded form request is expected but the request media type is {0}. Consider removing @FormParam annotations.    
\ No newline at end of file

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java Fri Oct  2 14:03:05 2009
@@ -37,6 +37,8 @@
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.ws.rs.CookieParam;
 import javax.ws.rs.Encoded;
 import javax.ws.rs.FormParam;
@@ -47,6 +49,7 @@
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.xml.bind.JAXBElement;
 
 import org.w3c.dom.Document;
@@ -68,6 +71,7 @@
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.resource.ResourceManager;
 
 public final class ResourceUtils {
@@ -80,6 +84,50 @@
         
     }
     
+    public static Method findPostConstructMethod(Class<?> c) {
+        if (Object.class == c || null == c) {
+            return null;
+        }
+        for (Method m : c.getDeclaredMethods()) {
+            if (m.getAnnotation(PostConstruct.class) != null) {
+                return m;
+            }
+        }
+        Method m = findPostConstructMethod(c.getSuperclass());
+        if (m != null) {
+            return m;
+        }
+        for (Class<?> i : c.getInterfaces()) {
+            m = findPostConstructMethod(i);
+            if (m != null) {
+                return m;
+            }
+        }
+        return null;
+    }
+    
+    public static Method findPreDestroyMethod(Class<?> c) {
+        if (Object.class == c || null == c) {
+            return null;
+        }
+        for (Method m : c.getDeclaredMethods()) {
+            if (m.getAnnotation(PreDestroy.class) != null) {
+                return m;
+            }
+        }
+        Method m = findPreDestroyMethod(c.getSuperclass());
+        if (m != null) {
+            return m;
+        }
+        for (Class<?> i : c.getInterfaces()) {
+            m = findPreDestroyMethod(i);
+            if (m != null) {
+                return m;
+            }
+        }
+        return null;
+    }
+    
     public static ClassResourceInfo createClassResourceInfo(
         Map<String, UserResource> resources, UserResource model, boolean isRoot, boolean enableStatic) {
         
@@ -448,4 +496,23 @@
         return op;
     }
     
+    @SuppressWarnings("unchecked")
+    public static Object[] createConstructorArguments(Constructor c, Message m) {
+        Class<?>[] params = c.getParameterTypes();
+        Annotation[][] anns = c.getParameterAnnotations();
+        Type[] genericTypes = c.getGenericParameterTypes();
+        MultivaluedMap<String, String> templateValues = m == null ? null
+            : (MultivaluedMap)m.get(URITemplate.TEMPLATE_PARAMETERS);
+        Object[] values = new Object[params.length];
+        for (int i = 0; i < params.length; i++) {
+            if (AnnotationUtils.isContextClass(params[i])) {
+                values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]);
+            } else {
+                Parameter p = ResourceUtils.getParameter(i, anns[i]);
+                values[i] = JAXRSUtils.createHttpParameterValue(
+                                p, params[i], genericTypes[i], m, templateValues, null);
+            }
+        }
+        return values;
+    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Fri Oct  2 14:03:05 2009
@@ -42,6 +42,7 @@
             <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="invoker" type="xsd:anyType" minOccurs="0"/>
+            <xsd:element name="serviceFactories" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="properties" type="beans:mapType" minOccurs="0"/>
@@ -60,7 +61,8 @@
           <xsd:attribute name="transportId" type="xsd:string"/>
           <xsd:attribute name="modelRef" type="xsd:string" />
           <xsd:attribute name="bindingId" type="xsd:string" />          
-          <xsd:attribute name="staticSubresourceResolution" type="xsd:boolean" />          
+          <xsd:attribute name="staticSubresourceResolution" type="xsd:boolean"/>          
+          <xsd:attribute name="beanNames" type="xsd:string"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java Fri Oct  2 14:03:05 2009
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.UUID;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -111,6 +113,9 @@
     private String b;
     private String name;
     
+    private boolean postConstuctCalled;
+    private boolean preDestroyCalled;
+    
     public Customer() {
         
     }
@@ -125,6 +130,24 @@
         this.queryParam = queryParam;
     }
     
+    @PostConstruct
+    public void postConstruct() {
+        postConstuctCalled = true;
+    }
+    
+    public boolean isPostConstuctCalled() {
+        return postConstuctCalled;
+    }
+    
+    @PreDestroy
+    public void preDestroy() {
+        preDestroyCalled = true;
+    }
+    
+    public boolean isPreDestroyCalled() {
+        return preDestroyCalled;
+    }
+    
     public String getName() {
         return name;
     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProviderTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProviderTest.java Fri Oct  2 14:03:05 2009
@@ -35,6 +35,9 @@
         Customer c = (Customer)rp.getInstance(message);
         assertNotNull(c.getUriInfo());
         assertEquals("aValue", c.getQueryParam());
+        assertTrue(c.isPostConstuctCalled());
+        rp.releaseInstance(message, c);
+        assertTrue(c.isPreDestroyCalled());
     }
 }
 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisElementProviderTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisElementProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AegisElementProviderTest.java Fri Oct  2 14:03:05 2009
@@ -113,7 +113,6 @@
         writer.writeTo(testMap, testMap.getClass(), mapType, null, null, null, os);
         byte[] bytes = os.toByteArray();
         String xml = new String(bytes, "utf-8");
-        System.out.println(xml);        
         MessageBodyReader<Object> reader = new AegisElementProvider();         
         byte[] simpleBytes = xml.getBytes("utf-8");
         

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Fri Oct  2 14:03:05 2009
@@ -57,6 +57,7 @@
 import org.xml.sax.ContentHandler;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.provider.index.TestBean;
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.CollectionsResource;
 import org.apache.cxf.jaxrs.resources.SuperBook;
@@ -83,6 +84,12 @@
     }
     
     @Test
+    public void testIsSupportedWithJaxbIndex() {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        assertTrue(provider.isSupported(TestBean.class, TestBean.class, new Annotation[]{}));
+    }
+    
+    @Test
     public void testIsWriteableJAXBElements() throws Exception {
         testIsWriteableCollection("getBookElements");
     }
@@ -613,5 +620,4 @@
         }
         
     }
-    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java Fri Oct  2 14:03:05 2009
@@ -448,7 +448,6 @@
                   MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), os);
         
         String s = os.toString();
-        System.out.println(s);
         assertEquals(
             "{\"post\":{\"title\":\"post\",\"comments\":[{\"title\":\"comment1\"},"
             + "{\"title\":\"comment2\"}]}}",
@@ -477,6 +476,7 @@
             s);
     }
     
+        
     private TagVO createTag(String name, String group) {
         return new TagVO(name, group);
     }
@@ -536,5 +536,6 @@
         }
     }
 
+    
 
 }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java Fri Oct  2 14:03:05 2009
@@ -49,7 +49,7 @@
         ints.add(new CustomOutInterceptor());
         sf.setOutInterceptors(ints);
         sf.setResourceProvider(BookStore.class,
-                               new SingletonResourceProvider(new BookStore()));
+                               new SingletonResourceProvider(new BookStore(), true));
         sf.setAddress("http://localhost:9080/");
 
         sf.create();        

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri Oct  2 14:03:05 2009
@@ -31,6 +31,8 @@
 import java.util.Locale;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
@@ -82,6 +84,16 @@
         init();
     }
     
+    @PostConstruct
+    public void postConstruct() {
+        System.out.println("PostConstruct called");
+    }
+    
+    @PreDestroy
+    public void preDestroy() {
+        System.out.println("PreDestroy called");
+    }
+    
     @GET
     @Path("webappexception")
     public Book throwException() {

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java Fri Oct  2 14:03:05 2009
@@ -23,6 +23,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.MatrixParam;
@@ -44,12 +46,24 @@
     private Long mainId = 123L;
     @Context
     private UriInfo ui;    
+    private boolean postConstructCalled;
     
     public BookStoreSpring() {
         init();
         System.out.println("----books: " + books.size());
     }
     
+    
+    @PostConstruct
+    public void postConstruct() {
+        postConstructCalled = true;
+    }
+    
+    @PreDestroy
+    public void preDestroy() {
+        System.out.println("PreDestroy called");
+    }
+    
     @GET
     @Path("/books/list/{id}")
     public Books getBookAsJsonList(@PathParam("id") Long id) {
@@ -81,7 +95,9 @@
     @GET
     @Path("/booksquery")
     public Book getBookByQuery(@QueryParam("id") String id) {
-        
+        if (!postConstructCalled) {
+            throw new RuntimeException();
+        }
         String[] values = id.split("\\+");
         StringBuilder b = new StringBuilder();
         b.append(values[0]).append(values[1]);        
@@ -116,7 +132,7 @@
     }
     
     @PUT
-    @Path("books/convert2")
+    @Path("books/convert2/{id}")
     @Consumes({"application/xml", "application/json", "application/jettison" })
     @Produces("application/xml")
     public Book convertBook2(Book2 book) {

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java Fri Oct  2 14:03:05 2009
@@ -38,8 +38,15 @@
 
 package org.apache.cxf.systest.jaxrs;
 
-public class BookStoreWithInterface extends BookStoreStorage implements BookInterface {
 
+
+
+
+public class BookStoreWithInterface extends BookStoreStorage 
+    implements BookInterface, LifecycleInterface {
+
+    private boolean postConstructCalled;
+    
     public BookStoreWithInterface() {
         Book book = new Book();
         book.setId(bookId);
@@ -47,7 +54,18 @@
         books.put(book.getId(), book);
     }
     
+    public void postConstruct() {
+        postConstructCalled = true;
+    }
+    
+    public void preDestroy() {
+        System.out.println("PreDestroy called");
+    }
+    
     public Book getThatBook(Long id, String s) throws BookNotFoundFault {
+        if (!postConstructCalled) {
+            throw new RuntimeException();
+        }
         if (!id.toString().equals(s)) {
             throw new RuntimeException();
         }
@@ -55,6 +73,9 @@
     }
     
     public Book getThatBook(Long id) throws BookNotFoundFault {
+        if (!postConstructCalled) {
+            throw new RuntimeException();
+        }
         return doGetBook(id);
     }
     

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java Fri Oct  2 14:03:05 2009
@@ -64,6 +64,32 @@
     }
     
     @Test
+    public void testGetThatBookSingleton() throws Exception {
+        getBook("http://localhost:9080/test/4/bookstore/books/123");
+        getBook("http://localhost:9080/test/4/bookstore/books/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterfaceSingleton() throws Exception {
+        getBook("http://localhost:9080/test/4/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
+    public void testGetThatBookPrototype() throws Exception {
+        getBook("http://localhost:9080/test/5/bookstore/books/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterfacePrototype() throws Exception {
+        getBook("http://localhost:9080/test/5/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
+    public void testGetThatBookInterface2Prototype() throws Exception {
+        getBook("http://localhost:9080/test/6/bookstorestorage/thosebooks/123");
+    }
+    
+    @Test
     public void testGetThatBook123UserResource() throws Exception {
         getBook("http://localhost:9080/test/2/bookstore/books/123");
     }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Fri Oct  2 14:03:05 2009
@@ -67,7 +67,7 @@
     
     @Test
     public void testGetBookXSLTHtml() throws Exception {
-        
+
         String endpointAddress =
             "http://localhost:9080/the/thebooks5/bookstore/books/xslt";
         WebClient wc = WebClient.create(endpointAddress);
@@ -326,7 +326,7 @@
     @Test
     public void testReaderWriterFromJaxrsFilters() throws Exception {
         String endpointAddress =
-            "http://localhost:9080/the/thebooks5/bookstore/books/convert2";
+            "http://localhost:9080/the/thebooks5/bookstore/books/convert2/123";
         WebClient wc = WebClient.create(endpointAddress);
         wc.type("application/xml").accept("application/xml");
         Book2 b = new Book2();

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java Fri Oct  2 14:03:05 2009
@@ -221,7 +221,7 @@
         objects.put(MediaType.APPLICATION_XML, jaxb);
         objects.put(MediaType.APPLICATION_JSON, json);
         objects.put(MediaType.APPLICATION_OCTET_STREAM, is1);
-        Collection<Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
+        Collection<? extends Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
         List<Attachment> result = new ArrayList<Attachment>(coll);
         Book jaxb2 = readBookFromInputStream(result.get(0).getDataHandler().getInputStream());
         assertEquals("jaxb", jaxb2.getName());
@@ -250,7 +250,7 @@
         objects.add(new Attachment("theroot", MediaType.APPLICATION_XML, jaxb));
         objects.add(new Attachment("thejson", MediaType.APPLICATION_JSON, json));
         objects.add(new Attachment("theimage", MediaType.APPLICATION_OCTET_STREAM, is1));
-        Collection<Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
+        Collection<? extends Attachment> coll = client.postAndGetCollection(objects, Attachment.class);
         List<Attachment> result = new ArrayList<Attachment>(coll);
         Book jaxb2 = readBookFromInputStream(result.get(0).getDataHandler().getInputStream());
         assertEquals("jaxb", jaxb2.getName());
@@ -279,7 +279,7 @@
         List<Book> books = new ArrayList<Book>();
         books.add(b);
         books.add(b2);
-        Collection<Book> coll = client.postAndGetCollection(books, Book.class);
+        Collection<? extends Book> coll = client.postAndGetCollection(books, Book.class);
         List<Book> result = new ArrayList<Book>(coll);
         Book jaxb = result.get(0);
         assertEquals("jaxb", jaxb.getName());

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XmlStreamReaderProvider.java Fri Oct  2 14:03:05 2009
@@ -20,9 +20,12 @@
 
 import java.io.InputStream;
 
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.message.Message;
@@ -30,9 +33,17 @@
 
 public class XmlStreamReaderProvider implements RequestHandler {
 
+    @Context
+    private MessageContext context;
+    
     public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
-        String method = m.get(Message.HTTP_REQUEST_METHOD).toString();
+        String method = context.get(Message.HTTP_REQUEST_METHOD).toString();
+        
         if ("PUT".equals(method)) {
+            MultivaluedMap<String, String> map = context.getUriInfo().getPathParameters();
+            if (!"123".equals(map.getFirst("id"))) {
+                throw new RuntimeException();
+            }
             XMLStreamReader reader = 
                 StaxUtils.createXMLStreamReader(m.getContent(InputStream.class));
             m.setContent(XMLStreamReader.class, new CustomXmlStreamReader(reader));

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java?rev=821023&r1=821022&r2=821023&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java Fri Oct  2 14:03:05 2009
@@ -31,7 +31,7 @@
 @Path("/bookstorestorage/")
 public class SecureBookStoreNoAnnotations implements BookInterface {
     private Map<Long, Book> books = new HashMap<Long, Book>();
-  
+    
     public SecureBookStoreNoAnnotations() {
         Book book = new Book();
         book.setId(123L);



Mime
View raw message