Skip to Content.
Sympa Menu

notify-dpml - r1897 - trunk/main/metro/part/src/main/net/dpml/runtime

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1897 - trunk/main/metro/part/src/main/net/dpml/runtime
  • Date: Mon, 12 Mar 2007 05:41:19 +0100

Author: mcconnell
Date: 2007-03-12 05:41:19 +0100 (Mon, 12 Mar 2007)
New Revision: 1897

Modified:
trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategy.java

trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategyHandler.java
trunk/main/metro/part/src/main/net/dpml/runtime/Profile.java
Log:
include support for activation override in profile an component strategy
directive

Modified:
trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategy.java
===================================================================
--- trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategy.java
2007-03-12 04:40:27 UTC (rev 1896)
+++ trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategy.java
2007-03-12 04:41:19 UTC (rev 1897)
@@ -99,8 +99,20 @@

private ServiceRegistry m_registry;

+ /**
+ * Creation of a new component strategy.
+ * @param partition the enclosing partition
+ * @param name the component name relative to the enclosing partition
+ * @param priority the component priority
+ * @param type the component class
+ * @param activation the activation policy
+ * @param context the context model
+ * @param parts the internal part structure
+ * @exception IOException if an IO error occurs
+ */
ComponentStrategy(
- final String partition, final String name, int priority, final Class
type, ContextModel context, PartsDirective parts )
+ final String partition, final String name, int priority, final Class
type,
+ ActivationPolicy activation, ContextModel context, PartsDirective
parts )
throws IOException
{
super( type.getClassLoader() );
@@ -114,7 +126,7 @@
m_context = context;
m_logger = getComponentLogger( m_path );
m_graph = getLifecycleGraph( m_class );
- m_activation = getActivationPolicy( m_class );
+ m_activation = activation;
m_parts = getPartsDirective( parts );

m_parts.initialize( this );
@@ -772,6 +784,7 @@
return LifestylePolicy.THREAD;
}

+ /*
private static ActivationPolicy getActivationPolicy( Class<?> c )
{
if( c.isAnnotationPresent( Activation.class ) )
@@ -782,6 +795,7 @@
}
return ActivationPolicy.SYSTEM;
}
+ */

private static State getLifecycleGraph( Class<?> c ) throws IOException
{

Modified:
trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategyHandler.java
===================================================================
---
trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategyHandler.java
2007-03-12 04:40:27 UTC (rev 1896)
+++
trunk/main/metro/part/src/main/net/dpml/runtime/ComponentStrategyHandler.java
2007-03-12 04:41:19 UTC (rev 1897)
@@ -37,6 +37,8 @@
import net.dpml.lang.StrategyHandler;
import net.dpml.lang.Buffer;

+import net.dpml.annotation.ActivationPolicy;
+
import net.dpml.util.Resolver;
import net.dpml.util.Logger;

@@ -66,7 +68,7 @@
Profile profile = new Profile( c, spec, null );
ContextModel context = getContextModel( null, c, spec, profile,
null, null, null );
PartsDirective parts = profile.getPartsDirective();
- return new ComponentStrategy( null, spec, 0, c, context, parts );
+ return new ComponentStrategy( null, spec, 0, c,
ActivationPolicy.SYSTEM, context, parts );
}

public Component newComponent( Class<?> c, String name ) throws
IOException
@@ -80,6 +82,7 @@
* @param element the DOM element definining the deployment strategy
* @param resolver symbolic property resolver
* @param partition the enclosing partition
+ * @param query the query fragment to applied to the component context
definition
* @return the strategy definition
* @exception IOException if an I/O error occurs
*/
@@ -95,6 +98,7 @@
Query q = new Query( query );
Element contextElement = ElementHelper.getChild( element, "context"
);
ContextModel context = getContextModel( classloader, c, path,
profile, contextElement, resolver, q );
+ ActivationPolicy activation = getActivationPolicy( element, profile
);

try
{
@@ -113,6 +117,7 @@
name,
priority,
c,
+ activation,
context,
parts );

