cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r123782 - in cocoon/trunk/src/core/java/org/apache/cocoon: components core/container
Date Fri, 31 Dec 2004 11:00:20 GMT
Author: cziegeler
Date: Fri Dec 31 03:00:19 2004
New Revision: 123782

URL: http://svn.apache.org/viewcvs?view=rev&rev=123782
Log:
Refactoring for better component instantiation
Modified:
   cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java?view=diff&rev=123782&p1=cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java&r1=123781&p2=cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java&r2=123782
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java	(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java	Fri Dec 31 03:00:19
2004
@@ -15,8 +15,6 @@
  */
 package org.apache.cocoon.components;
 
-import java.lang.reflect.Method;
-
 import org.apache.avalon.framework.configuration.Configuration;
 
 /**
@@ -37,10 +35,6 @@
     private String poolOutMethodName;
     private Class serviceClass;
     private String serviceClassName;
-    private Method initMethod;
-    private Method destroyMethod;
-    private Method poolInMethod;
-    private Method poolOutMethod;
     private Configuration configuration;
     
     public ServiceInfo() {
@@ -115,46 +109,6 @@
      */
     public void setPoolOutMethodName(String poolMethod) {
         this.poolOutMethodName = poolMethod;
-    }
-
-    /**
-     * @return Returns the destroyMethod.
-     */
-    public Method getDestroyMethod() throws Exception {
-        if ( this.destroyMethod == null && this.destroyMethodName != null ) {
-            this.destroyMethod = this.serviceClass.getMethod(this.destroyMethodName, null);
-        }
-        return destroyMethod;
-    }
-
-    /**
-     * @return Returns the initMethod.
-     */
-    public Method getInitMethod() throws Exception {
-        if ( this.initMethod == null && this.initMethodName != null ) {
-            this.initMethod = this.serviceClass.getMethod(this.initMethodName, null);
-        }
-        return initMethod;
-    }
-
-    /**
-     * @return Returns the poolInMethod.
-     */
-    public Method getPoolInMethod() throws Exception {
-        if ( this.poolInMethod == null && this.poolInMethodName != null ) {
-            this.poolInMethod = this.serviceClass.getMethod(this.poolInMethodName, null);
-        }
-        return poolInMethod;
-    }
-
-    /**
-     * @return Returns the poolInMethod.
-     */
-    public Method getPoolOutMethod() throws Exception {
-        if ( this.poolOutMethod == null && this.poolOutMethodName != null ) {
-            this.poolOutMethod = this.serviceClass.getMethod(this.poolOutMethodName, null);
-        }
-        return poolOutMethod;
     }
 
     /**

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java?view=diff&rev=123782&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java&r1=123781&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java&r2=123782
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentEnvironment.java
Fri Dec 31 03:00:19 2004
@@ -34,4 +34,5 @@
     public Logger logger;
     public LoggerManager loggerManager;
     public ClassLoader classloader;
+    
 }

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java?view=diff&rev=123782&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java&r1=123781&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java&r2=123782
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java	(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java	Fri
Dec 31 03:00:19 2004
@@ -40,6 +40,12 @@
      */
     protected Parameters parameters;
     
+    protected final Class serviceClass;
+    protected final Method initMethod;
+    protected final Method destroyMethod;
+    protected final Method poolInMethod;
+    protected final Method poolOutMethod;
+
     /**
      * Construct a new component factory for the specified component.
      *
@@ -50,7 +56,8 @@
      *
      */
     public ComponentFactory( final ComponentEnvironment environment,
-                             final ServiceInfo info) {
+                             final ServiceInfo info) 
+    throws Exception {
         this.environment = environment;
         this.serviceInfo = info;
         
@@ -63,8 +70,32 @@
             }
         }
         this.environment.logger = actualLogger;
+        
+        // now get the meta data for the component
+        // FIXME - load the class
+        this.serviceClass = this.serviceInfo.getServiceClass();
+        if ( this.serviceInfo.getDestroyMethodName() != null ) {
+            this.destroyMethod = this.serviceClass.getMethod(this.serviceInfo.getDestroyMethodName(),
null);
+        } else {
+            this.destroyMethod = null;
+        }
+        if ( this.serviceInfo.getInitMethodName() != null ) {
+            this.initMethod = this.serviceClass.getMethod(this.serviceInfo.getInitMethodName(),
null);
+        } else {
+            this.initMethod = null;
+        }
+        if ( this.serviceInfo.getPoolInMethodName() != null ) {
+            this.poolInMethod = this.serviceClass.getMethod(this.serviceInfo.getPoolInMethodName(),
null);
+        } else {
+            this.poolInMethod = null;
+        }
+        if ( this.serviceInfo.getPoolOutMethodName() != null ) {
+            this.poolOutMethod = this.serviceClass.getMethod(this.serviceInfo.getPoolOutMethodName(),
null);
+        } else {
+            this.poolOutMethod = null;
+        }
     }
-
+    
     /**
      * Create a new instance
      */
@@ -91,9 +122,8 @@
 
         ContainerUtil.initialize( component );
 
-        final Method method = this.serviceInfo.getInitMethod();
-        if ( method != null ) {
-            method.invoke(component, null);
+        if ( this.initMethod != null ) {
+            this.initMethod.invoke(component, null);
         }
 
         ContainerUtil.start( component );
@@ -118,9 +148,8 @@
         ContainerUtil.stop( component );
         ContainerUtil.dispose( component );
 
-        final Method method = this.serviceInfo.getDestroyMethod();
-        if ( method != null ) {
-            method.invoke(component, null);
+        if ( this.destroyMethod != null ) {
+            this.destroyMethod.invoke(component, null);
         }
     }
 
@@ -129,9 +158,8 @@
      */
     public void exitingPool( final Object component )
     throws Exception {
-        final Method method = this.serviceInfo.getPoolOutMethod();
-        if ( method != null ) {
-            method.invoke(component, null);
+        if ( this.poolOutMethod != null ) {
+            this.poolOutMethod.invoke(component, null);
         }         
     }
 
@@ -144,9 +172,8 @@
         if( component instanceof Recyclable ) {
             ( (Recyclable)component ).recycle();
         }
-        final Method method = this.serviceInfo.getPoolInMethod();
-        if ( method != null ) {
-            method.invoke(component, null);
+        if ( this.poolInMethod != null ) {
+            this.poolInMethod.invoke(component, null);
         }         
     }
 }

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java?view=diff&rev=123782&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java&r1=123781&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java&r2=123782
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java
Fri Dec 31 03:00:19 2004
@@ -192,7 +192,8 @@
         private final String role;
         private final RoleManager roleManager;
         
-        public Factory(ComponentEnvironment env, RoleManager manager, ServiceInfo info, String
role) {
+        public Factory(ComponentEnvironment env, RoleManager manager, ServiceInfo info, String
role) 
+        throws Exception {
             super(env, info);
             this.role = role;
             this.roleManager = manager;

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java?view=diff&rev=123782&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r1=123781&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r2=123782
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java
Fri Dec 31 03:00:19 2004
@@ -458,7 +458,8 @@
         
         private final RoleManager roleManager;
         
-        public Factory(ComponentEnvironment env, RoleManager roleManager, ServiceInfo info)
{
+        public Factory(ComponentEnvironment env, RoleManager roleManager, ServiceInfo info)

+        throws Exception {
             super(env, info);
             this.roleManager = roleManager;
         }

Mime
View raw message