cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1442931 [1/2] - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ rt/frontend/jaxrs/src/main/...
Date Wed, 06 Feb 2013 12:35:22 GMT
Author: sergeyb
Date: Wed Feb  6 12:35:21 2013
New Revision: 1442931

URL: http://svn.apache.org/viewvc?rev=1442931&view=rev
Log:
[CXF-4696] Split ProviderFactory before starting the client runtime move

Added:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java   (with props)
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java   (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseFilterInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/MessageContextImplTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProviderTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java
    cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/dom4j/DOM4JProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java Wed Feb  6 12:35:21 2013
@@ -26,7 +26,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
-import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.ws.rs.NotFoundException;
@@ -46,11 +45,7 @@ import org.apache.cxf.endpoint.AbstractE
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.EndpointImpl;
-import org.apache.cxf.jaxrs.model.BeanParamInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.provider.DataBindingProvider;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
@@ -320,8 +315,7 @@ public class AbstractJAXRSFactoryBean ex
         }
     }
     
-    protected ProviderFactory setupFactory(Endpoint ep) { 
-        ProviderFactory factory = ProviderFactory.createInstance(getBus()); 
+    protected void setupFactory(ProviderFactory factory, Endpoint ep) { 
         if (entityProviders != null) {
             factory.setUserProviders(entityProviders); 
         }
@@ -333,29 +327,7 @@ public class AbstractJAXRSFactoryBean ex
             factory.setSchemaLocations(schemaLocations);
         }
         
-        setBeanInfo(factory);
-        
-        ep.put(ProviderFactory.class.getName(), factory);
-        getBus().setProperty(ProviderFactory.class.getName(), factory);
-        return factory;
-    }
-
-    protected void setBeanInfo(ProviderFactory factory) {
-        List<ClassResourceInfo> cris = serviceFactory.getClassResourceInfo();
-        for (ClassResourceInfo cri : cris) {
-            Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
-            for (OperationResourceInfo ori : oris) {
-                List<Parameter> params = ori.getParameters();
-                for (Parameter param : params) {
-                    if (param.getType() == ParameterType.BEAN) {
-                        Class<?> cls = ori.getMethodToInvoke().getParameterTypes()[param.getIndex()];
-                        BeanParamInfo bpi = new BeanParamInfo(cls, getBus());
-                        factory.addBeanParamInfo(bpi);
-                    }
-                }
-            }
-        }
-        
+        ep.put(factory.getClass().getName(), factory);
     }
     
     protected void setDataBindingProvider(ProviderFactory factory, Service s) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Wed Feb  6 12:35:21 2013
@@ -55,7 +55,7 @@ import org.apache.cxf.jaxrs.model.Parame
 import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
@@ -104,7 +104,7 @@ public class JAXRSInvoker extends Abstra
             boolean suspended = exchange.getInMessage().getInterceptorChain().getState() == State.SUSPENDED;
             if (!suspended) {
                 if (exchange.isOneWay()) {
-                    ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
+                    ServerProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
                 }
                 if (!isServiceObjectRequestScope(exchange.getInMessage())) {
                     provider.releaseInstance(exchange.getInMessage(), rootInstance);
@@ -138,7 +138,7 @@ public class JAXRSInvoker extends Abstra
         final OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
         final ClassResourceInfo cri = ori.getClassResourceInfo();
         final Message inMessage = exchange.getInMessage();
-        final ProviderFactory providerFactory = ProviderFactory.getInstance(inMessage);
+        final ServerProviderFactory providerFactory = ServerProviderFactory.getInstance(inMessage);
 
         boolean wasSuspended = exchange.remove(REQUEST_WAS_SUSPENDED) != null;
         
@@ -285,7 +285,7 @@ public class JAXRSInvoker extends Abstra
         }
         Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause(), inMessage);
         if (excResponse == null) {
-            ProviderFactory.getInstance(inMessage).clearThreadLocalProxies();
+            ServerProviderFactory.getInstance(inMessage).clearThreadLocalProxies();
             ClassResourceInfo criRoot =
                 (ClassResourceInfo)inMessage.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
             if (criRoot != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Wed Feb  6 12:35:21 2013
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
@@ -41,9 +42,13 @@ import org.apache.cxf.jaxrs.ext.Resource
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.model.BeanParamInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -164,7 +169,7 @@ public class JAXRSServerFactoryBean exte
                 ep.getService().setInvoker(invoker);
             }
             
-            ProviderFactory factory = setupFactory(ep);
+            ServerProviderFactory factory = setupFactory(ep);
             ep.put(Application.class.getName(), appProvider);
             factory.setApplicationProvider(appProvider);
             factory.setRequestPreprocessor(
@@ -208,6 +213,31 @@ public class JAXRSServerFactoryBean exte
         return server;
     }
 
+    protected ServerProviderFactory setupFactory(Endpoint ep) { 
+        ServerProviderFactory factory = ServerProviderFactory.createInstance(getBus()); 
+        setBeanInfo(factory);
+        super.setupFactory(factory, ep);
+        return factory;
+    }
+
+    protected void setBeanInfo(ServerProviderFactory factory) {
+        List<ClassResourceInfo> cris = serviceFactory.getClassResourceInfo();
+        for (ClassResourceInfo cri : cris) {
+            Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
+            for (OperationResourceInfo ori : oris) {
+                List<Parameter> params = ori.getParameters();
+                for (Parameter param : params) {
+                    if (param.getType() == ParameterType.BEAN) {
+                        Class<?> cls = ori.getMethodToInvoke().getParameterTypes()[param.getIndex()];
+                        BeanParamInfo bpi = new BeanParamInfo(cls, getBus());
+                        factory.addBeanParamInfo(bpi);
+                    }
+                }
+            }
+        }
+        
+    }
+    
     protected void applyFeatures() {
         if (getFeatures() != null) {
             for (Feature feature : getFeatures()) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Wed Feb  6 12:35:21 2013
@@ -371,6 +371,10 @@ public abstract class AbstractClient imp
                 }
             }
         }
+        String ct = (String)responseMessage.get(Message.CONTENT_TYPE);
+        if (ct != null) {
+            currentResponseBuilder.type(ct);
+        }
         InputStream mStream = responseMessage.getContent(InputStream.class);
         currentResponseBuilder.entity(mStream);
         
@@ -392,7 +396,7 @@ public abstract class AbstractClient imp
         
         MediaType contentType = MediaType.valueOf(headers.getFirst("Content-Type").toString()); 
         
