|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.common.component.ComponentLibrary<ComponentType,ConfigType>
ComponentType
- the type of component being managed, which may be a subclass of Component
ConfigType
- the configuration type describing the components@ThreadSafe public class ComponentLibrary<ComponentType,ConfigType extends ComponentConfig>
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 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 component, or update any existing one that represents the same
configuration |
protected void |
configure(ComponentType newInstance,
ConfigType configuration)
|
protected ComponentType |
doCreateInstance(Class<?> componentClass)
Method that instantiates the supplied class. |
protected int |
findIndexOfMatchingConfiguration(ConfigType config)
Find the index for the matching configuration and component . |
protected int |
findIndexOfMatchingConfiguration(String name)
Find the index for the matching configuration and component . |
ClassLoaderFactory |
getClassLoaderFactory()
Get the class loader factory that should be used to load the component classes. |
ComponentType |
getInstance(String name)
Get the instance given by the configuration with the supplied name. |
List<ComponentType> |
getInstances()
Return the list of components. |
List<ConfigType> |
getSequenceConfigs()
Get the configurations for all Sequencers |
protected ComponentType |
newInstance(ConfigType config)
Instantiate, configure and return a new component described by the supplied configuration. |
boolean |
refreshInstances()
Refresh the instances by attempting to re-instantiate each registered configuration. |
boolean |
remove(ConfigType config)
Remove the configuration for a component. |
boolean |
removeAll()
|
boolean |
removeAllAndAdd(ConfigType config)
|
void |
setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
Set the Maven Repository that should be used to load the component classes. |
boolean |
update(ConfigType config)
Update the configuration for a component, or add it if there is no matching configuration
. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ClassLoaderFactory DEFAULT
current thread's context class
loader
(if not null) or component library's class loader.
Constructor Detail |
---|
public ComponentLibrary()
public ComponentLibrary(boolean addBeforeExistingConfigs)
addBeforeExistingConfigs
- true
if configurations should be added
before
previously added configurations.Method Detail |
---|
public ClassLoaderFactory getClassLoaderFactory()
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.
setClassLoaderFactory(ClassLoaderFactory)
public List<ConfigType> getSequenceConfigs()
setClassLoaderFactory(ClassLoaderFactory)
public void setClassLoaderFactory(ClassLoaderFactory classLoaderFactory)
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.
classLoaderFactory
- the class loader factory reference, or null if the default class loader factory
should be usedgetClassLoaderFactory()
public boolean add(ConfigType config)
same
configuration
config
- the new configuration
unchanged
component configuration
IllegalArgumentException
- if config
is nullupdate(ComponentConfig)
,
remove(ComponentConfig)
public ComponentType getInstance(String name)
name
- the configuration name
public boolean update(ConfigType config)
matching configuration
.
config
- the updated (or new) configuration
unchanged
component configuration
IllegalArgumentException
- if config
is nulladd(ComponentConfig)
,
remove(ComponentConfig)
public boolean remove(ConfigType config)
config
- the configuration to be removed
IllegalArgumentException
- if config
is nulladd(ComponentConfig)
,
update(ComponentConfig)
public boolean removeAll()
public boolean removeAllAndAdd(ConfigType config)
public boolean refreshInstances()
public List<ComponentType> getInstances()
protected ComponentType newInstance(ConfigType config)
config
- the configuration describing the component
IllegalArgumentException
- if the component could not be configured properlyprotected void configure(ComponentType newInstance, ConfigType configuration) throws Exception
Exception
protected ComponentType doCreateInstance(Class<?> componentClass) throws InstantiationException, IllegalAccessException
componentClass
-
InstantiationException
IllegalAccessException
protected int findIndexOfMatchingConfiguration(ConfigType config)
configuration
and component
.
config
- the configuration; may not be null
protected int findIndexOfMatchingConfiguration(String name)
configuration
and component
.
name
- the configuration name; may not be null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |