notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r981 - in trunk/main: central/src/docs/metro/tasks/graph central/src/docs/metro/tasks/types/state metro/part/api/src/main/net/dpml/part metro/state/api/src/main/net/dpml/state metro/state/impl/etc/test metro/state/impl/src/main/net/dpml/state/impl metro/state/impl/src/test/net/dpml/state/test metro/station/console/src/main/net/dpml/station/console metro/station/server/src/main/net/dpml/station/server metro/tools/src/main/net/dpml/metro/tools planet/http/demo planet/http/demo/src/main/net/dpml/http/demo
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r981 - in trunk/main: central/src/docs/metro/tasks/graph central/src/docs/metro/tasks/types/state metro/part/api/src/main/net/dpml/part metro/state/api/src/main/net/dpml/state metro/state/impl/etc/test metro/state/impl/src/main/net/dpml/state/impl metro/state/impl/src/test/net/dpml/state/test metro/station/console/src/main/net/dpml/station/console metro/station/server/src/main/net/dpml/station/server metro/tools/src/main/net/dpml/metro/tools planet/http/demo planet/http/demo/src/main/net/dpml/http/demo
- Date: Fri, 27 Jan 2006 13:48:15 +0100
Author: mcconnell
Date: 2006-01-27 13:48:05 +0100 (Fri, 27 Jan 2006)
New Revision: 981
Added:
trunk/main/central/src/docs/metro/tasks/graph/interface.xml
trunk/main/central/src/docs/metro/tasks/types/state/interface.xml
trunk/main/metro/state/api/src/main/net/dpml/state/Interface.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterface.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/InterfaceDataType.java
trunk/main/planet/http/demo/src/main/net/dpml/http/demo/ManagementOperations.java
Removed:
trunk/main/metro/part/api/src/main/net/dpml/part/local/
trunk/main/metro/part/api/src/main/net/dpml/part/remote/
Modified:
trunk/main/central/src/docs/metro/tasks/graph/navigation.xml
trunk/main/central/src/docs/metro/tasks/types/state/navigation.xml
trunk/main/metro/part/api/src/main/net/dpml/part/ProviderOperations.java
trunk/main/metro/state/api/src/main/net/dpml/state/NullState.java
trunk/main/metro/state/api/src/main/net/dpml/state/State.java
trunk/main/metro/state/api/src/main/net/dpml/state/StateMachine.java
trunk/main/metro/state/impl/etc/test/example.xgraph
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecAction.java
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
trunk/main/metro/station/console/src/main/net/dpml/station/console/StationPlugin.java
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplication.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
trunk/main/planet/http/demo/build.xml
trunk/main/planet/http/demo/src/main/net/dpml/http/demo/Demo.java
Log:
update the state graph object model to enable the declaration of an available
management interfaces within a state and aggregated management controls
relative to the active state path (preparation for intelligent remotable
management proxies)
Added: trunk/main/central/src/docs/metro/tasks/graph/interface.xml
===================================================================
--- trunk/main/central/src/docs/metro/tasks/graph/interface.xml 2006-01-26
07:36:59 UTC (rev 980)
+++ trunk/main/central/src/docs/metro/tasks/graph/interface.xml 2006-01-27
12:48:05 UTC (rev 981)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<document>
+
+ <properties>
+ <author email="mcconnell AT dpml.net">Stephen McConnell</author>
+ <title>DPML Metro Graph Interface Datatype</title>
+ </properties>
+
+ <body>
+
+ <section name="Interface Datatype">
+
+ <subsection name="Description">
+
+ <p>
+ Declaration of the exposure of a management interface. The set of
+ interfaces declared under states within the state graph correspond
to
+ the enabled management contract for a component within a particular
+ state.
+ </p>
+
+ </subsection>
+
+ <subsection name="Attributes">
+
+ <table>
+ <tr>
+ <td><tt>class</tt></td>
+ <td>The classname of the management interface.</td>
+ </tr>
+ </table>
+
+ </subsection>
+
+ </section>
+
+ </body>
+
+</document>
+
Modified: trunk/main/central/src/docs/metro/tasks/graph/navigation.xml
===================================================================
--- trunk/main/central/src/docs/metro/tasks/graph/navigation.xml
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/central/src/docs/metro/tasks/graph/navigation.xml
2006-01-27 12:48:05 UTC (rev 981)
@@ -28,6 +28,7 @@
<item name="Trigger" href="trigger/index.html"/>
<item name="Transition" href="transition.html"/>
<item name="Operation" href="operation.html"/>
+ <item name="Interface" href="interface.html"/>
<item name="State" href="state.html"/>
</menu>
Added: trunk/main/central/src/docs/metro/tasks/types/state/interface.xml
===================================================================
--- trunk/main/central/src/docs/metro/tasks/types/state/interface.xml
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/central/src/docs/metro/tasks/types/state/interface.xml
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<document>
+
+ <properties>
+ <author email="mcconnell AT dpml.net">Stephen McConnell</author>
+ <title>DPML Metro Graph Interface Datatype</title>
+ </properties>
+
+ <body>
+
+ <section name="Interface Datatype">
+
+ <subsection name="Description">
+
+ <p>
+ Declaration of the exposure of a management interface. The set of
+ interfaces declared under states within the state graph correspond
to
+ the enabled management contract for a component within a particular
+ state.
+ </p>
+
+ </subsection>
+
+ <subsection name="Attributes">
+
+ <table>
+ <tr>
+ <td><tt>class</tt></td>
+ <td>The classname of the interface.</td>
+ </tr>
+ </table>
+
+ </subsection>
+
+ </section>
+
+ </body>
+
+</document>
+
Modified: trunk/main/central/src/docs/metro/tasks/types/state/navigation.xml
===================================================================
--- trunk/main/central/src/docs/metro/tasks/types/state/navigation.xml
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/central/src/docs/metro/tasks/types/state/navigation.xml
2006-01-27 12:48:05 UTC (rev 981)
@@ -28,6 +28,7 @@
<item name="Trigger" href="trigger/index.html"/>
<item name="Transition" href="transition.html"/>
<item name="Operation" href="operation.html"/>
+ <item name="Interface" href="interface.html"/>
</menu>
</body>
Modified:
trunk/main/metro/part/api/src/main/net/dpml/part/ProviderOperations.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/ProviderOperations.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/ProviderOperations.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -71,6 +71,16 @@
Object getValue( boolean isolate ) throws RemoteException;
/**
+ * Return the runtime value associated with this instance.
+ * @param isolate if TRUE the value returned is a proxy exposing the
+ * service interfaces declared by the component type otherwise
+ * the instance value is returned.
+ * @return the value
+ * @exception RemoteException if a remote I/O error occurs
+ */
+ //Object getManagementService( boolean isolate ) throws RemoteException;
+
+ /**
* Apply a transition to the instance.
* @param key the transition name
* @return the state established as a result of applying the transition
Added: trunk/main/metro/state/api/src/main/net/dpml/state/Interface.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/Interface.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/Interface.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005 Stephen J. 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 net.dpml.state;
+
+/**
+ * An Interface action declares the classname of an interface
+ * implemented by a component class that may be dynamically
+ * exposed by a component through the assocation of the interface
+ * with an active state.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Interface extends Action
+{
+ /**
+ * Return the classname of a management interface implemented and
+ * potentially exposed by a component.
+ * @return the interface classname
+ */
+ String getClassname();
+}
Modified: trunk/main/metro/state/api/src/main/net/dpml/state/NullState.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/NullState.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/NullState.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -102,6 +102,15 @@
}
/**
+ * Return the array of operations associated with the state.
+ * @return the operation array
+ */
+ public Interface[] getInterfaces()
+ {
+ return new Interface[0];
+ }
+
+ /**
* Test is the state is a terminal state.
* @return true if terminal
*/
Modified: trunk/main/metro/state/api/src/main/net/dpml/state/State.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/State.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/State.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -87,6 +87,13 @@
Operation[] getOperations();
/**
+ * Return the array of management interfaces associated with
+ * the state.
+ * @return the interfaces array
+ */
+ Interface[] getInterfaces();
+
+ /**
* Test is the state is a terminal state.
* @return true if terminal
*/
Modified: trunk/main/metro/state/api/src/main/net/dpml/state/StateMachine.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/StateMachine.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/StateMachine.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -122,6 +122,12 @@
Operation[] getOperations();
/**
+ * Return all of the available interfaces relative to the current state.
+ * @return the available interface declarations
+ */
+ Interface[] getInterfaces();
+
+ /**
* Invoke termination of the supplied object using the termination action
* declared under the current state path.
*
Modified: trunk/main/metro/state/impl/etc/test/example.xgraph
===================================================================
--- trunk/main/metro/state/impl/etc/test/example.xgraph 2006-01-26 07:36:59
UTC (rev 980)
+++ trunk/main/metro/state/impl/etc/test/example.xgraph 2006-01-27 12:48:05
UTC (rev 981)
@@ -12,6 +12,7 @@
<transition name="terminate" target="../terminated"/>
</trigger>
<state name="started">
+ <interface class="org.acme.ManagementInterface"/>
<transition name="stop" target="../stopped">
<operation name="shutdown" method="stop"/>
</transition>
@@ -27,3 +28,4 @@
</state>
<state name="terminated" terminal="true"/>
</state>
+
Added:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterface.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterface.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterface.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2005 Stephen J. 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 net.dpml.state.impl;
+
+import java.io.Serializable;
+
+import net.dpml.state.Interface;
+
+/**
+ * Default implementation of an operation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class DefaultInterface implements Interface, Serializable
+{
+ private final String m_classname;
+
+ /**
+ * Creation of a new interface declaration.
+ * @param classname the overriding method name
+ * @exception NullPointerException if the operation name is null
+ */
+ public DefaultInterface( String classname ) throws NullPointerException
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ m_classname = classname;
+ }
+
+ /**
+ * Overriden method returning the interface classname.
+ * @return the name (interface classname)
+ * @see #getClassname()
+ */
+ public String getName()
+ {
+ return getClassname();
+ }
+
+ /**
+ * Return the interface classname.
+ * @return the classname
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Return a string representation of the instance.
+ * @return the string value
+ */
+ public String toString()
+ {
+ return "interface:" + m_classname;
+ }
+
+ /**
+ * Compare this object to another for equality.
+ * @param other the other object
+ * @return true if the object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof DefaultInterface )
+ {
+ DefaultInterface description = (DefaultInterface) other;
+ return m_classname.equals( description.m_classname );
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Compute the hashcode for this instance.
+ * @return the hashcode value
+ */
+ public int hashCode()
+ {
+ int hash = getClass().hashCode();
+ hash ^= m_classname.hashCode();
+ return hash;
+ }
+}
Added:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2005 Stephen J. 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 net.dpml.state.impl;
+
+import java.beans.SimpleBeanInfo;
+import java.beans.BeanDescriptor;
+import java.beans.DefaultPersistenceDelegate;
+
+/**
+ * BeanInfo for the DefaultInterface class that declares a persistence
delegate.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class DefaultInterfaceBeanInfo extends SimpleBeanInfo
+{
+ private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
+
+ /**
+ * Return the bean descriptor.
+ * @return the descriptor
+ */
+ public BeanDescriptor getBeanDescriptor()
+ {
+ return BEAN_DESCRIPTOR;
+ }
+
+ /**
+ * Internal persistence delagate.
+ * @return the bean descriptor
+ */
+ private static BeanDescriptor setupBeanDescriptor()
+ {
+ BeanDescriptor descriptor = new BeanDescriptor(
DefaultInterface.class );
+ descriptor.setValue(
+ "persistenceDelegate",
+ new DefaultPersistenceDelegate( new String[]{"classname"} ) );
+ return descriptor;
+ }
+}
Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -23,6 +23,7 @@
import net.dpml.state.State;
import net.dpml.state.Transition;
+import net.dpml.state.Interface;
import net.dpml.state.Operation;
import net.dpml.state.Trigger;
import net.dpml.state.Action;
@@ -38,6 +39,7 @@
private final String m_name;
private final Transition[] m_transitions;
private final Operation[] m_operations;
+ private final Interface[] m_interfaces;
private final State[] m_states;
private final Trigger[] m_triggers;
private final boolean m_terminal;
@@ -50,7 +52,7 @@
*/
public DefaultState( final String name )
{
- this( name, new Trigger[0], new Transition[0], new Operation[0], new
State[0], true );
+ this( name, new Trigger[0], new Transition[0], new Interface[0], new
Operation[0], new State[0], true );
}
/**
@@ -58,14 +60,15 @@
* @param name the state name
* @param triggers an array of triggers
* @param transitions an array of state transitions
+ * @param interfaces an array of management interface declarations
* @param operations an array of operations
* @param states an array of substates
*/
public DefaultState(
final String name, final Trigger[] triggers, final Transition[]
transitions,
- final Operation[] operations, final State[] states )
+ final Interface[] interfaces, final Operation[] operations, final
State[] states )
{
- this( name, triggers, transitions, operations, states, false );
+ this( name, triggers, transitions, interfaces, operations, states,
false );
}
/**
@@ -73,13 +76,14 @@
* @param name the state name
* @param triggers an array of triggers
* @param transitions an array of state transitions
+ * @param interfaces an array of management interface declarations
* @param operations an array of operations
* @param states an array of substates
* @param terminal the terminal flag
*/
public DefaultState(
final String name, final Trigger[] triggers, final Transition[]
transitions,
- final Operation[] operations, final State[] states, boolean terminal )
+ final Interface[] interfaces, final Operation[] operations, final
State[] states, boolean terminal )
{
if( null == name )
{
@@ -99,6 +103,7 @@
m_triggers = triggers;
m_transitions = transitions;
m_operations = operations;
+ m_interfaces = interfaces;
m_states = states;
m_terminal = terminal;
@@ -127,6 +132,15 @@
}
}
+ for( int i=0; i<interfaces.length; i++ )
+ {
+ Interface description = interfaces[i];
+ if( null == description )
+ {
+ throw new NullPointerException( "interface/" + i );
+ }
+ }
+
for( int i=0; i<states.length; i++ )
{
State state = states[i];
@@ -233,6 +247,15 @@
}
/**
+ * Return the array of management interfaces associated with the state.
+ * @return the interfaces array
+ */
+ public Interface[] getInterfaces()
+ {
+ return m_interfaces;
+ }
+
+ /**
* Return the terminal flag.
* @return true if terminal
*/
Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -60,7 +60,7 @@
"persistenceDelegate",
new DefaultPersistenceDelegate(
new String[]{
- "name", "triggers", "transitions", "operations",
+ "name", "triggers", "transitions", "interfaces", "operations",
"states", "terminal"} ) );
return descriptor;
}
Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -37,6 +37,7 @@
import net.dpml.state.State;
import net.dpml.state.Transition;
import net.dpml.state.Operation;
+import net.dpml.state.Interface;
import net.dpml.state.StateBuilderRuntimeException;
import net.dpml.state.Trigger;
import net.dpml.state.Trigger.TriggerEvent;
@@ -343,6 +344,32 @@
}
/**
+ * Return all of the available interfaces relative to the current state.
+ * @return the available interface declarations
+ */
+ public Interface[] getInterfaces()
+ {
+ checkDisposed();
+ Hashtable table = new Hashtable();
+ State[] states = m_state.getStatePath();
+ for( int i=( states.length-1 ); i>-1; i-- )
+ {
+ State state = states[i];
+ Interface[] interfaces = state.getInterfaces();
+ for( int j=0; j<interfaces.length; j++ )
+ {
+ Interface data = interfaces[j];
+ String name = data.getName();
+ if( null == table.get( name ) )
+ {
+ table.put( name, data );
+ }
+ }
+ }
+ return (Interface[]) table.values().toArray( new Interface[0] );
+ }
+
+ /**
* Invoke termination of the supplied object using the termination action
* declared under the current state path.
*
@@ -943,6 +970,7 @@
}
ArrayList transitionList = new ArrayList();
ArrayList operationList = new ArrayList();
+ ArrayList interfaceList = new ArrayList();
ArrayList stateList = new ArrayList();
ArrayList triggerList = new ArrayList();
Configuration[] children = config.getChildren();
@@ -960,6 +988,11 @@
Operation operation = buildOperation( child );
operationList.add( operation );
}
+ else if( name.equals( "interface" ) )
+ {
+ Interface data = buildInterface( child );
+ interfaceList.add( data );
+ }
else if( name.equals( "state" ) )
{
DefaultState state = buildState( child, false );
@@ -984,9 +1017,10 @@
}
DefaultTransition[] transitions = (DefaultTransition[])
transitionList.toArray( new DefaultTransition[0] );
DefaultOperation[] operations = (DefaultOperation[])
operationList.toArray( new DefaultOperation[0] );
+ DefaultInterface[] interfaces = (DefaultInterface[])
interfaceList.toArray( new DefaultInterface[0] );
DefaultState[] states = (DefaultState[]) stateList.toArray( new
DefaultState[0] );
DefaultTrigger[] triggers = (DefaultTrigger[]) triggerList.toArray(
new DefaultTrigger[0] );
- return new DefaultState( stateName, triggers, transitions,
operations, states, terminal );
+ return new DefaultState( stateName, triggers, transitions,
interfaces, operations, states, terminal );
}
private static Trigger buildTrigger( Configuration config ) throws
Exception
@@ -1074,6 +1108,28 @@
}
}
+ private static DefaultInterface buildInterface( Configuration config )
throws Exception
+ {
+ if( null == config )
+ {
+ return null;
+ }
+ String name = config.getName();
+ if( name.equals( "interface" ) )
+ {
+ String className = config.getAttribute( "class", null );
+ return new DefaultInterface( className );
+ }
+ else
+ {
+ final String error =
+ "Illegal element name ["
+ + name
+ + "] supplied to operation builder.";
+ throw new StateBuilderRuntimeException( error );
+ }
+ }
+
private static DefaultTransition buildTransition( Configuration config )
throws Exception
{
String name = config.getName();
Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecAction.java
===================================================================
--- trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecAction.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecAction.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -51,7 +51,7 @@
*/
public String getName()
{
- return "exec:"+ m_id;
+ return "exec:" + m_id;
}
/**
Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -27,6 +27,7 @@
import net.dpml.state.State;
import net.dpml.state.Transition;
import net.dpml.state.Operation;
+import net.dpml.state.Interface;
import net.dpml.state.Trigger;
import net.dpml.state.Action;
import net.dpml.state.impl.DefaultStateMachine;
@@ -257,6 +258,16 @@
+ "] --> [" + transition.getTargetName()
+ "]" );
}
+ Interface[] classes = state.getInterfaces();
+ for( int i=0; i<classes.length; i++ )
+ {
+ Interface interfaceDef = classes[i];
+ System.out.println(
+ pad + "# interface "
+ + "(" + ( i+1 ) + "): ["
+ + interfaceDef.getClassname()
+ + "]" );
+ }
Operation[] operations = state.getOperations();
for( int i=0; i<operations.length; i++ )
{
Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -21,8 +21,10 @@
import net.dpml.state.State;
import net.dpml.state.Transition;
import net.dpml.state.Operation;
+import net.dpml.state.Interface;
import net.dpml.state.Trigger;
import net.dpml.state.impl.DefaultOperation;
+import net.dpml.state.impl.DefaultInterface;
import net.dpml.state.impl.DefaultTransition;
import net.dpml.state.impl.DefaultState;
@@ -36,6 +38,7 @@
private String m_name;
private Transition[] m_transitions;
private Operation[] m_operations;
+ private Interface[] m_interfaces;
private State[] m_states;
private Trigger[] m_triggers;
private State m_state;
@@ -57,10 +60,15 @@
{
new DefaultOperation( "audit" )
};
+ m_interfaces =
+ new Interface[]
+ {
+ new DefaultInterface( "net.dpml.activity.Executable" )
+ };
m_states =
new State[]
{
- new DefaultState( "sub-one", new Trigger[0], new Transition[0],
new Operation[0], new State[0] ),
+ new DefaultState( "sub-one", new Trigger[0], new Transition[0],
new Interface[0], new Operation[0], new State[0] ),
new DefaultState( "sub-two" ),
};
m_triggers =
@@ -69,7 +77,7 @@
};
m_state =
new DefaultState(
- m_name, m_triggers, m_transitions, m_operations, m_states );
+ m_name, m_triggers, m_transitions, m_interfaces, m_operations,
m_states );
}
/**
@@ -109,6 +117,15 @@
}
/**
+ * Test interfaces accessor.
+ * @exception Exception if an error occurs
+ */
+ public void testInterfacess() throws Exception
+ {
+ assertEquals( "interrfaces", m_interfaces, m_state.getInterfaces() );
+ }
+
+ /**
* Test states accessor.
* @exception Exception if an error occurs
*/
Modified:
trunk/main/metro/station/console/src/main/net/dpml/station/console/StationPlugin.java
===================================================================
---
trunk/main/metro/station/console/src/main/net/dpml/station/console/StationPlugin.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/station/console/src/main/net/dpml/station/console/StationPlugin.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -46,9 +46,11 @@
import net.dpml.station.server.RemoteApplicationRegistry;
import net.dpml.part.Provider;
+
import net.dpml.state.State;
import net.dpml.state.Operation;
import net.dpml.state.Transition;
+import net.dpml.state.Interface;
import net.dpml.transit.Artifact;
import net.dpml.transit.Logger;
@@ -106,7 +108,7 @@
*
* @param logger the assigned logging channel
* @param args command line arguments
- * @exception Exception if an error occurs duirng plugin establishment
+ * @exception Exception if an error occurs during plugin establishment
*/
public StationPlugin( Logger logger, String[] args ) throws Exception
{
@@ -633,6 +635,15 @@
System.out.println( " " + operations[i] );
}
}
+ Interface[] interfaces = state.getInterfaces();
+ if( interfaces.length > 0 )
+ {
+ System.out.println( " Interfaces: (" +
interfaces.length + ")" );
+ for( int i=0; i<interfaces.length; i++ )
+ {
+ System.out.println( " " + interfaces[i] );
+ }
+ }
Transition[] transitions = state.getTransitions();
if( transitions.length > 0 )
{
Modified:
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplication.java
===================================================================
---
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplication.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/station/server/src/main/net/dpml/station/server/RemoteApplication.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -643,4 +643,5 @@
getLogger().error( "Process read error.", e );
}
}
- }}
+ }
+}
Added:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/InterfaceDataType.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/InterfaceDataType.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/InterfaceDataType.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2005 Stephen J. 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 net.dpml.metro.tools;
+
+import net.dpml.state.impl.DefaultInterface;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Defintion of a context entry parameter directive.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class InterfaceDataType
+{
+ private String m_name;
+ private String m_classname;
+
+ /**
+ * Set the operation name.
+ * @param name the operation name
+ */
+ public void setName( final String name )
+ {
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ m_name = name;
+ }
+
+ /**
+ * Set the operation method name.
+ * @param classname the name of the interface class
+ */
+ public void setClass( final String classname )
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ m_classname = classname;
+ }
+
+ DefaultInterface getInterface()
+ {
+ final String classname = getInterfaceClassname();
+ return new DefaultInterface( classname );
+ }
+
+ String getInterfaceClassname()
+ {
+ if( null != m_classname )
+ {
+ return m_classname;
+ }
+ else
+ {
+ throw new BuildException( "Missing interface 'classname'
attribute." );
+ }
+ }
+}
Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -32,6 +32,7 @@
import net.dpml.state.Trigger;
import net.dpml.state.State;
import net.dpml.state.Operation;
+import net.dpml.state.Interface;
import net.dpml.state.Transition;
import net.dpml.state.StateBuilder;
import net.dpml.state.impl.DefaultState;
@@ -56,6 +57,7 @@
private String m_name;
private List m_states = new ArrayList();
private List m_operations = new ArrayList();
+ private List m_interfaces = new ArrayList();
private List m_transitions = new ArrayList();
private List m_triggers = new ArrayList();
private boolean m_terminal = false;
@@ -195,6 +197,29 @@
}
/**
+ * Add an interface within this state.
+ * @return the interface datatype
+ */
+ public InterfaceDataType createInterface()
+ {
+ if( null != m_uri )
+ {
+ final String error =
+ "Interfaces may not be used in conjuction with a uri import.";
+ throw new BuildException( error, m_task.getLocation() );
+ }
+ if( null != m_classname )
+ {
+ final String error =
+ "Interfaces may not be used in conjuction with the class
attribute.";
+ throw new BuildException( error, m_task.getLocation() );
+ }
+ final InterfaceDataType data = new InterfaceDataType();
+ m_interfaces.add( data );
+ return data;
+ }
+
+ /**
* Add an transition within this state.
* @return the operation datatype
*/
@@ -269,9 +294,10 @@
String name = getStateName();
Trigger[] triggers = getTriggers();
Operation[] operations = getOperations();
+ Interface[] interfaces = getInterfaces();
Transition[] transitions = getTransitions();
State[] states = getStates();
- return new DefaultState( name, triggers, transitions,
operations, states, m_terminal );
+ return new DefaultState( name, triggers, transitions,
interfaces, operations, states, m_terminal );
}
}
@@ -311,6 +337,18 @@
return values;
}
+ Interface[] getInterfaces()
+ {
+ InterfaceDataType[] types = (InterfaceDataType[])
m_interfaces.toArray( new InterfaceDataType[0] );
+ Interface[] values = new Interface[ types.length ];
+ for( int i=0; i<types.length; i++ )
+ {
+ InterfaceDataType data = types[i];
+ values[i] = data.getInterface();
+ }
+ return values;
+ }
+
Transition[] getTransitions()
{
TransitionDataType[] types = (TransitionDataType[])
m_transitions.toArray( new TransitionDataType[0] );
Modified: trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -95,6 +95,15 @@
}
/**
+ * Add an interface within this state.
+ * @return the interface datatype
+ */
+ public InterfaceDataType createInterface()
+ {
+ return getData().createInterface();
+ }
+
+ /**
* Add an transition within this state.
* @return the operation datatype
*/
Modified: trunk/main/planet/http/demo/build.xml
===================================================================
--- trunk/main/planet/http/demo/build.xml 2006-01-26 07:36:59 UTC (rev
980)
+++ trunk/main/planet/http/demo/build.xml 2006-01-27 12:48:05 UTC (rev
981)
@@ -30,6 +30,7 @@
<state>
<operation name="memory" method="getMemoryStats"/>
<operation name="stats" method="getStats"/>
+ <interface name="control"
class="net.dpml.http.demo.ManagementOperations"/>
</state>
<parts>
<component type="net.dpml.http.impl.HttpServerImpl" key="server"
collection="hard">
Modified: trunk/main/planet/http/demo/src/main/net/dpml/http/demo/Demo.java
===================================================================
--- trunk/main/planet/http/demo/src/main/net/dpml/http/demo/Demo.java
2006-01-26 07:36:59 UTC (rev 980)
+++ trunk/main/planet/http/demo/src/main/net/dpml/http/demo/Demo.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -28,7 +28,7 @@
* and testing and validating interfaces and implementations related
* to remote management and control of interal parts.
*/
-public class Demo
+public class Demo implements ManagementOperations
{
/**
* HTTP Demo component context.
@@ -80,13 +80,23 @@
}
/**
- * Return
+ * Testing management interface declarations.
*/
+ public void doSomething()
+ {
+ getLogger().info( "Hello World!" );
+ }
+
+ /**
+ * Return the logging channel.
+ * @return the logger
+ */
private Logger getLogger()
{
return m_logger;
}
+
/**
* Return some stats infomation using a supplied argument.
* @param arg a value such as 'memory'
Added:
trunk/main/planet/http/demo/src/main/net/dpml/http/demo/ManagementOperations.java
===================================================================
---
trunk/main/planet/http/demo/src/main/net/dpml/http/demo/ManagementOperations.java
2006-01-26 07:36:59 UTC (rev 980)
+++
trunk/main/planet/http/demo/src/main/net/dpml/http/demo/ManagementOperations.java
2006-01-27 12:48:05 UTC (rev 981)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 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 net.dpml.http.demo;
+
+/**
+ * The set of management operations dynamically exposed by the HTTP demo.
+ */
+public interface ManagementOperations
+{
+ /**
+ * Do something.
+ */
+ void doSomething();
+}
+
- r981 - in trunk/main: central/src/docs/metro/tasks/graph central/src/docs/metro/tasks/types/state metro/part/api/src/main/net/dpml/part metro/state/api/src/main/net/dpml/state metro/state/impl/etc/test metro/state/impl/src/main/net/dpml/state/impl metro/state/impl/src/test/net/dpml/state/test metro/station/console/src/main/net/dpml/station/console metro/station/server/src/main/net/dpml/station/server metro/tools/src/main/net/dpml/metro/tools planet/http/demo planet/http/demo/src/main/net/dpml/http/demo, mcconnell at BerliOS, 01/27/2006
Archive powered by MHonArc 2.6.24.