cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1081299 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs: lifecycle/PerRequestResourceProvider.java lifecycle/ResourceProvider.java lifecycle/SingletonResourceProvider.java spring/SpringResourceFactory.java
Date Mon, 14 Mar 2011 10:08:12 GMT
Author: sergeyb
Date: Mon Mar 14 10:08:12 2011
New Revision: 1081299

URL: http://svn.apache.org/viewvc?rev=1081299&view=rev
Log:
JAX-RS: Documenting the ResourceProvider interface and implementations

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java?rev=1081299&r1=1081298&r2=1081299&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
Mon Mar 14 10:08:12 2011
@@ -30,6 +30,10 @@ import org.apache.cxf.jaxrs.utils.Inject
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 
+/**
+ * The default per-request resource provider which creates 
+ * a new resource instance per every request
+ */
 public class PerRequestResourceProvider implements ResourceProvider {
     private Constructor<?> c;
     private Method postConstructMethod;
@@ -45,15 +49,20 @@ public class PerRequestResourceProvider 
         preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz);
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public boolean isSingleton() {
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Object getInstance(Message m) {  
         return createInstance(m);
     }
     
-        
     protected Object createInstance(Message m) {
         
         Object[] values = ResourceUtils.createConstructorArguments(c, m);
@@ -77,10 +86,16 @@ public class PerRequestResourceProvider 
         
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void releaseInstance(Message m, Object o) {
         InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Class<?> getResourceClass() {
         return c.getDeclaringClass();
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java?rev=1081299&r1=1081298&r2=1081299&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
Mon Mar 14 10:08:12 2011
@@ -22,13 +22,33 @@ package org.apache.cxf.jaxrs.lifecycle;
 import org.apache.cxf.message.Message;
 
 /**
- * ResourceProviders are used to specify the lifecycle 
- * (per-request or singleton primarily) of root resources.
+ * ResourceProvider controls the life-cycle of the JAX-RS root resources.
  */
 public interface ResourceProvider {
 
+    /**
+     * Returns the resource instance which will handle the current request 
+     * @param m the current request message
+     * @return resource instance
+     */
     Object getInstance(Message m);
+    
+    /**
+     * Releases the resource instance if needed
+     * @param m the current request message
+     * @param o resource instance
+     */
     void releaseInstance(Message m, Object o);
+    
+    /**
+     * Returns the Class of the resource
+     * @return
+     */
     Class<?> getResourceClass();
+    
+    /**
+     * Indicates if the managed resource is a singleton
+     * @return
+     */
     boolean isSingleton();
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java?rev=1081299&r1=1081298&r2=1081299&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
Mon Mar 14 10:08:12 2011
@@ -24,6 +24,10 @@ import org.apache.cxf.jaxrs.utils.Inject
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 
+/**
+ * The default singleton resource provider which returns 
+ * the same resource instance per every request
+ */
 public class SingletonResourceProvider implements ResourceProvider {
     private Object resourceInstance;
     
@@ -39,18 +43,30 @@ public class SingletonResourceProvider i
         this(o, false);
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public boolean isSingleton() {
         return true;
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public Object getInstance(Message m) {
         return resourceInstance;
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public void releaseInstance(Message m, Object o) {
-        // TODO Auto-generated method stub
+        // complete
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public Class<?> getResourceClass() {
         return ClassHelper.getRealClass(resourceInstance);
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java?rev=1081299&r1=1081298&r2=1081299&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
Mon Mar 14 10:08:12 2011
@@ -31,6 +31,10 @@ import org.springframework.beans.BeansEx
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
+/**
+ * The ResourceProvider implementation which delegates to 
+ * ApplicationContext to manage the life-cycle of the resource
+ */
 public class SpringResourceFactory implements ResourceProvider, ApplicationContextAware {
 
     private Constructor<?> c;
@@ -63,6 +67,9 @@ public class SpringResourceFactory imple
         isSingleton = ac.isSingleton(beanId);
     }
     
+    /**
+     * {@inheritDoc}
+     */
     public Object getInstance(Message m) {
         Object[] values = ResourceUtils.createConstructorArguments(c, m);
         Object instance = values.length > 0 ? ac.getBean(beanId, values) : ac.getBean(beanId);
@@ -72,10 +79,16 @@ public class SpringResourceFactory imple
         return instance;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isSingleton() {
         return isSingleton; 
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void releaseInstance(Message m, Object o) {
         if (!isSingleton) {
             InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod);
@@ -99,6 +112,9 @@ public class SpringResourceFactory imple
         return c;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Class<?> getResourceClass() {
         return c.getDeclaringClass();
     }



Mime
View raw message