actually you can't use deployment service in the startup
service since deployment is loaded after the startup
service (usually startup is configured to start
deployment).
It would be useful to have some way to override this if
projects need to enable/disable components in startup
depending on deployment properties.
This could be done implementing a way to boot
components before startup ("boot components").
Here is a quick and flexible implementation:
add a property "carbon.bootstrap.Components" to
CarbonDeploymentConfig.properties which holds a
comma separated list of component logical names you
wish to boot at carbon startup:
----
carbon.bootstrap.Components=/core/config/Configuration
TypeService,/deployment/DeploymentService
----
Modify org.sape.carbon.core.bootstrap.BootStrapper
(note there is no way to extend it at the moment)
adding:
/**
* The key to a comma delimited string array with the
logical name of components
* to start before the startup service
*/
private static final String
BOOT_COMPONENTS_PROPERTY
= "carbon.bootstrap.Components";
in load() method, between steps commented as 2 and 3:
.......
// 2) get the ComponentKeeper
this.componentKeeper =
loader.fetchComponentKeeper(configurationService);
// 2.5 start boot components
String bootComponents =
deploymentProperties.get
(BOOT_COMPONENTS_PROPERTY);
if (bootComponents == null)
{
log.debug("No " +
BOOT_COMPONENTS_PROPERTY + " property found");
}
else
{
// split component list
String[] componentNames =
StringUtil.parseWhitespaceDelimitedList
(bootComponents);
for (int j = 0; j < componentNames.length;
j++)
{
String componentName =
componentNames[j];
log.info("Starting boot component [" +
componentName + "]");
try
{
Lookup.getInstance().fetchComponent
(componentName);
}
catch (Exception e)
{
if (log.isWarnEnabled())
{
log.warn(
"Could not start boot component
["
+ componentName
+ "] "
+
ExceptionUtility.printStackTracesToString(e));
}
}
}
}
// 3) start startup components
............
This will allow for an extreme flexibility in carbon boot.
Boot components could be core carbon components as
config and deployments, while components handled by
the startup service are usually more complex (or simply
configurable ones).