geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r464142 [2/4] - in /geronimo/gbuild/trunk: ./ gbuild-agent/ gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/activemq/ gbuild-agent/src/main/java/org/apache/geronimo/gb...
Date Sun, 15 Oct 2006 07:06:32 GMT
Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java (from r463604, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ContinuumBuildAgent.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ContinuumBuildAgent.java&r1=463604&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/ContinuumBuildAgent.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java Sun Oct 15 00:06:27 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.continuum;
 
 import java.io.File;
 import java.net.InetAddress;
@@ -30,21 +30,35 @@
 import javax.jms.MessageProducer;
 import javax.jms.ObjectMessage;
 
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
 import org.apache.maven.continuum.buildcontroller.BuildController;
 import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.store.ContinuumStore;
 
-import org.apache.geronimo.gbuild.agent.extension.BuildAgentExtentionManager;
 import org.apache.geronimo.gbuild.agent.client.Client;
+import org.apache.geronimo.gbuild.agent.extension.BuildAgentExtentionManager;
 
 /**
+ * Handles executing a build task recieved from the build queue.
+ *
+ * <p>
+ * Custom processing is handled by one or more {@link org.apache.geronimo.gbuild.agent.extension.BuildAgentExtension} instances.
+ * </p>
+ *
  * @version $Rev$ $Date$
  */
-public class ContinuumBuildAgent extends AbstractContinuumBuildAgent {
-
+public class ContinuumBuildAgent
+    extends AbstractContinuumBuildAgent
+    implements Initializable
+{
     public static final String KEY_BUILD_RESULTS = "build-results";
 
+    private Logger log;
+
     /**
      * @plexus.requirement
      */
@@ -83,49 +97,73 @@
     /**
      * @plexus.configuration
      */
-    private String workingDirectory;
+    private File workingDirectory;
 
     /**
      * @plexus.configuration
      */
-    private String buildOutputDirectory;
+    private File buildOutputDirectory;
+
+    public void initialize() throws InitializationException {
+        log = getLogger();
+    }
 
     public void run() {
         try {
-            getLogger().info("Continuum Build Agent starting.");
-            getLogger().debug("buildTaskQueue " + buildTaskQueue);
-            getLogger().debug("buildResultsTopic " + buildResultsTopic);
-            getLogger().debug("workingDirectory " + workingDirectory);
-            getLogger().debug("buildOutputDirectory " + buildOutputDirectory);
-            getLogger().debug("adminAddress " + adminAddress);
-            getLogger().debug("contributor " + contributor);
+            log.info("Running...");
 
+            if (log.isDebugEnabled()) {
+                log.debug("buildTaskQueue: " + buildTaskQueue);
+                log.debug("buildResultsTopic: " + buildResultsTopic);
+                log.debug("workingDirectory: " + workingDirectory);
+                log.debug("buildOutputDirectory: " + buildOutputDirectory);
+                log.debug("adminAddress: " + adminAddress);
+                log.debug("contributor: " + contributor);
+            }
 
-            getLogger().info("Continuum Build Agent started and waiting for work.");
+            log.info("Continuum Build Agent started and waiting for work.");
 
             while (isRunning()) {
                 Client client = getClient();
 
                 try {
                     processMessages(client);
-                } catch (JMSException e) {
-//                    onException(e);
                 }
-            }
+                catch (JMSException e) {
+                    log.error("Failed to process message", e);
 
-        } catch (Exception e) {
-            getLogger().error("Agent failed.", e);
+                    // Sleep for a bit after a failure
+                    Thread.sleep(500);
+                }
+            }
+        }
+        catch (Exception e) {
+            log.error("Agent failed", e);
         }
     }
 
-    private void processMessages(Client client) throws JMSException {
+    private void processMessages(final Client client) throws JMSException {
+        log.debug("Processing messages");
 
-        MessageConsumer buildConsumer = client.createQueueConsumer(buildTaskQueue, getHostName() + " is null");
+        //
+        // FIXME: The message select used here is broke on machines with complex host names... WTF is this for?
+        //
+        // MessageConsumer buildConsumer = client.createQueueConsumer(buildTaskQueue, getHostName() + " is null");
+        
+        MessageConsumer buildConsumer = client.createQueueConsumer(buildTaskQueue);
         MessageProducer resultsProducer = client.createTopicProducer(buildResultsTopic);
-        getLogger().debug("Processing messages.");
 
         while (isRunning() && client.isConnected()) {
+            // log.debug("Trying to rx...");
+
+            //
+            // FIXME: When using a vm:// connection, this is unnessicary
+            //
+
             Message message = buildConsumer.receive(1000);
+
+            // log.debug("Message: " + message);
+            
             if (message instanceof ObjectMessage) {
                 processMessage(message, client, resultsProducer);
             }
@@ -136,18 +174,17 @@
         try {
             InetAddress localHost = InetAddress.getLocalHost();
             return localHost.getHostName();
-        } catch (UnknownHostException e) {
+        }
+        catch (UnknownHostException e) {
             throw new RuntimeException("Unable to get host name.", e);
         }
     }
 
-    private void processMessage(Message message, Client client, MessageProducer resultsProducer) throws JMSException {
+    private void processMessage(final Message message, final Client client, final MessageProducer resultsProducer) throws JMSException {
         try {
-            getLogger().info("Message Received " + message.getJMSMessageID() + " on " + client.getConnection().getClientID() + ":" + buildTaskQueue);
-
-            ObjectMessage objectMessage = (ObjectMessage) message;
+            log.info("Message Received " + message.getJMSMessageID() + " on " + client.getConnection().getClientID() + ":" + buildTaskQueue);
 
-            Map build = getMap(objectMessage, message);
+            Map build = getMapFromMessage(message);
 
             execute(build);
 
@@ -155,36 +192,39 @@
 
             ObjectMessage resultMessage = client.getSession().createObjectMessage(results);
 
-            getLogger().info("Finished processing " + message.getJMSMessageID());
+            log.info("Finished processing: " + message.getJMSMessageID());
 
             resultsProducer.send(resultMessage);
 
-            getLogger().info("Results sent to " + buildResultsTopic);
+            log.info("Results sent to: " + buildResultsTopic);
+        }
+        catch (Exception e) {
+            log.error("Failed processing message: " + message.getJMSMessageID(), e);
 
-        } catch (Exception e) {
-            getLogger().error("Failed Processing message " + message.getJMSMessageID(), e);
             if (e instanceof JMSException){
                 throw (JMSException) e;
             }
         }
     }
 
-    private HashMap getBuildResults(Map build) {
+    private HashMap getBuildResults(final Map build) {
+        assert build != null;
+
         return (HashMap) getObject(build, KEY_BUILD_RESULTS);
     }
 
-    public void execute(Map context) throws Exception {
-
-        ContinuumStore store = getContinuumStore(context);
-
-        ThreadContextContinuumStore.setStore(store);
+    public void execute(final Map context) throws Exception {
+        assert context != null;
+        
+        ContinuumStore store = Context.getContinuumStore(context);
+        log.info("Using store: " + store);
+        
+        ThreadContextContinuumStoreFactory.setStore(store);
 
         init();
 
         int projectId = getProjectId(context);
-
         int buildDefinitionId = getBuildDefinitionId(context);
-
         int trigger = getTrigger(context);
 
         extentionManager.preProcess(context);
@@ -192,50 +232,39 @@
         build(projectId, buildDefinitionId, trigger);
 
         HashMap results = new HashMap();
-
-        context.put(KEY_BUILD_RESULTS, results);
-
-        results.put(KEY_STORE, store);
-
-        results.put(KEY_PROJECT_ID, new Integer(projectId));
-
-        results.put(KEY_BUILD_DEFINITION_ID, new Integer(buildDefinitionId));
-
-        results.put(KEY_TRIGGER, new Integer(trigger));
-
-        setSystemProperty(results, KEY_OS_VERSION);
-
-        setSystemProperty(results, KEY_OS_NAME);
-
-        setSystemProperty(results, KEY_JAVA_VERSION);
-
-        setSystemProperty(results, KEY_JAVA_VENDOR);
+        results.put(Context.KEY_STORE, store);
+        results.put(Context.KEY_PROJECT_ID, new Integer(projectId));
+        results.put(Context.KEY_BUILD_DEFINITION_ID, new Integer(buildDefinitionId));
+        results.put(Context.KEY_TRIGGER, new Integer(trigger));
+
+        setSystemProperty(results, Context.KEY_OS_VERSION);
+        setSystemProperty(results, Context.KEY_OS_NAME);
+        setSystemProperty(results, Context.KEY_JAVA_VERSION);
+        setSystemProperty(results, Context.KEY_JAVA_VENDOR);
 
         InetAddress localHost = InetAddress.getLocalHost();
 
-        results.put(KEY_HOST_NAME, localHost.getHostName());
-
-        results.put(KEY_HOST_ADDRESS, localHost.getHostAddress());
-
-        results.put(KEY_CONTRIBUTOR, contributor);
-
-        results.put(KEY_ADMIN_ADDRESS, adminAddress);
+        results.put(Context.KEY_HOST_NAME, localHost.getHostName());
+        results.put(Context.KEY_HOST_ADDRESS, localHost.getHostAddress());
+        results.put(Context.KEY_CONTRIBUTOR, contributor);
+        results.put(Context.KEY_ADMIN_ADDRESS, adminAddress);
 
+        context.put(KEY_BUILD_RESULTS, results);
+        
         extentionManager.postProcess(context, results);
     }
 
     public void init() throws ConfigurationLoadingException {
         configurationService.load();
-        configurationService.setWorkingDirectory(new File(workingDirectory));
-        configurationService.setBuildOutputDirectory(new File(buildOutputDirectory));
+        configurationService.setWorkingDirectory(workingDirectory);
+        configurationService.setBuildOutputDirectory(buildOutputDirectory);
     }
 
-    public void build(int projectId, int buildDefinitionId, int trigger) {
+    public void build(final int projectId, final int buildDefinitionId, final int trigger) {
         controller.build(projectId, buildDefinitionId, trigger);
     }
 
-    public static void setSystemProperty(Map results, String name) {
+    public static void setSystemProperty(final Map results, final String name) {
         results.put(name, System.getProperty(name));
     }
-
 }

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ContinuumBuildAgent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java (from r463602, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumNotificationDispatcher.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumNotificationDispatcher.java&r1=463602&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumNotificationDispatcher.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java Sun Oct 15 00:06:27 2006
@@ -17,32 +17,44 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.continuum;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 
 /**
+ * A dummy {@link ContinuumNotificationDispatcher} which simply logs events.
+ * 
  * @version $Rev$ $Date$
  */
-public class MockContinuumNotificationDispatcher implements ContinuumNotificationDispatcher {
-
-    public void buildStarted(Project project) {
+public class LoggingContinuumNotificationDispatcher
+    extends AbstractLogEnabled
+    implements ContinuumNotificationDispatcher
+{
+    public void buildStarted(final Project project) {
+        getLogger().info("Build started: " + project);
     }
 
-    public void checkoutStarted(Project project) {
+    public void checkoutStarted(final Project project) {
+        getLogger().info("Checkout started: " + project);
     }
 
-    public void checkoutComplete(Project project) {
+    public void checkoutComplete(final Project project) {
+        getLogger().info("Checkout complete: " + project);
     }
 
-    public void runningGoals(Project project, BuildResult build) {
+    public void runningGoals(final Project project, final BuildResult build) {
+        getLogger().info("Running goals: " + project + "; result: " + build);
     }
 
-    public void goalsCompleted(Project project, BuildResult build) {
+    public void goalsCompleted(final Project project, final BuildResult build) {
+        getLogger().info("Goals completed: " + project + "; result: " + build);
     }
 
-    public void buildComplete(Project project, BuildResult build) {
+    public void buildComplete(final Project project, final BuildResult build) {
+        getLogger().info("Build complete: " + project + "; result: " + build);
     }
 }

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/LoggingContinuumNotificationDispatcher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java (from r463602, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MapContinuumStore.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MapContinuumStore.java&r1=463602&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MapContinuumStore.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java Sun Oct 15 00:06:27 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.continuum;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -31,48 +31,71 @@
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
 /**
+ * A {@link org.apache.maven.continuum.store.ContinuumStore} backed up by a map.
+ *
+ * <p>
+ * This is used with the {@link ThreadContextContinuumStoreFactory} to configure Continuum to use
+ * store details from build task message.
+ * </p>
+ * 
  * @version $Rev$ $Date$
  */
-public class MapContinuumStore extends MockContinuumStore implements Serializable {
-
+public class MapContinuumStore
+    extends MockContinuumStore
+    implements Serializable
+{
     private final Map store = new HashMap();
 
-    public Project getProjectWithBuildDetails(int projectId) throws ContinuumStoreException {
+    public String toString() {
+        return store.toString();    
+    }
+
+    public Project getProjectWithBuildDetails(final int projectId) throws ContinuumStoreException {
+        return getProject(projectId);
+    }
+
+    public Project getProjectWithAllDetails(final int projectId) throws ContinuumStoreException {
         return getProject(projectId);
     }
 
-    public Project getProject(int projectId) throws ContinuumStoreException {
+    public Project getProject(final int projectId) throws ContinuumStoreException {
         return (Project) getObjectById(Project.class, projectId);
     }
 
-    public void updateProject(Project project) throws ContinuumStoreException {
+    public void updateProject(final Project project) throws ContinuumStoreException {
+        assert project != null;
+
         updateObject(project, project.getId());
     }
 
-    public BuildResult getBuildResult(int buildId) throws ContinuumStoreException {
+    public BuildResult getBuildResult(final int buildId) throws ContinuumStoreException {
         return (BuildResult) getObjectById(BuildResult.class, buildId);
     }
 
-    public void updateBuildResult(BuildResult build) throws ContinuumStoreException {
+    public void updateBuildResult(final BuildResult build) throws ContinuumStoreException {
+        assert build != null;
+
         updateObject(build, build.getId());
     }
 
-    public void addBuildResult(Project project, BuildResult build) throws ContinuumStoreException {
+    public void addBuildResult(final Project project, final BuildResult build) throws ContinuumStoreException {
+        assert project != null;
+        assert build != null;
+
         updateObject(build, build.getId());
 
         project.setLatestBuildId(build.getId());
-
         project.setState(build.getState());
-
         project.addBuildResult(build);
     }
 
-    public BuildDefinition getBuildDefinition(int buildDefinitionId) throws ContinuumStoreException {
+    public BuildDefinition getBuildDefinition(final int buildDefinitionId) throws ContinuumStoreException {
         return (BuildDefinition) getObjectById(BuildDefinition.class, buildDefinitionId);
     }
 
-    public BuildDefinition storeBuildDefinition(BuildDefinition buildDefinition)
-            throws ContinuumStoreException {
+    public BuildDefinition storeBuildDefinition(final BuildDefinition buildDefinition) throws ContinuumStoreException {
+        assert buildDefinition != null;
+
         updateObject(buildDefinition, buildDefinition.getId());
 
         return buildDefinition;
@@ -82,34 +105,39 @@
         return (SystemConfiguration) getMap(SystemConfiguration.class).get(new Integer(0));
     }
 
-    public SystemConfiguration addSystemConfiguration(SystemConfiguration systemConf) {
+    public SystemConfiguration addSystemConfiguration(final SystemConfiguration systemConf) {
+        assert systemConf != null;
+
         updateObject(systemConf, 0);
         return systemConf;
     }
 
-    private void updateObject(Object object, int id) {
+    private void updateObject(final Object object, final int id) {
+        assert object != null;
+
         Map map = getMap(object.getClass());
 
         map.put(new Integer(id), object);
     }
 
-    private Object getObjectById(Class clazz, int id) throws ContinuumStoreException {
+    private Object getObjectById(final Class clazz, final int id) throws ContinuumStoreException {
+        assert clazz != null;
+
         Map map = getMap(clazz);
 
         Object objectId = new Integer(id);
-
         Object object = map.get(objectId);
 
         if (object == null) {
-
             throw new ContinuumObjectNotFoundException(clazz.getName(), Integer.toString(id));
-
         }
 
         return object;
     }
 
-    private Map getMap(Class type) {
+    private Map getMap(final Class type) {
+        assert type != null;
+
         synchronized (store) {
             Map map = (Map) store.get(type);
             if (map == null) {

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MapContinuumStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java (from r463602, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumStore.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumStore.java&r1=463602&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/MockContinuumStore.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java Sun Oct 15 00:06:27 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.continuum;
 
 import java.util.Collection;
 import java.util.List;
@@ -35,283 +35,315 @@
 import org.apache.maven.continuum.model.system.Permission;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.model.system.UserGroup;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
 /**
+ * A {@link ContinuumStore} which will throw a {@link UnsupportedOperationException} for all methods.
+ *
+ * <p>
+ * This is a helper to implement custom stores.
+ * </p>
+ * 
  * @version $Rev$ $Date$
  */
-public class MockContinuumStore implements ContinuumStore {
+public class MockContinuumStore
+    implements ContinuumStore
+{
+    public Project getProjectByName(String string) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void removeNotifier(ProjectNotifier projectNotifier) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
+    }
 
-    public Project getProjectByName(String name) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectByName not implemented");
+    public ProjectNotifier storeNotifier(ProjectNotifier projectNotifier) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public void removeNotifier(ProjectNotifier notifier) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method removeNotifier not implemented");
+    public Map getDefaultBuildDefinitions() {
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectNotifier storeNotifier(ProjectNotifier notifier) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method storeNotifier not implemented");
+    public BuildDefinition getDefaultBuildDefinition(int i) {
+        throw new UnsupportedOperationException();
     }
 
-    public BuildDefinition getBuildDefinition(int buildDefinitionId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getBuildDefinition not implemented");
+    public BuildDefinition getBuildDefinition(int i) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
     public void removeBuildDefinition(BuildDefinition buildDefinition) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method removeBuildDefinition not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public BuildDefinition storeBuildDefinition(BuildDefinition buildDefinition) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method storeBuildDefinition not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectGroup addProjectGroup(ProjectGroup group) {
-        throw new UnsupportedOperationException("Method addProjectGroup not implemented");
+    public ProjectGroup addProjectGroup(ProjectGroup projectGroup) {
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectGroup getProjectGroup(int projectGroupId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectGroup not implemented");
+    public ProjectGroup getProjectGroup(int i) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
-    public void updateProjectGroup(ProjectGroup group) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateProjectGroup not implemented");
+    public void updateProjectGroup(ProjectGroup projectGroup) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
     public Collection getAllProjectGroupsWithProjects() {
-        throw new UnsupportedOperationException("Method getAllProjectGroupsWithProjects not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public List getAllProjectsByName() {
-        throw new UnsupportedOperationException("Method getAllProjectsByName not implemented");
+        throw new UnsupportedOperationException();
+    }
+
+    public List getAllProjectsByNameWithDependencies() {
+        throw new UnsupportedOperationException();
+    }
+
+    public List getAllProjectsByNameWithBuildDetails() {
+        throw new UnsupportedOperationException();
     }
 
     public List getAllSchedulesByName() {
-        throw new UnsupportedOperationException("Method getAllSchedulesByName not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public Schedule addSchedule(Schedule schedule) {
-        throw new UnsupportedOperationException("Method addSchedule not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public Schedule getScheduleByName(String name) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getScheduleByName not implemented");
+    public Schedule getScheduleByName(String string) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
     public Schedule storeSchedule(Schedule schedule) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method storeSchedule not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public List getAllProfilesByName() {
-        throw new UnsupportedOperationException("Method getAllProfilesByName not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public Profile addProfile(Profile profile) {
-        throw new UnsupportedOperationException("Method addProfile not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public Installation addInstallation(Installation installation) {
-        throw new UnsupportedOperationException("Method addInstallation not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public List getAllInstallations() {
-        throw new UnsupportedOperationException("Method getAllInstallations not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public List getAllBuildsForAProjectByDate(int projectId) {
-        throw new UnsupportedOperationException("Method getAllBuildsForAProjectByDate not implemented");
+    public List getAllBuildsForAProjectByDate(int i) {
+        throw new UnsupportedOperationException();
     }
 
-    public Project getProject(int projectId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProject not implemented");
+    public Project getProject(int i) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Map getProjectIdsAndBuildDefinitionsIdsBySchedule(int i) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
     public void updateProject(Project project) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateProject not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public void updateProfile(Profile profile) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateProfile not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public void updateSchedule(Schedule schedule) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateSchedule not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public Project getProjectWithBuilds(int projectId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectWithBuilds not implemented");
+    public Project getProjectWithBuilds(int i) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
     public void removeProfile(Profile profile) {
-        throw new UnsupportedOperationException("Method removeProfile not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public void removeSchedule(Schedule schedule) {
-        throw new UnsupportedOperationException("Method removeSchedule not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public Project getProjectWithCheckoutResult(int projectId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectWithCheckoutResult not implemented");
+    public Project getProjectWithCheckoutResult(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public BuildResult getBuildResult(int buildId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getBuildResult not implemented");
+    public BuildResult getBuildResult(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
     public void removeProject(Project project) {
-        throw new UnsupportedOperationException("Method removeProject not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public void removeProjectGroup(ProjectGroup projectGroup) {
-        throw new UnsupportedOperationException("Method removeProjectGroup not implemented");
+        throw new UnsupportedOperationException();
+    }
+
+    public ProjectGroup getProjectGroupWithBuildDetails(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectGroup getProjectGroupWithBuildDetails(int projectGroupId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectGroupWithBuildDetails not implemented");
+    public ProjectGroup getProjectGroupWithProjects(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
     public List getAllProjectGroupsWithBuildDetails() {
-        throw new UnsupportedOperationException("Method getAllProjectGroupsWithBuildDetails not implemented");
+        throw new UnsupportedOperationException();
     }
 
     public List getAllProjectsWithAllDetails() {
-        throw new UnsupportedOperationException("Method getAllProjectsWithAllDetails not implemented");
+        throw new UnsupportedOperationException();
     }
 
-    public Project getProjectWithAllDetails(int projectId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectWithAllDetails not implemented");
+    public Project getProjectWithAllDetails(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Schedule getSchedule(int scheduleId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getSchedule not implemented");
+    public Schedule getSchedule(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Profile getProfile(int profileId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProfile not implemented");
+    public Profile getProfile(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectGroup getProjectGroupByGroupId(String groupId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectGroupByGroupId not implemented");
+    public ProjectGroup getProjectGroupByGroupId(String string) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
-    public BuildResult getLatestBuildResultForProject(int projectId) {
-        throw new UnsupportedOperationException("Method getLatestBuildResultForProject not implemented");
+    public ProjectGroup getProjectGroupByGroupIdWithProjects(String string) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
-    public void addBuildResult(Project project, BuildResult build) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method addBuildResult not implemented");
+    public BuildResult getLatestBuildResultForProject(int i) {
+        throw new UnsupportedOperationException();
     }
 
-    public void updateBuildResult(BuildResult build) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateBuildResult not implemented");
+    public List getBuildResultsForProject(int i, long l) {
+        throw new UnsupportedOperationException();
     }
 
-    public Project getProjectWithBuildDetails(int projectId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectWithBuildDetails not implemented");
+    public Map getLatestBuildResults() {
+        throw new UnsupportedOperationException();
     }
 
-    public ProjectGroup getDefaultProjectGroup() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getDefaultProjectGroup not implemented");
+    public List getBuildResultByBuildNumber(int i, int i1) {
+        throw new UnsupportedOperationException();
     }
 
-    public SystemConfiguration addSystemConfiguration(SystemConfiguration systemConf) {
-        throw new UnsupportedOperationException("Method addSystemConfiguration not implemented");
+    public Map getBuildResultsInSuccess() {
+        throw new UnsupportedOperationException();
     }
 
-    public void updateSystemConfiguration(SystemConfiguration systemConf) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateSystemConfiguration not implemented");
+    public void addBuildResult(Project project, BuildResult buildResult) throws ContinuumStoreException, ContinuumObjectNotFoundException {
+        throw new UnsupportedOperationException();
     }
 
-    public SystemConfiguration getSystemConfiguration() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getSystemConfiguration not implemented");
+    public void updateBuildResult(BuildResult buildResult) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public ContinuumUser addUser(ContinuumUser user) {
-        throw new UnsupportedOperationException("Method addUser not implemented");
+    public Project getProjectWithBuildDetails(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public void updateUser(ContinuumUser user) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateUser not implemented");
+    public ProjectGroup getDefaultProjectGroup() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public ContinuumUser getUser(int userId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getUser not implemented");
+    public SystemConfiguration addSystemConfiguration(SystemConfiguration systemConfiguration) {
+        throw new UnsupportedOperationException();
     }
 
-    public ContinuumUser getGuestUser() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getGuestUser not implemented");
+    public void updateSystemConfiguration(SystemConfiguration systemConfiguration) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public List getUsers() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getUsers not implemented");
+    public SystemConfiguration getSystemConfiguration() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public ContinuumUser getUserByUsername(String username) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getUserByUsername not implemented");
+    public ContinuumUser addUser(ContinuumUser continuumUser) {
+        throw new UnsupportedOperationException();
     }
 
-    public void removeUser(ContinuumUser user) {
-        throw new UnsupportedOperationException("Method removeUser not implemented");
+    public void updateUser(ContinuumUser continuumUser) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public List getPermissions() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getPermissions not implemented");
+    public ContinuumUser getUser(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Permission getPermission(String name) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getPermission not implemented");
+    public ContinuumUser getGuestUser() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Permission addPermission(Permission perm) {
-        throw new UnsupportedOperationException("Method addPermission not implemented");
+    public List getUsers() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public UserGroup addUserGroup(UserGroup group) {
-        throw new UnsupportedOperationException("Method addUserGroup not implemented");
+    public ContinuumUser getUserByUsername(String string) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public void updateUserGroup(UserGroup group) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method updateUserGroup not implemented");
+    public void removeUser(ContinuumUser continuumUser) {
+        throw new UnsupportedOperationException();
     }
 
-    public List getUserGroups() throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getUserGroups not implemented");
+    public List getPermissions() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public UserGroup getUserGroup(int userGroupId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getUserGroup not implemented");
+    public Permission getPermission(String string) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public UserGroup getUserGroup(String name) {
-        throw new UnsupportedOperationException("Method getUserGroup not implemented");
+    public Permission addPermission(Permission permission) {
+        throw new UnsupportedOperationException();
     }
 
-    public void removeUserGroup(UserGroup group) {
-        throw new UnsupportedOperationException("Method removeUserGroup not implemented");
+    public UserGroup addUserGroup(UserGroup userGroup) {
+        throw new UnsupportedOperationException();
     }
 
-    public Map getDefaultBuildDefinitions() {
-        throw new UnsupportedOperationException("Method getDefaultBuildDefinitions not implemented");
+    public void updateUserGroup(UserGroup userGroup) throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public BuildDefinition getDefaultBuildDefinition(int projectId) {
-        throw new UnsupportedOperationException("Method getDefaultBuildDefinition not implemented");
+    public List getUserGroups() throws ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Map getProjectIdsAndBuildDefinitionIdsBySchedule(int scheduleId) throws ContinuumStoreException {
-        throw new UnsupportedOperationException("Method getProjectIdsAndBuildDefinitionIdsBySchedule not implemented");
+    public UserGroup getUserGroup(int i) throws ContinuumObjectNotFoundException, ContinuumStoreException {
+        throw new UnsupportedOperationException();
     }
 
-    public Map getLatestBuildResults() {
-        throw new UnsupportedOperationException("Method getLatestBuildResults not implemented");
+    public UserGroup getUserGroup(String string) {
+        throw new UnsupportedOperationException();
     }
 
-    public List getBuildResultByBuildNumber(int projectId, int buildNumber) {
-        throw new UnsupportedOperationException("Method getBuildResultByBuildNumber not implemented");
+    public void removeUserGroup(UserGroup userGroup) {
+        throw new UnsupportedOperationException();
     }
 
-    public Map getBuildResultsInSuccess() {
-        throw new UnsupportedOperationException("Method getBuildResultsInSuccess not implemented");
+    public void closeStore() {
+        throw new UnsupportedOperationException();
     }
 }

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/MockContinuumStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java?view=auto&rev=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java (added)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java Sun Oct 15 00:06:27 2006
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gbuild.agent.continuum;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.factory.AbstractComponentFactory;
+import org.codehaus.plexus.component.factory.ComponentInstantiationException;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.maven.continuum.store.ContinuumStore;
+
+/**
+ * Creates {@link ContinuumStore} instances which will delegate to the store in the current thread context
+ * set by {@link #setStore}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ThreadContextContinuumStoreFactory
+    extends AbstractComponentFactory
+{
+    private static final Log log = LogFactory.getLog(ThreadContextContinuumStoreFactory.class);
+
+    private static ThreadLocal stores = new ThreadLocal();
+
+    public static ContinuumStore getStore() {
+        ContinuumStore store = (ContinuumStore) stores.get();
+        if (store == null) {
+            throw new IllegalStateException("Not store found for the current thread");
+        }
+
+        return store;
+    }
+
+    public static void setStore(final ContinuumStore store) {
+        assert store != null;
+
+        stores.set(store);
+    }
+
+    //
+    // ComponentFactory
+    //
+
+    public Object newInstance(final ComponentDescriptor descriptor, final ClassRealm realm, final PlexusContainer container)
+        throws ComponentInstantiationException
+    {
+        assert descriptor != null;
+        assert realm != null;
+        assert container != null;
+
+        InvocationHandler handler = new InvocationHandler() {
+            public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+                Object target;
+
+                if (method.getDeclaringClass() == Object.class) {
+                    target = this;
+                }
+                else {
+                    target = getStore();
+                }
+
+                try {
+                    Object result = method.invoke(target, args);
+
+                    if (log.isTraceEnabled()) {
+                        String sig = method.getName() + "(" + (args != null ? Arrays.asList(args).toString() : "") + ")";
+                        if (method.getReturnType() == Void.TYPE) {
+                            log.trace(sig);
+                        }
+                        else {
+                            log.trace(sig + ": " + result);
+                        }
+                    }
+
+                    return result;
+                }
+                catch (InvocationTargetException e) {
+                    throw e.getTargetException();
+                }
+            }
+        };
+
+        try {
+            ClassLoader cl = ContinuumStore.class.getClassLoader();
+            return Proxy.newProxyInstance(cl, new Class[] { ContinuumStore.class }, handler);
+        }
+        catch (Exception e) {
+            throw new ComponentInstantiationException("Could not instanciate component: " + descriptor.getHumanReadableKey(), e);
+        }
+    }
+}

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/continuum/ThreadContextContinuumStoreFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtension.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtension.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtension.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtension.java Sun Oct 15 00:06:27 2006
@@ -22,14 +22,15 @@
 import java.util.Map;
 
 /**
+ * Allows custom processing of build tasks.
+ * 
  * @version $Rev$ $Date$
  */
-public interface BuildAgentExtension {
-
+public interface BuildAgentExtension
+{
     String ROLE = BuildAgentExtension.class.getName();
 
     void preProcess(Map build);
 
     void postProcess(Map build, Map results);
-    
 }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionManager.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionManager.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionManager.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionManager.java Sun Oct 15 00:06:27 2006
@@ -23,10 +23,12 @@
 import java.util.Map;
 
 /**
+ * Manages the set of configured {@link BuildAgentExtension} instances.
+ * 
  * @version $Rev$ $Date$
  */
-public interface BuildAgentExtentionManager {
-
+public interface BuildAgentExtentionManager
+{
     String ROLE = BuildAgentExtentionManager.class.getName();
 
     BuildAgentExtension getBuildAgentExtention(String id) throws NoSuchExtentionException;

Added: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java?view=auto&rev=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java (added)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java Sun Oct 15 00:06:27 2006
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gbuild.agent.extension;
+
+import java.util.Map;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+/**
+ * Support for {@link BuildAgentExtension} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuildAgentExtentionSupport
+    extends AbstractLogEnabled
+    implements BuildAgentExtension, Initializable
+{
+    protected Logger log;
+
+    public void initialize() throws InitializationException {
+        log = getLogger();
+    }
+
+    public void preProcess(final Map build) {
+        // empty
+    }
+
+    public void postProcess(final Map build, final Map results) {
+        // empty
+    }
+}

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildAgentExtentionSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtension.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtension.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtension.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtension.java Sun Oct 15 00:06:27 2006
@@ -22,12 +22,13 @@
 import java.util.Map;
 
 /**
+ * Allows custom processing of build results.
+ * 
  * @version $Rev$ $Date$
  */
-public interface BuildResultsExtension {
-
+public interface BuildResultsExtension
+{
     String ROLE = BuildResultsExtension.class.getName();
 
     void execute(Map context) throws java.lang.Exception;
-
 }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionManager.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionManager.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionManager.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionManager.java Sun Oct 15 00:06:27 2006
@@ -22,14 +22,15 @@
 import java.util.Map;
 
 /**
+ * Manages the set of configured {@link BuildResultsExtension} instances.
+ * 
  * @version $Rev$ $Date$
  */
-public interface BuildResultsExtensionManager {
-
+public interface BuildResultsExtensionManager
+{
     String ROLE = BuildResultsExtensionManager.class.getName();
 
     BuildResultsExtension getBuildResultsExtention(String id) throws NoSuchExtentionException;
 
     void execute(Map results) throws Exception;
-
 }

Added: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java?view=auto&rev=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java (added)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java Sun Oct 15 00:06:27 2006
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gbuild.agent.extension;
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+/**
+ * Support for {@link BuildResultsExtensionSupport} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuildResultsExtensionSupport
+    extends AbstractLogEnabled
+    implements BuildResultsExtension, Initializable
+{
+    protected Logger log;
+
+    public void initialize() throws InitializationException {
+        log = getLogger();
+    }
+}

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/BuildResultsExtensionSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildAgentExtensionManager.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildAgentExtensionManager.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildAgentExtensionManager.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildAgentExtensionManager.java Sun Oct 15 00:06:27 2006
@@ -26,72 +26,70 @@
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 /**
+ * Provides the default behavior of a {@link BuildAgentExtentionManager}.
+ *
  * @version $Rev$ $Date$
  */
-public class DefaultBuildAgentExtensionManager extends AbstractLogEnabled implements BuildAgentExtentionManager
+public class DefaultBuildAgentExtensionManager
+    extends AbstractLogEnabled
+    implements BuildAgentExtentionManager
 {
-
     /**
      * @plexus.requirement
      */
     private Map extentions;
 
-    public BuildAgentExtension getBuildAgentExtention(String id) throws NoSuchExtentionException {
+    public BuildAgentExtension getBuildAgentExtention(final String id) throws NoSuchExtentionException {
+        assert id != null;
 
         BuildAgentExtension agentExtension = (BuildAgentExtension) extentions.get(id);
 
         if (agentExtension == null){
             throw new NoSuchExtentionException(id);
         }
+
         return agentExtension;
     }
 
-    public void postProcess(Map build, HashMap results) {
-
-        for (Iterator iterator = extentions.entrySet().iterator(); iterator.hasNext();) {
-
-            Map.Entry entry = (Map.Entry) iterator.next();
+    public void preProcess(final Map build) {
+        assert build != null;
 
+        Iterator iter = extentions.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry entry = (Map.Entry) iter.next();
             String name = (String) entry.getKey();
 
             BuildAgentExtension extension = (BuildAgentExtension) entry.getValue();
 
-            getLogger().info("Executing extention "+name +" post process");
+            getLogger().info("Executing extention " + name + " pre process");
 
             try {
-
-                extension.postProcess(build, results);
-
+                extension.preProcess(build);
             } catch (Exception e) {
-
-                getLogger().warn("Extention Failed: "+name, e);
-
+                getLogger().warn("Extention Failed: " + name, e);
             }
         }
     }
-
-    public void preProcess(Map build) {
-
-        for (Iterator iterator = extentions.entrySet().iterator(); iterator.hasNext();) {
-
-            Map.Entry entry = (Map.Entry) iterator.next();
-
+    
+    public void postProcess(final Map build, final HashMap results) {
+        assert build != null;
+        assert results != null;
+
+        Iterator iter = extentions.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry entry = (Map.Entry) iter.next();
             String name = (String) entry.getKey();
 
             BuildAgentExtension extension = (BuildAgentExtension) entry.getValue();
 
-            getLogger().info("Executing extention "+name +" pre process");
+            getLogger().info("Executing extention " + name + " post process");
 
             try {
-
-                extension.preProcess(build);
-
-            } catch (Exception e) {
-
-                getLogger().warn("Extention Failed: "+name, e);
-
+                extension.postProcess(build, results);
+            }
+            catch (Exception e) {
+                getLogger().warn("Extention Failed: " + name, e);
             }
         }
     }
-
 }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildResultsExtensionManager.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildResultsExtensionManager.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildResultsExtensionManager.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/DefaultBuildResultsExtensionManager.java Sun Oct 15 00:06:27 2006
@@ -25,44 +25,48 @@
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 /**
+ * Provides the default behavior of a {@link BuildResultsExtensionManager}.
+ *
  * @version $Rev$ $Date$
  */
-public class DefaultBuildResultsExtensionManager extends AbstractLogEnabled implements BuildResultsExtensionManager
+public class DefaultBuildResultsExtensionManager
+    extends AbstractLogEnabled
+    implements BuildResultsExtensionManager
 {
-
     /**
      * @plexus.requirement
      */
     private Map extentions;
 
     public BuildResultsExtension getBuildResultsExtention(String id) throws NoSuchExtentionException {
+        assert id != null;
+        
         BuildResultsExtension agentExtension = (BuildResultsExtension) extentions.get(id);
 
         if (agentExtension == null){
             throw new NoSuchExtentionException(id);
         }
+
         return agentExtension;
     }
 
-    public void execute(Map results) throws Exception {
-        for (Iterator iterator = extentions.entrySet().iterator(); iterator.hasNext();) {
-
-            Map.Entry entry = (Map.Entry) iterator.next();
+    public void execute(final Map results) throws Exception {
+        assert results != null;
 
+        Iterator iter = extentions.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry entry = (Map.Entry) iter.next();
             String name = (String) entry.getKey();
 
             BuildResultsExtension extension = (BuildResultsExtension) entry.getValue();
 
-            getLogger().info("Executing extention "+name);
+            getLogger().info("Executing extention: " + name);
 
             try {
-
                 extension.execute(results);
-
-            } catch (Exception e) {
-
-                getLogger().warn("Extention Failed: "+name, e);
-
+            }
+            catch (Exception e) {
+                getLogger().warn("Extention Failed: " + name, e);
             }
         }
     }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/NoSuchExtentionException.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/NoSuchExtentionException.java?view=diff&rev=464142&r1=464141&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/NoSuchExtentionException.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/extension/NoSuchExtentionException.java Sun Oct 15 00:06:27 2006
@@ -20,12 +20,14 @@
 package org.apache.geronimo.gbuild.agent.extension;
 
 /**
+ * Thrown to indicate that a requested extention was not found.
+ * 
  * @version $Rev$ $Date$
  */
-public class NoSuchExtentionException extends Exception {
-
-    public NoSuchExtentionException(String id) {
+public class NoSuchExtentionException
+    extends Exception
+{
+    public NoSuchExtentionException(final String id) {
         super(id);
     }
-
 }

Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java (from r463604, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/BuildQueueReloader.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/BuildQueueReloader.java&r1=463604&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/BuildQueueReloader.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java Sun Oct 15 00:06:27 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.producer;
 
 import java.io.File;
 import java.util.Enumeration;
@@ -27,6 +27,9 @@
 import javax.jms.Session;
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
@@ -35,38 +38,47 @@
 import org.apache.geronimo.gbuild.agent.client.ClientManager;
 
 /**
+ * Reloads the build queue if the queue is currently empty.
+ *
+ * <p>
+ * Does not really reload, but instead touches the build task files so that the
+ * build producer will requeue the tasks.
+ * </p>
+ *
  * @version $Rev$ $Date$
  */
-public class BuildQueueReloader extends AbstractLogEnabled implements Startable, Runnable {
+public class BuildQueueReloader
+    extends AbstractLogEnabled
+    implements Initializable, Startable, Runnable
+{
+    private Logger log;
 
-    /**
-     * @plexus.requirement
-     */
     private ClientManager clientManager;
 
-    /**
-     * @plexus.configuration
-     */
     private String buildTaskQueue;
 
-    /**
-     * @plexus.configuration
-     */
-    private String tasksDirectory;
+    private File tasksDirectory;
 
     /**
-     * @plexus.configuration
+     * The interval to poll the build queue to see if its empty; in minutes.
      */
     private int pollInterval;
 
-
     private boolean running;
 
+    //
+    // Initializable
+    //
+
+    public void initialize() throws InitializationException {
+        log = getLogger();
+    }
+
     public synchronized boolean isRunning() {
         return running;
     }
 
-    public synchronized void setRunning(boolean running) {
+    public synchronized void setRunning(final boolean running) {
         this.running = running;
     }
 
@@ -84,24 +96,30 @@
     public void run() {
         while (isRunning()) {
             checkTasksQueue();
+
             try {
-                Thread.sleep(pollInterval*60000);
-            } catch (InterruptedException dontCare) {}
+                Thread.sleep(pollInterval * 60000);
+            }
+            catch (InterruptedException ignore) {
+                // empty
+            }
         }
     }
 
     private void checkTasksQueue() {
         if (isEmpty()){
-            getLogger().info(buildTaskQueue+" empty");
+            log.info(buildTaskQueue + " empty");
             long now = System.currentTimeMillis();
 
-            File dir = new File(tasksDirectory);
-            File[] files = dir.listFiles();
+            log.info("Checking for tasks in: " + tasksDirectory);
+            
+            File[] files = tasksDirectory.listFiles();
+
             for (int i = 0; i < files.length; i++) {
                 File file = files[i];
-                if (file.getName().endsWith("properties")) {
-                    getLogger().info("Touching file "+file.getName());
 
+                if (file.getName().endsWith("properties")) {
+                    log.info("Touching file " + file);
                     file.setLastModified(now);
                 }
             }
@@ -117,9 +135,9 @@
             QueueBrowser browser = session.createBrowser(queue);
 
             Enumeration enumeration = browser.getEnumeration();
-            boolean empty = !enumeration.hasMoreElements();
-            return empty;
-        } catch (JMSException e) {
+            return !enumeration.hasMoreElements();
+        }
+        catch (JMSException e) {
             throw (IllegalStateException)new IllegalStateException("JMS Failure").initCause(e);
         }
     }

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/BuildQueueReloader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java (from r463602, geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/DirectoryMonitor.java)
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java?view=diff&rev=464142&p1=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/DirectoryMonitor.java&r1=463602&p2=geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java&r2=464142
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/DirectoryMonitor.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java Sun Oct 15 00:06:27 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gbuild.agent;
+package org.apache.geronimo.gbuild.agent.producer;
 
 import java.io.File;
 import java.io.Serializable;
@@ -30,37 +30,29 @@
 import org.codehaus.plexus.logging.Logger;
 
 /**
+ * Monitors file activity under a directory.
+ *
  * @version $Rev$ $Date$
  */
-public class DirectoryMonitor extends AbstractLogEnabled implements Runnable {
-
-    public interface Listener {
-        /**
-         * @return true if the addition was processed successfully.  If not
-         *         the file will be added again next time it changes.
-         */
-        boolean fileAdded(File file);
-
-        /**
-         * @return true if the removal was processed successfully.  If not
-         *         the file will be removed again on the next pass.
-         */
-        boolean fileRemoved(File file);
-
-        void fileUpdated(File file);
-    }
-
-    private boolean run = false;
+public class DirectoryMonitor
+    extends AbstractLogEnabled
+    implements Runnable
+{
+    private boolean run;
+    
     private int pollIntervalMillis;
+
     private File directory;
+
     private Listener listener;
+
     private Map files = new HashMap();
 
-    public DirectoryMonitor(File directory, Listener listener, int pollIntervalMillis, Logger logger) {
-        assert listener == null: "No point in scanning without a listener.";
-        assert directory.isDirectory(): "File specified is not a directory. " + directory.getAbsolutePath();
-        assert directory.canRead(): "Directory specified cannot be read. " + directory.getAbsolutePath();
-        assert pollIntervalMillis > 0: "Poll Interval must be above zero.";
+    public DirectoryMonitor(final File directory, final Listener listener, final int pollIntervalMillis, final Logger logger) {
+        assert listener == null : "No point in scanning without a listener.";
+        assert directory.isDirectory() : "File specified is not a directory. " + directory.getAbsolutePath();
+        assert directory.canRead() : "Directory specified cannot be read. " + directory.getAbsolutePath();
+        assert pollIntervalMillis > 0 : "Poll Interval must be above zero.";
 
         this.directory = directory;
         this.listener = listener;
@@ -88,27 +80,32 @@
         this.run = false;
     }
 
-
     public void run() {
         run = true;
         initialize();
-        getLogger().debug("Scanner running.  Polling every "+pollIntervalMillis+ " milliseconds.");
+
+        getLogger().debug("Scanner running.  Polling every " + pollIntervalMillis + " milliseconds.");
+
         while (run) {
             try {
                 scanDirectory();
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 getLogger().error("Scan failed.", e);
             }
 
             try {
                 Thread.sleep(pollIntervalMillis);
-            } catch (InterruptedException e) {
+            }
+            catch (InterruptedException ignore) {
+                // empty
             }
         }
     }
 
     public void initialize() {
-        getLogger().debug("Doing initial scan of "+directory.getAbsolutePath());
+        getLogger().debug("Doing initial scan of " + directory.getAbsolutePath());
+
         File parent = directory;
         File[] children = parent.listFiles();
 
@@ -145,7 +142,7 @@
             missingFilesList.remove(child.getAbsolutePath());
 
             if (!child.canRead()) {
-                getLogger().debug("not readable "+ child.getName());
+                getLogger().debug("not readable " + child.getName());
                 continue;
             }
 
@@ -154,39 +151,36 @@
 
             newStatus.diff(oldStatus);
 
-            if ( oldStatus == null ) {
-
+            if (oldStatus == null) {
                 // Brand new, but assume it's changing and
                 // wait a bit to make sure it's not still changing
                 getLogger().debug("File Discovered: " + newStatus);
-
-            } else if ( newStatus.isChanging() ) {
-
+            }
+            else if (newStatus.isChanging()) {
                 // The two records are different -- record the latest as a file that's changing
                 // and later when it stops changing we'll do the add or update as appropriate.
                 getLogger().debug("File Changing: " + newStatus);
-
-            } else if (oldStatus.isNewFile()){
-
+            }
+            else if (oldStatus.isNewFile()) {
                 // Used to be changing, now in (hopefully) its final state
                 getLogger().info("New File: " + newStatus);
                 newStatus.setNewFile(!listener.fileAdded(child));
-
-            } else if ( oldStatus.isChanging() ){
-
+            }
+            else if (oldStatus.isChanging()) {
                 getLogger().info("Updated File: " + newStatus);
                 listener.fileUpdated(child);
 
                 missingFilesList.remove(oldStatus.getPath());
-
-            }// else it's just totally unchanged and we ignore it this pass
+            }
+            // else it's just totally unchanged and we ignore it this pass
         }
 
         // Look for any files we used to know about but didn't find in this pass
         for (Iterator iterator = missingFilesList.iterator(); iterator.hasNext();) {
             String path = (String) iterator.next();
             getLogger().info("File removed: " + path);
-            if (listener.fileRemoved(new File(path))){
+
+            if (listener.fileRemoved(new File(path))) {
                 files.remove(path);
             }
         }
@@ -196,50 +190,86 @@
         return (FileInfo) files.get(file.getAbsolutePath());
     }
 
-    private static class DirectoryInfo extends FileInfo {
-        /**
-         * We don't pay attention to the size of the directory or files in the
-         * directory, only the highest last modified time of anything in the
-         * directory.  Hopefully this is good enough.
-         */
-        public DirectoryInfo(File dir) {
+    /**
+     * Allows custom behavior to be hooked up to process file state changes.
+     */
+    public interface Listener
+    {
+        boolean fileAdded(File file);
+
+        boolean fileRemoved(File file);
+
+        void fileUpdated(File file);
+    }
+
+    /**
+     * Provides details about a directory.
+     */
+    private static class DirectoryInfo
+        extends FileInfo
+    {
+        public DirectoryInfo(final File dir) {
+            //
+            // We don't pay attention to the size of the directory or files in the
+            // directory, only the highest last modified time of anything in the
+            // directory.  Hopefully this is good enough.
+            //
             super(dir.getAbsolutePath(), 0, getLastModifiedInDir(dir));
         }
 
-        private static long getLastModifiedInDir(File dir) {
+        private static long getLastModifiedInDir(final File dir) {
+            assert dir != null;
+
             long value = dir.lastModified();
             File[] children = dir.listFiles();
             long test;
+
             for (int i = 0; i < children.length; i++) {
                 File child = children[i];
+
                 if (!child.canRead()) {
                     continue;
                 }
+
                 if (child.isDirectory()) {
                     test = getLastModifiedInDir(child);
-                } else {
+                }
+                else {
                     test = child.lastModified();
                 }
+
                 if (test > value) {
                     value = test;
                 }
             }
+
             return value;
         }
     }
 
-    private static class FileInfo implements Serializable {
+    /**
+     * Provides details about a file.
+     */
+    private static class FileInfo
+        implements Serializable
+    {
         private String path;
+
         private long size;
+
         private long modified;
+
         private boolean newFile;
+
         private boolean changing;
 
-        public FileInfo(File file) {
+        public FileInfo(final File file) {
             this(file.getAbsolutePath(), file.length(), file.lastModified());
         }
 
-        public FileInfo(String path, long size, long modified) {
+        public FileInfo(final String path, final long size, final long modified) {
+            assert path != null;
+
             this.path = path;
             this.size = size;
             this.modified = modified;
@@ -255,7 +285,7 @@
             return size;
         }
 
-        public void setSize(long size) {
+        public void setSize(final long size) {
             this.size = size;
         }
 
@@ -263,7 +293,7 @@
             return modified;
         }
 
-        public void setModified(long modified) {
+        public void setModified(final long modified) {
             this.modified = modified;
         }
 
@@ -271,8 +301,7 @@
             return newFile;
         }
 
-
-        public void setNewFile(boolean newFile) {
+        public void setNewFile(final boolean newFile) {
             this.newFile = newFile;
         }
 
@@ -280,14 +309,17 @@
             return changing;
         }
 
-        public void setChanging(boolean changing) {
+        public void setChanging(final boolean changing) {
             this.changing = changing;
         }
 
-        public boolean isSame(FileInfo info) {
+        public boolean isSame(final FileInfo info) {
+            assert info != null;
+
             if (!path.equals(info.path)) {
                 throw new IllegalArgumentException("Should only be used to compare two files representing the same path!");
             }
+
             return size == info.size && modified == info.modified;
         }
 
@@ -295,12 +327,11 @@
             return path;
         }
 
-        public void diff(FileInfo old) {
-            if (old != null){
+        public void diff(final FileInfo old) {
+            if (old != null) {
                 this.changing = !isSame(old);
                 this.newFile = old.newFile;
             }
         }
     }
-
 }

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/producer/DirectoryMonitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message