JBoss Modular Service Kernel API 1.0.0.Beta4-SNAPSHOT

org.jboss.msc.service
Interface ServiceBuilder<T>


public interface ServiceBuilder<T>

A builder for an individual service in a ServiceTarget. Create an instance via the ServiceTarget.addService(ServiceName, Service), ServiceTarget.addServiceValue(ServiceName, Value) or ServiceTarget.addServiceValueIfNotExist(ServiceName, Value) methods.

Author:
David M. Lloyd

Method Summary
 ServiceBuilder<T> addAliases(ServiceName... aliases)
          Add aliases for this service.
 ServiceBuilder<T> addDependencies(Iterable<ServiceName> dependencies)
          Add multiple, non-injected dependencies.
 ServiceBuilder<T> addDependencies(ServiceName... dependencies)
          Add multiple, non-injected dependencies.
 ServiceBuilder<T> addDependency(ServiceName dependency)
          Add a dependency.
<I> ServiceBuilder<T>
addDependency(ServiceName dependency, Class<I> type, Injector<I> target)
          Add a service dependency.
 ServiceBuilder<T> addDependency(ServiceName dependency, Injector<Object> target)
          Add a service dependency.
<I> ServiceBuilder<T>
addInjection(Injector<? super I> target, I value)
          Add an injection.
<I> ServiceBuilder<T>
addInjectionValue(Injector<? super I> target, Value<I> value)
          Add an injection value.
 ServiceBuilder<T> addListener(Collection<? extends ServiceListener<? super T>> listeners)
          Add service listeners that will be added to this service.
 ServiceBuilder<T> addListener(ServiceListener<? super T>... listeners)
          Add service listeners that will be added to this service.
 ServiceBuilder<T> addListener(ServiceListener<? super T> listener)
          Add a service listener that will be added to this service.
 ServiceBuilder<T> addOptionalDependencies(Iterable<ServiceName> dependencies)
          Add multiple, optional, non-injected dependencies.
 ServiceBuilder<T> addOptionalDependencies(ServiceName... dependencies)
          Add multiple, optional, non-injected dependencies.
 ServiceBuilder<T> addOptionalDependency(ServiceName dependency)
          Add an optional dependency.
<I> ServiceBuilder<T>
addOptionalDependency(ServiceName dependency, Class<I> type, Injector<I> target)
          Add an optional service dependency.
 ServiceBuilder<T> addOptionalDependency(ServiceName dependency, Injector<Object> target)
          Add an optional service dependency.
 void install()
          Install all the defined services into the container.
 ServiceBuilder<T> setInitialMode(ServiceController.Mode mode)
          Set the initial mode.
 ServiceBuilder<T> setLocation()
          Set the service definition location to be the caller's location.
 ServiceBuilder<T> setLocation(Location location)
          Set the service definition location, if any.
 

Method Detail

addAliases

ServiceBuilder<T> addAliases(ServiceName... aliases)
Add aliases for this service.

Parameters:
aliases - the service names to use as aliases
Returns:
the builder

setLocation

ServiceBuilder<T> setLocation()
Set the service definition location to be the caller's location.

Returns:
this builder

setLocation

ServiceBuilder<T> setLocation(Location location)
Set the service definition location, if any.

Parameters:
location - the location
Returns:
this builder

setInitialMode

ServiceBuilder<T> setInitialMode(ServiceController.Mode mode)
Set the initial mode.

Parameters:
mode - the initial mode
Returns:
this builder

addDependencies

ServiceBuilder<T> addDependencies(ServiceName... dependencies)
Add multiple, non-injected dependencies.

Parameters:
dependencies - the service names to depend on
Returns:
this builder

addOptionalDependencies

ServiceBuilder<T> addOptionalDependencies(ServiceName... dependencies)
Add multiple, optional, non-injected dependencies. If the dependencies do not exist, it will not stop the service from starting.

Parameters:
dependencies - the service names to depend on
Returns:
this builder

addDependencies

