cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r613972 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/ cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/ cocoon-portal-sample/src/main/resources/COB-INF/conf...
Date Mon, 21 Jan 2008 19:02:35 GMT
Author: cziegeler
Date: Mon Jan 21 11:02:31 2008
New Revision: 613972

URL: http://svn.apache.org/viewvc?rev=613972&view=rev
Log:
Convert deployment manager to spring.

Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/DefaultDeploymentManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/DefaultDeploymentManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/DefaultDeploymentManager.java?rev=613972&r1=613971&r2=613972&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/DefaultDeploymentManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/DefaultDeploymentManager.java
Mon Jan 21 11:02:31 2008
@@ -23,21 +23,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.StringTokenizer;
 
-import org.apache.avalon.framework.activity.Startable;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.portal.deployment.DeploymentEvent;
 import org.apache.cocoon.portal.deployment.DeploymentException;
 import org.apache.cocoon.portal.deployment.DeploymentManager;
 import org.apache.cocoon.portal.deployment.DeploymentObject;
 import org.apache.cocoon.portal.deployment.DeploymentStatus;
 import org.apache.cocoon.portal.deployment.UndeploymentEvent;
-import org.apache.cocoon.portal.util.AbstractComponent;
 import org.apache.cocoon.thread.RunnableManager;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
@@ -54,8 +46,8 @@
  * @version $Id$
  */
 public class DefaultDeploymentManager
-    extends AbstractComponent
-    implements DeploymentManager, Parameterizable, Startable, Runnable {
+    extends org.apache.cocoon.portal.util.AbstractBean
+    implements DeploymentManager, Runnable {
 
     /** Wait ten seconds before scanning. */
     protected static final int STARTUP_DELAY = 10 * 1000;
@@ -63,6 +55,9 @@
     /** Source resolver. */
     protected SourceResolver resolver;
 
+    /** Runnable manager. */
+    protected RunnableManager runnableManager;
+
     /** Are we already started? */
     protected boolean started = false;
 
@@ -76,7 +71,7 @@
     protected long scanningDelay = 60 * 1000;
 
     /** All locations to look for deployable artifacts. */
-    protected String[] deploymentUris;
+    protected String[] deploymentUris = new String[] {"conf/deploy"};
 
     /** These files have been ignored during the last scan. */
     protected final Map failedArtifacts;
@@ -93,39 +88,34 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.util.AbstractComponent#dispose()
+     * Dispose this object.
      */
     public void dispose() {
-        if ( this.manager != null ) {
-            this.manager.release(this.resolver);
-            this.resolver = null;
-        }
-        super.dispose();
+        this.stop();
     }
 
-    /**
-     * @see org.apache.cocoon.portal.util.AbstractComponent#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager aManager) throws ServiceException {
-        super.service(aManager);
-        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+    public void setSourceResolver(SourceResolver resolver) {
+        this.resolver = resolver;
     }
 
-    /**
-     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
-     */
-    public void parameterize(Parameters parameters) throws ParameterException {
-        this.scanningDelay = parameters.getParameterAsLong("scanning-delay", this.scanningDelay);
-        this.hotDeployment = parameters.getParameterAsBoolean("hot-deployment", this.hotDeployment);
-        final String deploymentDirs = parameters.getParameter("deployment-sources", "conf/deploy");
-        final StringTokenizer st = new StringTokenizer(deploymentDirs, ",");
-        this.deploymentUris = new String[st.countTokens()];
-        int i = 0;
-        while (st.hasMoreTokens()) {
-            this.deploymentUris[i] = st.nextToken();
-            i++;
-        }
-        this.threadPoolName = parameters.getParameter("thread-pool-name", this.threadPoolName);
+    public void setRunnableManager(RunnableManager manager) {
+        this.runnableManager = manager;
+    }
+
+    public void setScanningDelay(long delay) {
+        this.scanningDelay = delay;
+    }
+
+    public void setHotDeployment(boolean flag) {
+        this.hotDeployment = flag;
+    }
+
+    public void setDeploymentSources(String[] uris) {
+        this.deploymentUris = uris;
+    }
+
+    public void setThreadPoolName(String name) {
+        this.threadPoolName = name;
     }
 
     /**
@@ -159,11 +149,10 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.util.AbstractComponent#initialize()
+     * Initialize this component
      */
     public void initialize()
     throws Exception {
-        super.initialize();
         if ( this.getLogger().isInfoEnabled() ) {
             this.getLogger().info("Starting auto deployment service: " + this.getClass().getName());
             this.getLogger().info("Hot-Deployment: " + this.hotDeployment);
@@ -177,22 +166,17 @@
         if (this.scanningDelay > 0) {
             this.testSources();
         }
+        this.start();
     }
 
     /**
-     * @see org.apache.avalon.framework.activity.Startable#start()
+     * Start this service in the background.
      */
-    public void start() throws Exception {
+    protected void start() throws Exception {
         if ( this.scanningDelay > 0 ) {
             if ( this.hotDeployment ) {
                 this.started = true;
-                RunnableManager runnableManager = null;
-                try {
-                    runnableManager = (RunnableManager)this.manager.lookup(RunnableManager.ROLE);
-                    runnableManager.execute(this.threadPoolName, this, STARTUP_DELAY);
-                } finally {
-                    this.manager.release(runnableManager);
-                }
+                this.runnableManager.execute(this.threadPoolName, this, STARTUP_DELAY);
                 if ( this.getLogger().isInfoEnabled() ) {
                     this.getLogger().info("Deployment scanner successfuly started!");
                 }
@@ -204,9 +188,9 @@
     }
 
     /**
-     * @see org.apache.avalon.framework.activity.Startable#stop()
+     * Stop this service.
      */
-    public void stop() throws Exception {
+    protected void stop() {
         if ( this.started ) {
             if ( this.getLogger().isInfoEnabled() ) {
                 this.getLogger().info("Deployment scanner stopped.");

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles?rev=613972&r1=613971&r2=613972&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
Mon Jan 21 11:02:31 2008
@@ -26,11 +26,4 @@
     <role name="org.apache.excalibur.source.SourceFactory/layout"
           default-class="org.apache.cocoon.portal.source.LayoutSourceFactory"/>
 
-  <!--+
-      | Deployment Manager
-      |
-      +-->
-    <role name="org.apache.cocoon.portal.deployment.DeploymentManager"
-          shorthand="portal-deployment-manager"
-          default-class="org.apache.cocoon.portal.deployment.impl.DefaultDeploymentManager"/>
 </role-list>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf?rev=613972&r1=613971&r2=613972&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
Mon Jan 21 11:02:31 2008
@@ -44,16 +44,4 @@
   <!-- We use Castor for persisting/mapping the profiles to XML: -->
   <include src="resource://org/apache/cocoon/portal/persistence/castor/portal-castor.roles"/>
 
-  <!--+
-      | Deployment Manager.
-      +-->
-  <portal-deployment-manager>
-    <!-- Scan the provided directories every minute: -->
-    <scanning-delay>60000</scanning-delay>
-    <!-- Scan the following locations (comma-separated): -->
-    <deployment-sources>config/deploy</deployment-sources>
-    <!-- Turn on/off hot deployment: -->
-    <hot-deployment>true</hot-deployment>
-  </portal-deployment-manager>
- 
 </components>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml?rev=613972&r1=613971&r2=613972&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
Mon Jan 21 11:02:31 2008
@@ -162,4 +162,25 @@
       <!-- Add your aspects here -->
     </portal:profile-manager-aspects>
 
+  <!--+
+      | Deployment Manager.
+      +-->
+    <bean name="org.apache.cocoon.portal.deployment.DeploymentManager"
+          class="org.apache.cocoon.portal.deployment.impl.DefaultDeploymentManager"
+          parent="org.apache.cocoon.portal.util.AbstractBean"
+          scope="singleton">
+        <!-- Scan the following locations: -->
+        <property name="deploymentSources">
+            <list>
+                <value>conf/deploy</value>
+            </list>
+        </property>
+        <!-- Scan the provided directories every minute: -->
+        <property name="scanningDelay" value="60000"/>
+        <!-- Turn on/off hot deployment: -->
+        <property name="hotDeployment" value="true"/>
+        <property name="runnableManager" ref="org.apache.cocoon.thread.RunnableManager"/>
+        <property name="sourceResolver" ref="org.apache.excalibur.source.SourceResolver"/>
+    </bean> 
+
 </beans>



Mime
View raw message