cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1442931 [2/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
Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java?rev=1442931&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java Wed Feb  6 12:35:21 2013
@@ -0,0 +1,713 @@
+/**
+ * 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.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+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 javax.ws.rs.BindingPriority;
+import javax.ws.rs.RuntimeType;
+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.MultivaluedMap;
+import javax.ws.rs.ext.ExceptionMapper;
+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.util.ClassHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.ext.ResponseHandler;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+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.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.message.Message;
+
+public final class ServerProviderFactory extends ProviderFactory {
+    private static final String SHARED_SERVER_FACTORY = "jaxrs.shared.server.factory";
+    private static final Class<?>[] FILTER_INTERCEPTOR_CLASSES = 
+        new Class<?>[] {ContainerRequestFilter.class,
+                        ContainerResponseFilter.class,
+                        ReaderInterceptor.class,
+                        WriterInterceptor.class};
+    // 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>();
+    
+    private ServerProviderFactory(ProviderFactory baseFactory, Bus bus) {
+        super(baseFactory, bus);
+    }
+    
+    public static ServerProviderFactory getInstance() {
+        return createInstance(null);
+    }
+    
+    public static ServerProviderFactory createInstance(Bus bus) {
+        if (bus == null) {
+            bus = BusFactory.getThreadDefaultBus();
+        }
+        ServerProviderFactory baseFactory = initBaseFactory(bus);
+        ServerProviderFactory factory = new ServerProviderFactory(baseFactory, bus);
+        factory.setBusProviders();
+        return factory;
+    }
+    
+    public static ServerProviderFactory getInstance(Message m) {
+        Endpoint e = m.getExchange().get(Endpoint.class);
+        return (ServerProviderFactory)e.get(SERVER_FACTORY_NAME);
+    }
+    
+    private static synchronized ServerProviderFactory initBaseFactory(Bus bus) {
+        ServerProviderFactory factory = (ServerProviderFactory)bus.getProperty(SHARED_SERVER_FACTORY);
+        if (factory != null) {
+            return factory;
+        }
+        factory = new ServerProviderFactory(null, bus);
+        ProviderFactory.initBaseFactory(factory);
+        factory.setProviders(new WebApplicationExceptionMapper(),
+                             new WadlGenerator());
+        bus.setProperty(SHARED_SERVER_FACTORY, factory);
+        return factory;
+    }
+    
+    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);
+    }
+    
+    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 = ((ServerProviderFactory)getBaseFactory()).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(((ServerProviderFactory)getBaseFactory()).requestHandlers);    
+            }
+            handlers.addAll(requestHandlers);
+            
+        }
+        return Collections.unmodifiableList(handlers);
+    }
+    
+    public List<ProviderInfo<ResponseHandler>> getResponseHandlers() {
+        return Collections.unmodifiableList(responseHandlers);
+    }
+    
+    public void addBeanParamInfo(BeanParamInfo bpi) {
+        beanParams.put(bpi.getResourceClass(), bpi);
+    }
+    
+    public BeanParamInfo getBeanParamInfo(Class<?> beanClass) {
+        return beanParams.get(beanClass);
+    }
+   
+    public <T extends Throwable> ExceptionMapper<T> createExceptionMapper(Class<?> exceptionType,
+                                                                          Message m) {
+        ExceptionMapper<T> mapper = doCreateExceptionMapper(exceptionType, m);
+        if (mapper != null || isBaseFactory()) {
+            return mapper;
+        }
+        
+        return ((ServerProviderFactory)getBaseFactory()).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);
+    }
+    
+  //CHECKSTYLE:OFF 
+    @Override
+    protected void setProviders(Object... providers) {
+        super.setProviders(providers);
+        List<ProviderInfo<ContainerRequestFilter>> postMatchRequestFilters = 
+            new LinkedList<ProviderInfo<ContainerRequestFilter>>();
+        List<ProviderInfo<ContainerResponseFilter>> postMatchResponseFilters = 
+            new LinkedList<ProviderInfo<ContainerResponseFilter>>();
+        
+        for (Object o : providers) {
+            if (o == null) {
+                continue;
+            }
+            Class<?> oClass = ClassHelper.getRealClass(o);
+            
+            
+            if (RequestHandler.class.isAssignableFrom(oClass)) {
+                requestHandlers.add(new ProviderInfo<RequestHandler>((RequestHandler)o, getBus())); 
+            }
+            
+            if (ResponseHandler.class.isAssignableFrom(oClass)) {
+                responseHandlers.add(new ProviderInfo<ResponseHandler>((ResponseHandler)o, getBus())); 
+            }
+            
+            if (ContainerRequestFilter.class.isAssignableFrom(oClass)) {
+                addContainerFilter(postMatchRequestFilters,
+                   new ProviderInfo<ContainerRequestFilter>((ContainerRequestFilter)o, getBus()),
+                   preMatchContainerRequestFilters);
+            }
+            
+            if (ContainerResponseFilter.class.isAssignableFrom(oClass)) {
+                addContainerFilter(postMatchResponseFilters,
+                   new ProviderInfo<ContainerResponseFilter>((ContainerResponseFilter)o, getBus()),
+                   null); 
+            }
+            
+            if (DynamicFeature.class.isAssignableFrom(oClass)) {
+                dynamicFeatures.add((DynamicFeature)o);
+            }
+            
+            
+            if (ExceptionMapper.class.isAssignableFrom(oClass)) {
+                exceptionMappers.add(new ProviderInfo<ExceptionMapper<?>>((ExceptionMapper<?>)o, getBus())); 
+            }
+            
+        }
+        
+        Collections.sort(preMatchContainerRequestFilters, new BindingPriorityComparator(true));
+        mapContainerFilters(postMatchContainerRequestFilters, postMatchRequestFilters, true);
+        mapContainerFilters(postMatchContainerResponseFilters, postMatchResponseFilters, false);
+        
+        injectContextProxies( 
+            requestHandlers, responseHandlers, exceptionMappers,
+            postMatchContainerRequestFilters.values(), preMatchContainerRequestFilters,
+            postMatchContainerResponseFilters.values(),
+            readerInterceptors, writerInterceptors);
+    }
+//CHECKSTYLE:ON
+    
+    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);
+        }
+        
+    }
+    
+    public RequestPreprocessor getRequestPreprocessor() {
+        return requestPreprocessor;
+    }
+    
+    public void setApplicationProvider(ProviderInfo<Application> app) {
+        application = app;
+    }
+    
+    public void setRequestPreprocessor(RequestPreprocessor rp) {
+        this.requestPreprocessor = rp;
+    }
+    
+    public void clearExceptionMapperProxies() {
+        clearProxies(exceptionMappers);
+    }
+    
+    @Override
+    public void clearProviders() {
+        super.clearProviders();
+        exceptionMappers.clear();
+        requestHandlers.clear();
+        responseHandlers.clear();
+        postMatchContainerRequestFilters.clear();
+        postMatchContainerResponseFilters.clear();
+        preMatchContainerRequestFilters.clear();
+    }
+    
+    @Override
+    public void clearThreadLocalProxies() {
+        if (application != null) {
+            application.clearThreadLocalProxies();
+        }
+        super.clearThreadLocalProxies();
+    }
+    
+    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);    
+            }
+        }
+    }
+    
+    protected static boolean isPrematching(Class<?> filterCls) {
+        return AnnotationUtils.getAnnotation(filterCls.getAnnotations(), 
+                                      PreMatching.class) != null;
+    }
+    
+    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 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 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, getBus());
+            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); 
+            }
+        }
+    }
+    
+    private static class ExceptionMapperComparator implements 
+        Comparator<ExceptionMapper<? extends Throwable>> {
+    
+        public int compare(ExceptionMapper<? extends Throwable> em1, 
+                           ExceptionMapper<? extends Throwable> em2) {
+            return compareClasses(em1, em2);
+        }
+        
+    }
+}

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

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

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Wed Feb  6 12:35:21 2013
@@ -92,7 +92,7 @@ import org.apache.cxf.jaxrs.impl.tl.Thre
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 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.provider.ServerProviderFactory;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 
@@ -401,7 +401,7 @@ public final class InjectionUtils {
                                                     Message message) {
         T result = null;
         if (message != null) {
-            ParamConverter<T> pm = ProviderFactory.getInstance(message)
+            ParamConverter<T> pm = ServerProviderFactory.getInstance(message)
                 .createParameterHandler(pClass);
             if (pm != null) {
                 result = pm.fromString(value);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Wed Feb  6 12:35:21 2013
@@ -132,6 +132,7 @@ import org.apache.cxf.jaxrs.model.Provid
 import org.apache.cxf.jaxrs.model.URITemplate;
 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.multipart.AttachmentUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -895,7 +896,7 @@ public final class JAXRSUtils {
     }
     
     public static Object createBeanParamValue(Message m, Class<?> clazz, OperationResourceInfo ori) {
-        BeanParamInfo bmi = ProviderFactory.getInstance(m).getBeanParamInfo(clazz);
+        BeanParamInfo bmi = ServerProviderFactory.getInstance(m).getBeanParamInfo(clazz);
         if (bmi == null) {
             // we could've started introspecting now but the fact no bean info 
             // is available indicates that the one created at start up has been 
@@ -952,7 +953,7 @@ public final class JAXRSUtils {
             o = createServletResourceValue(contextMessage, clazz);
             if (o == null) {
                 ContextProvider<?> provider = 
-                    ProviderFactory.getInstance(m).createContextProvider(clazz, contextMessage);
+                    ServerProviderFactory.getInstance(m).createContextProvider(clazz, contextMessage);
                 if (provider != null) {
                     o = provider.createContext(contextMessage);
                 }
@@ -1122,7 +1123,7 @@ public final class JAXRSUtils {
         
         List<MediaType> types = JAXRSUtils.intersectMimeTypes(consumeTypes, contentType);
         
-        final ProviderFactory pf = ProviderFactory.getInstance(m);
+        final ProviderFactory pf = ServerProviderFactory.getInstance(m);
         for (MediaType type : types) { 
             List<ReaderInterceptor> readers = pf.createMessageBodyReaderInterceptor(
                                          targetTypeClass,
@@ -1412,7 +1413,7 @@ public final class JAXRSUtils {
         }
         
         ExceptionMapper<T>  mapper =
-            ProviderFactory.getInstance(inMessage).createExceptionMapper(ex.getClass(), inMessage);
+            ServerProviderFactory.getInstance(inMessage).createExceptionMapper(ex.getClass(), inMessage);
         if (mapper != null) {
             try {
                 return mapper.toResponse(ex);
@@ -1465,7 +1466,7 @@ public final class JAXRSUtils {
         return XMLUtils.convertStringToQName(name, "");
     }
     
-    public static boolean runContainerRequestFilters(ProviderFactory pf, Message m, boolean preMatch, 
+    public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, 
                                               List<String> names) {
         List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch 
             ? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names);
@@ -1485,7 +1486,7 @@ public final class JAXRSUtils {
         return false;
     }
     
-    public static void runContainerResponseFilters(ProviderFactory pf,
+    public static void runContainerResponseFilters(ServerProviderFactory pf,
                                                    Response r,
                                                    Message m, 
                                                    OperationResourceInfo ori) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java Wed Feb  6 12:35:21 2013
@@ -25,7 +25,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
 
 import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.resources.BookStore;
 import org.apache.cxf.message.MessageImpl;
 
@@ -48,8 +48,8 @@ public class JAXRSServerFactoryBeanTest 
         bean.setProviders(providers);
         Server s = bean.create();
         
-        ProviderFactory factory = 
-            (ProviderFactory)s.getEndpoint().get(ProviderFactory.class.getName());
+        ServerProviderFactory factory = 
+            (ServerProviderFactory)s.getEndpoint().get(ServerProviderFactory.class.getName());
         
         ExceptionMapper<Exception> mapper1 = 
             factory.createExceptionMapper(Exception.class, new MessageImpl());

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java Wed Feb  6 12:35:21 2013
@@ -36,7 +36,7 @@ import org.apache.cxf.jaxrs.fortest.Gene
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.Chapter;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -97,8 +97,8 @@ public class SelectMethodCandidatesTest 
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         e.getEndpointInfo();
         EasyMock.expectLastCall().andReturn(null).anyTimes();
-        e.get(ProviderFactory.class.getName());
-        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).times(2);
+        e.get(ServerProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(2);
         e.get("org.apache.cxf.jaxrs.comparator");
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(e);
@@ -149,8 +149,8 @@ public class SelectMethodCandidatesTest 
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         e.getEndpointInfo();
         EasyMock.expectLastCall().andReturn(null).anyTimes();
-        e.get(ProviderFactory.class.getName());
-        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).times(3);
+        e.get(ServerProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(3);
         e.get("org.apache.cxf.jaxrs.comparator");
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(e);
@@ -198,8 +198,8 @@ public class SelectMethodCandidatesTest 
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         e.getEndpointInfo();
         EasyMock.expectLastCall().andReturn(null).anyTimes();
-        e.get(ProviderFactory.class.getName());
-        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).times(3);
+        e.get(ServerProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(3);
         e.get("org.apache.cxf.jaxrs.comparator");
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(e);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/MessageContextImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/MessageContextImplTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/MessageContextImplTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/MessageContextImplTest.java Wed Feb  6 12:35:21 2013
@@ -40,6 +40,7 @@ import org.apache.cxf.jaxrs.impl.Request
 import org.apache.cxf.jaxrs.impl.SecurityContextImpl;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -142,7 +143,7 @@ public class MessageContextImplTest exte
     @Test
     public void testContextResolver() {
         ContextResolver<JAXBContext> resolver = new CustomContextResolver();
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         factory.registerUserProvider(resolver);
         
         Message m = new MessageImpl();
@@ -150,7 +151,7 @@ public class MessageContextImplTest exte
         m.setExchange(ex);
         ex.setInMessage(m);
         Endpoint e = EasyMock.createMock(Endpoint.class);
-        e.get(ProviderFactory.class.getName());
+        e.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory);
         EasyMock.replay(e);
         ex.put(Endpoint.class, e);
@@ -168,7 +169,7 @@ public class MessageContextImplTest exte
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
         Exchange e = new ExchangeImpl();
@@ -183,7 +184,7 @@ public class MessageContextImplTest exte
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         endpoint.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory).anyTimes();
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java Wed Feb  6 12:35:21 2013
@@ -33,7 +33,7 @@ import javax.ws.rs.core.Response;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -122,8 +122,8 @@ public class RequestPreprocessorTest ext
         Endpoint endp = control.createMock(Endpoint.class);
         e.put(Endpoint.class, endp);
         EasyMock.expect(endp.isEmpty()).andReturn(true).anyTimes();
-        endp.get(ProviderFactory.class.getName());
-        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).anyTimes();
+        endp.get(ServerProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).anyTimes();
         ServletDestination d = control.createMock(ServletDestination.class);
         e.setDestination(d);
         EndpointInfo epr = new EndpointInfo(); 

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Wed Feb  6 12:35:21 2013
@@ -1590,7 +1590,7 @@ public class JAXBElementProviderTest ext
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ServerProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
@@ -1606,7 +1606,7 @@ public class JAXBElementProviderTest ext
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         endpoint.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory).anyTimes();
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Wed Feb  6 12:35:21 2013
@@ -29,10 +29,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -42,7 +38,6 @@ import javax.ws.rs.WebApplicationExcepti
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -59,7 +54,6 @@ import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
 import org.apache.cxf.jaxrs.JAXBContextProvider;
 import org.apache.cxf.jaxrs.JAXBContextProvider2;
-import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
@@ -77,7 +71,6 @@ import org.easymock.EasyMock;
 
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class ProviderFactoryTest extends Assert {
@@ -85,20 +78,18 @@ public class ProviderFactoryTest extends
     
     @Before
     public void setUp() {
-        ProviderFactory.getInstance().clearProviders();
+        ServerProviderFactory.getInstance().clearProviders();
         AbstractResourceInfo.clearAllMaps();
     }
     
     @Test
     public void testMultipleFactories() {
-        assertNotSame(ProviderFactory.getInstance(), ProviderFactory.getSharedInstance());
-        assertSame(ProviderFactory.getSharedInstance(), ProviderFactory.getSharedInstance());
-        assertNotSame(ProviderFactory.getInstance(), ProviderFactory.getInstance());
+        assertNotSame(ServerProviderFactory.getInstance(), ServerProviderFactory.getInstance());
     }
     
     @Test
     public void testCustomWadlHandler() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         assertEquals(1, pf.getRequestHandlers().size());
         assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
         
@@ -111,7 +102,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testCustomTestHandler() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         assertEquals(1, pf.getRequestHandlers().size());
         assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
         
@@ -124,7 +115,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testCustomTestAndWadlHandler() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         assertEquals(1, pf.getRequestHandlers().size());
         assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
         
@@ -139,90 +130,10 @@ public class ProviderFactoryTest extends
         assertSame(th, pf.getRequestHandlers().get(1).getProvider());
     }
     
-    @Test
-    public void testDefaultJaxbProvider() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        doTestDefaultJaxbProviderCloned(pf, "http://localhost:8080/base/");
-        checkJaxbProvider(pf);
-    }
-    
-    @Test
-    public void testDefaultJaxbProviderMultipleThreads() throws Exception {
-        for (int i = 0; i < 100; i++) {
-            doTestDefaultJaxbProviderClonedMultipleThreads();
-        }
-    }
-    
-    
-    public void doTestDefaultJaxbProviderClonedMultipleThreads() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        ThreadPoolExecutor executor = new ThreadPoolExecutor(50, 50, 0, TimeUnit.SECONDS,
-                                                             new ArrayBlockingQueue<Runnable>(10));
-        CountDownLatch startSignal = new CountDownLatch(1);
-        CountDownLatch doneSignal = new CountDownLatch(50);
-        
-        addThreads(executor, pf, startSignal, doneSignal, 50);
-        
-        startSignal.countDown();
-        doneSignal.await(60, TimeUnit.SECONDS);
-        executor.shutdownNow();
-        assertEquals("Not all invocations have completed", 0, doneSignal.getCount());
-        checkJaxbProvider(pf);
-    }
-    
-    private void addThreads(ThreadPoolExecutor executor, ProviderFactory pf,
-                            CountDownLatch startSignal, CountDownLatch doneSignal, int count) {
-        
-        for (int i = 1; i <= count; i++) {
-            executor.execute(new TestRunnable(pf, startSignal, doneSignal, 
-                                              "http://localhost:8080/base/" + i));
-        }
-    }
-    
-    private void doTestDefaultJaxbProviderCloned(ProviderFactory pf, String property) {
-        Message message = new MessageImpl();
-        message.put(Message.QUERY_STRING, "uri=" + property);
-        MessageBodyReader<Book> customJaxbReader = pf.createMessageBodyReader(Book.class, null, null, 
-                                                              MediaType.TEXT_XML_TYPE, message);
-        assertTrue(customJaxbReader instanceof JAXBElementProvider);
-        
-        JAXBElementProvider<Book> provider = (JAXBElementProvider<Book>)customJaxbReader;
-        MessageContext mc = provider.getContext();
-        assertNotNull(mc);
-        UriInfo ui = mc.getUriInfo();
-        MultivaluedMap<String, String> queries = ui.getQueryParameters();
-        assertEquals(1, queries.size());
-        List<String> uriQuery = queries.get("uri");
-        assertEquals(1, uriQuery.size());
-        assertEquals(property, uriQuery.get(0));
-        
-        MessageBodyReader<?> customJaxbReader2 = pf.createMessageBodyReader((Class<?>)Book.class, null, null, 
-                                                              MediaType.TEXT_XML_TYPE, message);
-        assertSame(customJaxbReader, customJaxbReader2);
-         
-        MessageBodyWriter<?> customJaxbWriter = pf.createMessageBodyWriter((Class<?>)Book.class, null, null, 
-                                                              MediaType.TEXT_XML_TYPE, message);
-        assertSame(customJaxbReader, customJaxbWriter);
-        
-        MessageBodyReader<?> jaxbReader = ProviderFactory.getSharedInstance().createMessageBodyReader(
-            (Class<?>)Book.class, null, null, MediaType.TEXT_XML_TYPE, message);
-        assertTrue(jaxbReader instanceof JAXBElementProvider);
-        assertNotSame(jaxbReader, customJaxbReader);
-    }
-    
-    private void checkJaxbProvider(ProviderFactory pf) {
-        int count = 0;
-        for (Object provider : pf.getReadersWriters()) {
-            if (((ProviderInfo<?>)provider).getProvider() instanceof JAXBElementProvider) {
-                count++;
-            }
-        }
-        assertEquals(1, count);
-    }
     
     @Test
     public void testCustomJaxbProvider() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         JAXBElementProvider<Book> provider = new JAXBElementProvider<Book>();
         pf.registerUserProvider(provider);
         MessageBodyReader<Book> customJaxbReader = pf.createMessageBodyReader(Book.class, null, null, 
@@ -236,7 +147,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testDataSourceReader() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new DataSourceProvider<Object>());
         MessageBodyReader<DataSource> reader = pf.createMessageBodyReader(
               DataSource.class, null, null, 
@@ -250,7 +161,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testDataSourceWriter() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new DataSourceProvider<Object>());
         MessageBodyWriter<DataSource> writer = pf.createMessageBodyWriter(
               DataSource.class, null, null, 
@@ -264,7 +175,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testNoDataSourceWriter() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new DataSourceProvider<Object>());
         MessageBodyWriter<DataSource> writer = pf.createMessageBodyWriter(
               DataSource.class, null, null, 
@@ -275,12 +186,12 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testSchemaLocations() {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        pf.setSchemaLocations(Collections.singletonList("classpath:/test.xsd"));
-        MessageBodyReader<Book> customJaxbReader = pf.createMessageBodyReader(Book.class, null, null, 
+        ProviderFactory pf = ServerProviderFactory.getInstance();
+        MessageBodyReader<Book> jaxbReader = pf.createMessageBodyReader(Book.class, null, null, 
                                                               MediaType.TEXT_XML_TYPE, new MessageImpl());
-        assertTrue(customJaxbReader instanceof JAXBElementProvider);
-        MessageBodyReader<Book> jaxbReader = ProviderFactory.getSharedInstance().createMessageBodyReader(
+        assertTrue(jaxbReader instanceof JAXBElementProvider);
+        pf.setSchemaLocations(Collections.singletonList("classpath:/test.xsd"));
+        MessageBodyReader<Book> customJaxbReader = pf.createMessageBodyReader(
             Book.class, null, null, MediaType.TEXT_XML_TYPE, new MessageImpl());
         assertTrue(jaxbReader instanceof JAXBElementProvider);
         assertNotSame(jaxbReader, customJaxbReader);
@@ -291,12 +202,12 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testGetFactoryInboundMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         Exchange e = new ExchangeImpl();
         m.setExchange(e);
         Endpoint endpoint = EasyMock.createMock(Endpoint.class);
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory);
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);
@@ -305,7 +216,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testDefaultUserExceptionMappers() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         ExceptionMapper<?> mapper = 
             pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
         assertNotNull(mapper);
@@ -319,7 +230,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testExceptionMappersHierarchy1() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
         pf.registerUserProvider(wm);
         assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
@@ -332,7 +243,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testExceptionMappersHierarchy2() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         
         TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper(); 
         pf.registerUserProvider(rm);
@@ -347,7 +258,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testExceptionMappersHierarchyWithGenerics() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ServerProviderFactory pf = ServerProviderFactory.getInstance();
         RuntimeExceptionMapper1 exMapper1 = new RuntimeExceptionMapper1(); 
         pf.registerUserProvider(exMapper1);
         RuntimeExceptionMapper2 exMapper2 = new RuntimeExceptionMapper2(); 
@@ -358,7 +269,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testMessageBodyHandlerHierarchy() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         List<Object> providers = new ArrayList<Object>();
         BookReaderWriter bookHandler = new BookReaderWriter();
         providers.add(bookHandler);
@@ -381,7 +292,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testMessageBodyWriterNoTypes() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         List<Object> providers = new ArrayList<Object>();
         SuperBookReaderWriter2<SuperBook> superBookHandler = new SuperBookReaderWriter2<SuperBook>();
         providers.add(superBookHandler);
@@ -396,7 +307,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testSortEntityProviders() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new TestStringProvider());
         pf.registerUserProvider(new PrimitiveTextProvider<Object>());
         
@@ -414,7 +325,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testParameterHandlerProvider() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         ParamConverterProvider h = new CustomerParameterHandler();
         pf.registerUserProvider(h);
         ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class);
@@ -430,7 +341,7 @@ public class ProviderFactoryTest extends
     public void testGetBinaryProvider() throws Exception {
         verifyProvider(byte[].class, BinaryDataProvider.class, "*/*");
         verifyProvider(InputStream.class, BinaryDataProvider.class, "image/png");
-        MessageBodyWriter<File> writer = ProviderFactory.getInstance()
+        MessageBodyWriter<File> writer = ServerProviderFactory.getInstance()
             .createMessageBodyWriter(File.class, null, null, MediaType.APPLICATION_OCTET_STREAM_TYPE, 
                                      new MessageImpl());
         assertTrue(BinaryDataProvider.class == writer.getClass());
@@ -440,7 +351,7 @@ public class ProviderFactoryTest extends
         throws Exception {
         
         if (pf == null) {
-            pf = ProviderFactory.getInstance();
+            pf = ServerProviderFactory.getInstance();
         }
         
         MediaType mType = MediaType.valueOf(mediaType);
@@ -467,14 +378,14 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testGetStringProviderUsingProviderDeclaration() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new TestStringProvider());
         verifyProvider(pf, String.class, TestStringProvider.class, "text/html");
     }    
     
     @Test
     public void testRegisterCustomJSONEntityProvider() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new CustomJSONProvider());
         verifyProvider(pf, Book.class, CustomJSONProvider.class, 
                        "application/json");
@@ -483,7 +394,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testRegisterCustomResolver() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
         Message message = prepareMessage("*/*", null);
         ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class, message);
@@ -495,7 +406,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testRegisterCustomResolver2() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
         pf.registerUserProvider(new JAXBContextProvider2());
         Message message = prepareMessage("text/xml+b", null);
@@ -508,7 +419,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testNoCustomResolver() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
         pf.registerUserProvider(new JAXBContextProvider2());
         Message message = prepareMessage("text/xml+c", null);
@@ -518,7 +429,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testCustomResolverOut() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
         pf.registerUserProvider(new JAXBContextProvider2());
         Message message = prepareMessage("text/xml+c", "text/xml+a");
@@ -530,7 +441,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testCustomResolverProxy() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new JAXBContextProvider());
         pf.registerUserProvider(new JAXBContextProvider2());
         Message message = prepareMessage("text/xml+*", null);
@@ -560,7 +471,7 @@ public class ProviderFactoryTest extends
     
     @Test
     public void testRegisterCustomEntityProvider() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(new CustomWidgetProvider());
         
         verifyProvider(pf, org.apache.cxf.jaxrs.resources.Book.class, CustomWidgetProvider.class, 
@@ -690,7 +601,7 @@ public class ProviderFactoryTest extends
     @Test
     public void testSetSchemasFromClasspath() {
         JAXBElementProvider<?> provider = new JAXBElementProvider<Object>();
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         pf.registerUserProvider(provider);
         
         List<String> locations = new ArrayList<String>();
@@ -827,39 +738,7 @@ public class ProviderFactoryTest extends
         }
         
     }
