You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by ah...@apache.org on 2007/02/11 22:07:23 UTC

svn commit: r506135 - in /hivemind/hivemind2/trunk/examples: ./ src/java/org/apache/examples/annotations/ src/java/org/apache/examples/annotations/panorama/ src/java/org/apache/hivemind/examples/

Author: ahuegen
Date: Sun Feb 11 13:07:22 2007
New Revision: 506135

URL: http://svn.apache.org/viewvc?view=rev&rev=506135
Log:
Implemented panorama example with annotations

Added:
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaDiscussionsModule.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMailModule.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaModule.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaStartupModule.java
    hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/panorama.properties
Removed:
    hivemind/hivemind2/trunk/examples/src/java/org/apache/hivemind/examples/
Modified:
    hivemind/hivemind2/trunk/examples/pom.xml

Modified: hivemind/hivemind2/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/pom.xml?view=diff&rev=506135&r1=506134&r2=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/pom.xml (original)
+++ hivemind/hivemind2/trunk/examples/pom.xml Sun Feb 11 13:07:22 2007
@@ -25,6 +25,11 @@
             <artifactId>hivemind-xml</artifactId>
             <version>2.0.0_M1</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.hivemind</groupId>
+            <artifactId>hivemind-annotations</artifactId>
+            <version>2.0.0_M1</version>
+        </dependency>
         <!-- PROVIDED -->
         <dependency>
             <groupId>log4j</groupId>

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaDiscussionsModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaDiscussionsModule.java?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaDiscussionsModule.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaDiscussionsModule.java Sun Feb 11 13:07:22 2007
@@ -0,0 +1,25 @@
+package org.apache.examples.annotations.panorama;
+
+import java.util.List;
+
+import org.apache.examples.panorama.discussions.DiscussionsStartup;
+import org.apache.examples.panorama.startup.impl.ExecuteStatic;
+import org.apache.examples.panorama.startup.impl.Task;
+import org.apache.hivemind.annotations.AbstractAnnotatedModule;
+import org.apache.hivemind.annotations.definition.Contribution;
+
+public class PanoramaDiscussionsModule extends AbstractAnnotatedModule
+{
+    @Contribution( configurationId="panorama.startup.tasks" )
+    public void contributeTaks(List<Task> tasks)
+    {
+        Task discussionStartupTask = new Task();
+        ExecuteStatic executable = new ExecuteStatic();
+        executable.setTargetClass(DiscussionsStartup.class);
+        discussionStartupTask.setExecutable(executable);
+        discussionStartupTask.setId("discussions");
+        discussionStartupTask.setTitle("Discussions");
+        
+        tasks.add(discussionStartupTask);
+    }
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMailModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMailModule.java?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMailModule.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMailModule.java Sun Feb 11 13:07:22 2007
@@ -0,0 +1,32 @@
+package org.apache.examples.annotations.panorama;
+
+import java.util.List;
+
+import org.apache.examples.panorama.mail.MailStartup;
+import org.apache.examples.panorama.startup.Executable;
+import org.apache.examples.panorama.startup.impl.Task;
+import org.apache.hivemind.annotations.AbstractAnnotatedModule;
+import org.apache.hivemind.annotations.definition.Contribution;
+import org.apache.hivemind.annotations.definition.Service;
+
+public class PanoramaMailModule extends AbstractAnnotatedModule
+{
+    @Service( id="MailStartup" )
+    public Executable getMailStartupService()
+    {
+        Executable startup = new MailStartup();
+        return startup;
+    }
+    
+    @Contribution( configurationId="panorama.startup.tasks" )
+    public void contributeTaks(List<Task> tasks)
+    {
+        Task mailStartupTask = new Task();
+        mailStartupTask.setExecutable(service("MailStartup", Executable.class));
+        mailStartupTask.setId("mail");
+        mailStartupTask.setTitle("Mail");
+        
+        tasks.add(mailStartupTask);
+    }
+
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaMain.java Sun Feb 11 13:07:22 2007
@@ -0,0 +1,35 @@
+// Copyright 2005 The Apache Software Foundation
+//
+// Licensed 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.examples.annotations.panorama;
+
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.annotations.AnnotatedRegistryBuilder;
+
+/**
+ * Builds the Registry for Panorama example based on annotations, then exits. 
+ * 
+ * @author Achim Huegen
+ */
+public class PanoramaMain
+{
+
+    public static void main(String[] args)
+    {
+        AnnotatedRegistryBuilder builder = new AnnotatedRegistryBuilder();
+        Registry registry = builder.constructRegistry(PanoramaModule.class);
+
+        registry.shutdown();
+    }
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaModule.java?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaModule.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaModule.java Sun Feb 11 13:07:22 2007
@@ -0,0 +1,30 @@
+package org.apache.examples.annotations.panorama;
+
+import org.apache.hivemind.annotations.definition.Module;
+import org.apache.hivemind.annotations.definition.Submodule;
+
+/**
+ * @author Huegen
+ */
+@Module( id="panorama" )
+public class PanoramaModule
+{
+    @Submodule( id="panorama.startup")
+    public PanoramaStartupModule getStartupModule()
+    {
+        return new PanoramaStartupModule();
+    }
+    
+    @Submodule( id="panorama.mail")
+    public PanoramaMailModule getMailModule()
+    {
+        return new PanoramaMailModule();
+    }
+    
+    @Submodule( id="panorama.discussions")
+    public PanoramaDiscussionsModule getDiscussionsModule()
+    {
+        return new PanoramaDiscussionsModule();
+    }
+
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaStartupModule.java
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaStartupModule.java?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaStartupModule.java (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/PanoramaStartupModule.java Sun Feb 11 13:07:22 2007
@@ -0,0 +1,48 @@
+package org.apache.examples.annotations.panorama;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.examples.panorama.startup.impl.Task;
+import org.apache.examples.panorama.startup.impl.TaskExecutor;
+import org.apache.hivemind.ErrorLog;
+import org.apache.hivemind.annotations.AbstractAnnotatedModule;
+import org.apache.hivemind.annotations.definition.Configuration;
+import org.apache.hivemind.annotations.definition.Contribution;
+import org.apache.hivemind.annotations.definition.Service;
+import org.apache.hivemind.impl.DefaultErrorHandler;
+import org.apache.hivemind.impl.ErrorLogImpl;
+import org.apache.hivemind.impl.MessageFormatter;
+
+public class PanoramaStartupModule extends AbstractAnnotatedModule
+{
+
+    @Service( id="Startup" )
+    public Runnable getStartupService()
+    {
+        TaskExecutor executor = new TaskExecutor();
+        executor.setTasks(configuration("tasks", List.class));
+        // Some of the logic which is automatically provided by the builder factory
+        // must be done manually
+        ErrorLog errorLog = new ErrorLogImpl(new DefaultErrorHandler(), LogFactory.getLog(TaskExecutor.class));
+        executor.setErrorLog(errorLog);
+        executor.setMessages(new MessageFormatter(PanoramaStartupModule.class, "panorama"));
+        executor.setLog(LogFactory.getLog(TaskExecutor.class));
+        
+        return executor;
+    }
+    
+    @Configuration( id="tasks" )
+    public List<Task> getTasks()
+    {
+        return new ArrayList<Task>();
+    }
+    
+    @Contribution( configurationId="hivemind.Startup" )
+    public void contributeStartupServices(List services)
+    {
+        services.add(service("Startup", Runnable.class));
+    }
+    
+}

Added: hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/panorama.properties
URL: http://svn.apache.org/viewvc/hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/panorama.properties?view=auto&rev=506135
==============================================================================
--- hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/panorama.properties (added)
+++ hivemind/hivemind2/trunk/examples/src/java/org/apache/examples/annotations/panorama/panorama.properties Sun Feb 11 13:07:22 2007
@@ -0,0 +1,19 @@
+# Copyright 2004, 2005 The Apache Software Foundation
+#
+# Licensed 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.
+
+task=task
+executing-task=Executing task {0}.
+exception-in-task=Exception while executing task {0}: {1}
+success=Executed {0,choice,1#one task|1<{0} tasks} (in {0} milliseconds).
+failure=Executed {0,choice,1#one task|1<{0} tasks} with {1,choice,1#one failure|1<{1} failures} (in {2} milliseconds).
\ No newline at end of file