Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1588 - in development/main/central/tutorials: . startable startable/src startable/src/main startable/src/main/tutorial

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1588 - in development/main/central/tutorials: . startable startable/src startable/src/main startable/src/main/tutorial
  • Date: Tue, 25 Jan 2005 23:28:32 +0100

Author: mcconnell
Date: Tue Jan 25 23:28:32 2005
New Revision: 1588

Added:
development/main/central/tutorials/startable/
development/main/central/tutorials/startable/build.xml
development/main/central/tutorials/startable/src/
development/main/central/tutorials/startable/src/main/
development/main/central/tutorials/startable/src/main/tutorial/

development/main/central/tutorials/startable/src/main/tutorial/HelloComponent.java
Modified:
development/main/central/tutorials/index.xml
Log:
add a startable demo

Modified: development/main/central/tutorials/index.xml
==============================================================================
--- development/main/central/tutorials/index.xml (original)
+++ development/main/central/tutorials/index.xml Tue Jan 25 23:28:32
2005
@@ -380,4 +380,19 @@
</plugins>
</project>

+ <project basedir="startable">
+ <info>
+ <group>dpml/central</group>
+ <name>dpml-tutorial-startable</name>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-metro-unit" test="true" runtime="false"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
</index>

Added: development/main/central/tutorials/startable/build.xml
==============================================================================
--- (empty file)
+++ development/main/central/tutorials/startable/build.xml Tue Jan 25
23:28:32 2005
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-tutorial-startable" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="build" depends="standard.build">
+ <x:block name="tutorial" embed="MAIN">
+ <x:component name="hello" class="tutorial.HelloComponent"/>
+ </x:block>
+ </target>
+
+</project>
+

Added:
development/main/central/tutorials/startable/src/main/tutorial/HelloComponent.java
==============================================================================
--- (empty file)
+++
development/main/central/tutorials/startable/src/main/tutorial/HelloComponent.java
Tue Jan 25 23:28:32 2005
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * 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 tutorial;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.activity.Startable;
+
+
+/**
+ * A sample component.
+ *
+ * @metro.component
+ * version="1.0"
+ * name="hello"
+ * lifestyle="singleton"
+ */
+public class HelloComponent implements Startable
+{
+ //-------------------------------------------------------
+ // state
+ //-------------------------------------------------------
+
+ private final Logger m_logger;
+
+ private final Thread m_thread = new Worker();
+
+ //-------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------
+
+ /**
+ * Creation of a new hello component instance.
+ *
+ * @param logger the logging channel supplied by the container
+ */
+ public HelloComponent( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ //-------------------------------------------------------
+ // Startable
+ //-------------------------------------------------------
+
+ /**
+ * Startup of the component. This method is invoked by the container
+ * during the deployment sequence.
+ */
+ public void start()
+ {
+ m_logger.info( "Starting Hello World!" );
+ m_thread.start();
+ m_logger.info( "Started Hello World!" );
+ }
+
+ /**
+ * Stop the component. This method is invoked by the container
+ * during the decommissioning sequence.
+ */
+ public void stop()
+ {
+ m_thread.interrupt();
+ m_logger.info( "Goodbye World!" );
+ }
+
+ /**
+ * A little worker thread to do the background stuff.
+ */
+ private static class Worker extends Thread
+ {
+ private boolean m_continue = true;
+
+ public void run()
+ {
+ while( m_continue )
+ {
+ try
+ {
+ // do something usefull
+ System.out.print( "." );
+ sleep( 1000 );
+ }
+ catch( InterruptedException ie )
+ {
+ // time to close up shop
+ System.out.println( " " );
+ m_continue = false;
+ }
+ }
+ }
+ }
+}



  • svn commit: r1588 - in development/main/central/tutorials: . startable startable/src startable/src/main startable/src/main/tutorial, mcconnell, 01/25/2005

Archive powered by MHonArc 2.6.24.

Top of Page