org.apache.xbean.kernel
Class StaticServiceFactory

java.lang.Object
  extended byorg.apache.xbean.kernel.AbstractServiceFactory
      extended byorg.apache.xbean.kernel.StaticServiceFactory
All Implemented Interfaces:
ServiceFactory

public class StaticServiceFactory
extends AbstractServiceFactory

A basic service factory that always creates the supplied object.

Since:
2.0
Version:
$Id$
Author:
Dain Sundstrom

Constructor Summary
StaticServiceFactory(java.lang.Object service)
          Creates a non-restartable service factory which will simply returns the specified service from the createService method.
 
Method Summary
 java.lang.Object createService(ServiceContext serviceContext)
          Returns the static service instance.
 void destroyService(ServiceContext serviceContext)
          This method is a noop.
 java.util.Set getOwnedServices()
          Gets the names of services owned by this service. This information is used for the startRecursive method on the kernel. When a servcie is started with startRecursive all owned services will be started with startRecursive.
 java.lang.Class[] getTypes()
          Gets the types of the service this service factory will create.
 boolean isRestartable()
          A restartable service can be started and stopped repeatedly in the kernel. A service that is not restartable immediately enters the RUNNING state when registered with the kernel, and can not be started or stopped.
 
Methods inherited from class org.apache.xbean.kernel.AbstractServiceFactory
addStartCondition, addStopCondition, getStartConditions, getStopConditions, isEnabled, removeStartCondition, removeStopCondition, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticServiceFactory

public StaticServiceFactory(java.lang.Object service)
                     throws java.lang.NullPointerException
Creates a non-restartable service factory which will simply returns the specified service from the createService method.

Parameters:
service - the static to which this factory "creates"
Throws:
java.lang.NullPointerException - if service is null
Method Detail

getTypes

public java.lang.Class[] getTypes()
Description copied from interface: ServiceFactory
Gets the types of the service this service factory will create. These types is used to index the service within the kernel. It is a start error to return an object from create service that is not an instance of every type. This is the only type used to index the service, so if the service factory returns a subclass of this type from createService, the subtypes will now be reflected in the index.

Returns:
the type of the service this service factory will create

isRestartable

public boolean isRestartable()
A restartable service can be started and stopped repeatedly in the kernel. A service that is not restartable immediately enters the RUNNING state when registered with the kernel, and can not be started or stopped.

Returns:
true if this service can be started and stopped; false otherwise

getOwnedServices

public java.util.Set getOwnedServices()
Gets the names of services owned by this service. This information is used for the startRecursive method on the kernel. When a servcie is started with startRecursive all owned services will be started with startRecursive.

Returns:
the names of the services owned by this service

createService

public java.lang.Object createService(ServiceContext serviceContext)
Returns the static service instance.

Parameters:
serviceContext - ignored
Returns:
the static service instance

destroyService

public void destroyService(ServiceContext serviceContext)
This method is a noop.

Parameters:
serviceContext - ignored


Copyright © {inceptionYear}-2006 Apache Software Foundation. All Rights Reserved.