com.sun.sgs.impl.kernel
Class KernelContext

java.lang.Object
  extended by com.sun.sgs.impl.kernel.KernelContext
Direct Known Subclasses:
StartupKernelContext

 class KernelContext
extends Object

This is the implementation of KernelAppContext used by the kernel to manage the context of a single application. It knows the name of an application, its available managers, and its backing services. FIXME: the context should check that it isn't shutdown before handing out services and managers


Field Summary
protected  ComponentRegistry managerComponents
           
protected  ComponentRegistry serviceComponents
           
 
Constructor Summary
(package private) KernelContext(KernelContext context)
          Creates an instance of KernelContext based on the components that have already been collected in another instance.
protected KernelContext(String applicationName, ComponentRegistry serviceComponents, ComponentRegistry managerComponents)
          Creates an instance KernelContext with the given name and components.
 
Method Summary
(package private)  ChannelManager getChannelManager()
          Returns the ChannelManager used in this context.
(package private)  DataManager getDataManager()
          Returns the DataManager used in this context.
(package private)
<T> T
getManager(Class<T> type)
          Returns a manager based on the given type.
(package private)
<T extends Service>
T
getService(Class<T> type)
          Returns a Service based on the given type.
(package private)  TaskManager getTaskManager()
          Returns the TaskManager used in this context.
(package private)  void notifyReady()
          Notifies all included Services that the system is now ready.
(package private)  void shutdownServices()
          Shut down all the service components in the reverse order that they were added.
 String toString()
          Returns a unique representation of this context, in this case the name of the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

managerComponents

protected final ComponentRegistry managerComponents

serviceComponents

protected final ComponentRegistry serviceComponents
Constructor Detail

KernelContext

KernelContext(KernelContext context)
Creates an instance of KernelContext based on the components that have already been collected in another instance.

Parameters:
context - the existing KernelContext to use as a source of components

KernelContext

protected KernelContext(String applicationName,
                        ComponentRegistry serviceComponents,
                        ComponentRegistry managerComponents)
Creates an instance KernelContext with the given name and components. This is used by sub-classes to create an instance that can be provided components as needed by adding to the provided ComponentRegistry instances.

Parameters:
applicationName - the name of the application represented by this context
serviceComponents - the services available in this context
managerComponents - the managers available in this context
Method Detail

getChannelManager

ChannelManager getChannelManager()
Returns the ChannelManager used in this context.

Returns:
the context's ChannelManager

getDataManager

DataManager getDataManager()
Returns the DataManager used in this context.

Returns:
the context's DataManager

getTaskManager

TaskManager getTaskManager()
Returns the TaskManager used in this context.

Returns:
the context's TaskManager

getManager

<T> T getManager(Class<T> type)
Returns a manager based on the given type. If the manager type is unknown, or if there is more than one manager of the given type, ManagerNotFoundException is thrown. This may be used to find any available manager, including the three standard managers.

Parameters:
type - the Class of the requested manager
Returns:
the requested manager
Throws:
ManagerNotFoundException - if there wasn't exactly one match to the requested type

getService

<T extends Service> T getService(Class<T> type)
Returns a Service based on the given type. If the type is unknown, or if there is more than one Service of the given type, MissingResourceException is thrown. This is the only way to resolve service components directly, and should be used with care, as Services should not be resolved and invoked directly outside of a transactional context.

Parameters:
type - the Class of the requested Service
Returns:
the requested Service
Throws:
MissingResourceException - if there wasn't exactly one match to the requested type

notifyReady

void notifyReady()
           throws Exception
Notifies all included Services that the system is now ready.

Throws:
Exception - if there is any failure during notification

shutdownServices

void shutdownServices()
Shut down all the service components in the reverse order that they were added.


toString

public String toString()
Returns a unique representation of this context, in this case the name of the application.

Overrides:
toString in class Object
Returns:
a String representation of the context

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved