Class Main
Main
is the externally visible Standalone Java Application
launcher for Sling. Please refer to the full description The Sling
Launchpad on the Sling Web Site for a full description of this class.
Logging goes to standard output for informational messages and to standard error for error messages.
This class goes into the secondary artifact with the classifier app to be used as the main class when starting the Java Application.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
The name of the configuration property indicating theControlAction
to be taken in thedoControlAction()
method.protected static final String
The name of the configuration property indicating the socket to use for the control connection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
After instantiating this class, this method may be called to help with the communication with a running Sling instance.protected boolean
doStart()
Starts the application with the configuration supplied with the configuration properties when this instance has been created.protected boolean
protected void
doStop()
Maybe called by the application to cause the Sling Application to properly terminate by stopping the OSGi Framework.protected static void
Return the absolute path to sling homeprotected static void
static void
The main entry point to the Sling Launcher Standalone Java Application.
-
Field Details
-
PROP_CONTROL_ACTION
The name of the configuration property indicating theControlAction
to be taken in thedoControlAction()
method.- See Also:
-
PROP_CONTROL_SOCKET
The name of the configuration property indicating the socket to use for the control connection. The value of this property is either just a port number (in which case the host is assumed to belocalhost
) or a host name (or IP address) and port number separated by a colon.- See Also:
-
-
Constructor Details
-
Main
Creates an instance of this main loader class. The provided arguments are used to configure the OSGi framework being launched with thedoStart(URL)
method.- Parameters:
args
- The map of configuration properties to be supplied to the OSGi framework. The keys in this map are assumed to be usefull without translation to the launcher and the OSGi Framework. If this parameter isnull
and empty map without configuration is assumed.
-
-
Method Details
-
main
The main entry point to the Sling Launcher Standalone Java Application. This method is generally only called by the Java VM to launch Sling.- Parameters:
args
- The command line arguments supplied when starting the Sling Launcher through the Java VM.
-
doControlAction
protected int doControlAction()After instantiating this class, this method may be called to help with the communication with a running Sling instance. To setup this communication the configuration properties supplied to the constructor are evaluated as follows:Control Properties "sling.control.socket"
Specifies the socket to use for the control connection. This specification is of the form host:port where the host can be a host name or IP Address and may be omitted (along with the separating colon) and port is just the numeric port number at which to listen. The default is localhost:63000. It is suggested to not use an externally accessible interface for security reasons because there is no added security on this control channel for now. "sling.control.action"
The actual action to execute: - start -- Start the listener on the configured socket and expect commands there. This action is useful only when launching the Sling application since this action helps manage a running system.
- stop -- Connects to the listener running on the configured socket and send the command to terminate the Sling Application. If this command is used, it is expected the Sling Application will not start.
- status -- Connects to the listener running on the configured socket and query about its status. If this command is used, it is expected the Sling Application will not start.
After this method has executed the
j
andPROP_CONTROL_ACTION
properties have been removed from the configuration properties.While the
doStart()
anddoStop()
methods may be called multiple times this method should only be called once after creating this class's instance.- Returns:
- An code indicating whether the Java VM is expected to be
terminated or not. If
-1
is returned, the VM should continue as intended, maybe starting the Sling Application. This code is returned if the start action (or no action at all) is supplied. Otherwise the VM should terminate with the returned code as its exit code. For the stop action, this will be zero. For the status action, this will be a LSB compliant code for daemon status check: 0 (application running), 1 (Program Dead), 3 (Program Not Running), 4 (Unknown Problem). - See Also:
-
doStart
protected boolean doStart()Starts the application with the configuration supplied with the configuration properties when this instance has been created.Calling this method multiple times before calling
doStop()
will cause a message to be printed andtrue
being returned.- Returns:
true
if startup was successful or the application is considered to be started already. Otherwise an error message has been logged andfalse
is returned.
-
doStart
-
doStop
protected void doStop()Maybe called by the application to cause the Sling Application to properly terminate by stopping the OSGi Framework.After calling this method the Sling Application can be started again by calling the
doStart()
method.Calling this method multiple times without calling the
doStart()
method in between has no effect after the Sling Application has been terminated. -
getSlingHome
Return the absolute path to sling home- Returns:
- The path to sling home
-
info
-
error
-