Utility class for setting up Avalon components. Similar to Excalibur's
, but on existing objects.
| Constructor: |
public LifecycleHelper(Logger logger,
Context context,
ServiceManager serviceManager,
Configuration configuration) {
this(logger, context, serviceManager, null, null, configuration);
}
Construct a new LifecycleHelper that can be used repeatedly to
setup several components.
Note : if a parameter is null,
the corresponding method isn't called (e.g. if configuration is
null, configure() isn't called). Parameters:
logger - the Logger to pass to LogEnableds, unless there is
a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
serviceManager - the service manager to pass to Serviceables.
configuration - the Configuration object to pass to new instances.
|
public LifecycleHelper(Logger logger,
Context context,
ComponentManager componentManager,
RoleManager roles,
Configuration configuration) {
this(logger, context, null, componentManager, roles, configuration);
}
Construct a new LifecycleHelper that can be used repeatedly to
setup several components.
Note : if a parameter is null,
the corresponding method isn't called (e.g. if configuration is
null, configure() isn't called). Parameters:
logger - the Logger to pass to LogEnableds, unless there is
a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
componentManager - the component manager to pass to Composables.
roles - the RoleManager to pass to DefaultComponentSelectors.
configuration - the Configuration object to pass to new instances.
|
public LifecycleHelper(Logger logger,
Context context,
ServiceManager serviceManager,
RoleManager roles,
Configuration configuration) {
this(logger, context, serviceManager, null, roles, configuration);
}
Construct a new LifecycleHelper that can be used repeatedly to
setup several components.
Note : if a parameter is null,
the corresponding method isn't called (e.g. if configuration is
null, configure() isn't called). Parameters:
logger - the Logger to pass to LogEnableds, unless there is
a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
serviceManager - the service manager to pass to Serviceables.
roles - the RoleManager to pass to DefaultComponentSelectors.
configuration - the Configuration object to pass to new instances.
|
public LifecycleHelper(Logger logger,
Context context,
ServiceManager serviceManager,
ComponentManager componentManager,
RoleManager roles,
Configuration configuration) {
this.logger = logger;
this.context = context;
this.serviceManager = serviceManager;
this.componentManager = componentManager;
this.roles = roles;
this.configuration = configuration;
}
Construct a new LifecycleHelper that can be used repeatedly to
setup several components.
Note : if a parameter is null,
the corresponding method isn't called (e.g. if configuration is
null, configure() isn't called). Parameters:
logger - the Logger to pass to LogEnableds, unless there is
a LogKitManager and the configuration specifies a logger name.
context - the Context to pass to Contexutalizables.
serviceManager - the service manager to pass to Serviceables.
componentManager - the component manager to pass to Composables.
roles - the RoleManager to pass to DefaultComponentSelectors.
configuration - the Configuration object to pass to new instances.
|
| Method from org.apache.cocoon.components.LifecycleHelper Detail: |
public static final void decommission(Object component) throws Exception {
if (component instanceof Startable) {
((Startable) component).stop();
}
dispose(component);
}
Decomission a component, by stopping (if it's Startable) and
disposing (if it's Disposable) a component. |
public static final void dispose(Object component) {
if (component instanceof Disposable) {
((Disposable) component).dispose();
}
}
Dispose a component if it's Disposable. Otherwhise, do nothing. |
public Object setupComponent(Object component) throws Exception {
return setupComponent(component, true);
}
Setup a component, including initialization and start. |
public Object setupComponent(Object component,
boolean initializeAndStart) throws Exception {
return setupComponent(
component,
this.logger,
this.context,
this.serviceManager,
this.componentManager,
this.roles,
this.configuration,
initializeAndStart);
}
Setup a component, and optionnaly initializes (if it's Initializable)
and starts it (if it's Startable). |
public static Object setupComponent(Object component,
Logger logger,
Context context,
ServiceManager serviceManager,
Configuration configuration) throws Exception {
return setupComponent(
component,
logger,
context,
serviceManager,
null,
configuration,
true);
}
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger. |
public static Object setupComponent(Object component,
Logger logger,
Context context,
ComponentManager componentManager,
RoleManager roles,
Configuration configuration) throws Exception {
return setupComponent(
component,
logger,
context,
componentManager,
roles,
configuration,
true);
} Deprecated! ComponentManager - and RoleManager are deprecated
|
public static Object setupComponent(Object component,
Logger logger,
Context context,
ServiceManager serviceManager,
RoleManager roles,
Configuration configuration) throws Exception {
return setupComponent(
component,
logger,
context,
serviceManager,
roles,
configuration,
true);
} Deprecated! RoleManager - is deprecated
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger. |
public static Object setupComponent(Object component,
Logger logger,
Context context,
ServiceManager serviceManager,
Configuration configuration,
boolean initializeAndStart) throws Exception {
return setupComponent(
component,
logger,
context,
serviceManager,
null,
null,
configuration,
initializeAndStart);
}
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger. |
public static Object setupComponent(Object component,
Logger logger,
Context context,
ComponentManager componentManager,
RoleManager roles,
Configuration configuration,
boolean initializeAndStart) throws Exception {
return setupComponent(
component,
logger,
context,
null,
componentManager,
roles,
configuration,
initializeAndStart);
} Deprecated! ComponentManager - and RoleManager are deprecated
|
public static Object setupComponent(Object component,
Logger logger,
Context context,
ServiceManager serviceManager,
RoleManager roles,
Configuration configuration,
boolean initializeAndStart) throws Exception {
return setupComponent(
component,
logger,
context,
serviceManager,
null,
roles,
configuration,
initializeAndStart);
} Deprecated! RoleManager - is deprecated
Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger. |
public static Object setupComponent(Object component,
Logger logger,
Context context,
ServiceManager serviceManager,
ComponentManager componentManager,
RoleManager roles,
Configuration configuration,
boolean initializeAndStart) throws Exception {
if (component instanceof LogEnabled) {
((LogEnabled) component).enableLogging(logger);
}
if (null != context && component instanceof Contextualizable) {
((Contextualizable) component).contextualize(context);
}
if (null != componentManager && component instanceof Composable) {
((Composable) component).compose(componentManager);
}
if (null != serviceManager && component instanceof Serviceable) {
((Serviceable) component).service(serviceManager);
}
if (null != roles && component instanceof RoleManageable) {
((RoleManageable) component).setRoleManager(roles);
}
if (null != configuration && component instanceof Configurable) {
((Configurable) component).configure(configuration);
}
if (null != configuration && component instanceof Parameterizable) {
((Parameterizable) component).parameterize(
Parameters.fromConfiguration(configuration));
}
if (initializeAndStart && component instanceof Initializable) {
((Initializable) component).initialize();
}
if (initializeAndStart && component instanceof Startable) {
((Startable) component).start();
}
return component;
} Deprecated! ComponentManager - and RoleManager are deprecated
|