net.dpml.runtime
Class ComponentStrategy

java.lang.Object
  extended by net.dpml.lang.Strategy
      extended by net.dpml.runtime.ComponentStrategy
All Implemented Interfaces:
Comparable<Strategy>, ServiceRegistry, Component

public class ComponentStrategy
extends Strategy
implements Component, ServiceRegistry

Component strategy.

Version:
2.0.1
Author:
Digital Product Management Laboratory

Method Summary
 void addComponentListener(ComponentListener listener)
          Add a listener to the component.
 void encode(Buffer buffer, String key)
          Write the strategy to the supplied buffer in XML format.
 ActivationPolicy getActivationPolicy()
          Return the assigned activation policy.
 CollectionPolicy getCollectionPolicy()
          Return the assigned collection policy.
<T> T
getContentForClass(Class<T> c)
          Return a value assignable to the supplied type or null if the type cannot be resolved from this strategy.
<T> T
getInstance(Class<T> clazz)
          Instantiate a service returning an instance assigned to the supplied type.
 LifestylePolicy getLifestylePolicy()
          Return the assigned lifestyle policy.
 String getName()
          Return the short name of this strategy.
 int getPriority()
          Return the priority assigned to this strategy.
 Provider getProvider()
          Return a decommissioning provider.
 void initialize(ServiceRegistry registry)
          Composite strategies are strategy implementations that contain subidary strategies.
 boolean isaCandidate(Class<?> type)
          Return true if this strategy is a candidate with result to the supply of an instance assignable to the supplied type.
<T> T
lookup(Class<T> service)
           
 void release(Provider provider)
          Release a provider.
 void removeComponentListener(ComponentListener listener)
          Remove a listener from the component.
 void terminate()
          Terminate the component.
 String toString()
          Returns the string representing of the component.
 
Methods inherited from class net.dpml.lang.Strategy
compareTo, getClassLoader, load, load, load
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public String getName()
Description copied from class: Strategy
Return the short name of this strategy.

Specified by:
getName in interface Component
Specified by:
getName in class Strategy
Returns:
the name

getPriority

public int getPriority()
Description copied from class: Strategy
Return the priority assigned to this strategy.

Specified by:
getPriority in class Strategy
Returns:
the priority value

addComponentListener

public void addComponentListener(ComponentListener listener)
Add a listener to the component.

Specified by:
addComponentListener in interface Component
Parameters:
listener - the component listener

removeComponentListener

public void removeComponentListener(ComponentListener listener)
Remove a listener from the component.

Specified by:
removeComponentListener in interface Component
Parameters:
listener - the component listener

getProvider

public Provider getProvider()
Description copied from interface: Component
Return a decommissioning provider.

Specified by:
getProvider in interface Component
Returns:
the provider

release

public void release(Provider provider)
Description copied from interface: Component
Release a provider.

Specified by:
release in interface Component
Parameters:
provider - the provider to release

initialize

public void initialize(ServiceRegistry registry)
Description copied from class: Strategy
Composite strategies are strategy implementations that contain subidary strategies. During lookup operations, a subsidiary strategy may request a service from the enclosing strategy. To enable traversal from a subsidary to enclosing context a service registry shall be provided to all subsidiary strategies.

Specified by:
initialize in class Strategy
Parameters:
registry - the service registry

isaCandidate

public boolean isaCandidate(Class<?> type)
Description copied from class: Strategy
Return true if this strategy is a candidate with result to the supply of an instance assignable to the supplied type.

Specified by:
isaCandidate in class Strategy
Parameters:
type - the requested type
Returns:
type if this strategy is a condidate

lookup

public <T> T lookup(Class<T> service)
Specified by:
lookup in interface ServiceRegistry

terminate

public void terminate()
Description copied from interface: Component
Terminate the component.

Specified by:
terminate in interface Component

getCollectionPolicy

public CollectionPolicy getCollectionPolicy()
Return the assigned collection policy.

Returns:
the collection policy

getLifestylePolicy

public LifestylePolicy getLifestylePolicy()
Return the assigned lifestyle policy.

Returns:
the lifestyle policy

getActivationPolicy

public ActivationPolicy getActivationPolicy()
Return the assigned activation policy.

Returns:
the activation policy

getInstance

public <T> T getInstance(Class<T> clazz)
Description copied from class: Strategy
Instantiate a service returning an instance assigned to the supplied type.

Specified by:
getInstance in class Strategy
Parameters:
clazz - the return type
Returns:
an instance of the type

getContentForClass

public <T> T getContentForClass(Class<T> c)
                     throws IOException
Description copied from class: Strategy
Return a value assignable to the supplied type or null if the type cannot be resolved from this strategy.

Specified by:
getContentForClass in class Strategy
Parameters:
c - the target class
Returns:
an instance of the class or null
Throws:
IOException - if an IO error occurs

encode

public void encode(Buffer buffer,
                   String key)
            throws IOException
Description copied from class: Strategy
Write the strategy to the supplied buffer in XML format.

Specified by:
encode in class Strategy
Parameters:
buffer - the output buffer
key - the optional identifying key
Throws:
IOException - if an IO error occurs

toString

public String toString()
Returns the string representing of the component.

Overrides:
toString in class Object
Returns:
the component as a string