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.1.0
Author:
Digital Product Management Library

Method Summary
 void addComponentListener(ComponentListener listener)
          Add a listener to the component.
 void encode(Buffer buffer, String key)
          Encode the component model to the supplied buffer.
 ActivationPolicy getActivationPolicy()
          Return the assigned activation policy.
 CollectionPolicy getCollectionPolicy()
          Return the assigned collection policy.
<T> T
getContentForClass(Class<T> c)
          Return an instance of the requested class.
<T> T
getInstance(Class<T> clazz)
          Return an instance of the requested class.
 LifestylePolicy getLifestylePolicy()
          Return the assigned lifestyle policy.
 String getName()
          Get the component name.
 int getPriority()
          Get the component priority.
 Provider getProvider()
          Get a runtime provider for this component.
 void initialize(ServiceRegistry registry)
          Initialize the component with a supplied service registry.
 boolean isaCandidate(Class<?> type)
          Test if this component model can handle the supplied service type.
<T> T
lookup(Class<T> service)
          Get a service reference for the supplied type.
 void release(Provider provider)
          Release a provider back to the component.
 void removeComponentListener(ComponentListener listener)
          Remove a listener from the component.
 void terminate()
          Terminate the component model.
 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()
Get the component name.

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

getPriority

public int getPriority()
Get the component priority.

Specified by:
getPriority in class Strategy
Returns:
the priority

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()
Get a runtime provider for this component.

Specified by:
getProvider in interface Component
Returns:
the provider

release

public void release(Provider provider)
Release a provider back to the component.

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

initialize

public void initialize(ServiceRegistry registry)
Initialize the component with a supplied service registry.

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

isaCandidate

public boolean isaCandidate(Class<?> type)
Test if this component model can handle the supplied service type.

Specified by:
isaCandidate in class Strategy
Parameters:
type - the service type
Returns:
true if the component is type compatible

lookup

public <T> T lookup(Class<T> service)
Get a service reference for the supplied type.

Specified by:
lookup in interface ServiceRegistry
Parameters:
service - the service type
Returns:
a service instance or null if unresolvable

terminate

public void terminate()
Terminate the component model.

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)
Return an instance of the requested class.

Specified by:
getInstance in class Strategy
Parameters:
clazz - the class
Returns:
the instance

getContentForClass

public <T> T getContentForClass(Class<T> c)
                     throws IOException
Return an instance of the requested class.

Specified by:
getContentForClass in class Strategy
Parameters:
c - the class
Returns:
the instance
Throws:
IOException - if an error occurs

encode

public void encode(Buffer buffer,
                   String key)
            throws IOException
Encode the component model to the supplied buffer.

Specified by:
encode in class Strategy
Parameters:
buffer - the endoding buffer
key - the component key
Throws:
IOException - if an error occurs

toString

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

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