wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r821358 - in /incubator/wink/trunk: wink-common/src/main/java/org/apache/wink/common/internal/registry/ wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/ wink-server/src/main/java/org/apache/wink/server/internal/...
Date Sat, 03 Oct 2009 16:40:07 GMT
Author: bluk
Date: Sat Oct  3 16:40:07 2009
New Revision: 821358

URL: http://svn.apache.org/viewvc?rev=821358&view=rev
Log:
Make distinction between user and system providers

Add boolean flag to indicate different types of
providers to cleanup code.

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/CookieFieldsTest.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/utils/RegistrationUtils.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/application/ApplicationProcessorTest.java
    incubator/wink/trunk/wink-spring-support/src/main/java/org/apache/wink/spring/Registrar.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
Sat Oct  3 16:40:07 2009
@@ -94,27 +94,35 @@
         this.applicationValidator = applicationValidator;
     }
 
-    @SuppressWarnings("unchecked")
     public boolean addProvider(Class<?> cls, double priority) {
+        return addProvider(cls, priority, false);
+    }
+
+    @SuppressWarnings("unchecked")
+    public boolean addProvider(Class<?> cls, double priority, boolean isSystemProvider)
{
         if (cls == null) {
             throw new NullPointerException("cls");
         }
         ObjectFactory<?> objectFactory = factoryFactoryRegistry.getObjectFactory(cls);
-        return addProvider(new PriorityObjectFactory(objectFactory, priority));
+        return addProvider(new PriorityObjectFactory(objectFactory, priority, isSystemProvider));
 
     }
 
-    @SuppressWarnings("unchecked")
     public boolean addProvider(Object provider, double priority) {
+        return addProvider(provider, priority, false);
+    }
+
+    @SuppressWarnings("unchecked")
+    public boolean addProvider(Object provider, double priority, boolean isSystemProvider)
{
         if (provider == null) {
             throw new NullPointerException("provider");
         }
         ObjectFactory<?> objectFactory = factoryFactoryRegistry.getObjectFactory(provider);
-        return addProvider(new PriorityObjectFactory(objectFactory, priority));
+        return addProvider(new PriorityObjectFactory(objectFactory, priority, isSystemProvider));
     }
 
     @SuppressWarnings("unchecked")
-    private synchronized boolean addProvider(ObjectFactory<?> objectFactory) {
+    private synchronized boolean addProvider(PriorityObjectFactory<?> objectFactory)
{
         Class<? extends Object> cls = objectFactory.getInstanceClass();
 
         logger.debug("Processing provider of type {}", cls);
@@ -126,7 +134,7 @@
         }
 
         if (ContextResolver.class.isAssignableFrom(cls)) {
-            contextResolvers.putProvider((ObjectFactory<ContextResolver<?>>)objectFactory);
+            contextResolvers.putProvider((PriorityObjectFactory<ContextResolver<?>>)objectFactory);
             retValue = true;
         }
         if (ExceptionMapper.class.isAssignableFrom(cls)) {
@@ -139,11 +147,13 @@
             retValue = true;
         }
         if (MessageBodyReader.class.isAssignableFrom(cls)) {
-            messageBodyReaders.putProvider((ObjectFactory<MessageBodyReader<?>>)objectFactory);
+            messageBodyReaders
+                .putProvider((PriorityObjectFactory<MessageBodyReader<?>>)objectFactory);
             retValue = true;
         }
         if (MessageBodyWriter.class.isAssignableFrom(cls)) {
-            messageBodyWriters.putProvider((ObjectFactory<MessageBodyWriter<?>>)objectFactory);
+            messageBodyWriters
+                .putProvider((PriorityObjectFactory<MessageBodyWriter<?>>)objectFactory);
             retValue = true;
         }
         if (retValue == false) {
@@ -184,7 +194,7 @@
             return null;
         }
 
-        final List<ObjectFactory<ContextResolver<?>>> factories =
+        final List<MediaTypeMap<ContextResolver<?>>.OFHolder<ContextResolver<?>>>
factories =
             contextResolvers.getProvidersByMediaType(mediaType, contextType);
 
         if (factories.isEmpty()) {
@@ -349,7 +359,7 @@
                 .debug("Getting MessageBodyReader for class type {}, genericType {}, annotations
{}, and media type {}",
                        new Object[] {type, genericType, anns, mediaType});
         }
-        List<ObjectFactory<MessageBodyReader<?>>> factories =
+        List<MediaTypeMap<MessageBodyReader<?>>.OFHolder<MessageBodyReader<?>>>
factories =
             messageBodyReaders.getProvidersByMediaType(mediaType, type);
 
         logger.debug("Found possible MessageBodyReader ObjectFactories {}", factories);
@@ -391,7 +401,7 @@
                 .debug("Getting MessageBodyWriter for class type {}, genericType {}, annotations
{}, and media type {}",
                        new Object[] {type, genericType, anns, mediaType});
         }
