|
 |
|
Depends: |
n/a |
Related: |
n/a |
|
|
|
Description
The 'startup' service instantiates specified startable instances on xTier startup. The startup is a
special type of service - it starts always the last allowing user code to be executed explicitly after all other
xTier services have been successfully started. This service is usually used to automatically launch user
application code during xTier startup.
'startup' service is part of two-way non-intrusive integration facility provided by xTier in
which user code can either be integrated into xTier (using startup service) or xTier can be
integrated into hosting environment of user code (by using micro kernel).
Top
Configuration
'startup' service uses notion of startable that is equivalent to any POJO in Java and specified as IoC descriptor in
XML configuration. Startables specified in configuration are created automatically and can be accessed at runtime by their names.
'startup' service is configured via pre-defined xtier_startup.xml configuration file. This file follows standard
xTier service configuration pattern that can be demonstrated by the following complete example of startup configuration (from examples):
| 1 |  | <xtier-startup> |
| 2 |  | <region name="examples"> |
| 3 |  | <!----> |
| 4 |  | <startable name="id"> |
| 5 |  | <ioc policy="new"> |
| 6 |  | <java class= "com.fitechlabs.xtier.examples. |
| 7 |  | services.startup.StartupClass"> |
| 8 |  | <call method="start"> |
| 9 |  | </call> |
| 10 |  | </java> |
| 11 |  | </ioc> |
| 12 |  | </startable> |
| 13 |  | <region name="examples"> |
| 14 |  | </xtier-startup> |
Formal sepcification for this service configuration can be found in xtier_starup.dtd file in
${XTIER_ROOT}/config/dtd folder.
<startable> tag should include one <ioc> element. <ioc> tag
is defined in %XTIER_ROOT%/config/dtd/xtier_dtd_includes.dtd, it points to startable class and can describe
constructor, methods, invoked automatically after instance is created, and their parameters. See
IocService for <ioc> tag usage details.
Top
Examples
Usage of 'startup' service follows the standard pattern of using xTier service: you need to obtain
an instance of
xTier kernel that serves as a service registry. Once you have xTier kernel you can get an instance of any service, in our
case the 'startup' service. Once the service instance is obtained the service API can be used. The following
code snippet illustrates the basic usage pattern for the 'startup' service:
| 1 |  | |
| 2 |  | XtierKernel xtier = XtierKernel.getInstance(); |
| 3 |  | |
| 4 |  | |
| 5 |  | StartupService startup = xtier.startup(); |
| 6 |  | |
| 7 |  | |
| 8 |  | |
| 9 |  | Map startables = startup.getStartables(); |
| 10 |  | |
| 11 |  | |
| 12 |  | Object startable = startup.getStartable("id"); |
Download xTier for full examples and documentation.
Top
|