-        List<WriterInterceptor> writers = ProviderFactory.getInstance(outMessage)
+        List<WriterInterceptor> writers = ClientProviderFactory.getInstance(outMessage)
             .createMessageBodyWriterInterceptor(theClass, type, anns, contentType, outMessage);
         if (writers != null) {
             try {
@@ -463,7 +467,7 @@ public abstract class AbstractClient imp
         MediaType contentType = getResponseContentType(r);
         
         List<ReaderInterceptor> readers 
-            = ProviderFactory.getInstance(outMessage).createMessageBodyReaderInterceptor(
+            = ClientProviderFactory.getInstance(outMessage).createMessageBodyReaderInterceptor(
                 cls, type, anns, contentType, outMessage);
         if (readers != null) {
             try {
@@ -687,7 +691,7 @@ public abstract class AbstractClient imp
         // so we can keep a map of ParamConverter on the bus, that said
         // it seems an over-optimization at this stage, it's a 5% case;
         // typical requests have a limited number of simple URI parameters
-        ProviderFactory pf = ProviderFactory.getInstance(cfg.getBus());
+        ProviderFactory pf = ClientProviderFactory.getInstance(cfg.getBus());
         if (pf != null) {
             @SuppressWarnings("unchecked")
             ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass);

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java?rev=1442931&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java Wed Feb  6 12:35:21 2013
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.client;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.util.ClassHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.message.Message;
+
+public final class ClientProviderFactory extends ProviderFactory {
+    private static final String SHARED_CLIENT_FACTORY = "jaxrs.shared.client.factory";
+    
+    private List<ProviderInfo<ClientRequestFilter>> clientRequestFilters = 
+        new ArrayList<ProviderInfo<ClientRequestFilter>>(1);
+    private List<ProviderInfo<ClientResponseFilter>> clientResponseFilters = 
+        new ArrayList<ProviderInfo<ClientResponseFilter>>(1);
+    private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers = 
+        new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
+   
+    
+    private ClientProviderFactory(ProviderFactory baseFactory, Bus bus) {
+        super(baseFactory, bus);
+    }
+    
+    public static ClientProviderFactory createInstance(Bus bus) {
+        if (bus == null) {
+            bus = BusFactory.getThreadDefaultBus();
+        }
+        ClientProviderFactory baseFactory = initBaseFactory(bus);
+        ClientProviderFactory factory = new ClientProviderFactory(baseFactory, bus);
+        factory.setBusProviders();
+        return factory;
+    }
+    
+    public static ClientProviderFactory getInstance(Bus bus) {
+        return (ClientProviderFactory)bus.getProperty(CLIENT_FACTORY_NAME);
+    }
+    
+    public static ClientProviderFactory getInstance(Message m) {
+        Endpoint e = m.getExchange().get(Endpoint.class);
+        return (ClientProviderFactory)e.get(CLIENT_FACTORY_NAME);
+    }
+       
+    private static synchronized ClientProviderFactory initBaseFactory(Bus bus) {
+        ClientProviderFactory factory = (ClientProviderFactory)bus.getProperty(SHARED_CLIENT_FACTORY);
+        if (factory != null) {
+            return factory;
+        }
+        factory = new ClientProviderFactory(null, bus);
+        ProviderFactory.initBaseFactory(factory);
+        bus.setProperty(SHARED_CLIENT_FACTORY, factory);
+        return factory;
+    }
+    
+    
+    //CHECKSTYLE:OFF 
+    @Override
+    protected void setProviders(Object... providers) {
+        super.setProviders(providers);
+        for (Object o : providers) {
+            if (o == null) {
+                continue;
+            }
+            Class<?> oClass = ClassHelper.getRealClass(o);
+            if (ClientRequestFilter.class.isAssignableFrom(oClass)) {
+                clientRequestFilters.add(
+                   new ProviderInfo<ClientRequestFilter>((ClientRequestFilter)o, getBus()));
+            }
+            
+            if (ClientResponseFilter.class.isAssignableFrom(oClass)) {
+                clientResponseFilters.add(
+                   new ProviderInfo<ClientResponseFilter>((ClientResponseFilter)o, getBus()));
+            }
+            
+            if (ResponseExceptionMapper.class.isAssignableFrom(oClass)) {
+                responseExceptionMappers.add(
+                    new ProviderInfo<ResponseExceptionMapper<?>>((ResponseExceptionMapper<?>)o, getBus())); 
+            }
+        
+            
+        }
+        Collections.sort(clientRequestFilters, new BindingPriorityComparator(true));
+        Collections.sort(clientResponseFilters, new BindingPriorityComparator(false));
+        
+        injectContextProxies(responseExceptionMappers, clientRequestFilters, clientResponseFilters);
+    }
+//CHECKSTYLE:ON
+    
+    @SuppressWarnings("unchecked")
+    public <T extends Throwable> ResponseExceptionMapper<T> createResponseExceptionMapper(
+                                 Class<?> paramType) {
+        
+        List<ResponseExceptionMapper<?>> candidates = new LinkedList<ResponseExceptionMapper<?>>();
+        
+        for (ProviderInfo<ResponseExceptionMapper<?>> em : responseExceptionMappers) {
+            handleMapper(candidates, em, paramType, null, ResponseExceptionMapper.class, true);
+        }
+        if (candidates.size() == 0) {
+            return null;
+        }
+        Collections.sort(candidates, new ProviderFactory.ClassComparator());
+        return (ResponseExceptionMapper<T>) candidates.get(0);
+    }
+    
+    @Override
+    public void clearProviders() {
+        super.clearProviders();
+        responseExceptionMappers.clear();
+        clientRequestFilters.clear();
+        clientResponseFilters.clear();
+    }
+    
+    public List<ProviderInfo<ClientRequestFilter>> getClientRequestFilters() {
+        return Collections.unmodifiableList(clientRequestFilters);
+    }
+    
+    public List<ProviderInfo<ClientResponseFilter>> getClientResponseFilters() {
+        return Collections.unmodifiableList(clientResponseFilters);
+    }
+    
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Wed Feb  6 12:35:21 2013
@@ -60,7 +60,6 @@ import org.apache.cxf.jaxrs.model.ClassR
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.Parameter;
 import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.FormUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
@@ -307,7 +306,7 @@ public class ClientProxyImpl extends Abs
     }
     
     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
-        ProviderFactory pf = ProviderFactory.getInstance(message);
+        ClientProviderFactory pf = ClientProviderFactory.getInstance(message);
         Class<?>[] exTypes = m.getExceptionTypes();
         if (exTypes.length == 0) {
             exTypes = new Class[]{WebApplicationException.class};
@@ -595,7 +594,7 @@ public class ClientProxyImpl extends Abs
             return readBody(r, outMessage, method.getReturnType(), 
                             method.getGenericReturnType(), method.getDeclaredAnnotations());
         } finally {
-            ProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
+            ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java Wed Feb  6 12:35:21 2013
@@ -361,8 +361,11 @@ public class JAXRSClientFactoryBean exte
         if (headers != null && addHeaders) {
             client.headers(headers);
         }
+        ClientProviderFactory factory = ClientProviderFactory.createInstance(getBus()); 
+        setupFactory(factory, ep);
+        getBus().setProperty(ClientProviderFactory.class.getName(), factory);
         
-        setupFactory(ep);
+
     }
     
     protected void applyFeatures(AbstractClient client) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Wed Feb  6 12:35:21 2013
@@ -56,7 +56,6 @@ import org.apache.cxf.jaxrs.ext.form.For
 import org.apache.cxf.jaxrs.impl.ResponseImpl;
 import org.apache.cxf.jaxrs.model.ParameterType;
 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.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ParameterizedCollectionType;
@@ -992,7 +991,7 @@ public class WebClient extends AbstractC
             throw (ex instanceof ClientException) ? (ClientException)ex
                                                   : new ClientException(ex);
         } finally {
-            ProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
+            ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java Wed Feb  6 12:35:21 2013
@@ -28,8 +28,8 @@ import javax.ws.rs.core.Response;
 
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxrs.client.ClientProviderFactory;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -44,7 +44,7 @@ public class ClientRequestFilterIntercep
     }
     
     public void handleMessage(Message outMessage) throws Fault {
-        ProviderFactory pf = ProviderFactory.getInstance(outMessage);
+        ClientProviderFactory pf = ClientProviderFactory.getInstance(outMessage);
         if (pf == null) {
             return;
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseFilterInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseFilterInterceptor.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseFilterInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseFilterInterceptor.java Wed Feb  6 12:35:21 2013
@@ -32,8 +32,8 @@ import javax.ws.rs.core.Response.Respons
 
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxrs.client.ClientProviderFactory;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
@@ -45,7 +45,7 @@ public class ClientResponseFilterInterce
     }
     
     public void handleMessage(Message inMessage) throws Fault {
-        ProviderFactory pf = ProviderFactory.getInstance(inMessage);
+        ClientProviderFactory pf = ClientProviderFactory.getInstance(inMessage);
         if (pf == null) {
             return;
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java Wed Feb  6 12:35:21 2013
@@ -30,6 +30,7 @@ import javax.ws.rs.ext.MessageBodyWriter
 import javax.ws.rs.ext.Providers;
 
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.message.Message;
 
 public class ProvidersImpl implements Providers {
@@ -56,7 +57,7 @@ public class ProvidersImpl implements Pr
     }
 
     public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> type) {
-        return ProviderFactory.getInstance(m).createExceptionMapper(type, m);
+        return ServerProviderFactory.getInstance(m).createExceptionMapper(type, m);
     }
 
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java Wed Feb  6 12:35:21 2013
@@ -33,7 +33,7 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
 
@@ -207,7 +207,7 @@ public class RequestPreprocessor {
     }
     
     private Response handleMetadataRequest(Message m) { 
-        List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(m).getRequestHandlers();
+        List<ProviderInfo<RequestHandler>> shs = ServerProviderFactory.getInstance(m).getRequestHandlers();
         // this is actually being tested by ProviderFactory unit tests but just in case
         // WadlGenerator, the custom or default one, must be the first one
         if (shs.size() > 0 && shs.get(0).getProvider() instanceof WadlGenerator) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Wed Feb  6 12:35:21 2013
@@ -45,7 +45,7 @@ import org.apache.cxf.jaxrs.model.ClassR
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -80,7 +80,7 @@ public class JAXRSInInterceptor extends 
                 LOG.warning("Exception occurred during releasing the service instance, " + tex.getMessage());
             }
         }
-        ProviderFactory.getInstance(message).clearThreadLocalProxies();
+        ServerProviderFactory.getInstance(message).clearThreadLocalProxies();
         ClassResourceInfo cri = (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
         if (cri != null) {
             cri.clearThreadLocalProxies();
@@ -99,7 +99,7 @@ public class JAXRSInInterceptor extends 
         } catch (RuntimeException ex) {
             Response excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
             if (excResponse == null) {
-                ProviderFactory.getInstance(message).clearThreadLocalProxies();
+                ServerProviderFactory.getInstance(message).clearThreadLocalProxies();
                 message.getExchange().put(Message.PROPOGATE_EXCEPTION, 
                                           JAXRSUtils.propogateException(message));
                 throw ex;
@@ -112,7 +112,7 @@ public class JAXRSInInterceptor extends 
     
     private void processRequest(Message message) {
         
-        ProviderFactory providerFactory = ProviderFactory.getInstance(message);
+        ServerProviderFactory providerFactory = ServerProviderFactory.getInstance(message);
         
         RequestPreprocessor rp = providerFactory.getRequestPreprocessor();
         if (rp != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Wed Feb  6 12:35:21 2013
@@ -60,7 +60,7 @@ import org.apache.cxf.jaxrs.model.ClassR
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -82,7 +82,7 @@ public class JAXRSOutInterceptor extends
     }
 
     public void handleMessage(Message message) {
-        ProviderFactory providerFactory = ProviderFactory.getInstance(message);
+        ServerProviderFactory providerFactory = ServerProviderFactory.getInstance(message);
         try {
             processResponse(providerFactory, message);
         } finally {
@@ -107,7 +107,7 @@ public class JAXRSOutInterceptor extends
 
     }
     
-    private void processResponse(ProviderFactory providerFactory, Message message) {
+    private void processResponse(ServerProviderFactory providerFactory, Message message) {
         
         if (isResponseAlreadyHandled(message)) {
             return;
@@ -144,7 +144,7 @@ public class JAXRSOutInterceptor extends
         serializeMessage(message, response, ori, !retryHappened);        
     }
 
-    private Response runResponseFilters(ProviderFactory providerFactory,
+    private Response runResponseFilters(ServerProviderFactory providerFactory,
                                 Message message, 
                                 Response response, 
                                 OperationResourceInfo ori) {
@@ -156,7 +156,7 @@ public class JAXRSOutInterceptor extends
         }
         
         List<ProviderInfo<ResponseHandler>> handlers = 
-            ProviderFactory.getInstance(message).getResponseHandlers();
+            ServerProviderFactory.getInstance(message).getResponseHandlers();
         for (ProviderInfo<ResponseHandler> rh : handlers) {
             InjectionUtils.injectContexts(rh.getProvider(), rh, 
                                                message.getExchange().getInMessage());
@@ -244,7 +244,7 @@ public class JAXRSOutInterceptor extends
         List<WriterInterceptor> writers = null;
         MediaType responseType = null;
         for (MediaType type : availableContentTypes) { 
-            writers = ProviderFactory.getInstance(message)
+            writers = ServerProviderFactory.getInstance(message)
                 .createMessageBodyWriterInterceptor(targetType, genericType, annotations, type, message);
             
             if (writers != null) {
@@ -370,7 +370,7 @@ public class JAXRSOutInterceptor extends
         }
     }
     
-    private Response handleFilterException(ProviderFactory pf,
+    private Response handleFilterException(ServerProviderFactory pf,
                                        Message message, 
                                        Response response, 
                                        OperationResourceInfo ori,

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Wed Feb  6 12:35:21 2013
@@ -28,32 +28,15 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
-import javax.ws.rs.BindingPriority;
 import javax.ws.rs.Produces;
-import javax.ws.rs.RuntimeType;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.ContainerResponseFilter;
-import javax.ws.rs.container.DynamicFeature;
-import javax.ws.rs.container.PreMatching;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Configuration;
-import javax.ws.rs.core.Feature;
-import javax.ws.rs.core.FeatureContext;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -64,60 +47,39 @@ import javax.ws.rs.ext.ReaderInterceptor
 import javax.ws.rs.ext.WriterInterceptor;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
-import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR;
-import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
-import org.apache.cxf.jaxrs.impl.ResourceInfoImpl;
-import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.impl.WriterInterceptorMBW;
-import org.apache.cxf.jaxrs.model.BeanParamInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
-import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 
-public final class ProviderFactory {
-    private static final Class<?>[] FILTER_INTERCEPTOR_CLASSES = 
-        new Class<?>[] {ContainerRequestFilter.class,
-                        ContainerResponseFilter.class,
-                        ReaderInterceptor.class,
-                        WriterInterceptor.class};
+public abstract class ProviderFactory {
+    protected static final String DEFAULT_FILTER_NAME_BINDING = "org.apache.cxf.filter.binding";
+    protected static final String SERVER_FACTORY_NAME = "org.apache.cxf.jaxrs.provider.ServerProviderFactory";
+    protected static final String CLIENT_FACTORY_NAME = "org.apache.cxf.jaxrs.client.ClientProviderFactory";
+    
     private static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
     private static final Logger LOG = LogUtils.getL7dLogger(ProviderFactory.class);
-    private static final ProviderFactory SHARED_FACTORY = getInstance();
     
-    private static final String DEFAULT_FILTER_NAME_BINDING = "org.apache.cxf.filter.binding";
     private static final String JAXB_PROVIDER_NAME = "org.apache.cxf.jaxrs.provider.JAXBElementProvider";
     private static final String JSON_PROVIDER_NAME = "org.apache.cxf.jaxrs.provider.json.JSONProvider";
     private static final String BUS_PROVIDERS_ALL = "org.apache.cxf.jaxrs.bus.providers";
     
-    static {
-        SHARED_FACTORY.setProviders(new BinaryDataProvider<Object>(),
-                                    new SourceProvider<Object>(),
-                                    new DataSourceProvider<Object>(),
-                                    new FormEncodingProvider<Object>(),
-                                    new PrimitiveTextProvider<Object>(),
-                                    new MultipartProvider(),
-                                    new WebApplicationExceptionMapper(),
-                                    new WadlGenerator());
-        
-    }
+    protected List<ProviderInfo<ReaderInterceptor>> readerInterceptors = 
+        new ArrayList<ProviderInfo<ReaderInterceptor>>(1);
+    protected List<ProviderInfo<WriterInterceptor>> writerInterceptors = 
+        new ArrayList<ProviderInfo<WriterInterceptor>>(1);
     
     private List<ProviderInfo<MessageBodyReader<?>>> messageReaders = 
         new ArrayList<ProviderInfo<MessageBodyReader<?>>>();
@@ -130,84 +92,41 @@ public final class ProviderFactory {
     
     private ParamConverterProvider newParamConverter;
     
-    private List<ProviderInfo<MessageBodyReader<?>>> jaxbReaders = 
-        new ArrayList<ProviderInfo<MessageBodyReader<?>>>();
-    private List<ProviderInfo<MessageBodyWriter<?>>> jaxbWriters = 
-        new ArrayList<ProviderInfo<MessageBodyWriter<?>>>();
-    
-    private List<ProviderInfo<ReaderInterceptor>> readerInterceptors = 
-        new ArrayList<ProviderInfo<ReaderInterceptor>>(1);
-    private List<ProviderInfo<WriterInterceptor>> writerInterceptors = 
-        new ArrayList<ProviderInfo<WriterInterceptor>>(1);
-    
-    // Server specific providers
-    private List<ProviderInfo<ExceptionMapper<?>>> exceptionMappers = 
-        new ArrayList<ProviderInfo<ExceptionMapper<?>>>(1);
-    
-    // RequestHandler & ResponseHandler will have to be deprecated for 2.7.0
-    private List<ProviderInfo<RequestHandler>> requestHandlers = 
-        new ArrayList<ProviderInfo<RequestHandler>>(1);
-    private List<ProviderInfo<ResponseHandler>> responseHandlers = 
-        new ArrayList<ProviderInfo<ResponseHandler>>(1);
-    
-    // ContainerRequestFilter & ContainerResponseFilter are introduced in JAX-RS 2.0
-    private List<ProviderInfo<ContainerRequestFilter>> preMatchContainerRequestFilters = 
-        new ArrayList<ProviderInfo<ContainerRequestFilter>>(1);
-    //TODO: consider using List as a value type for postmatching filters
-    private Map<NameKey, ProviderInfo<ContainerRequestFilter>> postMatchContainerRequestFilters = 
-        new LinkedHashMap<NameKey, ProviderInfo<ContainerRequestFilter>>();
-    private Map<NameKey, ProviderInfo<ContainerResponseFilter>> postMatchContainerResponseFilters = 
-        new LinkedHashMap<NameKey, ProviderInfo<ContainerResponseFilter>>();
-    private RequestPreprocessor requestPreprocessor;
-    private ProviderInfo<Application> application;
-    private List<DynamicFeature> dynamicFeatures = new LinkedList<DynamicFeature>();
-    
-    // This may be better be kept at OperationResourceInfo ? Though we may have many methods
-    // across different resources that use the same BeanParam. 
-    private Map<Class<?>, BeanParamInfo> beanParams = new HashMap<Class<?>, BeanParamInfo>();
-    
     // List of injected providers
     private Collection<ProviderInfo<?>> injectedProviders = 
         new LinkedList<ProviderInfo<?>>();
     
-    
-    //TODO: Client-only providers, consider introducing ClientProviderFactory,
-    //      will make it easier to split the client API into a separate module
-    private List<ProviderInfo<ClientRequestFilter>> clientRequestFilters = 
-        new ArrayList<ProviderInfo<ClientRequestFilter>>(1);
-    private List<ProviderInfo<ClientResponseFilter>> clientResponseFilters = 
-        new ArrayList<ProviderInfo<ClientResponseFilter>>(1);
-    private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers = 
-        new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
-   
     private Bus bus;
     
+    private ProviderFactory baseFactory;
     
-    private ProviderFactory(Bus bus) {
+    protected ProviderFactory(ProviderFactory baseFactory, Bus bus) {
+        this.baseFactory = baseFactory;
         this.bus = bus;
-        initJaxbProviders();
-        setBusProviders();
     }
     
-    // Not ideal but in the end seems like the simplest option compared 
-    // to adding default readers/writers to existing messageReaders/Writers 
-    // (due to all sort of conflicts with custom providers) and cloning 
-    // at the request time
-    private void initJaxbProviders() {
-        Object jaxbProvider = createProvider(JAXB_PROVIDER_NAME);
-        if (jaxbProvider != null) {
-            jaxbReaders.add(new ProviderInfo<MessageBodyReader<?>>((MessageBodyReader<?>)jaxbProvider, bus));
-            jaxbWriters.add(new ProviderInfo<MessageBodyWriter<?>>((MessageBodyWriter<?>)jaxbProvider, bus));
-        }
-        Object jsonProvider = createProvider(JSON_PROVIDER_NAME);
-        if (jsonProvider != null) {
-            jaxbReaders.add(new ProviderInfo<MessageBodyReader<?>>((MessageBodyReader<?>)jsonProvider, bus));
-            jaxbWriters.add(new ProviderInfo<MessageBodyWriter<?>>((MessageBodyWriter<?>)jsonProvider, bus));
-        }
-        injectContextProxies(jaxbReaders, jaxbWriters);
+    protected Bus getBus() {
+        return bus;
     }
     
+    protected ProviderFactory getBaseFactory() {
+        return baseFactory;
+    }
     
+    protected boolean isBaseFactory() {
+        return baseFactory == null;
+    }
+    
+    protected static void initBaseFactory(ProviderFactory factory) {
+        factory.setProviders(new BinaryDataProvider<Object>(),
+                                    new SourceProvider<Object>(),
+                                    new DataSourceProvider<Object>(),
+                                    new FormEncodingProvider<Object>(),
+                                    new PrimitiveTextProvider<Object>(),
+                                    createProvider(JAXB_PROVIDER_NAME),
+                                    createProvider(JSON_PROVIDER_NAME),
+                                    new MultipartProvider());
+    }
     
     private static Object createProvider(String className) {
         
@@ -225,35 +144,6 @@ public final class ProviderFactory {
         return null;
     }
     
-    public static ProviderFactory getInstance() {
-        return new ProviderFactory(BusFactory.getThreadDefaultBus());
-    }
-    
-    public static ProviderFactory createInstance(Bus bus) {
-        return new ProviderFactory(bus);
-    }
-    
-    public static ProviderFactory getInstance(Bus bus) {
-        return (ProviderFactory)bus.getProperty(ProviderFactory.class.getName());
-    }
-    
-    public static ProviderFactory getInstance(Message m) {
-        Endpoint e = m.getExchange().get(Endpoint.class);
-        return (ProviderFactory)e.get(ProviderFactory.class.getName());
-    }
-    
-    public static ProviderFactory getSharedInstance() {
-        return SHARED_FACTORY;
-    }
-    
-    public void addBeanParamInfo(BeanParamInfo bpi) {
-        beanParams.put(bpi.getResourceClass(), bpi);
-    }
-    
-    public BeanParamInfo getBeanParamInfo(Class<?> beanClass) {
-        return beanParams.get(beanClass);
-    }
-    
     public <T> ContextResolver<T> createContextResolver(Type contextType, 
                                                         Message m) {
         boolean isRequestor = MessageUtils.isRequestor(m);
@@ -350,31 +240,6 @@ public final class ProviderFactory {
         return null;
     }
     
-    public <T extends Throwable> ExceptionMapper<T> createExceptionMapper(Class<?> exceptionType,
-                                                                          Message m) {
-        ExceptionMapper<T> mapper = doCreateExceptionMapper(exceptionType, m);
-        if (mapper != null || this == SHARED_FACTORY) {
-            return mapper;
-        }
-        
-        return SHARED_FACTORY.createExceptionMapper(exceptionType, m);
-    }
-    
-    @SuppressWarnings("unchecked")
-    private <T extends Throwable> ExceptionMapper<T> doCreateExceptionMapper(
-        Class<?> exceptionType, Message m) {
-        
-        List<ExceptionMapper<?>> candidates = new LinkedList<ExceptionMapper<?>>();
-        for (ProviderInfo<ExceptionMapper<?>> em : exceptionMappers) {
-            handleMapper(candidates, em, exceptionType, m, ExceptionMapper.class, true);
-        }
-        if (candidates.size() == 0) {
-            return null;
-        }
-        Collections.sort(candidates, new ExceptionMapperComparator());
-        return (ExceptionMapper<T>) candidates.get(0);
-    }
-    
     public <T> ParamConverter<T> createParameterHandler(Class<T> paramType) {
         
         if (newParamConverter != null) {
@@ -385,23 +250,7 @@ public final class ProviderFactory {
         
     }
     
-    @SuppressWarnings("unchecked")
-    public <T extends Throwable> ResponseExceptionMapper<T> createResponseExceptionMapper(
-                                 Class<?> paramType) {
-        
-        List<ResponseExceptionMapper<?>> candidates = new LinkedList<ResponseExceptionMapper<?>>();
-        
-        for (ProviderInfo<ResponseExceptionMapper<?>> em : responseExceptionMappers) {
-            handleMapper(candidates, em, paramType, null, ResponseExceptionMapper.class, true);
-        }
-        if (candidates.size() == 0) {
-            return null;
-        }
-        Collections.sort(candidates, new ClassComparator());
-        return (ResponseExceptionMapper<T>) candidates.get(0);
-    }
-    
-    private static <T> void handleMapper(List<T> candidates, 
+    protected static <T> void handleMapper(List<T> candidates, 
                                      ProviderInfo<T> em, 
                                      Class<?> expectedType, 
                                      Message m, 
@@ -541,108 +390,16 @@ public final class ProviderFactory {
                                                       mediaType,
                                                       m);
         
-        if (mr == null) {
-            mr = chooseMessageReader(jaxbReaders,
-                                     bodyType,
-                                     parameterType,
-                                     parameterAnnotations,
-                                     mediaType,
-                                     m);
-        }
-        
-        if (mr != null || SHARED_FACTORY == this) {
+        if (mr != null || isBaseFactory()) {
             return mr;
         }
-        return SHARED_FACTORY.createMessageBodyReader(bodyType,
+        return baseFactory.createMessageBodyReader(bodyType,
                                                       parameterType,
                                                       parameterAnnotations,
                                                       mediaType,
                                                       m);
     }
     
-    private boolean isJaxbBasedProvider(Object sharedProvider) {
-        String clsName = sharedProvider.getClass().getName();
-        return JAXB_PROVIDER_NAME.equals(clsName) || JSON_PROVIDER_NAME.equals(clsName);
-    }
-    
-    public List<ProviderInfo<ContainerRequestFilter>> getPreMatchContainerRequestFilters() {
-        return Collections.unmodifiableList(preMatchContainerRequestFilters);
-    }
-    
-    public List<ProviderInfo<ContainerRequestFilter>> getPostMatchContainerRequestFilters(List<String> names) {
-        return getPostMatchContainerFilters(postMatchContainerRequestFilters, 
-                                            names);
-    }
-    
-    public List<ProviderInfo<ContainerResponseFilter>> getContainerResponseFilters(List<String> names) {
-        return getPostMatchContainerFilters(postMatchContainerResponseFilters, 
-                                            names);
-    }
-    
-    public List<ProviderInfo<ClientRequestFilter>> getClientRequestFilters() {
-        return Collections.unmodifiableList(clientRequestFilters);
-    }
-    
-    public List<ProviderInfo<ClientResponseFilter>> getClientResponseFilters() {
-        return Collections.unmodifiableList(clientResponseFilters);
-    }
-
-    //TODO: Also sort based on BindingPriority
-    private static <T> List<ProviderInfo<T>> getPostMatchContainerFilters(Map<NameKey, ProviderInfo<T>> boundFilters,
-                                                                          List<String> names) {
-        
-        if (boundFilters.isEmpty()) {
-            return Collections.emptyList();
-        }
-        names = names == null ? Collections.<String>emptyList() : names;
-        
-        MultivaluedMap<ProviderInfo<T>, String> map = 
-            new MetadataMap<ProviderInfo<T>, String>();
-        for (Map.Entry<NameKey, ProviderInfo<T>> entry : boundFilters.entrySet()) {
-            String entryName = entry.getKey().getName();
-            if (entryName.equals(DEFAULT_FILTER_NAME_BINDING)) {
-                map.put(entry.getValue(), Collections.<String>emptyList());
-            } else {
-                map.add(entry.getValue(), entryName);
-            }
-        }
-        List<ProviderInfo<T>> list = new LinkedList<ProviderInfo<T>>();
-        for (Map.Entry<ProviderInfo<T>, List<String>> entry : map.entrySet()) {
-            if (names.containsAll(entry.getValue())) {
-                list.add(entry.getKey());
-            }
-        }
-        return list;
-    }
-    
-    public List<ProviderInfo<RequestHandler>> getRequestHandlers() {
-        List<ProviderInfo<RequestHandler>> handlers = null;
-        if (requestHandlers.size() == 0) {
-            handlers = SHARED_FACTORY.requestHandlers;
-        } else {
-            handlers = new ArrayList<ProviderInfo<RequestHandler>>();
-            boolean customWADLHandler = false;
-            for (int i = 0; i < requestHandlers.size(); i++) {
-                if (requestHandlers.get(i).getProvider() instanceof WadlGenerator) {
-                    customWADLHandler = true;
-                    break;
-                }
-            }
-            if (!customWADLHandler) {
-                // TODO : this works only because we know we only have a single 
-                // system handler which is a default WADLGenerator, think of a better approach
-                handlers.addAll(SHARED_FACTORY.requestHandlers);    
-            }
-            handlers.addAll(requestHandlers);
-            
-        }
-        return Collections.unmodifiableList(handlers);
-    }
-    
-    public List<ProviderInfo<ResponseHandler>> getResponseHandlers() {
-        return Collections.unmodifiableList(responseHandlers);
-    }
-
     public <T> MessageBodyWriter<T> createMessageBodyWriter(Class<T> bodyType,
                                                             Type parameterType,
                                                             Annotation[] parameterAnnotations,
@@ -656,27 +413,19 @@ public final class ProviderFactory {
                                                       mediaType,
                                                       m);
         
-        if (mw == null) {
-            mw = chooseMessageWriter(jaxbWriters, 
-                                     bodyType,
-                                     parameterType,
-                                     parameterAnnotations,
-                                     mediaType,
-                                     m);
-        }
         
-        if (mw != null || SHARED_FACTORY == this) {
+        if (mw != null || isBaseFactory()) {
             return mw;
         }
         
-        return SHARED_FACTORY.createMessageBodyWriter(bodyType,
+        return baseFactory.createMessageBodyWriter(bodyType,
                                                   parameterType,
                                                   parameterAnnotations,
                                                   mediaType,
                                                   m);
     }
     
-    private void setBusProviders() {
+    protected void setBusProviders() {
         List<Object> extensions = new LinkedList<Object>(); 
         final String alreadySetProp = "bus.providers.set";
         if (bus.getProperty(alreadySetProp) == null) {
@@ -707,13 +456,8 @@ public final class ProviderFactory {
         }
     }
     
-//CHECKSTYLE:OFF       
-    private void setProviders(Object... providers) {
-        
-        List<ProviderInfo<ContainerRequestFilter>> postMatchRequestFilters = 
-            new LinkedList<ProviderInfo<ContainerRequestFilter>>();
-        List<ProviderInfo<ContainerResponseFilter>> postMatchResponseFilters = 
-            new LinkedList<ProviderInfo<ContainerResponseFilter>>();
+    //CHECKSTYLE:OFF       
+    protected void setProviders(Object... providers) {
         
         for (Object o : providers) {
             if (o == null) {
@@ -737,26 +481,6 @@ public final class ProviderFactory {
                 contextProviders.add(new ProviderInfo<ContextProvider<?>>((ContextProvider<?>)o, bus)); 
             }
             
-            if (RequestHandler.class.isAssignableFrom(oClass)) {
-                requestHandlers.add(new ProviderInfo<RequestHandler>((RequestHandler)o, bus)); 
-            }
-            
-            if (ResponseHandler.class.isAssignableFrom(oClass)) {
-                responseHandlers.add(new ProviderInfo<ResponseHandler>((ResponseHandler)o, bus)); 
-            }
-            
-            if (ContainerRequestFilter.class.isAssignableFrom(oClass)) {
-                addContainerFilter(postMatchRequestFilters,
-                   new ProviderInfo<ContainerRequestFilter>((ContainerRequestFilter)o, bus),
-                   preMatchContainerRequestFilters);
-            }
-            
-            if (ContainerResponseFilter.class.isAssignableFrom(oClass)) {
-                addContainerFilter(postMatchResponseFilters,
-                   new ProviderInfo<ContainerResponseFilter>((ContainerResponseFilter)o, bus),
-                   null); 
-            }
-            
             if (ReaderInterceptor.class.isAssignableFrom(oClass)) {
                 readerInterceptors.add(
                    new ProviderInfo<ReaderInterceptor>((ReaderInterceptor)o, bus));
@@ -767,28 +491,6 @@ public final class ProviderFactory {
                    new ProviderInfo<WriterInterceptor>((WriterInterceptor)o, bus));
             }
             
-            if (DynamicFeature.class.isAssignableFrom(oClass)) {
-                dynamicFeatures.add((DynamicFeature)o);
-            }
-            
-            if (ClientRequestFilter.class.isAssignableFrom(oClass)) {
-                clientRequestFilters.add(
-                   new ProviderInfo<ClientRequestFilter>((ClientRequestFilter)o, bus));
-            }
-            
-            if (ClientResponseFilter.class.isAssignableFrom(oClass)) {
-                clientResponseFilters.add(
-                   new ProviderInfo<ClientResponseFilter>((ClientResponseFilter)o, bus));
-            }
-            
-            if (ExceptionMapper.class.isAssignableFrom(oClass)) {
-                exceptionMappers.add(new ProviderInfo<ExceptionMapper<?>>((ExceptionMapper<?>)o, bus)); 
-            }
-            
-            if (ResponseExceptionMapper.class.isAssignableFrom(oClass)) {
-                responseExceptionMappers.add(new ProviderInfo<ResponseExceptionMapper<?>>((ResponseExceptionMapper<?>)o, bus)); 
-            }
-            
             if (ParamConverterProvider.class.isAssignableFrom(oClass)) {
                 newParamConverter = (ParamConverterProvider)o;
             }
@@ -797,57 +499,13 @@ public final class ProviderFactory {
         sortWriters();
         sortContextResolvers();
         
-        Collections.sort(preMatchContainerRequestFilters, new BindingPriorityComparator(true));
-        mapContainerFilters(postMatchContainerRequestFilters, postMatchRequestFilters, true);
-        mapContainerFilters(postMatchContainerResponseFilters, postMatchResponseFilters, false);
         Collections.sort(readerInterceptors, new BindingPriorityComparator(true));
         Collections.sort(writerInterceptors, new BindingPriorityComparator(false));
         
-        Collections.sort(clientRequestFilters, new BindingPriorityComparator(true));
-        Collections.sort(clientResponseFilters, new BindingPriorityComparator(false));
-        
         injectContextProxies(messageReaders, messageWriters, contextResolvers, 
-            requestHandlers, responseHandlers, exceptionMappers,
-            postMatchContainerRequestFilters.values(), preMatchContainerRequestFilters,
-            postMatchContainerResponseFilters.values(),
-            responseExceptionMappers, clientRequestFilters, clientResponseFilters,
             readerInterceptors, writerInterceptors);
     }
-//CHECKSTYLE:ON
-    
-    private static <T> void mapContainerFilters(Map<NameKey, ProviderInfo<T>> map,
-                                                List<ProviderInfo<T>> postMatchFilters,
-                                                boolean ascending) {
-        
-        Collections.sort(postMatchFilters, new PostMatchFilterComparator(ascending));
-        for (ProviderInfo<T> p : postMatchFilters) { 
-            List<String> names = AnnotationUtils.getNameBindings(
-                p.getProvider().getClass().getAnnotations());
-            names = names.isEmpty() ? Collections.singletonList(DEFAULT_FILTER_NAME_BINDING) : names;
-            for (String name : names) {
-                map.put(new NameKey(name, AnnotationUtils.getBindingPriority(p.getProvider().getClass())), 
-                        p);
-            }
-        }
-        
-    }
-    
-    private static <T> void addContainerFilter(List<ProviderInfo<T>> postMatchFilters,
-                                               ProviderInfo<T> p,
-                                               List<ProviderInfo<T>> preMatchFilters) {
-        T filter = p.getProvider();
-        if (preMatchFilters != null && isPrematching(filter.getClass())) {
-            preMatchFilters.add(p);
-        } else {
-            postMatchFilters.add(p);
-        }
-        
-    }
-    
-    private static boolean isPrematching(Class<?> filterCls) {
-        return AnnotationUtils.getAnnotation(filterCls.getAnnotations(), 
-                                      PreMatching.class) != null;
-    }
+    //CHECKSTYLE:ON
     
     static void injectContextValues(ProviderInfo<?> pi, Message m) {
         if (m != null) {
@@ -855,13 +513,10 @@ public final class ProviderFactory {
         }
     }
     
-    void injectContextProxies(Collection<?> ... providerLists) {
+    protected void injectContextProxies(Collection<?> ... providerLists) {
         for (Collection<?> list : providerLists) {
             Collection<ProviderInfo<?>> l2 = CastUtils.cast(list);
             for (ProviderInfo<?> pi : l2) {
-                if (ProviderFactory.SHARED_FACTORY == this && isJaxbBasedProvider(pi.getProvider())) {
-                    continue;
-                }
                 injectContextProxiesIntoProvider(pi);
             }
         }
@@ -915,7 +570,7 @@ public final class ProviderFactory {
         List<MessageBodyReader<?>> candidates = new LinkedList<MessageBodyReader<?>>();
         for (ProviderInfo<MessageBodyReader<?>> ep : readers) {
             if (matchesReaderCriterias(ep, type, genericType, annotations, mediaType, m)) {
-                if (this == SHARED_FACTORY) {
+                if (isBaseFactory()) {
                     return (MessageBodyReader<T>) ep.getProvider();
                 }
                 handleMapper(candidates, ep, type, m, MessageBodyReader.class, false);
@@ -946,7 +601,7 @@ public final class ProviderFactory {
             return false;
         }
         boolean injected = false;
-        if (this != SHARED_FACTORY || !isJaxbBasedProvider(ep)) {
+        if (m.get(ACTIVE_JAXRS_PROVIDER_KEY) != ep) {
             injectContextValues(pi, m);
             injected = true;
         }
@@ -977,7 +632,7 @@ public final class ProviderFactory {
         List<MessageBodyWriter<?>> candidates = new LinkedList<MessageBodyWriter<?>>();
         for (ProviderInfo<MessageBodyWriter<?>> ep : writers) {
             if (matchesWriterCriterias(ep, type, genericType, annotations, mediaType, m)) {
-                if (this == SHARED_FACTORY) {
+                if (isBaseFactory()) {
                     return (MessageBodyWriter<T>) ep.getProvider();
                 }
                 handleMapper(candidates, ep, type, m, MessageBodyWriter.class, false);
@@ -1007,8 +662,7 @@ public final class ProviderFactory {
             return false;
         }
         boolean injected = false;
-        if ((this != SHARED_FACTORY || !isJaxbBasedProvider(ep))
-            && m.get(ACTIVE_JAXRS_PROVIDER_KEY) != ep) {
+        if (m.get(ACTIVE_JAXRS_PROVIDER_KEY) != ep) {
             injectContextValues(pi, m);
             injected = true;
         }
@@ -1095,30 +749,10 @@ public final class ProviderFactory {
         }
     }
     
-    public void setApplicationProvider(ProviderInfo<Application> app) {
-        application = app;
-    }
-    
-    public void setRequestPreprocessor(RequestPreprocessor rp) {
-        this.requestPreprocessor = rp;
-    }
-    
-    public RequestPreprocessor getRequestPreprocessor() {
-        return requestPreprocessor;
-    }
-    
-    public void clearExceptionMapperProxies() {
-        clearProxies(exceptionMappers);
-    }
-    
     public void clearThreadLocalProxies() {
         clearProxies(injectedProviders);
-        
-        if (application != null) {
-            application.clearThreadLocalProxies();
-        }
-        if (this != SHARED_FACTORY) {
-            SHARED_FACTORY.clearThreadLocalProxies();
+        if (baseFactory != null) {
+            baseFactory.clearThreadLocalProxies();
         }
     }
     
@@ -1136,15 +770,6 @@ public final class ProviderFactory {
         messageWriters.clear();
         contextResolvers.clear();
         contextProviders.clear();
-        exceptionMappers.clear();
-        requestHandlers.clear();
-        responseHandlers.clear();
-        postMatchContainerRequestFilters.clear();
-        postMatchContainerResponseFilters.clear();
-        preMatchContainerRequestFilters.clear();
-        responseExceptionMappers.clear();
-        clientRequestFilters.clear();
-        clientResponseFilters.clear();
     }
     
     public void setBus(Bus bus) {
@@ -1156,30 +781,6 @@ public final class ProviderFactory {
         }
     }
     
-    public void applyDynamicFeatures(List<ClassResourceInfo> list) {
-        if (dynamicFeatures.size() > 0) {
-            for (ClassResourceInfo cri : list) {
-                doApplyDynamicFeatures(cri);
-            }
-        }
-    }
-    
-    private void doApplyDynamicFeatures(ClassResourceInfo cri) {
-        Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
-        for (OperationResourceInfo ori : oris) {
-            for (DynamicFeature feature : dynamicFeatures) {
-                FeatureContext methodConfigurable = new MethodConfigurable(ori);
-                feature.configure(new ResourceInfoImpl(ori), methodConfigurable);
-            }
-        }
-        Collection<ClassResourceInfo> subs = cri.getSubResources();
-        for (ClassResourceInfo sub : subs) {
-            if (sub != cri) {
-                doApplyDynamicFeatures(sub);    
-            }
-        }
-    }
-    
     private boolean injectProviderProperty(Object provider, String mName, Class<?> pClass, 
                                         Object pValue) {
         try {
@@ -1199,7 +800,9 @@ public final class ProviderFactory {
                 injectProviderProperty(r.getProvider(), "setSchemaLocations", List.class, schemas);
         }
         if (!schemasMethodAvailable) {
-            for (ProviderInfo<MessageBodyReader<?>> r : jaxbReaders) {
+            setProviders(createProvider(JAXB_PROVIDER_NAME),
+                         createProvider(JSON_PROVIDER_NAME));
+            for (ProviderInfo<MessageBodyReader<?>> r : messageReaders) {
                 injectProviderProperty(r.getProvider(), "setSchemaLocations", List.class, schemas);
             }
         }
@@ -1213,40 +816,37 @@ public final class ProviderFactory {
                 ((AbstractConfigurableProvider)provider).init(cris);
             }
         }
-        if (this != SHARED_FACTORY) {
-            SHARED_FACTORY.initProviders(cris);
+        if (!isBaseFactory()) {
+            baseFactory.initProviders(cris);
         }
     }
     
     Set<Object> getReadersWriters() {
         Set<Object> set = new HashSet<Object>();
         set.addAll(messageReaders);
-        set.addAll(jaxbReaders);
         set.addAll(messageWriters);
-        set.addAll(jaxbWriters);
         return set;
     }
     
-    private static class ExceptionMapperComparator implements 
-        Comparator<ExceptionMapper<? extends Throwable>> {
-
-        public int compare(ExceptionMapper<? extends Throwable> em1, 
-                           ExceptionMapper<? extends Throwable> em2) {
-            return compareClasses(em1, em2);
-        }
-        
-    }
-    
-    private static class ClassComparator implements 
+    public static class ClassComparator implements 
         Comparator<Object> {
     
         public int compare(Object em1, Object em2) {
             return compareClasses(em1, em2);
         }
+    }
+    
+    public static ProviderFactory getInstance(Message m) {
+        Endpoint e = m.getExchange().get(Endpoint.class);
+        
+        Message outM = m.getExchange().getOutMessage();
+        boolean isClient = outM != null && MessageUtils.isRequestor(outM);
+        String name = isClient ? CLIENT_FACTORY_NAME : SERVER_FACTORY_NAME;
         
+        return (ProviderFactory)e.get(name);
     }
     
-    private static int compareClasses(Object o1, Object o2) {
+    protected static int compareClasses(Object o1, Object o2) {
         Class<?> cl1 = ClassHelper.getRealClass(o1); 
         Class<?> cl2 = ClassHelper.getRealClass(o2);
         
@@ -1286,30 +886,7 @@ public final class ProviderFactory {
         return getGenericInterfaces(cls.getSuperclass());
     }
     
-    private static class PostMatchFilterComparator extends BindingPriorityComparator {
-        public PostMatchFilterComparator(boolean ascending) {
-            super(ascending);
-        }
-        
-        @Override
-        public int compare(ProviderInfo<?> p1, ProviderInfo<?> p2) {
-            int result = super.compare(p1, p2);
-            if (result == 0) {
-                Integer namesSize1 = 
-                    AnnotationUtils.getNameBindings(p1.getProvider().getClass().getAnnotations()).size();
-                Integer namesSize2 = 
-                    AnnotationUtils.getNameBindings(p2.getProvider().getClass().getAnnotations()).size();
-                
-                // if we have two filters with the same binding priority, 
-                // then put a filter with more name bindings upfront 
-                // (this effectively puts name bound filters before global ones)
-                result = namesSize1.compareTo(namesSize2) * -1;
-            }
-            return result; 
-        }
-    }
-    
-    private static class BindingPriorityComparator extends AbstactBindingPriorityComparator {
+    protected static class BindingPriorityComparator extends AbstactBindingPriorityComparator {
         public BindingPriorityComparator(boolean ascending) {
             super(ascending);
         }
@@ -1357,295 +934,5 @@ public final class ProviderFactory {
         }
     }
     
-    private static class NameKey { 
-        private String name;
-        private int bindingPriority;
-        public NameKey(String name, int priority) {
-            this.name = name;
-            this.bindingPriority = priority;
-        }
-        
-        public String getName() {
-            return name;
-        }
-        
-        public int getPriority() {
-            return bindingPriority;
-        }
-    }
     
-    private class MethodConfigurable implements FeatureContext, Configuration {
-        
-        private OperationResourceInfo ori;
-        private String nameBinding;
-        private boolean bindingSet;
-        
-        public MethodConfigurable(OperationResourceInfo ori) {
-            this.ori = ori;
-            nameBinding = DEFAULT_FILTER_NAME_BINDING 
-                + ori.getClassResourceInfo().getServiceClass().getName()
-                + "."
-                + ori.getMethodToInvoke().getName();
-        }
-        
-
-        @Override
-        public Configuration getConfiguration() {
-            return this;
-        }
-        
-        @Override
-        public FeatureContext register(Object provider) {
-            return register(provider, AnnotationUtils.getBindingPriority(provider.getClass()));
-        }
-
-        @Override
-        public FeatureContext register(Object provider, int bindingPriority) {
-            return doRegister(provider, bindingPriority, FILTER_INTERCEPTOR_CLASSES);
-        }
-        
-        @Override
-        public FeatureContext register(Object provider, Class<?>... contracts) {
-            return register(provider, BindingPriority.USER, contracts);
-        }
-        
-        //@Override
-        public FeatureContext register(Object provider, int priority, Class<?>... contracts) {
-            return register(provider, priority, contracts);
-        }
-        
-        @Override
-        public FeatureContext register(Object provider, Map<Class<?>, Integer> contracts) {
-            for (Map.Entry<Class<?>, Integer> entry : contracts.entrySet()) {
-                doRegister(provider, entry.getValue(), entry.getKey());
-            }
-            return this;
-        }
-        
-        @Override
-        public FeatureContext register(Class<?> providerClass) {
-            return register(providerClass, AnnotationUtils.getBindingPriority(providerClass));
-        }
-
-        @Override
-        public FeatureContext register(Class<?> providerClass, int bindingPriority) {
-            return doRegister(createProvider(providerClass), bindingPriority, 
-                              FILTER_INTERCEPTOR_CLASSES);
-        }
-
-        @Override
-        public FeatureContext register(Class<?> providerClass, Class<?>... contracts) {
-            return register(providerClass, BindingPriority.USER, contracts);
-        }
-
-        @Override
-        public FeatureContext register(Class<?> providerClass, Map<Class<?>, Integer> contracts) {
-            Object provider = createProvider(providerClass);
-            for (Map.Entry<Class<?>, Integer> entry : contracts.entrySet()) {
-                doRegister(provider, entry.getValue(), entry.getKey());
-            }
-            return this;
-        }
-        
-        public FeatureContext replaceWith(Configuration config) {
-            // nothing to do in this case
-            return this;
-        }
-        
-        //@Override
-        public FeatureContext register(Class<?> providerClass, int bindingPriority,
-                                         Class<?>... contracts) {
-            return doRegister(createProvider(providerClass), bindingPriority, contracts);
-        }
-        
-        private FeatureContext doRegister(Object provider, int bindingPriority, Class<?>... contracts) {
-        
-            if (provider instanceof Feature) {
-                ((Feature)provider).configure(this);
-                return this;
-            }
-            
-            boolean setIsNeeded = false;
-            for (Class<?> contract : contracts) {
-                if (contract == ContainerRequestFilter.class && provider instanceof ContainerRequestFilter) {
-                    if (isPrematching(provider.getClass())) {
-                        addToInterceptors(preMatchContainerRequestFilters, provider, bindingPriority, true);
-                    } else {
-                        postMatchContainerRequestFilters = 
-                            addToPostMatching(postMatchContainerRequestFilters, provider, bindingPriority, true);
-                        setIsNeeded = true;
-                    }
-                }
-                if (contract == ContainerResponseFilter.class && provider instanceof ContainerResponseFilter) {
-                    postMatchContainerResponseFilters = 
-                        addToPostMatching(postMatchContainerResponseFilters, provider, bindingPriority, false);
-                    setIsNeeded = true;    
-                }
-                if (contract == ReaderInterceptor.class && provider instanceof ReaderInterceptor) {
-                    addToInterceptors(readerInterceptors, provider, bindingPriority, true);
-                }
-                if (contract == WriterInterceptor.class && provider instanceof WriterInterceptor) {
-                    addToInterceptors(writerInterceptors, provider, bindingPriority, false);
-                }
-            }
-            
-            if (setIsNeeded && !bindingSet) {
-                ori.addNameBindings(Collections.singletonList(nameBinding));
-                bindingSet = true;
-            }
-
-            return this;
-        }
-        
-        @SuppressWarnings("unchecked")
-        private <T> void addToInterceptors(List<ProviderInfo<T>> providers, Object provider, 
-                                           int priority, boolean asc) {
-            int size = providers.size();
-            if (size > 0) {
-                for (int i = 0; i < size; i++) {
-                    int providerPriority = AnnotationUtils.getBindingPriority(
-                        providers.get(i).getProvider().getClass());
-                    if (asc) {
-                        if (priority < providerPriority || i + 1 == size) {
-                            int index = priority < providerPriority ? i : i + 1;
-                            providers.add(index, (ProviderInfo<T>)newProvider(provider));
-                            break;
-                        }
-                    } else if (priority > providerPriority || i + 1 == size) {
-                        int index = priority > providerPriority ? i : i + 1; 
-                        providers.add(index, (ProviderInfo<T>)newProvider(provider));
-                        break;
-                    }
-                }
-            } else {
-                providers.add((ProviderInfo<T>)newProvider(provider));
-            }
-        }
-        
-        private <T> ProviderInfo<T> newProvider(T provider) {
-            ProviderInfo<T> newProvider = new ProviderInfo<T>(provider, bus);
-            injectContextProxiesIntoProvider(newProvider);
-            return newProvider;
-        }
-        
-        @SuppressWarnings("unchecked")
-        private <T> Map<NameKey, ProviderInfo<T>> addToPostMatching(
-            Map<NameKey, ProviderInfo<T>> map, Object provider, int priority, boolean asc) {
-            Map<NameKey, ProviderInfo<T>> newMap = new LinkedHashMap<NameKey, ProviderInfo<T>>();
-            
-            Iterator<Map.Entry<NameKey, ProviderInfo<T>>> it = map.entrySet().iterator();
-            if (it.hasNext()) {
-                boolean added = false;
-                while (it.hasNext()) {
-                    Map.Entry<NameKey, ProviderInfo<T>> entry = it.next();
-                    int providerPriority = entry.getKey().getPriority();
-                    // this surely can be collapsed further
-                    if (!added && asc && (priority < providerPriority || !it.hasNext())) {
-                        addNewProvider(newMap, entry, provider, priority, providerPriority >= priority);
-                        added = true;
-                    } else if (!added && !asc && (priority > providerPriority || !it.hasNext())) {
-                        addNewProvider(newMap, entry, provider, priority, priority > providerPriority);
-                        added = true;
-                    } else {
-                        newMap.put(entry.getKey(), entry.getValue());
-                    }   
-                }
-            } else {
-                newMap.put(new NameKey(nameBinding, priority), (ProviderInfo<T>)newProvider(provider));
-            }
-            return newMap;
-            
-                
-        }
-        
-        @SuppressWarnings("unchecked")
-        private <T> void addNewProvider(Map<NameKey, ProviderInfo<T>> newMap, 
-                                        Map.Entry<NameKey, ProviderInfo<T>> entry,
-                                        Object provider, 
-                                        int priority,
-                                        boolean first) {
-            if (first) {
-                newMap.put(new NameKey(nameBinding, priority), (ProviderInfo<T>)newProvider(provider));
-                newMap.put(entry.getKey(), entry.getValue());
-            } else {
-                newMap.put(entry.getKey(), entry.getValue());
-                newMap.put(new NameKey(nameBinding, priority), (ProviderInfo<T>)newProvider(provider));
-            }
-        }
-        
-        @Override
-        public Set<Class<?>> getClasses() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-        
-        @Override
-        public Map<Class<?>, Integer> getContracts(Class<?> componentClass) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public Set<Object> getInstances() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public Map<String, Object> getProperties() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public boolean isEnabled(Feature feature) {
-            return false;
-        }
-        
-        @Override
-        public boolean isEnabled(Class<? extends Feature> featureClass) {
-            return false;
-        }
-        
-        @Override
-        public RuntimeType getRuntimeType() {
-            return null;
-        }
-        
-        @Override
-        public Object getProperty(String name) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-        
-        @Override
-        public Collection<String> getPropertyNames() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public boolean isRegistered(Class<?> componentClass) {
-            return false;
-        }
-        
-        @Override
-        public boolean isRegistered(Object component) {
-            return false;
-        }
-        
-        @Override
-        public FeatureContext setProperty(String name, Object value) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-        
-        private Object createProvider(Class<?> cls) {
-            try {
-                return cls.newInstance();
-            } catch (Throwable ex) {
-                throw new RuntimeException(ex); 
-            }
-        }
-    }
 }



Mime
View raw message