[exo-jcr-commits] exo-jcr SVN: r130 - in ws/trunk/rest/core/src: main/java/org/exoplatform/services/rest/impl/resource and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Sep 3 01:21:21 EDT 2009


Author: aparfonov
Date: 2009-09-03 01:21:20 -0400 (Thu, 03 Sep 2009)
New Revision: 130

Modified:
   ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
   ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
   ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
   ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
Log:
EXOJCR-129 : Remove constraint for same name of field in resource class and super class. Both of them will be initialized.

Modified: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
===================================================================
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java	2009-09-02 16:17:17 UTC (rev 129)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java	2009-09-03 05:21:20 UTC (rev 130)
@@ -147,23 +147,6 @@
    /**
     * {@inheritDoc}
     */
-   @Override
-   public boolean equals(Object other)
-   {
-      if (other == null)
-      {
-         return false;
-      }
-      if (getClass() != other.getClass())
-      {
-         return false;
-      }
-      return getName().equals(((FieldInjectorImpl)other).getName());
-   }
-   
-   /**
-    * {@inheritDoc}
-    */
    public Annotation getAnnotation()
    {
       return annotation;

Modified: ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
===================================================================
--- ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java	2009-09-02 16:17:17 UTC (rev 129)
+++ ws/trunk/rest/core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java	2009-09-03 05:21:20 UTC (rev 130)
@@ -199,10 +199,12 @@
             for (java.lang.reflect.Field jfield : sc.getDeclaredFields())
             {
                int modif = jfield.getModifiers();
+               // TODO process fields with package visibility.
                if (Modifier.isPublic(modif) || Modifier.isProtected(modif))
                {
                   FieldInjector inj = new FieldInjectorImpl(resourceClass, jfield);
-                  if (inj.getAnnotation() != null && !fields.contains(inj))
+                  // Skip not annotated field. They will be not injected from container.  
+                  if (inj.getAnnotation() != null)
                   {
                      fields.add(new FieldInjectorImpl(resourceClass, jfield));
                   }

Modified: ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java
===================================================================
--- ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java	2009-09-02 16:17:17 UTC (rev 129)
+++ ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/RequestDispatcherTest.java	2009-09-03 05:21:20 UTC (rev 130)
@@ -347,6 +347,9 @@
 
       @Context
       public Request request;
+      
+      @Context
+      protected UriInfo something;
    }
 
    public abstract static class ExtResource extends AbstractResource
@@ -361,12 +364,19 @@
    {
       @Context
       private HttpHeaders header;
+      
+      @Context
+      private SecurityContext something;
 
       @GET
       public void m1()
       {
          assertNotNull(uriInfo);
          assertNotNull(request);
+         assertNotNull(this.something);
+         assertNotNull(super.something);
+         assertTrue(this.something instanceof SecurityContext);
+         assertTrue(super.something instanceof UriInfo);
          assertNotNull(sc);
          assertNotNull(header);
       }

Modified: ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
===================================================================
--- ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java	2009-09-02 16:17:17 UTC (rev 129)
+++ ws/trunk/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java	2009-09-03 05:21:20 UTC (rev 130)
@@ -758,7 +758,7 @@
    public void testInitializeFieldSuperClass()
    {
       AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(EndResource.class);
-      assertEquals(4, resource.getFieldInjectors().size());
+      assertEquals(6, resource.getFieldInjectors().size());
    }
 
    public abstract static class AbstractResource
@@ -768,6 +768,9 @@
 
       @Context
       public Request request;
+
+      @Context
+      protected UriInfo something;
    }
 
    public abstract static class ExtResource extends AbstractResource
@@ -784,6 +787,10 @@
       @Context
       private HttpHeaders header;
 
+      @SuppressWarnings("unused")
+      @Context
+      private UriInfo something;
+
       @GET
       public void m1()
       {



More information about the exo-jcr-commits mailing list