notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1015 - in trunk/main/metro: exec/src/main/net/dpml/metro/exec model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test part/api/src/main/net/dpml/part runtime/src/main/net/dpml/metro/runtime test test/src/main/net/dpml/test/app test/src/test/net/dpml/metro/runtime/test tools/src/main/net/dpml/metro/tools
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1015 - in trunk/main/metro: exec/src/main/net/dpml/metro/exec model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test part/api/src/main/net/dpml/part runtime/src/main/net/dpml/metro/runtime test test/src/main/net/dpml/test/app test/src/test/net/dpml/metro/runtime/test tools/src/main/net/dpml/metro/tools
- Date: Fri, 3 Feb 2006 18:22:23 +0100
Author: mcconnell
Date: 2006-02-03 18:22:04 +0100 (Fri, 03 Feb 2006)
New Revision: 1015
Added:
trunk/main/metro/model/src/main/net/dpml/metro/data/NullDirective.java
trunk/main/metro/model/src/main/net/dpml/metro/info/Composite.java
Modified:
trunk/main/metro/exec/src/main/net/dpml/metro/exec/AbstractAdapter.java
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ApplicationHandler.java
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ComponentAdapter.java
trunk/main/metro/model/src/main/net/dpml/metro/PartsManager.java
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
trunk/main/metro/part/api/src/main/net/dpml/part/ComponentOperations.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
trunk/main/metro/test/build.xml
trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ComponentModelTestCase.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
Log:
* improve part key evaluation technique through return type validation
* include dynamic parts handling in component directive
* add support for container managed context entries
* make activation policy references in <component> refer to enum names
(instead of boolean values)
Modified:
trunk/main/metro/exec/src/main/net/dpml/metro/exec/AbstractAdapter.java
===================================================================
--- trunk/main/metro/exec/src/main/net/dpml/metro/exec/AbstractAdapter.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/exec/src/main/net/dpml/metro/exec/AbstractAdapter.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -27,6 +27,7 @@
import net.dpml.part.Provider;
import net.dpml.part.Service;
import net.dpml.part.ServiceNotFoundException;
+import net.dpml.part.ActivationPolicy;
import net.dpml.transit.Logger;
@@ -67,6 +68,23 @@
//------------------------------------------------------------------------------
/**
+ * Get the activation policy. If the activation policy is STARTUP, an
implementation
+ * a handler shall immidiately activation a runtime instance. If the
policy is on DEMAND
+ * an implementation shall defer activiation until an explicit request is
received. If
+ * the policy if SYSTEM activation may occur at the discretion of an
implementation.
+ *
+ * @return the activation policy
+ * @exception RemoteException if a remote exception occurs
+ * @see ActivationPolicy#SYSTEM
+ * @see ActivationPolicy#STARTUP
+ * @see ActivationPolicy#DEMAND
+ */
+ public ActivationPolicy getActivationPolicy() throws RemoteException
+ {
+ return ActivationPolicy.SYSTEM;
+ }
+
+ /**
* Return a handler capable of supporting the requested service.
* @param service the service descriptor
* @return a component matching the requested service
Modified:
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ApplicationHandler.java
===================================================================
---
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ApplicationHandler.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ApplicationHandler.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -156,12 +156,11 @@
m_callback = new LocalCallback();
}
- Properties properties = getCommandLineProperties( line );
- properties.list( System.out );
URI config = getConfigurationURI( line );
URI params = getParametersURI( line );
URI categories = getCategoriesURI( line );
+ Properties properties = getCommandLineProperties( line );
Component component = resolveTargetComponent( logger, uri, config,
params, categories, properties );
m_callback.started( PROCESS_ID, component );
Modified:
trunk/main/metro/exec/src/main/net/dpml/metro/exec/ComponentAdapter.java
===================================================================
--- trunk/main/metro/exec/src/main/net/dpml/metro/exec/ComponentAdapter.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/exec/src/main/net/dpml/metro/exec/ComponentAdapter.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -32,6 +32,7 @@
import net.dpml.metro.info.EntryDescriptor;
import net.dpml.metro.data.ValueDirective;
+import net.dpml.part.ActivationPolicy;
import net.dpml.part.ControlException;
import net.dpml.part.ServiceNotFoundException;
import net.dpml.part.Controller;
@@ -184,6 +185,23 @@
//------------------------------------------------------------------------------
/**
+ * Get the activation policy. If the activation policy is STARTUP, an
implementation
+ * a handler shall immidiately activation a runtime instance. If the
policy is on DEMAND
+ * an implementation shall defer activiation until an explicit request is
received. If
+ * the policy if SYSTEM activation may occur at the discretion of an
implementation.
+ *
+ * @return the activation policy
+ * @exception RemoteException if a remote exception occurs
+ * @see ActivationPolicy#SYSTEM
+ * @see ActivationPolicy#STARTUP
+ * @see ActivationPolicy#DEMAND
+ */
+ public ActivationPolicy getActivationPolicy() throws RemoteException
+ {
+ return m_component.getActivationPolicy();
+ }
+
+ /**
* Return a handler capable of supporting the requested service.
* @param service the service descriptor
* @return a component matchi9ng the requested service
Modified: trunk/main/metro/model/src/main/net/dpml/metro/PartsManager.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/PartsManager.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/model/src/main/net/dpml/metro/PartsManager.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -19,6 +19,7 @@
package net.dpml.metro;
import net.dpml.part.ControlException;
+import net.dpml.part.Service;
import net.dpml.lang.UnknownKeyException;
@@ -46,6 +47,13 @@
ComponentHandler getComponentHandler( String key ) throws
UnknownKeyException;
/**
+ * Return an array of component handlers assignable to the supplied
service.
+ * @param service the service class to match against
+ * @return the local component handler array
+ */
+ ComponentHandler[] getComponentHandlers( Class service );
+
+ /**
* Return the commissioned state of the part collection.
* @return true if commissioned else false
*/
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -166,7 +166,7 @@
CollectionPolicy.SYSTEM,
LifestylePolicy.TRANSIENT,
classname,
- null, null, null, null, null );
+ null, null, null, null, null, null );
}
/**
@@ -186,7 +186,8 @@
template.getContextDirective(),
template.getParameters(),
template.getConfiguration(),
- template.getClassLoaderDirective() );
+ template.getClassLoaderDirective(),
+ template.getPartReferences() );
}
/**
@@ -212,9 +213,10 @@
final ContextDirective context,
final Parameters parameters,
final Configuration config,
- final ClassLoaderDirective classloader )
+ final ClassLoaderDirective classloader,
+ final PartReference[] parts )
{
- super( name, activation, categories, classloader );
+ super( name, activation, categories, classloader, parts );
if( null == classname )
{
@@ -339,19 +341,19 @@
{
return false;
}
- else if( !m_context.equals( profile.getContextDirective() ) )
+ if( !m_context.equals( profile.getContextDirective() ) )
{
return false;
}
- else if( !equals( m_collection, profile.getCollectionPolicy() ) )
+ if( !equals( m_collection, profile.getCollectionPolicy() ) )
{
return false;
}
- else if( !equals( m_lifestyle, profile.getLifestylePolicy() ) )
+ if( !equals( m_lifestyle, profile.getLifestylePolicy() ) )
{
return false;
}
- else if( !equals( m_parameters, profile.getParameters() ) )
+ if( !equals( m_parameters, profile.getParameters() ) )
{
return false;
}
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -64,7 +64,7 @@
public Expression instantiate( Object old, Encoder encoder )
{
ComponentDirective directive = (ComponentDirective) old;
- Object[] args = new Object[10];
+ Object[] args = new Object[11];
args[0] = directive.getName();
args[1] = directive.getActivationPolicy();
args[2] = directive.getCollectionPolicy();
@@ -75,6 +75,7 @@
args[7] = directive.getParameters();
args[8] = directive.getConfiguration();
args[9] = directive.getClassLoaderDirective();
+ args[10] = directive.getPartReferences();
return new Expression( old, old.getClass(), "new", args );
}
}
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -19,6 +19,8 @@
package net.dpml.metro.data;
import net.dpml.part.ActivationPolicy;
+import net.dpml.metro.info.Composite;
+import net.dpml.metro.info.PartReference;
/**
* Abstract base class for the ComponentDirective.
@@ -26,7 +28,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public abstract class DeploymentDirective extends AbstractDirective
implements Comparable
+public abstract class DeploymentDirective extends Composite implements
Comparable
{
//--------------------------------------------------------------------------
// static
@@ -81,8 +83,10 @@
*/
public DeploymentDirective(
final String name, ActivationPolicy activation, CategoriesDirective
categories,
- ClassLoaderDirective classloader )
+ ClassLoaderDirective classloader, PartReference[] parts )
{
+ super( parts );
+
m_activation = activation;
if( null == categories )
@@ -204,7 +208,7 @@
*/
public boolean equals( Object other )
{
- if( null == other )
+ if( !super.equals( other ) )
{
return false;
}
@@ -243,11 +247,11 @@
*/
public int hashCode()
{
- int hash = m_name.hashCode();
+ int hash = super.hashCode();
+ hash ^= m_name.hashCode();
hash ^= m_activation.hashCode();
hash ^= m_categories.hashCode();
hash ^= m_classloader.hashCode();
return hash;
}
-
}
Added: trunk/main/metro/model/src/main/net/dpml/metro/data/NullDirective.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/data/NullDirective.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/model/src/main/net/dpml/metro/data/NullDirective.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004 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.data;
+
+import net.dpml.part.Directive;
+
+/**
+ * A <code>NullDirective</code> is used to mark a solution as resolved
+ * on the basis that the solution will be managed by an enclosing component.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class NullDirective extends AbstractDirective implements Directive
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+
//--------------------------------------------------------------------------
+ // constructors
+
//--------------------------------------------------------------------------
+
+ /**
+ * Create a new null directive.
+ */
+ public NullDirective()
+ {
+ }
+
+
//--------------------------------------------------------------------------
+ // NullDirective
+
//--------------------------------------------------------------------------
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ return ( other instanceof NullDirective );
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ return getClass().hashCode();
+ }
+}
Added: trunk/main/metro/model/src/main/net/dpml/metro/info/Composite.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/Composite.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/Composite.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1999-2004 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 net.dpml.metro.info;
+
+import java.beans.Encoder;
+import java.beans.XMLEncoder;
+import java.beans.XMLDecoder;
+import java.beans.ExceptionListener;
+import java.beans.Expression;
+import java.beans.DefaultPersistenceDelegate;
+import java.io.Serializable;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+
+import net.dpml.part.Directive;
+import net.dpml.state.State;
+
+/**
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public abstract class Composite implements Serializable
+{
+ static final long serialVersionUID = 1L;
+
+ private final PartReference[] m_parts;
+
+ /**
+ * Creation of a new Composite instance.
+ *
+ * @param parts an array of part descriptors
+ */
+ public Composite( final PartReference[] parts )
+ {
+ if( null == parts )
+ {
+ m_parts = new PartReference[0];
+ }
+ else
+ {
+ m_parts = parts;
+ }
+ }
+
+ /**
+ * Returns the parts declared by this component type.
+ *
+ * @return the part descriptors
+ */
+ public PartReference[] getPartReferences()
+ {
+ return m_parts;
+ }
+
+ /**
+ * Retrieve an identified directive.
+ *
+ * @param key the directive key
+ * @return the directive or null if the directive key is unknown
+ */
+ public Directive getDirective( final String key )
+ {
+ for ( int i = 0; i < m_parts.length; i++ )
+ {
+ PartReference reference = m_parts[i];
+ if( reference.getKey().equals( key ) )
+ {
+ return reference.getDirective();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Test is the supplied object is equal to this object.
+ * @param other the other object
+ * @return true if the object are equivalent
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( !( other instanceof Composite ) )
+ {
+ return false;
+ }
+ Composite t = (Composite) other;
+ if( m_parts.length != t.m_parts.length )
+ {
+ return false;
+ }
+ else
+ {
+ for( int i=0; i<m_parts.length; i++ )
+ {
+ if( !m_parts[i].equals( t.m_parts[i] ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return the hashcode for the object.
+ * @return the hashcode value
+ */
+ public int hashCode()
+ {
+ int hash = getClass().hashCode();
+ for( int i = 0; i < m_parts.length; i++ )
+ {
+ hash ^= m_parts[i].hashCode();
+ hash = hash - 163611323;
+ }
+ return hash;
+ }
+
+ /**
+ * Utility to compare two object for equality.
+ * @param a the first object
+ * @param b the second object
+ * @return true if the objects are equal
+ */
+ protected boolean equals( Object a, Object b )
+ {
+ if( null == a )
+ {
+ return ( null == b );
+ }
+ else
+ {
+ return a.equals( b );
+ }
+ }
+}
Modified: trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -54,7 +54,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class Type implements Serializable
+public class Type extends Composite implements Serializable
{
static final long serialVersionUID = 1L;
@@ -260,7 +260,6 @@
private final CategoryDescriptor[] m_categories;
private final ContextDescriptor m_context;
private final ServiceDescriptor[] m_services;
- private final PartReference[] m_parts;
private final State m_graph;
/**
@@ -284,6 +283,8 @@
final PartReference[] parts, State graph )
throws NullPointerException
{
+ super( parts );
+
if( null == info )
{
throw new NullPointerException( "info" );
@@ -313,15 +314,6 @@
m_categories = loggers;
m_context = context;
m_graph = graph;
-
- if( null == parts )
- {
- m_parts = new PartReference[0];
- }
- else
- {
- m_parts = parts;
- }
}
/**
@@ -444,35 +436,6 @@
//}
/**
- * Returns the parts declared by this component type.
- *
- * @return the part descriptors
- */
- public PartReference[] getPartReferences()
- {
- return m_parts;
- }
-
- /**
- * Retrieve an identified directive.
- *
- * @param key the directive key
- * @return the directive or null if the directive key is unknown
- */
- public Directive getDirective( final String key )
- {
- for ( int i = 0; i < m_parts.length; i++ )
- {
- PartReference reference = m_parts[i];
- if( reference.getKey().equals( key ) )
- {
- return reference.getDirective();
- }
- }
- return null;
- }
-
- /**
* Return a string representation of the type.
* @return the stringified type
*/
@@ -488,7 +451,7 @@
*/
public boolean equals( Object other )
{
- if( null == other )
+ if( !super.equals( other ) )
{
return false;
}
@@ -501,20 +464,6 @@
{
return false;
}
- if( m_parts.length != t.m_parts.length )
- {
- return false;
- }
- else
- {
- for( int i=0; i<m_parts.length; i++ )
- {
- if( !m_parts[i].equals( t.m_parts[i] ) )
- {
- return false;
- }
- }
- }
if( !m_context.equals( t.m_context ) )
{
return false;
@@ -546,14 +495,10 @@
*/
public int hashCode()
{
- int hash = m_info.hashCode();
+ int hash = super.hashCode();
+ hash ^= m_info.hashCode();
hash ^= m_context.hashCode();
hash ^= m_graph.hashCode();
- for( int i = 0; i < m_parts.length; i++ )
- {
- hash ^= m_parts[i].hashCode();
- hash = hash - 163611323;
- }
for( int i = 0; i < m_services.length; i++ )
{
hash ^= m_services[i].hashCode();
Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -59,6 +59,7 @@
private Configuration m_configuration;
private ClassLoaderDirective m_classloader;
private ComponentDirective m_directive;
+ private PartReference[] m_parts;
/**
* Setup the test case.
@@ -76,10 +77,11 @@
m_parameters = DefaultParameters.EMPTY_PARAMETERS;
m_configuration = new DefaultConfiguration( "" );
m_classloader = createClassLoaderDirective();
+ m_parts = new PartReference[0];
m_directive =
new ComponentDirective(
m_name, m_activation, m_collection, m_lifestyle, m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader );
+ m_categories, m_context, m_parameters, m_configuration,
m_classloader, m_parts );
}
/**
@@ -122,7 +124,7 @@
{
new ComponentDirective(
"", m_activation, m_collection, m_lifestyle, m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader );
+ m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
fail( "Did not throw an IllegalArgumentException for a '' name."
);
}
catch( IllegalArgumentException e )
@@ -140,7 +142,7 @@
{
new ComponentDirective(
"fred.blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader );
+ m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
fail( "Did not throw an IllegalArgumentException for a name with
a period." );
}
catch( IllegalArgumentException e )
@@ -158,7 +160,7 @@
{
new ComponentDirective(
"fred,blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader );
+ m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
fail( "Did not throw an IllegalArgumentException for a name with
a comma." );
}
catch( IllegalArgumentException e )
@@ -176,7 +178,7 @@
{
new ComponentDirective(
"fred/blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader );
+ m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
fail( "Did not throw an IllegalArgumentException for a name with
a '/'." );
}
catch( IllegalArgumentException e )
Modified:
trunk/main/metro/part/api/src/main/net/dpml/part/ComponentOperations.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/ComponentOperations.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/ComponentOperations.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -48,6 +48,20 @@
boolean isaCandidate( Service service ) throws RemoteException;
/**
+ * Get the activation policy. If the activation policy is STARTUP, an
implementation
+ * a handler shall immidiately activation a runtime instance. If the
policy is on DEMAND
+ * an implementation shall defer activiation until an explicit request is
received. If
+ * the policy if SYSTEM activation may occur at the discretion of an
implementation.
+ *
+ * @return the activation policy
+ * @exception RemoteException if a remote exception occurs
+ * @see ActivationPolicy#SYSTEM
+ * @see ActivationPolicy#STARTUP
+ * @see ActivationPolicy#DEMAND
+ */
+ ActivationPolicy getActivationPolicy() throws RemoteException;
+
+ /**
* Initiate activation of a runtime handler.
* @exception ControlException if an activation error occurs
* @exception InvocationTargetException if the component declares
activation on startup
Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -652,6 +652,7 @@
String spec = uri.getSchemeSpecificPart();
ServiceDescriptor request = new ServiceDescriptor(
spec );
DefaultService service = loadService( handler,
request );
+
try
{
return executeLookup( handler, service );
@@ -695,7 +696,7 @@
else
{
final String error =
- "Unsuppored context directive argument class: " +
directive;
+ "Unsuppored context directive class: " +
directive.getClass();
throw new ControllerException( error );
}
}
@@ -725,7 +726,6 @@
try
{
Component component = parent.lookup( service );
- component.activate();
return component.getProvider().getValue( false );
}
catch( RemoteException e )
Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -399,6 +399,15 @@
+ "]." );
}
+ // check if this component can handle the request
+
+ //if( isaCandidate( service ) )
+ //{
+ // return this;
+ //}
+
+ // check if a child component can handle the request
+
Component[] components = m_parts.getComponents();
for( int i=0; i<components.length; i++ )
{
@@ -408,6 +417,9 @@
return component;
}
}
+
+ // delegate to the parent
+
if( m_parent != null )
{
return m_parent.lookup( service );
@@ -545,6 +557,23 @@
}
/**
+ * Get the activation policy. If the activation policy is STARTUP, an
implementation
+ * a handler shall immidiately activation a runtime instance. If the
policy is on DEMAND
+ * an implementation shall defer activiation until an explicit request is
received. If
+ * the policy if SYSTEM activation may occur at the discretion of an
implementation.
+ *
+ * @return the activation policy
+ * @exception RemoteException if a remote exception occurs
+ * @see ActivationPolicy#SYSTEM
+ * @see ActivationPolicy#STARTUP
+ * @see ActivationPolicy#DEMAND
+ */
+ public ActivationPolicy getActivationPolicy() throws RemoteException
+ {
+ return m_model.getActivationPolicy();
+ }
+
+ /**
* Deactivate the component.
*/
public synchronized void deactivate()
@@ -579,7 +608,7 @@
{
return m_services;
}
-
+
/**
* Return true if this handler is a candidate for the supplied service
definition.
* @param service the service definition
@@ -596,7 +625,13 @@
DefaultService s = services[i];
Version v = s.getVersion();
Class c = s.getServiceClass();
- if( v.complies( version ) && clazz.isAssignableFrom( c ) )
+
+ //System.out.println( "# CLASS: " + clazz + " / " + c + ", " +
clazz.isAssignableFrom( c ) );
+ //System.out.println( "# VERSION: " + version + " / " + v + ", "
+ v.complies( version ) );
+ //System.out.println( "# VERSION/2: " + version.complies( v ) );
+ //if( v.complies( version ) && clazz.isAssignableFrom( c ) )
+
+ if( version.complies( v ) && clazz.isAssignableFrom( c ) )
{
return true;
}
Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.EventObject;
import java.util.EventListener;
+import java.util.Map;
import net.dpml.metro.data.ComponentDirective;
import net.dpml.metro.data.ClassLoaderDirective;
@@ -32,6 +33,7 @@
import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.Type;
import net.dpml.metro.info.PartReference;
+import net.dpml.metro.info.Composite;
import net.dpml.metro.ComponentModel;
import net.dpml.metro.ContextModel;
import net.dpml.metro.ComponentManager;
@@ -73,7 +75,7 @@
private final Type m_type;
private final ComponentDirective m_directive;
private final ClassLoader m_classloader;
- private final String[] m_partKeys;
+ //private final String[] m_partKeys;
private final HashMap m_parts = new HashMap();
private final DefaultContextModel m_context;
private final String m_path;
@@ -118,22 +120,33 @@
m_context = new DefaultContextModel( this, logger, m_classloader,
m_type, context );
final String base = m_path + PARTITION_SEPARATOR;
- m_partKeys = getPartKeys( m_type );
- for( int i=0; i < m_partKeys.length; i++ )
+ processParts( controller, classloader, m_type, m_parts, base );
+ processParts( controller, classloader, m_directive, m_parts, base );
+ }
+
+ private void processParts(
+ ComponentController controller, ClassLoader classloader, Composite
composite, Map map, String base )
+ throws ControlException, RemoteException
+ {
+ PartReference[] references = composite.getPartReferences();
+ for( int i=0; i < references.length; i++ )
{
- String key = m_partKeys[i];
- Directive part = m_type.getDirective( key );
+ PartReference ref = references[i];
+ String key = ref.getKey();
+ Directive part = composite.getDirective( key );
if( part instanceof ComponentDirective )
{
ComponentDirective component = (ComponentDirective) part;
ComponentModel model =
- m_controller.createComponentModel( m_classloader, base,
component );
- m_parts.put( key, model );
+ controller.createComponentModel( classloader, base,
component );
+ map.put( key, model );
}
else
{
final String error =
- "Support for foreign parts not supported at this time.";
+ "Foreign part ["
+ + part.getClass()
+ + "] not supported.";
throw new UnsupportedOperationException( error );
}
}
@@ -330,12 +343,12 @@
}
/**
- * Return the set of component model keys.
+ * Return the internal part keys.
* @return the component part keys
*/
public String[] getPartKeys()
{
- return m_partKeys;
+ return (String[]) m_parts.keySet().toArray( new String[0] );
}
/**
Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -30,9 +30,12 @@
import net.dpml.metro.ComponentManager;
import net.dpml.metro.ComponentModel;
+import net.dpml.part.ActivationPolicy;
import net.dpml.part.ControlException;
import net.dpml.part.Component;
import net.dpml.part.Model;
+import net.dpml.part.Service;
+import net.dpml.part.Version;
import net.dpml.lang.UnknownKeyException;
@@ -133,7 +136,7 @@
//-------------------------------------------------------------------
/**
- * Return the array of keys used to idenetity internal parts.
+ * Return the array of keys used to identify internal parts.
* @return the part key array
*/
public String[] getKeys()
@@ -157,6 +160,41 @@
throw new UnknownKeyException( key );
}
}
+
+ /**
+ * Return an array of component handlers assignable to the supplied
service.
+ * @param clazz the service class to match against
+ * @return the local component handler array
+ */
+ public ComponentHandler[] getComponentHandlers( Class clazz )
+ {
+ Service service = new DefaultService( clazz, Version.getVersion(
"-1" ) );
+ ArrayList list = new ArrayList();
+ Component[] components = getComponents();
+ for( int i=0; i<components.length; i++ )
+ {
+ Component component = components[i];
+ if( component instanceof ComponentHandler )
+ {
+ ComponentHandler handler = (ComponentHandler) component;
+ try
+ {
+ if( handler.isaCandidate( service ) )
+ {
+ list.add( component );
+ }
+ }
+ catch( RemoteException e )
+ {
+ final String error =
+ "Unexpected remote exception raised during subsidiary
component evaluation."
+ + "\nEnclosing Component: " + m_handler;
+ throw new ControllerRuntimeException( error, e );
+ }
+ }
+ }
+ return (ComponentHandler[]) list.toArray( new ComponentHandler[0] );
+ }
/**
* Return the component model for the supplied component.
@@ -187,6 +225,10 @@
*/
public synchronized ComponentHandler getComponentHandler( String key )
throws UnknownKeyException
{
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
if( m_handlers.containsKey( key ) )
{
return (ComponentHandler) m_handlers.get( key );
@@ -223,7 +265,7 @@
throw new IllegalStateException( error );
}
- getLogger().debug( "commissioning" );
+ getLogger().debug( "commissioning internal parts" );
ArrayList list = new ArrayList();
Component[] components = getComponents();
ControlException exception = null;
@@ -232,8 +274,11 @@
Component component = components[i];
try
{
- component.activate();
- list.add( component );
+ if( component.getActivationPolicy().equals(
ActivationPolicy.STARTUP ) )
+ {
+ component.activate();
+ list.add( component );
+ }
}
catch( Throwable e )
{
@@ -241,7 +286,7 @@
"Error during the commission of the internal parts of a
component."
+ "\nEnclosing Component: " + m_handler
+ "\nInternal Part: " + component;
- exception = new ControllerException( error, e );
+ exception = new ControllerException( error, e );
break;
}
}
Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -18,6 +18,7 @@
package net.dpml.metro.runtime;
+import java.util.Map;
import java.beans.Introspector;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -25,6 +26,7 @@
import net.dpml.metro.ComponentHandler;
import net.dpml.metro.PartsManager;
import net.dpml.part.Component;
+import net.dpml.part.Provider;
/**
* Invoication handler for the Context inner class. The invocation handler
is
@@ -87,7 +89,7 @@
final int semantic = getPartSemantic( method );
final String postfix = getPartPostfix( method );
- final String key = getPartKey( method, semantic );
+ final String key = getPartKey( method, semantic, postfix );
final ComponentHandler handler = m_manager.getComponentHandler( key
);
@@ -227,20 +229,21 @@
public static String getPartPostfix( Method method )
{
+ Class type = method.getReturnType();
String name = method.getName();
- if( name.endsWith( COMPONENT_KEY ) )
+ if( name.endsWith( COMPONENT_KEY ) &&
Component.class.isAssignableFrom( type ) )
{
return COMPONENT_KEY;
}
- else if( name.endsWith( HANDLER_KEY ) )
+ else if( name.endsWith( HANDLER_KEY ) &&
ComponentHandler.class.isAssignableFrom( type ) )
{
return HANDLER_KEY;
}
- else if( name.endsWith( PROVIDER_KEY ) )
+ else if( name.endsWith( PROVIDER_KEY ) &&
Provider.class.isAssignableFrom( type ) )
{
return PROVIDER_KEY;
}
- else if( name.endsWith( MAP_KEY ) )
+ else if( name.endsWith( MAP_KEY ) && Map.class.isAssignableFrom(
type ) )
{
return MAP_KEY;
}
@@ -250,33 +253,37 @@
}
}
- public static String getPartKey( Method method, int semantic )
+ public static String getPartKey( Method method, int semantic, String
postfix )
{
String name = method.getName();
if( GET == semantic )
{
- if( name.endsWith( COMPONENT_KEY ) )
+ if( null == postfix )
{
+ return formatKey( name, 3 );
+ }
+ else if( COMPONENT_KEY.equals( postfix ) )
+ {
int n = COMPONENT_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
}
- else if( name.endsWith( PROVIDER_KEY ) )
+ else if( PROVIDER_KEY.equals( postfix ) )
{
int n = PROVIDER_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
}
- else if( name.endsWith( HANDLER_KEY ) )
+ else if( HANDLER_KEY.equals( postfix ) )
{
int n = HANDLER_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
}
- else if( name.endsWith( MAP_KEY ) )
+ else if( MAP_KEY.equals( postfix ) )
{
int n = MAP_KEY.length();
int j = name.length() - n;
@@ -285,7 +292,9 @@
}
else
{
- return formatKey( name, 3 );
+ final String error =
+ "Unrecognized part postfix argument [" + postfix + "].";
+ throw new IllegalArgumentException( error );
}
}
else if( RELEASE == semantic )
Modified: trunk/main/metro/test/build.xml
===================================================================
--- trunk/main/metro/test/build.xml 2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/test/build.xml 2006-02-03 17:22:04 UTC (rev 1015)
@@ -138,7 +138,7 @@
<type class="net.dpml.test.composite.ChildComponent" name="child"/>
<type class="net.dpml.test.composite.CompositeComponent" name="parent">
<parts>
- <component type="net.dpml.test.composite.ChildComponent"
key="child" activation="false">
+ <component type="net.dpml.test.composite.ChildComponent"
key="child">
<context>
<entry key="color" method="BLUE"/>
</context>
@@ -147,7 +147,7 @@
</type>
<type class="net.dpml.test.composite.PartsComponent" name="parent">
<parts>
- <component type="net.dpml.test.composite.ChildComponent"
key="child" activation="false">
+ <component type="net.dpml.test.composite.ChildComponent"
key="child">
<context>
<entry key="color" method="BLUE"/>
</context>
@@ -156,14 +156,14 @@
</type>
</types>
- <c:component dest="target/test/composite.part" test="true"
activation="false"
+ <c:component dest="target/test/composite.part" test="true"
type="net.dpml.test.composite.CompositeComponent" collection="hard">
<context>
<entry key="color" method="RED"/>
</context>
</c:component>
- <c:component dest="target/test/parts.part" test="true" activation="false"
+ <c:component dest="target/test/parts.part" test="true"
type="net.dpml.test.composite.PartsComponent" collection="hard">
<context>
<entry key="color" method="RED"/>
@@ -195,14 +195,14 @@
</state>
</c:type>
- <c:component dest="target/test/lifecycle.part" test="true"
activation="false"
+ <c:component dest="target/test/lifecycle.part" test="true"
type="net.dpml.test.lifecycle.StartableComponent" collection="hard">
</c:component>
<!-- categories component -->
<c:type class="net.dpml.test.categories.CategoriesComponent"
name="categories" lifestyle="thread"/>
- <c:component dest="target/test/categories.part" test="true"
activation="true"
+ <c:component dest="target/test/categories.part" test="true"
activation="STARTUP"
type="net.dpml.test.categories.CategoriesComponent"
collection="hard">
<categories>
<category name="alpha" priority="warn"/>
@@ -213,7 +213,7 @@
<!-- configuration component -->
<c:type class="net.dpml.test.config.ConfigurableComponent" name="config"
lifestyle="thread"/>
- <c:component dest="target/test/config.part" test="true" activation="true"
+ <c:component dest="target/test/config.part" test="true"
activation="STARTUP"
type="net.dpml.test.config.ConfigurableComponent" collection="hard">
<configuration name="fred">
<place>Cafe de'Orleans</place>
@@ -226,7 +226,7 @@
<!-- parameterizable component -->
<c:type class="net.dpml.test.params.ParameterizableComponent"
name="params" lifestyle="thread"/>
- <c:component dest="target/test/params.part" test="true" activation="true"
+ <c:component dest="target/test/params.part" test="true"
activation="STARTUP"
type="net.dpml.test.params.ParameterizableComponent"
collection="hard">
<parameters>
<param name="name" value="fred"/>
@@ -241,12 +241,12 @@
<type name="listener" class="net.dpml.test.app.DefaultListener"
lifestyle="singleton"/>
<type name="demo" class="net.dpml.test.app.Demo" lifestyle="singleton">
<parts>
- <component key="server" type="net.dpml.test.app.DefaultServer">
+ <component key="server" type="net.dpml.test.app.DefaultServer" >
<context>
<entry key="port" value="1010"/>
</context>
</component>
- <component key="listener" type="net.dpml.test.app.DefaultListener">
+ <component key="listener" type="net.dpml.test.app.DefaultListener"
>
<context>
<entry key="server" lookup="net.dpml.test.app.Server"/>
</context>
@@ -256,7 +256,7 @@
</c:types>
<c:component type="net.dpml.test.app.Demo"
- dest="target/test/application.part" test="true" activation="true"
collection="hard"/>
+ dest="target/test/application.part" test="true" collection="hard"/>
<!-- operations test -->
@@ -267,7 +267,7 @@
</state>
</c:type>
- <c:component dest="target/test/state.part" test="true" activation="true"
+ <c:component dest="target/test/state.part" test="true"
activation="STARTUP"
type="net.dpml.test.state.ManagedComponent" collection="hard"/>
</target>
Modified: trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java
===================================================================
--- trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java 2006-02-03
06:01:19 UTC (rev 1014)
+++ trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java 2006-02-03
17:22:04 UTC (rev 1015)
@@ -56,8 +56,10 @@
public int test( String message ) throws Exception
{
m_logger.debug( "test: " + message );
- getServer().triggerNotify( message );
- return getListener().getCount();
+ DefaultServer server = getServer();
+ DefaultListener listener = getListener();
+ server.triggerNotify( message );
+ return listener.getCount();
}
DefaultServer getServer() throws Exception
Modified:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ComponentModelTestCase.java
===================================================================
---
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ComponentModelTestCase.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ComponentModelTestCase.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -91,7 +91,7 @@
*/
public void testActivationPolicy() throws Exception
{
- assertEquals( "initial-activation", ActivationPolicy.STARTUP,
m_model.getActivationPolicy() );
+ assertEquals( "initial-activation", ActivationPolicy.SYSTEM,
m_model.getActivationPolicy() );
ActivationPolicy policy = ActivationPolicy.DEMAND;
// uncomment remainder as this is under the ComponentManager
Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-02-03 06:01:19 UTC (rev 1014)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -65,15 +65,16 @@
private String m_classname;
private LifestylePolicy m_lifestyle;
private CollectionPolicy m_collection;
- private boolean m_activation = true;
+ private ActivationPolicy m_activation = ActivationPolicy.SYSTEM;
private CategoriesDataType m_categories;
private ContextDataType m_context;
private ParametersDataType m_parameters;
private ConfigurationDataType m_configuration;
+ private PartsDataType m_parts;
private File m_output;
private Type m_type;
private ComponentDirective m_profile;
-
+
/**
* Override the default output destination.
*
@@ -151,9 +152,9 @@
* Set the activation policy value.
* @param policy the activation policy
*/
- public void setActivation( boolean policy )
+ public void setActivation( String policy )
{
- m_activation = policy;
+ m_activation = ActivationPolicy.parse( policy );
}
/**
@@ -235,6 +236,25 @@
}
/**
+ * Create a new part datatype.
+ * @return a new part datatype
+ */
+ public PartsDataType createParts()
+ {
+ if( m_parts == null )
+ {
+ m_parts = new PartsDataType( this );
+ return m_parts;
+ }
+ else
+ {
+ final String error =
+ "Illegal attempt to create a duplicate parts element.";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+
+ /**
* Execute the task.
*/
public void execute()
@@ -293,53 +313,6 @@
Thread.currentThread().setContextClassLoader( current );
}
- /*
- FileOutputStream output = new FileOutputStream( file );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- throw new BuildException( "Directive encoding failure.",
e );
- }
- }
- );
- try
- {
- encoder.writeObject( profile );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- throw new BuildException( "Directive encoding error.", e );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- encoder.close();
- }
- */
-
- /*
- URI uri = getResource().getArtifact( Part.ARTIFACT_TYPE
).toURI();
- if( null == m_output )
- {
- log( "saving part to: " + uri );
- }
- else
- {
- log( "saving part to: " + m_output );
- }
- URI handler = getPartHandlerURI();
- byte[] bytes = SerializableObjectHelper.writeToByteArray(
profile );
- PartHolder holder = new PartHolder( handler, bytes );
- SerializableObjectHelper.write( holder, file );
- */
-
return profile;
}
@@ -492,7 +465,7 @@
}
/**
- * Build a pert reference.
+ * Build a part reference.
* @param classloader the classloader
* @param type the component type
* @return the part reference
@@ -565,6 +538,7 @@
ContextDirective context = getContextDirective( classloader, type );
Parameters parameters = getParameters();
Configuration configuration = getConfiguration();
+ PartReference[] parts = getParts( classloader );
//
// return the component profile
@@ -572,7 +546,7 @@
return new ComponentDirective(
id, activation, collection, lifestyle, classname, categories,
context,
- parameters, configuration, cld );
+ parameters, configuration, cld, parts );
}
private Type loadType( ClassLoader classloader, String classname )
@@ -701,14 +675,7 @@
*/
public ActivationPolicy getActivationPolicy()
{
- if( m_activation )
- {
- return ActivationPolicy.STARTUP;
- }
- else
- {
- return m_profile.getActivationPolicy();
- }
+ return m_activation;
}
/**
@@ -813,6 +780,28 @@
}
}
+ private PartReference[] getParts( ClassLoader classloader )
+ throws IntrospectionException, IOException
+ {
+ if( null != m_parts )
+ {
+ try
+ {
+ return m_parts.getParts( classloader, null );
+ }
+ catch( ClassNotFoundException cnfe )
+ {
+ final String error =
+ "Unable to load a class referenced by a nested part within
a component type.";
+ throw new BuildException( error, cnfe );
+ }
+ }
+ else
+ {
+ return new PartReference[0];
+ }
+ }
+
/**
* Utility class used to handle uri persistence.
*/
Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
2006-02-03 06:01:19 UTC (rev 1014)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
2006-02-03 17:22:04 UTC (rev 1015)
@@ -25,6 +25,7 @@
import net.dpml.metro.data.ValueDirective;
import net.dpml.part.Directive;
import net.dpml.metro.data.ReferenceDirective;
+import net.dpml.metro.data.NullDirective;
import net.dpml.metro.data.FeatureDirective;
import net.dpml.metro.info.EntryDescriptor;
import net.dpml.metro.info.Type;
@@ -45,6 +46,7 @@
private ClassLoader m_classloader;
private URI m_uri;
private int m_feature = -1;
+ private boolean m_validate = true;
/**
* Set the key that this directive qualifies.
@@ -65,6 +67,15 @@
}
/**
+ * Set the validation flag.
+ * @param flag if false entry validation is disabled
+ */
+ public void setValidate( final boolean flag )
+ {
+ m_validate = flag;
+ }
+
+ /**
* Set the interface classname to locate with the enclosing component.
* @param service the service classname
*/
@@ -164,21 +175,29 @@
public PartReference buildPartReference( ClassLoader classloader, Type
type )
{
String key = getKey();
- URI uri = getURI();
- if( null != uri )
+ if( !m_validate )
{
- Directive directive = new ReferenceDirective( m_uri );
+ Directive directive = new NullDirective();
return new PartReference( key, directive );
}
- else if( m_feature > -1 )
- {
- Directive directive = new FeatureDirective( key, m_feature );
- return new PartReference( key, directive );
- }
else
{
- Directive directive = getValueDirective( classloader, type );
- return new PartReference( key, directive );
+ URI uri = getURI();
+ if( null != uri )
+ {
+ Directive directive = new ReferenceDirective( m_uri );
+ return new PartReference( key, directive );
+ }
+ else if( m_feature > -1 )
+ {
+ Directive directive = new FeatureDirective( key, m_feature );
+ return new PartReference( key, directive );
+ }
+ else
+ {
+ Directive directive = getValueDirective( classloader, type );
+ return new PartReference( key, directive );
+ }
}
}
- r1015 - in trunk/main/metro: exec/src/main/net/dpml/metro/exec model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test part/api/src/main/net/dpml/part runtime/src/main/net/dpml/metro/runtime test test/src/main/net/dpml/test/app test/src/test/net/dpml/metro/runtime/test tools/src/main/net/dpml/metro/tools, mcconnell at BerliOS, 02/03/2006
Archive powered by MHonArc 2.6.24.