cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r123784 - cocoon/trunk/src/core/java/org/apache/cocoon/core/container
Date Fri, 31 Dec 2004 11:15:28 GMT
Author: cziegeler
Date: Fri Dec 31 03:15:25 2004
New Revision: 123784

URL: http://svn.apache.org/viewcvs?view=rev&rev=123784
Log:
Refactoring for better component instantiation
Modified:
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
   cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.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/core/container/AbstractComponentHandler.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java?view=diff&rev=123784&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java&r1=123783&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java&r2=123784
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
Fri Dec 31 03:15:25 2004
@@ -77,6 +77,7 @@
     throws Exception {
         int numInterfaces = 0;
 
+        // FIXME we don't need the class but a classloader
         final ServiceInfo info = new ServiceInfo();
         info.setServiceClass(componentClass);
         info.setServiceClassName(componentClass.getName());

Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java?view=diff&rev=123784&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java&r1=123783&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java&r2=123784
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java
(original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java
Fri Dec 31 03:15:25 2004
@@ -607,6 +607,7 @@
         if (handler != null) {
             // Overloaded component: we only allow selectors to be overloaded
             ServiceInfo info = handler.getInfo();
+            // FIXME - info should not contain the class, we need to get it from somewhere
else
             if (!DefaultServiceSelector.class.isAssignableFrom(component) ||
                 !DefaultServiceSelector.class.isAssignableFrom(info.getServiceClass())) {
                 throw new ServiceException(role, "Component declared at " + info.getLocation()
+ " is redefined at " +

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=123784&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java&r1=123783&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java&r2=123784
==============================================================================
--- 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:15:25 2004
@@ -72,8 +72,8 @@
         this.environment.logger = actualLogger;
         
         // now get the meta data for the component
-        // FIXME - load the class
-        this.serviceClass = this.serviceInfo.getServiceClass();
+        // FIXME - get the classloader from the environment
+        this.serviceClass = this.getClass().getClassLoader().loadClass(this.serviceInfo.getServiceClassName());
         if ( this.serviceInfo.getDestroyMethodName() != null ) {
             this.destroyMethod = this.serviceClass.getMethod(this.serviceInfo.getDestroyMethodName(),
null);
         } else {
@@ -101,11 +101,11 @@
      */
     public Object newInstance()
     throws Exception {
-        final Object component = this.serviceInfo.getServiceClass().newInstance();
+        final Object component = this.serviceClass.newInstance();
 
         if( this.environment.logger.isDebugEnabled() ) {
             this.environment.logger.debug( "ComponentFactory creating new instance of " +
-                    this.serviceInfo.getServiceClass().getName() + "." );
+                    this.serviceClass.getName() + "." );
         }
 
         ContainerUtil.enableLogging(component, this.environment.logger);
@@ -132,7 +132,7 @@
     }
 
     public Class getCreatedClass() {
-        return this.serviceInfo.getServiceClass();
+        return this.serviceClass;
     }
 
     /**
@@ -142,7 +142,7 @@
     throws Exception {
         if( this.environment.logger.isDebugEnabled() ) {
             this.environment.logger.debug( "ComponentFactory decommissioning instance of
" +
-                    this.serviceInfo.getServiceClass().getName() + "." );
+                    this.serviceClass.getName() + "." );
         }
 
         ContainerUtil.stop( component );

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=123784&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java&r1=123783&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/DefaultServiceSelector.java&r2=123784
==============================================================================
--- 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:15:25 2004
@@ -201,7 +201,7 @@
         
         public Object newInstance()
         throws Exception {
-            final DefaultServiceSelector component = (DefaultServiceSelector)this.serviceInfo.getServiceClass().newInstance();
+            final DefaultServiceSelector component = (DefaultServiceSelector)this.serviceClass.newInstance();
 
             ContainerUtil.enableLogging(component, this.environment.logger);
             ContainerUtil.contextualize(component, this.environment.context);

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=123784&p1=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r1=123783&p2=cocoon/trunk/src/core/java/org/apache/cocoon/core/container/StandaloneServiceSelector.java&r2=123784
==============================================================================
--- 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:15:25 2004
@@ -466,7 +466,7 @@
         
         public Object newInstance()
         throws Exception {
-            final StandaloneServiceSelector component = (StandaloneServiceSelector)this.serviceInfo.getServiceClass().newInstance();
+            final StandaloneServiceSelector component = (StandaloneServiceSelector)this.serviceClass.newInstance();
 
             ContainerUtil.enableLogging(component, this.environment.logger);
             ContainerUtil.contextualize(component, this.environment.context);

Mime
View raw message