notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1378 - in development/laboratory/planet/components/transitionmachine: api/src/main/net/dpml/transitionmachine basic/src/main/net/dpml/transitionmachine/basic demo/trafficlight demo/trafficlight/app demo/trafficlight/src/main/net/dpml/demo/trafficlight
- From: niclas AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1378 - in development/laboratory/planet/components/transitionmachine: api/src/main/net/dpml/transitionmachine basic/src/main/net/dpml/transitionmachine/basic demo/trafficlight demo/trafficlight/app demo/trafficlight/src/main/net/dpml/demo/trafficlight
- Date: Tue, 04 Jan 2005 09:17:02 +0100
Author: niclas
Date: Tue Jan 4 09:17:02 2005
New Revision: 1378
Added:
development/laboratory/planet/components/transitionmachine/demo/trafficlight/app/
Modified:
development/laboratory/planet/components/transitionmachine/api/src/main/net/dpml/transitionmachine/TransitionEvent.java
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/CommandRule.java
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/StateImpl.java
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionImpl.java
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionMachineImpl.java
development/laboratory/planet/components/transitionmachine/demo/trafficlight/build.xml
development/laboratory/planet/components/transitionmachine/demo/trafficlight/src/main/net/dpml/demo/trafficlight/TrafficLight.java
Log:
More work on the traffic light.
Modified:
development/laboratory/planet/components/transitionmachine/api/src/main/net/dpml/transitionmachine/TransitionEvent.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/api/src/main/net/dpml/transitionmachine/TransitionEvent.java
(original)
+++
development/laboratory/planet/components/transitionmachine/api/src/main/net/dpml/transitionmachine/TransitionEvent.java
Tue Jan 4 09:17:02 2005
@@ -38,6 +38,23 @@
private Object m_source;
private Date m_TransitionDate;
+ /** Normal constructor.
+ * <p/>
+ * NOTE: Only TransitionMachine implementations should be instantiating
TransitionEvents.
+ *
+ * @param source The source that is passed to the
<code>TransitionMachine.trigger()</code> method.
+ * @param transition The Transition that was performed.
+ * @param transitionMachine The TransitionMachine instance where the
Transition was performed.
+ */
+ public TransitionEvent(
+ Object source, Transition transition, TransitionMachine
transitionMachine )
+ {
+ m_transition = transition;
+ m_transitionMachine = transitionMachine;
+ m_source = source;
+ m_TransitionDate = new Date();
+ }
+
/**
* Returns the Transition instance that has just been transited.
*
@@ -83,23 +100,6 @@
return m_TransitionDate;
}
- /** Normal constructor.
- * <p/>
- * NOTE: Only TransitionMachine implementations should be instantiating
TransitionEvents.
- *
- * @param source The source that is passed to the
<code>TransitionMachine.trigger()</code> method.
- * @param transition The Transition that was performed.
- * @param transitionMachine The TransitionMachine instance where the
Transition was performed.
- */
- public TransitionEvent(
- Object source, Transition transition, TransitionMachine
transitionMachine )
- {
- m_transition = transition;
- m_transitionMachine = transitionMachine;
- m_source = source;
- m_TransitionDate = new Date();
- }
-
/** Overridden equals() method.
*
* Two TransitionEvent instances can be equal() even though they are not
the same JVM instance,
Modified:
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/CommandRule.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/CommandRule.java
(original)
+++
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/CommandRule.java
Tue Jan 4 09:17:02 2005
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-package net.dpml.planet.transitionmachine.basic;
+package net.dpml.transitionmachine.basic;
import net.dpml.transitionmachine.TransitionRule;
import net.dpml.parameters.Parameters;
Modified:
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/StateImpl.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/StateImpl.java
(original)
+++
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/StateImpl.java
Tue Jan 4 09:17:02 2005
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-package net.dpml.planet.transitionmachine.basic;
+package net.dpml.transitionmachine.basic;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -49,8 +49,12 @@
* error.description=Something has gone wrong and it is set into an error
state. Reset command
* required.
* </pre></code>
+ *
+ * @metro.component name="state" lifestyle="singleton"
+ * @metro.service type="net.dpml.transitionmachine.State"
*/
-public class StateImpl implements State
+public class StateImpl
+ implements State
{
private String m_identity;
Modified:
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionImpl.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionImpl.java
(original)
+++
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionImpl.java
Tue Jan 4 09:17:02 2005
@@ -1,5 +1,5 @@
-package net.dpml.planet.transitionmachine.basic;
+package net.dpml.transitionmachine.basic;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -37,6 +37,7 @@
* </pre></code>
*
* @metro.component name="transition" lifestyle="transient" collection="hard"
+ * @metro.service type="net.dpml.transitionmachine.Transition"
*/
public class TransitionImpl implements Transition
{
Modified:
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionMachineImpl.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionMachineImpl.java
(original)
+++
development/laboratory/planet/components/transitionmachine/basic/src/main/net/dpml/transitionmachine/basic/TransitionMachineImpl.java
Tue Jan 4 09:17:02 2005
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-package net.dpml.planet.transitionmachine.basic;
+package net.dpml.transitionmachine.basic;
import java.util.Collection;
import java.util.HashMap;
Modified:
development/laboratory/planet/components/transitionmachine/demo/trafficlight/build.xml
==============================================================================
---
development/laboratory/planet/components/transitionmachine/demo/trafficlight/build.xml
(original)
+++
development/laboratory/planet/components/transitionmachine/demo/trafficlight/build.xml
Tue Jan 4 09:17:02 2005
@@ -5,4 +5,105 @@
<magic:import uri="artifact:template:dpml/magic/standard"/>
+ <target name="build" depends="standard.build" >
+ <x:block name="trafficlight" >
+ <x:component name="machine"
class="net.dpml.transitionmachine.basic.TransitionMachineImpl" >
+ <x:dependencies>
+ <x:dependency key="red-to-green" source="transition-red-to-green"
/>
+ <x:dependency key="green-to-yellow"
source="transition-green-to-yellow" />
+ <x:dependency key="yellow-to-red"
source="transition-yellow-to-red" />
+ <x:dependency key="red-to-redyellow"
source="transition-red-to-redyellow" />
+ <x:dependency key="redyellow-to-green"
source="transition-redyellow-to-green" />
+ <x:dependency key="green-to-greenyellow"
source="transition-green-to-greenyellow" />
+ <x:dependency key="greenyellow-to-red"
source="transition-greenyellow-to-red" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="rule"
class="net.dpml.transitionmachine.basic.CommandRule" >
+ <x:parameters>
+ <x:parameter name="command" value="tick" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="state-red"
class="net.dpml.transitionmachine.basic.StateImpl" >
+ <x:parameters>
+ <x:parameter name="identity" value="state-red" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="state-redyellow"
class="net.dpml.transitionmachine.basic.StateImpl" >
+ <x:parameters>
+ <x:parameter name="identity" value="state-redyellow" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="state-yellow"
class="net.dpml.transitionmachine.basic.StateImpl" >
+ <x:parameters>
+ <x:parameter name="identity" value="state-yellow" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="state-green"
class="net.dpml.transitionmachine.basic.StateImpl" >
+ <x:parameters>
+ <x:parameter name="identity" value="state-green" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="state-greenyellow"
class="net.dpml.transitionmachine.basic.StateImpl" >
+ <x:parameters>
+ <x:parameter name="identity" value="state-greenyellow" />
+ </x:parameters>
+ </x:component>
+
+ <x:component name="transition-red-to-green"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-red" />
+ <x:dependency key="end" source="state-green" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-red-to-redyellow"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-red" />
+ <x:dependency key="end" source="state-redyellow" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-yellow-to-red"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-yellow" />
+ <x:dependency key="end" source="state-red" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-green-to-yellow"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-green" />
+ <x:dependency key="end" source="state-yellow" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-green-to-greenyellow"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-gree" />
+ <x:dependency key="end" source="state-greenyellow" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-greenyellow-to-red"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-greenyellow" />
+ <x:dependency key="end" source="state-red" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="transition-redyellow-to-green"
class="net.dpml.transitionmachine.basic.TransitionImpl" >
+ <x:dependencies>
+ <x:dependency key="begin" source="state-redyellow" />
+ <x:dependency key="end" source="state-green" />
+ </x:dependencies>
+ </x:component>
+
+ </x:block>
+ </target>
</project>
Modified:
development/laboratory/planet/components/transitionmachine/demo/trafficlight/src/main/net/dpml/demo/trafficlight/TrafficLight.java
==============================================================================
---
development/laboratory/planet/components/transitionmachine/demo/trafficlight/src/main/net/dpml/demo/trafficlight/TrafficLight.java
(original)
+++
development/laboratory/planet/components/transitionmachine/demo/trafficlight/src/main/net/dpml/demo/trafficlight/TrafficLight.java
Tue Jan 4 09:17:02 2005
@@ -17,15 +17,23 @@
* limitations under the License.
*/
-package net.dpml.planet.demo.trafficlight;
+package net.dpml.transitionmachine.trafficlight.demo;
-import java.util.ArrayList;
import java.io.Serializable;
+
+import java.text.SimpleDateFormat;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Locale;
+
import net.dpml.activity.Startable;
import net.dpml.parameters.Parameters;
import net.dpml.service.ServiceException;
import net.dpml.service.ServiceManager;
import net.dpml.transitionmachine.Transition;
+import net.dpml.transitionmachine.TransitionEvent;
+import net.dpml.transitionmachine.TransitionListener;
import net.dpml.transitionmachine.TransitionMachine;
import net.dpml.transitionmachine.State;
@@ -40,7 +48,7 @@
* @metro.component name="TrafficLight" lifestyle="singleton"
collection="hard"
*/
public class TrafficLight
- implements Runnable, Startable, Serializable
+ implements Runnable, Startable, Serializable, TransitionListener
{
private TransitionMachine m_transitionMachine;
@@ -141,7 +149,7 @@
{
synchronized( this )
{
- wait();
+ wait( 5000 );
m_transitionMachine.trigger( this, command );
}
}
@@ -149,4 +157,13 @@
{
}
}
+
+ public void transition( TransitionEvent event )
+ {
+ Transition transition = event.getTransition();
+ Date date = event.getTransitionDate();
+ State state = transition.getEndState();
+ SimpleDateFormat sdf = new SimpleDateFormat( "HH:mm:ss" );
+ System.out.println( sdf.format( date ) + " : " + state.getName(
Locale.getDefault() ) );
+ }
}
- svn commit: r1378 - in development/laboratory/planet/components/transitionmachine: api/src/main/net/dpml/transitionmachine basic/src/main/net/dpml/transitionmachine/basic demo/trafficlight demo/trafficlight/app demo/trafficlight/src/main/net/dpml/demo/trafficlight, niclas, 01/04/2005
Archive powered by MHonArc 2.6.24.