Class ServiceManager<T>
java.lang.Object
com.jme3.network.service.ServiceManager<T>
- Type Parameters:
T- the parent type exposed to managed services
- Direct Known Subclasses:
ClientServiceManager, HostedServiceManager
The base service manager class from which the HostedServiceManager
and ClientServiceManager classes are derived. This manages
the underlying services and their life cycles.
- Author:
- Paul Speed
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddService(S s) Adds the specified service and initializes it.protected abstract TRetrieves the 'parent' of this service manager, usually a more specifically typed version of 'this' but it can be anything the services are expecting.getService(Class<S> type) Retrieves the first service of the specified type.Returns the complete list of services managed by this service manager.booleanReturns true if this service manager has been started.removeService(S s) Removes the specified service from this service manager, stopping and terminating it as required.voidstart()Starts this service manager and all services that it contains.voidstop()Stops all services and puts the service manager into a stopped state.voidTerminates all services.toString()
-
Constructor Details
-
ServiceManager
protected ServiceManager()Creates a service manager.
-
-
Method Details
-
getParent
Retrieves the 'parent' of this service manager, usually a more specifically typed version of 'this' but it can be anything the services are expecting.- Returns:
- the parent object exposed to managed services
-
getServices
-
start
public void start()Starts this service manager and all services that it contains. Any services added after the service manager has started will have their start() methods called. -
isStarted
public boolean isStarted()Returns true if this service manager has been started.- Returns:
- true if the manager is started
-
stop
public void stop()Stops all services and puts the service manager into a stopped state. -
addService
-
removeService
Removes the specified service from this service manager, stopping and terminating it as required. If this service manager is in a started state then the service will be stopped. After removal, the service will be terminated.- Type Parameters:
S- the concrete service type- Parameters:
s- the service to remove
-
terminate
public void terminate()Terminates all services. If the service manager has not been stopped yet, then it will be stopped. -
getService
-
toString
-