com.sun.jini.start
Class ServiceStarter

java.lang.Object
  extended by com.sun.jini.start.ServiceStarter

public class ServiceStarter
extends Object

This class provides the main routine for starting shared groups, non-activatable services, and activatable services. The following implementation-specific items are discussed below:

Configuring ServiceStarter

This implementation of ServiceStarter supports the following configuration entries, with component com.sun.jini.start:
loginContext
  Type: LoginContext
  Default: null
  Description: If not null, specifies the JAAS login context to use for performing a JAAS login and supplying the Subject to use when running the service starter. If null, no JAAS login is performed.
serviceDescriptors
  Type: ServiceDescriptor[]
  Default: no default
  Description: Array of service descriptors to start.

Loggers and Logging Levels

The implementation uses the Logger, named com.sun.jini.start.service.starter. The following table describes the type of information logged as well as the levels of information logged.

com.sun.jini.start.service.starter
Level Description
SEVERE for problems that prevent service creation from proceeding
WARNING for problems with service creation that don't prevent further processing
FINER for high level service creation operation tracing
FINEST for low level service creation operation tracing

Since:
2.0
Author:
Sun Microsystems, Inc.

Nested Class Summary
private static class ServiceStarter.Result
          Trivial class used as the return value by the create methods.
 
Field Summary
(package private) static Logger logger
          Configure logger
(package private) static String START_PACKAGE
          Component name for service starter configuration entries
private static ArrayList transient_service_refs
          Array of strong references to transient services
 
Constructor Summary
private ServiceStarter()
          Prevent instantiation
 
Method Summary
private static void checkResultFailures(ServiceStarter.Result[] results)
          Utility routine that prints out warning messages for each service descriptor that produced an exception or that was null.
private static ServiceStarter.Result[] create(ServiceDescriptor[] descs, Configuration config)
          Generic service creation method that attempts to start the services defined by the provided ServiceDescriptor[] argument.
private static ServiceStarter.Result[] createWithLogin(ServiceDescriptor[] descs, Configuration config, LoginContext loginContext)
          Generic service creation method that attempts to login via the provided LoginContext and then call the create overload without a login context argument.
(package private) static void ensureSecurityManager()
          Utility routine that sets a security manager if one isn't already present.
(package private) static ActivationSystem getActivationSystem(String host, int port, Configuration config)
          Utility routine that returns a "prepared" activation system proxy for a system at the given host and port.
(package private) static int getActivationSystemPort()
          Utility routine that returns a "default" activation system port.
static void main(Configuration config)
          The main method for embidding the ServiceStarter application.
static void main(String[] args)
          The main method for the ServiceStarter application.
private static void maintainNonActivatableReferences(ServiceStarter.Result[] results)
          Utility routine that maintains strong references to any transient services in the provided Result[].
private static void processServiceDescriptors(Configuration config)
          Workhorse function for both main() entrypoints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_PACKAGE

static final String START_PACKAGE
Component name for service starter configuration entries

See Also:
Constant Field Values

logger

static Logger logger
Configure logger


transient_service_refs

private static ArrayList transient_service_refs
Array of strong references to transient services

Constructor Detail

ServiceStarter

private ServiceStarter()
Prevent instantiation

Method Detail

createWithLogin

private static ServiceStarter.Result[] createWithLogin(ServiceDescriptor[] descs,
                                                       Configuration config,
                                                       LoginContext loginContext)
                                                throws Exception
Generic service creation method that attempts to login via the provided LoginContext and then call the create overload without a login context argument.

Parameters:
descs - The ServiceDescriptor[] that contains the descriptors for the services to start.
config - The associated Configuration object used to customize the service creation process.
loginContext - The associated LoginContext object used to login/logout.
Returns:
Returns a Result[] that is the same length as descs, which contains the details for each service creation attempt.
Throws:
Exception - If there was a problem logging in/out or a problem creating the service.
See Also:
ServiceStarter.Result, ServiceDescriptor, Configuration, LoginContext

create

private static ServiceStarter.Result[] create(ServiceDescriptor[] descs,
                                              Configuration config)
                                       throws Exception
Generic service creation method that attempts to start the services defined by the provided ServiceDescriptor[] argument.

Parameters:
descs - The ServiceDescriptor[] that contains the descriptors for the services to start.
config - The associated Configuration object used to customize the service creation process.
Returns:
Returns a Result[] that is the same length as descs, which contains the details for each service creation attempt.
Throws:
Exception - If there was a problem creating the service.
See Also:
ServiceStarter.Result, ServiceDescriptor, Configuration

ensureSecurityManager

static void ensureSecurityManager()
Utility routine that sets a security manager if one isn't already present.


getActivationSystem

static ActivationSystem getActivationSystem(String host,
                                            int port,
                                            Configuration config)
                                     throws ActivationException,
                                            ConfigurationException
Utility routine that returns a "prepared" activation system proxy for a system at the given host and port.

Parameters:
host - The host of the desired activation system
port - The port of the desired activation system
config - The Configuration used to prepare the system proxy.
Returns:
A prepared activation system proxy
Throws:
ActivationException - If there was a problem communicating with the activation system.
ConfigurationException
See Also:
Configuration

getActivationSystemPort

static int getActivationSystemPort()
Utility routine that returns a "default" activation system port. The default port is determined by:

Returns:
The activation system port
See Also:
ActivationSystem

maintainNonActivatableReferences

private static void maintainNonActivatableReferences(ServiceStarter.Result[] results)
Utility routine that maintains strong references to any transient services in the provided Result[]. This prevents the transient services from getting garbage collected.


checkResultFailures

private static void checkResultFailures(ServiceStarter.Result[] results)
Utility routine that prints out warning messages for each service descriptor that produced an exception or that was null.


processServiceDescriptors

private static void processServiceDescriptors(Configuration config)
                                       throws Exception
Workhorse function for both main() entrypoints.

Throws:
Exception

main

public static void main(String[] args)
The main method for the ServiceStarter application. The args argument is passed directly to ConfigurationProvider.getInstance() in order to obtain a Configuration object. This configuration object is then queried for the com.sun.jini.start.serviceDescriptors entry, which is assumed to be a ServiceDescriptor[]. The create() method is then called on each of the array elements.

Parameters:
args - String[] passed to ConfigurationProvider.getInstance() in order to obtain a Configuration object.
See Also:
ServiceDescriptor, SharedActivatableServiceDescriptor, SharedActivationGroupDescriptor, NonActivatableServiceDescriptor, Configuration, ConfigurationProvider

main

public static void main(Configuration config)
The main method for embidding the ServiceStarter application. The config argument is queried for the com.sun.jini.start.serviceDescriptors entry, which is assumed to be a ServiceDescriptor[]. The create() method is then called on each of the array elements.

Parameters:
config - the Configuration object.
See Also:
ServiceDescriptor, SharedActivatableServiceDescriptor, SharedActivationGroupDescriptor, NonActivatableServiceDescriptor, Configuration


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.