-    
-    @Ignore
-    private class TestRunnable implements Runnable {
-
-        private CountDownLatch startSignal;
-        private CountDownLatch doneSignal;
-        private ProviderFactory pf;
-        private String property; 
-        public TestRunnable(ProviderFactory pf,
-                            CountDownLatch startSignal,
-                            CountDownLatch doneSignal,
-                            String property) {
-            this.startSignal = startSignal;
-            this.doneSignal = doneSignal;
-            this.pf = pf;
-            this.property = property;
-        }
-        
-        public void run() {
-            
-            try {
-                startSignal.await();
-                ProviderFactoryTest.this.doTestDefaultJaxbProviderCloned(pf, property);
-                doneSignal.countDown();
-            } catch (Exception ex) {
-                ex.printStackTrace();
-                Assert.fail(ex.getMessage());
-            } 
-            
-        }
         
-    }
-    
     private static class RuntimeExceptionMapper1 
         extends AbstractTestExceptionMapper<RuntimeException> {
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProviderTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProviderTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProviderTest.java Wed Feb  6 12:35:21 2013
@@ -234,7 +234,7 @@ public class XSLTJaxbProviderTest extend
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
@@ -250,7 +250,7 @@ public class XSLTJaxbProviderTest extend
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         endpoint.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory).anyTimes();
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java Wed Feb  6 12:35:21 2013
@@ -36,6 +36,7 @@ import javax.xml.bind.annotation.adapter
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -212,7 +213,7 @@ public class InjectionUtilsTest extends 
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
         Exchange e = new ExchangeImpl();

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Wed Feb  6 12:35:21 2013
@@ -92,6 +92,7 @@ import org.apache.cxf.jaxrs.model.Operat
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.FormEncodingProvider;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -1832,7 +1833,7 @@ public class JAXRSUtilsTest extends Asse
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
         Exchange e = new ExchangeImpl();
