org.jboss.dna.common.component
Class ComponentLibrary<ComponentType,ConfigType extends ComponentConfig>

java.lang.Object
  extended by org.jboss.dna.common.component.ComponentLibrary<ComponentType,ConfigType>
Type Parameters:
ComponentType - the type of component being managed, which may be a subclass of Component
ConfigType - the configuration type describing the components
Direct Known Subclasses:
SequencerLibrary

@ThreadSafe
public class ComponentLibrary<ComponentType,ConfigType extends ComponentConfig>
extends Object

Maintains the list of component instances for the system. This class does not actively update the component configurations, but is designed to properly maintain the sequencer instances when those configurations are changed by other callers. If the components are subclasses of Component, then they will be configured with the appropriate configuration.

Therefore, this library does guarantee that the instances at the time they are obtained are always reflected by the configurations.


Field Summary
static ClassLoaderFactory DEFAULT
          Class loader factory instance that always returns the current thread's context class loader (if not null) or component library's class loader.
 
Constructor Summary
ComponentLibrary()
          Create a new library of components.
ComponentLibrary(boolean addBeforeExistingConfigs)
          Create a new library of components.
 
Method Summary
 boolean add(ConfigType config)
          Add the configuration for a sequencer, or update any existing one that represents the same configuration
 ClassLoaderFactory getClassLoaderFactory()
          Get the class loader factory that should be used to load the component classes.
 List<ComponentType> getInstances()
          Return the list of sequencers.
 boolean refreshInstances()
          Refresh the instances by attempting to re-instantiate each registered configuration.
 boolean remove(ConfigType config)
          Remove the configuration for a sequencer.
 void setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
          Set the Maven Repository that should be used to load the sequencer classes.
 boolean update(ConfigType config)
          Update the configuration for a sequencer, or add it if there is no matching configuration .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final ClassLoaderFactory DEFAULT
Class loader factory instance that always returns the current thread's context class loader (if not null) or component library's class loader.

Constructor Detail

ComponentLibrary

public ComponentLibrary()
Create a new library of components.


ComponentLibrary

public ComponentLibrary(boolean addBeforeExistingConfigs)
Create a new library of components.

Parameters:
addBeforeExistingConfigs - true if configurations should be added before previously added configurations.
Method Detail

getClassLoaderFactory

public ClassLoaderFactory getClassLoaderFactory()
Get the class loader factory that should be used to load the component classes. Unless changed, the library uses the default class loader factory, which uses the current thread's context class loader if not null or the class loader that loaded the library class.

Returns:
the class loader factory; never null
See Also:
setClassLoaderFactory(ClassLoaderFactory)

setClassLoaderFactory

public void setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
Set the Maven Repository that should be used to load the sequencer classes. Unless changed, the library uses the default class loader factory, which uses the current thread's context class loader if not null or the class loader that loaded the library class.

Parameters:
classLoaderFactory - the class loader factory reference, or null if the default class loader factory should be used
See Also:
getClassLoaderFactory()

add

public boolean add(ConfigType config)
Add the configuration for a sequencer, or update any existing one that represents the same configuration

Parameters:
config - the new configuration
Returns:
true if the component was added, or false if there already was an existing and unchanged component configuration
Throws:
IllegalArgumentException - if config is null
See Also:
update(ComponentConfig), remove(ComponentConfig)

update

public boolean update(ConfigType config)
Update the configuration for a sequencer, or add it if there is no matching configuration .

Parameters:
config - the updated (or new) configuration
Returns:
true if the component was updated, or false if there already was an existing and unchanged component configuration
Throws:
IllegalArgumentException - if config is null
See Also:
add(ComponentConfig), remove(ComponentConfig)

remove

public boolean remove(ConfigType config)
Remove the configuration for a sequencer.

Parameters:
config - the configuration to be removed
Returns:
true if the component was remove, or false if there was no existing configuration
Throws:
IllegalArgumentException - if config is null
See Also:
add(ComponentConfig), update(ComponentConfig)

refreshInstances

public boolean refreshInstances()
Refresh the instances by attempting to re-instantiate each registered configuration.

Returns:
true if at least one instance was instantiated, or false if none were

getInstances

public List<ComponentType> getInstances()
Return the list of sequencers.

Returns:
the unmodifiable list of sequencers; never null


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.