@@ -136,6 +141,31 @@
}
}

+ /**
+ * Return the activation policy.
+ *
+ * @return the resolved activation policy
+ */
+ private static ActivationPolicy getActivationPolicy( Element element,
Profile profile )
+ {
+ if( null == element )
+ {
+ return profile.getActivationPolicy();
+ }
+ else
+ {
+ String value = ElementHelper.getAttribute( element, "activation"
);
+ if( null == value )
+ {
+ return profile.getActivationPolicy();
+ }
+ else
+ {
+ return ActivationPolicy.valueOf( value.toUpperCase() );
+ }
+ }
+ }
+
private int getPriority( Element element, Resolver resolver )
{
String value = ElementHelper.getAttribute( element, "priority",
null, resolver );

Modified: trunk/main/metro/part/src/main/net/dpml/runtime/Profile.java
===================================================================
--- trunk/main/metro/part/src/main/net/dpml/runtime/Profile.java
2007-03-12 04:40:27 UTC (rev 1896)
+++ trunk/main/metro/part/src/main/net/dpml/runtime/Profile.java
2007-03-12 04:41:19 UTC (rev 1897)
@@ -24,14 +24,19 @@

import dpml.lang.DOM3DocumentBuilder;

+import net.dpml.annotation.Activation;
+import net.dpml.annotation.ActivationPolicy;
+
import net.dpml.util.Resolver;
+
import dpml.util.ElementHelper;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
- * Component interface.
+ * A component profile is a datastructure bundled with a class that allows
for
+ * the declaration of default activation, context and part structure.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -44,25 +49,39 @@
private Element m_element;
private ContextDirective m_context;
private PartsDirective m_parts;
+ private ActivationPolicy m_activation;

+ /**
+ * Creation of a new profile using a supplied class, path and property
resolver.
+ * @param c the class
+ * @param path the path
+ * @param resolver the property resolver
+ * @exception IOException if an IO error occurs
+ */
Profile( Class<?> c, String path, Resolver resolver ) throws IOException
{
m_element = getProfileElement( c );
ClassLoader classloader = c.getClassLoader();
m_context = getContextProfile( classloader, m_element, resolver );
m_parts = getPartsProfile( classloader, m_element, resolver, path );
+ m_activation = getActivationPolicy( m_element, c );
}

ContextDirective getContextDirective()
{
return m_context;
}
-
+
PartsDirective getPartsDirective()
{
return m_parts;
}
-
+
+ ActivationPolicy getActivationPolicy()
+ {
+ return m_activation;
+ }
+
private static Element getProfileElement( Class<?> c ) throws IOException
{
ClassLoader classloader = c.getClassLoader();
@@ -91,7 +110,38 @@
return null;
}
}
-
+
+ /**
+ * Return the activation policy. If the element declares the activation
attribute
+ * that value (resolved to the policy enum) is returne, otherwise the
class is checked for
+ * the declaration of an explicit activivation policy and if present the
value is returned,
+ * otherwise the default SYSTEM activation policy is returned.
+ *
+ * @return the resolved activation policy
+ */
+ private static ActivationPolicy getActivationPolicy( Element element,
Class<?> c )
+ {
+ if( null == element )
+ {
+ return ActivationPolicy.SYSTEM;
+ }
+ String value = ElementHelper.getAttribute( element, "activation" );
+ if( null == value )
+ {
+ if( c.isAnnotationPresent( Activation.class ) )
+ {
+ Activation annotation =
+ c.getAnnotation( Activation.class );
+ return annotation.value();
+ }
+ return ActivationPolicy.SYSTEM;
+ }
+ else
+ {
+ return ActivationPolicy.valueOf( value.toUpperCase() );
+ }
+ }
+
private static ContextDirective getContextProfile(
ClassLoader classloader, Element profile, Resolver resolver ) throws
IOException
{




  • r1897 - trunk/main/metro/part/src/main/net/dpml/runtime, mcconnell at BerliOS, 03/12/2007

Archive powered by MHonArc 2.6.24.

Top of Page