-        List<ObjectFactory<MessageBodyWriter<?>>> writersFactories =
+        List<MediaTypeMap<MessageBodyWriter<?>>.OFHolder<MessageBodyWriter<?>>>
writersFactories =
             messageBodyWriters.getProvidersByMediaType(mediaType, type);
         logger.debug("Found possible MessageBodyWriter ObjectFactories {}", writersFactories);
         for (ObjectFactory<MessageBodyWriter<?>> factory : writersFactories)
{
@@ -419,7 +429,7 @@
         Set<MediaType> mediaTypes = new HashSet<MediaType>();
         logger.debug("Searching MessageBodyReaders media types limited by class type {}",
type);
 
-        List<ObjectFactory<MessageBodyReader<?>>> readerFactories =
+        List<MediaTypeMap<MessageBodyReader<?>>.OFHolder<MessageBodyReader<?>>>
readerFactories =
             messageBodyReaders.getProvidersByMediaType(MediaType.WILDCARD_TYPE, type);
         logger.debug("Found all MessageBodyReader ObjectFactories limited by class type {}",
                      readerFactories);
@@ -467,7 +477,7 @@
             super(rawType);
         }
 
-        public void putProvider(ObjectFactory<T> objectFactory) {
+        public void putProvider(PriorityObjectFactory<T> objectFactory) {
             Produces produces = objectFactory.getInstanceClass().getAnnotation(Produces.class);
             if (produces == null) {
                 put(MediaType.WILDCARD_TYPE, objectFactory);
@@ -486,7 +496,7 @@
             super(rawType);
         }
 
-        public void putProvider(ObjectFactory<T> objectFactory) {
+        public void putProvider(PriorityObjectFactory<T> objectFactory) {
             Consumes consumes = objectFactory.getInstanceClass().getAnnotation(Consumes.class);
             if (consumes == null) {
                 put(MediaType.WILDCARD_TYPE, objectFactory);
@@ -501,17 +511,17 @@
 
     private abstract class MediaTypeMap<T> {
 
-        private volatile HashMap<MediaType, HashSet<ObjectFactory<T>>>
                                 data           =
-                                                                                        
                                  new HashMap<MediaType, HashSet<ObjectFactory<T>>>();
+        private volatile HashMap<MediaType, HashSet<PriorityObjectFactory<T>>>
                    data           =
+                                                                                        
                             new HashMap<MediaType, HashSet<PriorityObjectFactory<T>>>();
         @SuppressWarnings("unchecked")
-        private volatile Entry<MediaType, HashSet<ObjectFactory<T>>>[]
                                 entrySet       =
-                                                                                        
                                  data
-                                                                                        
                                      .entrySet()
-                                                                                        
                                      .toArray(new Entry[0]);
-        private final Class<?>                                                    
                     rawType;
+        private volatile Entry<MediaType, HashSet<PriorityObjectFactory<T>>>[]
                    entrySet       =
+                                                                                        
                             data
+                                                                                        
                                 .entrySet()
+                                                                                        
                                 .toArray(new Entry[0]);
+        private final Class<?>                                                    
                rawType;
 
-        private final SoftConcurrentMap<Class<?>, SoftConcurrentMap<MediaType,
List<ObjectFactory<T>>>> providersCache =
-                                                                                        
                                  new SoftConcurrentMap<Class<?>, SoftConcurrentMap<MediaType,
List<ObjectFactory<T>>>>(); ;
+        private final SoftConcurrentMap<Class<?>, SoftConcurrentMap<MediaType,
List<OFHolder<T>>>> providersCache =
+                                                                                        
                             new SoftConcurrentMap<Class<?>, SoftConcurrentMap<MediaType,
List<OFHolder<T>>>>(); ;
 
         public MediaTypeMap(Class<?> rawType) {
             super();
@@ -529,7 +539,7 @@
          * @param cls
          * @return
          */
-        public List<ObjectFactory<T>> getProvidersByMediaType(MediaType mediaType,
Class<?> cls) {
+        public List<OFHolder<T>> getProvidersByMediaType(MediaType mediaType,
Class<?> cls) {
             String subtype = mediaType.getSubtype();
             String type = mediaType.getType();
             if (!mediaType.getParameters().isEmpty()) {
@@ -540,18 +550,17 @@
                 .debug("Getting providers by media type by calling getProvidersByMediaType({},
{})",
                        mediaType,
                        cls);
-            SoftConcurrentMap<MediaType, List<ObjectFactory<T>>> mediaTypeToProvidersCache
=
+            SoftConcurrentMap<MediaType, List<OFHolder<T>>> mediaTypeToProvidersCache
=
                 providersCache.get(cls);
             if (mediaTypeToProvidersCache == null) {
                 logger
                     .debug("MediaType to providers cache for class {} does not exist so creating",
                            cls);
-                mediaTypeToProvidersCache =
-                    new SoftConcurrentMap<MediaType, List<ObjectFactory<T>>>();
+                mediaTypeToProvidersCache = new SoftConcurrentMap<MediaType, List<OFHolder<T>>>();
                 providersCache.put(cls, mediaTypeToProvidersCache);
             }
 
-            List<ObjectFactory<T>> list = mediaTypeToProvidersCache.get(mediaType);
+            List<OFHolder<T>> list = mediaTypeToProvidersCache.get(mediaType);
 
             logger.debug("Get media type to providers cache for media type {} resulted in
{}",
                          mediaType,
@@ -564,15 +573,13 @@
             return list;
         }
 
-        private List<ObjectFactory<T>> internalGetProvidersByMediaType(MediaType
mediaType,
-                                                                       Class<?> cls)
{
-            Set<ObjectFactory<T>> compatible =
-                new TreeSet<ObjectFactory<T>>(Collections.reverseOrder());
-            for (Entry<MediaType, HashSet<ObjectFactory<T>>> entry : entrySet)
{
+        private List<OFHolder<T>> internalGetProvidersByMediaType(MediaType mediaType,
Class<?> cls) {
+            Set<OFHolder<T>> compatible = new TreeSet<OFHolder<T>>(Collections.reverseOrder());
+            for (Entry<MediaType, HashSet<PriorityObjectFactory<T>>> entry
: entrySet) {
                 if (entry.getKey().isCompatible(mediaType)) {
                     // media type is compatible, check generic type of the
                     // subset
-                    for (ObjectFactory<T> of : entry.getValue()) {
+                    for (PriorityObjectFactory<T> of : entry.getValue()) {
                         if (GenericsUtils.isGenericInterfaceAssignableFrom(cls, of
                             .getInstanceClass(), rawType)) {
                             // Both media type and generic types are compatible.
@@ -583,23 +590,24 @@
 
                             // This is done via the equals() of the OFHolder
                             // which doesn't compare the MediaType
-                            compatible.add(new OFHolder<T>(entry.getKey(), of));
+                            compatible
+                                .add(new OFHolder<T>(entry.getKey(), of, of.isSystemProvider));
                         }
                     }
                 }
             }
             @SuppressWarnings("unchecked")
-            ObjectFactory<T>[] tmp = compatible.toArray(new ObjectFactory[compatible.size()]);
+            OFHolder<T>[] tmp = compatible.toArray(new OFHolder[compatible.size()]);
             return Arrays.asList(tmp);
         }
 
         public Set<MediaType> getProvidersMediaTypes(Class<?> type) {
             Set<MediaType> mediaTypes = new HashSet<MediaType>();
 
-            l1: for (Entry<MediaType, HashSet<ObjectFactory<T>>> entry
: data.entrySet()) {
+            l1: for (Entry<MediaType, HashSet<PriorityObjectFactory<T>>>
entry : data.entrySet()) {
                 MediaType mediaType = entry.getKey();
-                Set<ObjectFactory<T>> set = entry.getValue();
-                for (ObjectFactory<T> t : set) {
+                Set<PriorityObjectFactory<T>> set = entry.getValue();
+                for (PriorityObjectFactory<T> t : set) {
                     if (GenericsUtils.isGenericInterfaceAssignableFrom(type,
                                                                        t.getInstanceClass(),
                                                                        rawType)) {
@@ -612,17 +620,17 @@
         }
 
         @SuppressWarnings("unchecked")
-        synchronized void put(MediaType key, ObjectFactory<T> objectFactory) {
-            HashMap<MediaType, HashSet<ObjectFactory<T>>> copyOfMap =
-                new HashMap<MediaType, HashSet<ObjectFactory<T>>>(data);
+        synchronized void put(MediaType key, PriorityObjectFactory<T> objectFactory)
{
+            HashMap<MediaType, HashSet<PriorityObjectFactory<T>>> copyOfMap
=
+                new HashMap<MediaType, HashSet<PriorityObjectFactory<T>>>(data);
             if (!key.getParameters().isEmpty()) {
                 key = new MediaType(key.getType(), key.getSubtype());
             }
-            HashSet<ObjectFactory<T>> set = data.get(key);
+            HashSet<PriorityObjectFactory<T>> set = data.get(key);
             if (set == null) {
-                set = new HashSet<ObjectFactory<T>>();
+                set = new HashSet<PriorityObjectFactory<T>>();
             } else {
-                set = new HashSet<ObjectFactory<T>>(set);
+                set = new HashSet<PriorityObjectFactory<T>>(set);
             }
             copyOfMap.put(key, set);
             if (!set.add(objectFactory)) {
@@ -630,19 +638,21 @@
             } else {
 
                 // need to resort the entry set
-                Entry<MediaType, HashSet<ObjectFactory<T>>>[] newEntrySet
=
+                Entry<MediaType, HashSet<PriorityObjectFactory<T>>>[] newEntrySet
=
                     copyOfMap.entrySet().toArray(new Entry[0]);
                 // It's important to sort the media types here to ensure that
                 // provider of the more dominant media type will precede, when
                 // adding to the compatible set.
-                Arrays.sort(newEntrySet, Collections
-                    .reverseOrder(new Comparator<Entry<MediaType, HashSet<ObjectFactory<T>>>>()
{
-
-                        public int compare(Entry<MediaType, HashSet<ObjectFactory<T>>>
o1,
-                                           Entry<MediaType, HashSet<ObjectFactory<T>>>
o2) {
-                            return MediaTypeUtils.compareTo(o1.getKey(), o2.getKey());
-                        }
-                    }));
+                Arrays
+                    .sort(newEntrySet,
+                          Collections
+                              .reverseOrder(new Comparator<Entry<MediaType, HashSet<PriorityObjectFactory<T>>>>()
{
+
+                                  public int compare(Entry<MediaType, HashSet<PriorityObjectFactory<T>>>
o1,
+                                                     Entry<MediaType, HashSet<PriorityObjectFactory<T>>>
o2) {
+                                      return MediaTypeUtils.compareTo(o1.getKey(), o2.getKey());
+                                  }
+                              }));
 
                 if (logger.isDebugEnabled()) {
                     logger.debug("Added ObjectFactory {} with MediaType {} to MediaTypeMap
{}",
@@ -695,16 +705,20 @@
             return sb.toString();
         }
 
-        private class OFHolder<T> implements ObjectFactory<T>, Comparable<OFHolder<T>>
{
+        class OFHolder<T> implements ObjectFactory<T>, Comparable<OFHolder<T>>
{
 
             private final PriorityObjectFactory<T> of;
             private final MediaType                mediaType;
             private final Class<?>                 genericType;
+            private final boolean                  isSystemProvider;
 
-            public OFHolder(MediaType mediaType, ObjectFactory<T> of) {
+            public OFHolder(MediaType mediaType,
+                            PriorityObjectFactory<T> of,
+                            boolean isSystemProvider) {
                 super();
-                this.of = (PriorityObjectFactory<T>)of;
+                this.of = of;
                 this.mediaType = mediaType;
+                this.isSystemProvider = isSystemProvider;
                 genericType =
                     GenericsUtils.getClassType(GenericsUtils.getGenericInterfaceParamType(of
                         .getInstanceClass(), rawType));
@@ -757,23 +771,21 @@
                 return of.getInstanceClass();
             }
 
-            private static final double MAX_SYSTEM_PRIORITY = WinkApplication.SYSTEM_PRIORITY
+ 0.1;
-
             public int compareTo(OFHolder<T> o) {
                 // check if this is a system provider
                 // system providers are less than
                 // WinkApplication.SYSTEM_PRIORITY + 0.1 (they start at
                 // WinkApplication.SYSTEM_PRIORITY and
                 // unless there are 10000000000, this shouldn't matter)
-                if (of.priority < MAX_SYSTEM_PRIORITY) {
+                if (isSystemProvider) {
                     // this is a system provider
-                    if (o.of.priority > MAX_SYSTEM_PRIORITY) {
+                    if (!o.isSystemProvider) {
                         // the other is a user provider so this is > 0.2
                         return -1;
                     }
-                } else if (o.of.priority < MAX_SYSTEM_PRIORITY) {
+                } else if (o.isSystemProvider) {
                     // the other is a system provider
-                    if (of.priority > MAX_SYSTEM_PRIORITY) {
+                    if (!isSystemProvider) {
                         // this is a user provider
                         return 1;
                     }
@@ -803,13 +815,15 @@
 
         private final ObjectFactory<T> of;
         private final double           priority;
+        final boolean                  isSystemProvider;
         private static double          counter = 0.00000000001;
         private static final double    inc     = 0.00000000001;
 
-        public PriorityObjectFactory(ObjectFactory<T> of, double priority) {
+        public PriorityObjectFactory(ObjectFactory<T> of, double priority, boolean
isSystemProvider) {
             super();
             this.of = of;
             this.priority = priority + (counter += inc);
+            this.isSystemProvider = isSystemProvider;
         }
 
         public T getInstance(RuntimeContext context) {

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/CookieFieldsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/CookieFieldsTest.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/CookieFieldsTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-params/src/test/java/org/apache/wink/itest/CookieFieldsTest.java
Sat Oct  3 16:40:07 2009
@@ -38,7 +38,7 @@
  */
 public class CookieFieldsTest extends TestCase {
 
-    protected HttpClient  httpclient = new HttpClient();
+    protected HttpClient  httpclient;
 
     private static String BASE_URI   =
                                          ServerEnvironmentInfo.getBaseURI() + "/newcookies/cookiestests";
@@ -49,6 +49,11 @@
         }
     }
 
+    @Override
+    public void setUp() {
+        httpclient = new HttpClient();
+    }
+
     /**
      * Test that the HttpHeaders.getCookies() method returns correct cookies and
      * information
@@ -56,7 +61,6 @@
      * @throws Exception
      */
     public void testHttpHeadersGetCookie() throws Exception {
-        httpclient = new HttpClient();
         setCookies();
         // call get to exercise HttpHeaders.getCookies()
         GetMethod getHttpMethod = new GetMethod();
@@ -123,7 +127,6 @@
      * @throws Exception
      */
     public void testCookieParamPrivateVar() throws Exception {
-        httpclient = new HttpClient();
         setCookies();
         GetMethod getHttpMethod = new GetMethod();
         getHttpMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2965);

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
Sat Oct  3 16:40:07 2009
@@ -257,8 +257,9 @@
         return errorUserHandlers;
     }
 
-    public void addApplication(Application application) {
-        new ApplicationProcessor(application, resourceRegistry, providersRegistry).process();
+    public void addApplication(Application application, boolean isSystemApplication) {
+        new ApplicationProcessor(application, resourceRegistry, providersRegistry,
+                                 isSystemApplication).process();
     }
 
     // init methods

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
Sat Oct  3 16:40:07 2009
@@ -85,7 +85,7 @@
             RegistrationUtils.InnerApplication application =
                 new RegistrationUtils.InnerApplication(classes);
             application.setPriority(WinkApplication.SYSTEM_PRIORITY);
-            configuration.addApplication(application);
+            configuration.addApplication(application, true);
         } catch (FileNotFoundException e) {
             throw new WebApplicationException(e);
         }
@@ -100,7 +100,7 @@
             RegistrationUtils.InnerApplication application =
                 new RegistrationUtils.InnerApplication(RootResource.class);
             application.setPriority(WinkApplication.SYSTEM_PRIORITY);
-            configuration.addApplication(application);
+            configuration.addApplication(application, true);
         } else if (registerRootResource.equals(PROPERTY_ROOT_RESOURCE_NONE)) {
             // do nothing
         } else {
@@ -113,7 +113,7 @@
             RegistrationUtils.InnerApplication application =
                 new RegistrationUtils.InnerApplication(instance);
             application.setPriority(WinkApplication.SYSTEM_PRIORITY);
-            configuration.addApplication(application);
+            configuration.addApplication(application, true);
         }
     }
 

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
Sat Oct  3 16:40:07 2009
@@ -51,14 +51,17 @@
     private final Application       application;
     private final ResourceRegistry  resourceRegistry;
     private final ProvidersRegistry providersRegistry;
+    private final boolean           isSystemApplication;
 
     public ApplicationProcessor(Application application,
                                 ResourceRegistry resourceRegistry,
-                                ProvidersRegistry providersRegistry) {
+                                ProvidersRegistry providersRegistry,
+                                boolean isSystemApplication) {
         super();
         this.application = application;
         this.resourceRegistry = resourceRegistry;
         this.providersRegistry = providersRegistry;
+        this.isSystemApplication = isSystemApplication;
     }
 
     public void process() {
@@ -111,7 +114,7 @@
                 } else if (ResourceMetadataCollector.isStaticResource(cls)) {
                     resourceRegistry.addResource(obj, priority);
                 } else if (ProviderMetadataCollector.isProvider(cls)) {
-                    providersRegistry.addProvider(obj, priority);
+                    providersRegistry.addProvider(obj, priority, isSystemApplication);
                 } else {
                     logger.warn(Messages
                         .getMessage("classNotADynamicResourceNorResourceNorProvider"), obj);
@@ -135,7 +138,7 @@
                 if (ResourceMetadataCollector.isStaticResource(cls)) {
                     resourceRegistry.addResource(cls, priority);
                 } else if (ProviderMetadataCollector.isProvider(cls)) {
-                    providersRegistry.addProvider(cls, priority);
+                    providersRegistry.addProvider(cls, priority, isSystemApplication);
                 } else {
                     logger.warn(Messages.getMessage("classNotAResourceNorProvider"), cls);
                 }
@@ -158,7 +161,7 @@
                 if (ResourceMetadataCollector.isStaticResource(cls)) {
                     resourceRegistry.addResource(obj, priority);
                 } else if (ProviderMetadataCollector.isProvider(cls)) {
-                    providersRegistry.addProvider(obj, priority);
+                    providersRegistry.addProvider(obj, priority, isSystemApplication);
                 } else {
                     logger.warn(Messages.getMessage("classNotAResourceNorProvider"), obj);
                 }

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
Sat Oct  3 16:40:07 2009
@@ -110,7 +110,7 @@
         DeploymentConfiguration deploymentConfiguration = getDeploymentConfiguration();
         RequestProcessor requestProcessor = new RequestProcessor(deploymentConfiguration);
         logger.debug("Creating request processor {} for servlet {}", requestProcessor, this);
-        deploymentConfiguration.addApplication(getApplication());
+        deploymentConfiguration.addApplication(getApplication(), false);
         return requestProcessor;
     }
 

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/utils/RegistrationUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/utils/RegistrationUtils.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/utils/RegistrationUtils.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/utils/RegistrationUtils.java
Sat Oct  3 16:40:07 2009
@@ -82,7 +82,7 @@
                                            String requestProcessorAttribute) {
         RequestProcessor requestProcessor =
             RequestProcessor.getRequestProcessor(servletContext, requestProcessorAttribute);
-        requestProcessor.getConfiguration().addApplication(application);
+        requestProcessor.getConfiguration().addApplication(application, false);
     }
 
     public static class InnerApplication extends WinkApplication {

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/application/ApplicationProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/application/ApplicationProcessorTest.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/application/ApplicationProcessorTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/application/ApplicationProcessorTest.java
Sat Oct  3 16:40:07 2009
@@ -100,12 +100,26 @@
             return classes.add(cls);
         }
 
+        public boolean addProvider(Class<?> cls, double priority, boolean isSystemProvider)
{
+            if (BadProvider.class == cls) {
+                throw new BadProvider("BadProvider cannot be added");
+            }
+            return classes.add(cls);
+        }
+
         public boolean addProvider(Object provider, double priority) {
             if (provider instanceof BadProvider) {
                 throw new BadProvider("BadProvider cannot be added");
             }
             return instances.add(provider);
         }
+
+        public boolean addProvider(Object provider, double priority, boolean isSystemProvider)
{
+            if (provider instanceof BadProvider) {
+                throw new BadProvider("BadProvider cannot be added");
+            }
+            return instances.add(provider);
+        }
     }
 
     @Provider
@@ -207,7 +221,7 @@
     public void testApplication() {
         ResourceRegistryMock resourceRegistry = new ResourceRegistryMock();
         ProvidersRegistryMock providersRegistry = new ProvidersRegistryMock();
-        new ApplicationProcessor(new ApplicationMock(), resourceRegistry, providersRegistry)
+        new ApplicationProcessor(new ApplicationMock(), resourceRegistry, providersRegistry,
false)
             .process();
         assertTrue(providersRegistry.classes.contains(FileProvider.class));
         assertTrue(resourceRegistry.classes.contains(RootResource.class));
@@ -222,8 +236,8 @@
     public void testWinkApplication() {
         ResourceRegistryMock resourceRegistry = new ResourceRegistryMock();
         ProvidersRegistryMock providersRegistry = new ProvidersRegistryMock();
-        new ApplicationProcessor(new WinkApplicationMock(), resourceRegistry, providersRegistry)
-            .process();
+        new ApplicationProcessor(new WinkApplicationMock(), resourceRegistry, providersRegistry,
+                                 false).process();
         assertTrue(providersRegistry.classes.contains(FileProvider.class));
         assertTrue(resourceRegistry.classes.contains(RootResource.class));
         assertEquals(1, providersRegistry.classes.size());

Modified: incubator/wink/trunk/wink-spring-support/src/main/java/org/apache/wink/spring/Registrar.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-spring-support/src/main/java/org/apache/wink/spring/Registrar.java?rev=821358&r1=821357&r2=821358&view=diff
==============================================================================
--- incubator/wink/trunk/wink-spring-support/src/main/java/org/apache/wink/spring/Registrar.java
(original)
+++ incubator/wink/trunk/wink-spring-support/src/main/java/org/apache/wink/spring/Registrar.java
Sat Oct  3 16:40:07 2009
@@ -52,7 +52,7 @@
     }
 
     public void register(ResourceRegistry resourceRegistry, ProvidersRegistry providersRegistry)
{
-        new ApplicationProcessor(this, resourceRegistry, providersRegistry).process();
+        new ApplicationProcessor(this, resourceRegistry, providersRegistry, false).process();
     }
 
     public void setInstances(Set<Object> instances) {



Mime
View raw message