ServiceBuilder<T> addDependencies(Iterable<ServiceName> dependencies)
Add multiple, non-injected dependencies.

Parameters:
dependencies - the service names to depend on
Returns:
this builder

addOptionalDependencies

ServiceBuilder<T> addOptionalDependencies(Iterable<ServiceName> dependencies)
Add multiple, optional, non-injected dependencies. If the dependencies do not exist, it will not stop the service from starting.

Parameters:
dependencies - the service names to depend on
Returns:
this builder

addDependency

ServiceBuilder<T> addDependency(ServiceName dependency)
Add a dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.

Parameters:
dependency - the name of the dependency
Returns:
an injection builder for optionally injecting the dependency

addOptionalDependency

ServiceBuilder<T> addOptionalDependency(ServiceName dependency)
Add an optional dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency. If the dependencies do not exist, it will not stop the service from starting.

Parameters:
dependency - the name of the dependency
Returns:
an injection builder for optionally injecting the dependency

addDependency

ServiceBuilder<T> addDependency(ServiceName dependency,
                                Injector<Object> target)
Add a service dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.

Parameters:
dependency - the name of the dependency
target - the injector into which the dependency should be stored
Returns:
this builder

addOptionalDependency

ServiceBuilder<T> addOptionalDependency(ServiceName dependency,
                                        Injector<Object> target)
Add an optional service dependency. This will Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency. If the dependencies do not exist, it will not stop the service from starting.

Parameters:
dependency - the name of the dependency
target - the injector into which the dependency should be stored
Returns:
this builder

addDependency

<I> ServiceBuilder<T> addDependency(ServiceName dependency,
                                    Class<I> type,
                                    Injector<I> target)
Add a service dependency. The type of the dependency is checked before it is passed into the (type-safe) injector instance. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.

Type Parameters:
I - the type of the value of the dependency
Parameters:
dependency - the name of the dependency
type - the class of the value of the dependency
target - the injector into which the dependency should be stored
Returns:
this builder

addOptionalDependency

<I> ServiceBuilder<T> addOptionalDependency(ServiceName dependency,
                                            Class<I> type,
                                            Injector<I> target)
Add an optional service dependency. The type of the dependency is checked before it is passed into the (type-safe) injector instance. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency. If the dependencies do not exist, it will not stop the service from starting.

Type Parameters:
I - the type of the value of the dependency
Parameters:
dependency - the name of the dependency
type - the class of the value of the dependency
target - the injector into which the dependency should be stored
Returns:
this builder

addInjection

<I> ServiceBuilder<T> addInjection(Injector<? super I> target,
                                   I value)
Add an injection. The given value will be injected into the given injector before service start, and uninjected after service stop.

Type Parameters:
I - the injection type
Parameters:
target - the injection target
value - the injection value
Returns:
this builder

addInjectionValue

<I> ServiceBuilder<T> addInjectionValue(Injector<? super I> target,
                                        Value<I> value)
Add an injection value. The given value will be injected into the given injector before service start, and uninjected after service stop.

Type Parameters:
I - the injection type
Parameters:
target - the injection target
value - the injection value
Returns:
this builder

addListener

ServiceBuilder<T> addListener(ServiceListener<? super T> listener)
Add a service listener that will be added to this service.

Parameters:
listener - the listener to add to the service
Returns:
this builder

addListener

ServiceBuilder<T> addListener(ServiceListener<? super T>... listeners)
Add service listeners that will be added to this service.

Parameters:
listeners - a list of listeners to add to the service
Returns:
this builder

addListener

ServiceBuilder<T> addListener(Collection<? extends ServiceListener<? super T>> listeners)
Add service listeners that will be added to this service.

Parameters:
listeners - a collection of listeners to add to the service
Returns:
this builder

install

void install()
             throws ServiceRegistryException
Install all the defined services into the container.

Throws:
ServiceRegistryException

JBoss Modular Service Kernel API 1.0.0.Beta4-SNAPSHOT

Copyright © 2010 JBoss, a division of Red Hat, Inc.