public class StrolchComponent extends Object
A StrolchComponent is a configurable extension to Strolch. Every major feature should be implemented as a
StrolchComponent so that they can be easily added or removed from a Strolch runtime.
A StrolchComponent has access to the container and can perform different operations. They can be passive or
active and their life cycle is bound to the container's life cycle
A StrolchComponent is registered in the Strolch configuration file and can have different configuration
depending on the container's runtime environment
| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_VERSION_PROPERTIES |
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
StrolchComponent(ComponentContainer container,
String componentName)
Constructor which takes a reference to the container and the component's name under which it can be retrieved at
runtime (although one mostly retrieves the component by interface class for automatic casting)
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertContainerStarted()
Can be used by sub classes to assert that the entire container is started and thus ready to use, before any
component methods are used
|
protected void |
assertStarted()
Can be used by sub classes to assert that the component is started and thus ready to use, before any component
methods are used
|
void |
destroy()
Life cycle step destroy.
|
protected ComponentConfiguration |
getConfiguration()
The components current configuration dependent on the environment which is loaded
|
protected ComponentContainer |
getContainer()
Returns the reference to the container for sub classes
|
String |
getName() |
ComponentState |
getState()
Returns the current component's state
|
ComponentVersion |
getVersion()
Returns the version of this component.
|
void |
initialize(ComponentConfiguration configuration)
Life cycle step initialize.
|
protected void |
runAs(String username,
PrivilegedRunnable runnable)
Performs the given
PrivilegedRunnable as the given system user |
protected void |
runAs(String username,
SystemAction action)
Performs the given
PrivilegedRunnable as the given system user |
protected void |
runAsAgent(PrivilegedRunnable runnable)
Performs the given
PrivilegedRunnable as the privileged system user
StrolchConstants.SYSTEM_USER_AGENT |
protected void |
runAsAgent(SystemAction action)
Performs the given
PrivilegedRunnable as the given system user |
protected <T> T |
runAsAgentWithResult(PrivilegedRunnableWithResult<T> runnable)
Performs the given
PrivilegedRunnable as the privileged system user
StrolchConstants.SYSTEM_USER_AGENT |
protected <T> T |
runAsAgentWithResult(SystemActionWithResult<T> action)
Performs the given
PrivilegedRunnable as the given system user |
protected <T> T |
runWithResult(String username,
PrivilegedRunnableWithResult<T> runnable)
Performs the given
PrivilegedRunnable as the given system user |
protected <T> T |
runWithResult(String username,
SystemActionWithResult<T> action)
Performs the given
PrivilegedRunnable as the given system user |
void |
setup(ComponentConfiguration configuration)
Life cycle step setup.
|
void |
start()
Life cycle step start.
|
void |
stop()
Life cycle step stop.
|
public static final String COMPONENT_VERSION_PROPERTIES
protected static final org.slf4j.Logger logger
public StrolchComponent(ComponentContainer container, String componentName)
container - the containercomponentName - the component namepublic String getName()
public ComponentState getState()
protected ComponentContainer getContainer()
protected ComponentConfiguration getConfiguration()
protected void assertStarted()
protected void assertContainerStarted()
public void setup(ComponentConfiguration configuration)
configuration - public void initialize(ComponentConfiguration configuration) throws Exception
configuration - Exceptionpublic void start()
throws Exception
Exceptionpublic void stop()
throws Exception
Exceptionpublic void destroy()
throws Exception
Exceptionprotected void runAs(String username, SystemAction action) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asaction - the action to performPrivilegeExceptionprotected <T> T runWithResult(String username, SystemActionWithResult<T> action) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asaction - the action to performPrivilegeExceptionprotected void runAs(String username, PrivilegedRunnable runnable) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asrunnable - the runnable to performPrivilegeExceptionprotected <T> T runWithResult(String username, PrivilegedRunnableWithResult<T> runnable) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asrunnable - the runnable to performPrivilegeExceptionprotected void runAsAgent(SystemAction action) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asaction - the action to performPrivilegeExceptionprotected <T> T runAsAgentWithResult(SystemActionWithResult<T> action) throws PrivilegeException
PrivilegedRunnable as the given system userusername - the name of the system user to perform the action asaction - the action to performPrivilegeExceptionprotected void runAsAgent(PrivilegedRunnable runnable) throws PrivilegeException
PrivilegedRunnable as the privileged system user
StrolchConstants.SYSTEM_USER_AGENTrunnable - the runnable to performPrivilegeExceptionprotected <T> T runAsAgentWithResult(PrivilegedRunnableWithResult<T> runnable) throws PrivilegeException
PrivilegedRunnable as the privileged system user
StrolchConstants.SYSTEM_USER_AGENTrunnable - the runnable to performPrivilegeExceptionpublic ComponentVersion getVersion() throws IOException
COMPONENT_VERSION_PROPERTIES. See ComponentVersion for more informationIOExceptionCopyright © 2011–2016 Strolch. All rights reserved.