cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r614006 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/deployment/impl/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ cocoon-portal-sample/ cocoon-portal-sample/src/ma...
Date Mon, 21 Jan 2008 20:52:05 GMT
Author: cziegeler
Date: Mon Jan 21 12:52:02 2008
New Revision: 614006

URL: http://svn.apache.org/viewvc?rev=614006&view=rev
Log:
Use files instead of uris for deployment; remove obsolete stuff.

Removed:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/java/
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/java/org/apache/cocoon/portal/profile/PersistenceType.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/pom.xml
    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=614006&r1=614005&r2=614006&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 12:52:02 2008
@@ -16,9 +16,11 @@
  */
 package org.apache.cocoon.portal.deployment.impl;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -30,10 +32,8 @@
 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.AbstractBean;
 import org.apache.cocoon.thread.RunnableManager;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.TraversableSource;
 
 /**
  * This is the default deployment manager scanning a directory for artifacts to deploy.
@@ -46,15 +46,12 @@
  * @version $Id$
  */
 public class DefaultDeploymentManager
-    extends org.apache.cocoon.portal.util.AbstractBean
+    extends AbstractBean
     implements DeploymentManager, Runnable {
 
     /** Wait ten seconds before scanning. */
     protected static final int STARTUP_DELAY = 10 * 1000;
 
-    /** Source resolver. */
-    protected SourceResolver resolver;
-
     /** Runnable manager. */
     protected RunnableManager runnableManager;
 
@@ -71,7 +68,7 @@
     protected long scanningDelay = 60 * 1000;
 
     /** All locations to look for deployable artifacts. */
-    protected String[] deploymentUris = new String[] {"conf/deploy"};
+    protected File[] deploymentSources;
 
     /** These files have been ignored during the last scan. */
     protected final Map failedArtifacts;
@@ -94,10 +91,6 @@
         this.stop();
     }
 
-    public void setSourceResolver(SourceResolver resolver) {
-        this.resolver = resolver;
-    }
-
     public void setRunnableManager(RunnableManager manager) {
         this.runnableManager = manager;
     }
@@ -110,8 +103,8 @@
         this.hotDeployment = flag;
     }
 
-    public void setDeploymentSources(String[] uris) {
-        this.deploymentUris = uris;
+    public void setDeploymentSources(File[] uris) {
+        this.deploymentSources = uris;
     }
 
     public void setThreadPoolName(String name) {
@@ -123,27 +116,20 @@
      */
     protected void testSources()
     throws IOException {
-        if ( this.getLogger().isInfoEnabled() ) {
-            this.getLogger().info("Testing configured deployment sources.");
-        }
-        for (int i = 0; i < this.deploymentUris.length; i++) {
-            Source source = null;
-            try {
-                source = this.resolver.resolveURI(this.deploymentUris[i]);
-                if (!source.exists()) {
-                    this.getLogger().warn("Deployment source '" + source.getURI() +
+        if ( this.deploymentSources != null ) {
+            if ( this.getLogger().isInfoEnabled() ) {
+                this.getLogger().info("Testing configured deployment sources.");
+            }
+            for (int i = 0; i < this.deploymentSources.length; i++) {
+                if (!this.deploymentSources[i].exists()) {
+                    this.getLogger().warn("Deployment source '" + this.deploymentSources[i]
+
                                           "' does not exist. It will be ignored for deployment.");
-                    this.deploymentUris[i] = null;
-                } else if ( !(source instanceof TraversableSource) ) {
-                    this.getLogger().warn("Deployment source '" + source.getURI() +
+                    this.deploymentSources[i] = null;
+                } else if ( !this.deploymentSources[i].isDirectory() ) {
+                    this.getLogger().warn("Deployment source '" + this.deploymentSources[i]
+
                                           "' is not a directory. It will be ignored for deployment.");
-                    this.deploymentUris[i] = null;
-                } else {
-                    // use absolute url
-                    this.deploymentUris[i] = source.getURI();
+                    this.deploymentSources[i] = null;
                 }
-            } finally {
-                this.resolver.release(source);
             }
         }
     }
@@ -173,7 +159,7 @@
      * Start this service in the background.
      */
     protected void start() throws Exception {
-        if ( this.scanningDelay > 0 ) {
+        if ( this.scanningDelay > 0 && this.deploymentSources != null ) {
             if ( this.hotDeployment ) {
                 this.started = true;
                 this.runnableManager.execute(this.threadPoolName, this, STARTUP_DELAY);
@@ -238,43 +224,39 @@
         Collection deploymentArtifacts = this.getAllDeploymentArtifactSources();
         Iterator i = deploymentArtifacts.iterator();
         final List newlyProcessedArtifacts = new ArrayList();
-        try {
-            while ( i.hasNext() ) {
-                // check for new deployment
-                final Source current = (Source)i.next();
-                newlyProcessedArtifacts.add(current.getURI());
-                if (!ignoreSource(current) && !this.deployedArtifacts.contains(current.getURI())
) {
-                    DeploymentStatus status = null;
-                    Exception de = null;
-                    try {
-                        status = this.deploy(current.getURI());
-                    } catch (Exception e) {
-                        de = e;
-                    }
+        while ( i.hasNext() ) {
+            // check for new deployment
+            final File current = (File)i.next();
+            newlyProcessedArtifacts.add(current.getAbsolutePath());
+            if (!ignoreSource(current) && !this.deployedArtifacts.contains(current.getAbsolutePath())
) {
+                DeploymentStatus status = null;
+                Exception de = null;
+                try {
+                    status = this.deploy(current.toURI().toASCIIString());
+                } catch (Exception e) {
+                    de = e;
+                }
 
-                    if ( status != null
-                         && status.getStatus() == DeploymentStatus.STATUS_OKAY )
{
-                        if ( this.getLogger().isInfoEnabled() ) {
-                            this.getLogger().info("Deployed source " + current.getURI());
-                        }
-                        this.deployedArtifacts.add(current.getURI());
+                if ( status != null
+                     && status.getStatus() == DeploymentStatus.STATUS_OKAY ) {
+                    if ( this.getLogger().isInfoEnabled() ) {
+                        this.getLogger().info("Deployed source " + current.getAbsolutePath());
+                    }
+                    this.deployedArtifacts.add(current.getAbsolutePath());
+                } else {
+                    if ( de != null ) {
+                        this.getLogger().error("Failure deploying " + current.getAbsolutePath(),
de);
+                    } else if (status == null
+                               || status.getStatus() == DeploymentStatus.STATUS_EVAL) {
+                        this.getLogger().warn("Unrecognized source: " + current.getAbsolutePath());
                     } else {
-                        if ( de != null ) {
-                            this.getLogger().error("Failure deploying " + current.getURI(),
de);
-                        } else if (status == null
-                                   || status.getStatus() == DeploymentStatus.STATUS_EVAL)
{
-                            this.getLogger().warn("Unrecognized source: " + current.getURI());
-                        } else {
-                            this.getLogger().error("Failure deploying " + current.getURI());
-                        }
-                        this.failedArtifacts.put(current.getURI(), new Long(current.getLastModified()));
+                        this.getLogger().error("Failure deploying " + current.getAbsolutePath());
                     }
+                    this.failedArtifacts.put(current.getAbsolutePath(), new Long(current.lastModified()));
                 }
             }
-        } finally {
-            // release everything
-            this.releaseSources(deploymentArtifacts);
         }
+
         // now check for undeployment
         i = this.deployedArtifacts.iterator();
         while ( i.hasNext() ) {
@@ -308,11 +290,11 @@
         }
     }
 
-    protected boolean ignoreSource(Source source) {
-        Long previousModified = (Long)this.failedArtifacts.get(source.getURI());
+    protected boolean ignoreSource(File source) {
+        Long previousModified = (Long)this.failedArtifacts.get(source.getAbsolutePath());
         if (previousModified != null) {
-            if (previousModified.longValue() != source.getLastModified()) {
-                this.failedArtifacts.remove(source.getURI());
+            if (previousModified.longValue() != source.lastModified()) {
+                this.failedArtifacts.remove(source.getAbsolutePath());
             } else {
                 return true;
             }
@@ -326,42 +308,15 @@
      */
     protected Collection getAllDeploymentArtifactSources() {
         final ArrayList sourceList = new ArrayList();
-        boolean release = true;
-        try {
-            for (int i = 0; i < this.deploymentUris.length; i++) {
-                Source source = null;
-                try {
-                    if ( this.deploymentUris[i] != null ) {
-                        source = this.resolver.resolveURI(this.deploymentUris[i]);
-                        if ( source.exists() && source instanceof TraversableSource
) {
-                            final TraversableSource ts = (TraversableSource)source;
-                            sourceList.addAll(ts.getChildren());
-                        }
-                    }
-                } catch (IOException ioe) {
-                    this.getLogger().warn("Exception during scanning of " + this.deploymentUris[i],
ioe);
-                } finally {
-                    this.resolver.release(source);
+        for (int i = 0; i < this.deploymentSources.length; i++) {
+            if ( this.deploymentSources[i] != null ) {
+                if ( this.deploymentSources[i].exists() && this.deploymentSources[i].isDirectory()
) {
+                    Collections.addAll(sourceList, this.deploymentSources[i].listFiles());
                 }
             }
-            release = false;
-        } finally {
-            // release all sources in case of an error
-            if ( release ) {
-                this.releaseSources(sourceList);
-            }
         }
 
         return sourceList;
-    }
-
-    protected void releaseSources(Collection c) {
-        final Iterator i = c.iterator();
-        while ( i.hasNext() ) {
-            final Source current = (Source)i.next();
-            this.resolver.release(current);
-        }
-        c.clear();
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/PersistenceType.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/PersistenceType.java?rev=614006&r1=614005&r2=614006&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/PersistenceType.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/PersistenceType.java
Mon Jan 21 12:52:02 2008
@@ -21,7 +21,7 @@
 import java.util.Map;
 
 /**
- * This bean describes a persistence type. It is used by the {@link Converter} and
+ * This bean describes a persistence type. It is used by the
  * the {@link ProfileStore} to load and save parts of the portal profile.
  *
  * The correct profile type is specified by a constant. For resolving

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/pom.xml?rev=614006&r1=614005&r2=614006&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/pom.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/pom.xml Mon Jan 21 12:52:02 2008
@@ -47,10 +47,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cocoon</groupId>
-      <artifactId>cocoon-cron-impl</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.cocoon</groupId>
       <artifactId>cocoon-portal-auth-impl</artifactId>
     </dependency>
     <dependency>

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=614006&r1=614005&r2=614006&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 12:52:02 2008
@@ -180,7 +180,6 @@
         <!-- 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