@@ -1847,7 +1848,7 @@ public class JAXRSUtilsTest extends Asse
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         endpoint.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory).anyTimes();
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);

Modified: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java (original)
+++ cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java Wed Feb  6 12:35:21 2013
@@ -37,12 +37,12 @@ public class ProviderFactoryAllTest exte
 
     @Before
     public void setUp() {
-        ProviderFactory.getInstance().clearProviders();
+        ServerProviderFactory.getInstance().clearProviders();
     }
     
     @Test
     public void testAtomPojoProvider() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         AtomPojoProvider provider = new AtomPojoProvider();
         pf.registerUserProvider(provider);
         MessageBodyReader<?> feedReader = pf.createMessageBodyReader(Book.class,
@@ -61,7 +61,7 @@ public class ProviderFactoryAllTest exte
     
     @Test
     public void testCustomJsonProvider() {
-        ProviderFactory pf = ProviderFactory.getInstance();
+        ProviderFactory pf = ServerProviderFactory.getInstance();
         JSONProvider<Book> provider = new JSONProvider<Book>();
         pf.registerUserProvider(provider);
         MessageBodyReader<?> customJsonReader = pf.createMessageBodyReader(Book.class, null, null, 
@@ -73,33 +73,11 @@ public class ProviderFactoryAllTest exte
         assertSame(customJsonWriter, provider);
     }
     
-    @Test
-    public void testDefaultJsonProviderCloned() {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        MessageBodyReader<?> customJsonReader = pf.createMessageBodyReader(Book.class, null, null, 
-                                                MediaType.APPLICATION_JSON_TYPE, new MessageImpl());
-        assertTrue(customJsonReader instanceof JSONProvider);
-        
-        MessageBodyReader<?> customJsonReader2 = pf.createMessageBodyReader(Book.class, null, null, 
-                                                MediaType.APPLICATION_JSON_TYPE, new MessageImpl());
-        assertSame(customJsonReader, customJsonReader2);
-        
-        MessageBodyWriter<?> customJsonWriter = pf.createMessageBodyWriter(Book.class, null, null, 
-                                                MediaType.APPLICATION_JSON_TYPE, new MessageImpl());
-        assertSame(customJsonReader, customJsonWriter);
-        
-        MessageBodyReader<?> jsonReader = ProviderFactory.getSharedInstance().createMessageBodyReader(
-            Book.class, null, null, MediaType.APPLICATION_JSON_TYPE, new MessageImpl());
-        assertTrue(jsonReader instanceof JSONProvider);
-        assertNotSame(jsonReader, customJsonReader);
-    }
-    
-        
     private void verifyProvider(ProviderFactory pf, Class<?> type, Class<?> provider, String mediaType) 
         throws Exception {
         
         if (pf == null) {
-            pf = ProviderFactory.getInstance();
+            pf = ServerProviderFactory.getInstance();
         }
         
         MediaType mType = MediaType.valueOf(mediaType);

Modified: cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/dom4j/DOM4JProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/dom4j/DOM4JProviderTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/dom4j/DOM4JProviderTest.java (original)
+++ cxf/trunk/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/dom4j/DOM4JProviderTest.java Wed Feb  6 12:35:21 2013
@@ -29,6 +29,7 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.ProvidersImpl;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -102,7 +103,7 @@ public class DOM4JProviderTest extends A
     }
     
     private Message createMessage() {
-        ProviderFactory factory = ProviderFactory.getInstance();
+        ProviderFactory factory = ServerProviderFactory.getInstance();
         Message m = new MessageImpl();
         m.put("org.apache.cxf.http.case_insensitive_queries", false);
         Exchange e = new ExchangeImpl();
@@ -117,7 +118,7 @@ public class DOM4JProviderTest extends A
         EasyMock.expectLastCall().andReturn(0).anyTimes();
         endpoint.isEmpty();
         EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
+        endpoint.get(ServerProviderFactory.class.getName());
         EasyMock.expectLastCall().andReturn(factory).anyTimes();
         EasyMock.replay(endpoint);
         e.put(Endpoint.class, endpoint);

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java?rev=1442931&r1=1442930&r2=1442931&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java Wed Feb  6 12:35:21 2013
@@ -53,7 +53,7 @@ public class JAXRSSpringSecurityClassTes
         
         WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstorestorage/bookforms", 
                                         "foo", "bar", null);
-        
+        wc.accept("application/xml");
         Response r = wc.form(new Form().set("name", "CXF Rocks").set("id", "123"));
         
         Book b = readBook((InputStream)r.getEntity());
@@ -66,7 +66,7 @@ public class JAXRSSpringSecurityClassTes
         
         WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstorestorage/bookforms2", 
                                         "foo", "bar", null);
-        
+        wc.accept("application/xml");
         Response r = wc.form(new Form().set("name", "CXF Rocks").set("id", "123"));
         
         Book b = readBook((InputStream)r.getEntity());



Mime
View raw message