org.gcube.common.core.contexts
Class GCUBEServiceContext

java.lang.Object
  extended by org.gcube.common.core.contexts.GCUBEContext
      extended by org.gcube.common.core.contexts.GCUBEServiceContext
All Implemented Interfaces:
GCUBEScopeManager, GCUBESecurityManager, GCUBEServiceSecurityManager

public abstract class GCUBEServiceContext
extends GCUBEContext
implements GCUBEServiceSecurityManager, GCUBEScopeManager

Partial implementation of contexts for gCube services. A GCUBEServiceContext exposes the configuration of the service and manages the lifetime of its Running Instance on the GHN, notifying interesting parties of key lifetime events. It also acts as a GCUBEServiceSecurityManager and a GCUBEScopeManager in the rest of the service implementation .

Typically, the creation of the context is cached. The following example illustrates a simple but thread-safe caching pattern for a hypothetical subclass MyServiceContext:

class MyServiceContext {
 ...
 static private MyServiceContext cache = new MyServiceContext();//cache on load
 ...
 private MyServiceContext(){} //force caching
 ...
 public static MyServiceContext getContext() {
  return cache;
 }

Author:
Fabio Simeoni (University of Strathclyde), Manuele Simi (CNR-ISTI), Ciro Formisano (ENG)

Nested Class Summary
static class GCUBEServiceContext.IllegalStateTransitionException
          Illegal state transition exception (runtime).
 class GCUBEServiceContext.RILifetimeEvent
          RI lifetime event.
static class GCUBEServiceContext.RILifetimeTopic
          Enumerates RI lifetime topics.
static class GCUBEServiceContext.ServiceSecurityStatus
          enum of the security status available
protected  class GCUBEServiceContext.Stager
          A Consumer for staging INITIALISED RIs.
static class GCUBEServiceContext.StateTransitionException
          Illegal state transition exception (runtime).
static class GCUBEServiceContext.Status
          Enumerates the possible statuses of the service.
 
Nested classes/interfaces inherited from interface org.gcube.common.core.security.GCUBEServiceSecurityManager
GCUBEServiceSecurityManager.LifetimeConsumer, GCUBEServiceSecurityManager.LifetimeEvent, GCUBEServiceSecurityManager.LifetimeTopic
 
Nested classes/interfaces inherited from interface org.gcube.common.core.security.GCUBESecurityManager
GCUBESecurityManager.AuthMethod, GCUBESecurityManager.AuthMode, GCUBESecurityManager.DelegationMode
 
Nested classes/interfaces inherited from interface org.gcube.common.core.scope.GCUBEScopeManager
GCUBEScopeManager.IllegalScopeException
 
Field Summary
static String AUTHENTICATION_MANAGER_JNDI_NAME
          Name of Authentication Manager JNDI environment.
static String AUTHORISATION_MANAGER_JNDI_NAME
          Name of Authorisation Manager JNDI environment.
static String CONFIG_DIR_JNDI_NAME
          Name of the configuration directory JNDI environment.
protected static long LISTENER_UPDATE_INTERVAL
          Interval for the scheduling of the local credentials listener.
protected  GCUBEProducer<GCUBEServiceContext.RILifetimeTopic,GCUBEServiceContext> LTEventProducer
          Embedded GCUBEProducer for RI lifetime events.
static String PERSISTENCE_MANAGER_JNDI_NAME
          Name of Persistence Manager JNDI environment.
static String PLUGIN_MANAGER_JNDI_NAME
          Name of Plugin Manager JNDI environment.
static String PROFILE_FILE_NAME
          Name of Service Profile JNDI environment.
static String PROPAGATE_CALLER_CREDENTIALS_JNDI_NAME
          Use Caller Credentials property JNDI environment.
static String PUBLISHED_HOST_JNDI_NAME
          The name of the host to publish in the local profiles, if different from the container's one
static String PUBLISHED_PORT_JNDI_NAME
          The name of the port to publish in the local profiles, if different from the container's one
static String RIPROFILE_FILENAME
          Name of the RI serialisation file.
static String SECURITY_MANAGER_JNDI_NAME
          Name of Security Manager JNDI environment.
static String START_SCOPES_JNDI_NAME
          Name of Start Scopes JNDI environment.
 
Fields inherited from class org.gcube.common.core.contexts.GCUBEContext
logger, timers
 
Fields inherited from interface org.gcube.common.core.scope.GCUBEScopeManager
CLASS_HEADER_NAME, DEFAULT, NAME_HEADER_NAME, SCOPE_HEADER_NAME, SCOPE_NS
 
Constructor Summary
protected GCUBEServiceContext()
          Creates and preinitialises an instance.
 
Method Summary
 Set<GCUBEScope> addScope(GCUBEScope... scopes)
          Adds one or more scopes to the service instance.
 GCUBEServiceAuthenticationController getAuthenticationManager()
           
 GCUBEServiceAuthorizationController getAuthorizationManager()
           
 SecurityCredentials getCallerCredentials()
          If security is enabled, it extracts credentials from the current request.
 SecurityCredentials getCredentials()
          It returns the credentials for outgoing calls currently set in the current thread.
 GCUBEException getDefaultException(String msg, Throwable cause)
          Returns the default exception
 GCUBEException getDefaultException(Throwable cause)
          Returns the default exception
 File getFile(String path, boolean... writeMode)
          Gives read or write access to a File.
 String getID()
          Returns the service identifier.
 GCUBERunningInstance getInstance()
          Returns the GCUBERunningInstance resource of the service.
protected abstract  String getJNDIName()
          Return the name of the port-type in the JNDI configuration
 GCUBELog getLogger()
          Returns the context's logger.
 RI getManagementBean()
          Return the management bean of the Running Instance.
 String getName()
          Returns the name of the service.
 File getPersistenceRoot()
          Returns the root of persistence of the Running Instance on the local file system.
 File getPersistentFile(String path, boolean... writeMode)
          Gives read or write access to a File that will persist across redployments of the Running Instance.
 GCUBEPluginManager<?> getPluginManager()
          Returns the plugin manager.
 GCUBEAuthzPolicy getPolicy()
          Returns the current authorisation policy.
 Object getProperty(String prop, boolean... required)
          Resolve a configuration property against the naming service.
 GCUBEScope getScope()
          Gets the scope for outgoing calls in the current thread.
 GCUBEScopeManager getScopeManager()
          Returns the inner scope manager used by the context.
 GCUBEServiceSecurityManager getSecurityManager()
          Returns the GCUBEServiceSecurityManager to which the context will delegate security-related functionality.
 GCUBEService getService()
          Returns the GCUBEService resource of the service.
 String getServiceClass()
          Returns the name of the service.
 SecurityCredentials getServiceCredentials()
          If security is enabled, it returns the service credentials.
 GCUBEServiceContext.ServiceSecurityStatus getServiceSecurityStatus()
           
 GCUBEScope[] getStartScopes()
          Gets the start scopes of the RI.
 GCUBEServiceContext.Status getStatus()
          Returns the current status of the service.
 void initialise(GCUBEServiceContext ctxt)
          Initialise the manager with the context of the associated service.
 boolean isSecurityEnabled()
          Indicates whether the manager is operating in a secure context.
 boolean needServiceCredentials()
          Indicates whether the service makes use of service credentials.
 void notifyStateChange()
          Notifies of a change to the persistent state of the RI.
protected  void onFailure()
          Invoked when the Running Instance fails.
protected  void onInitialisation()
          Invoked when the Running Instance has completed initialisation.
protected  void onReady()
          Invoked when the Running Instance is ready to operate.
protected  void onShutdown()
          Invoked when the Running Instance is going down.
protected  void onStateChange()
          Invoked upon a change to the RI's stateful resources, if any.
protected  void onUpdate()
          Invoked when the Runnning Instance is updated.
 void prepareCall(Remote remote, String clazz, String name, GCUBEScope... scope)
          Sets the scope for an outgoing call to a target gCube service.
 void propagateCallerCredentials(boolean propagateCallerCredentials)
          Indicates whether the service, without any further configurationm, makes use of caller credentials: by default is true and, if false, the service will use its own credentials (without further configuration) to perform calls
 Set<GCUBEScope> removeScope(GCUBEScope... scopes)
          Removes one or more scopes from the service instance.
 void setAuthMethod(GCUBESecurityManager.AuthMethod m)
          Adds an authentication method to be used in this security context
 void setScope(GCUBEScope scope)
          Sets the scope of outgoing calls in the current thread.
 void setScope(Thread thread, GCUBEScope... scope)
          Deprecated. 
 void setScope(Thread thread, GCUBEScope scope)
          Deprecated. 
 void setSecurity(Remote s, GCUBESecurityManager.AuthMode e, GCUBESecurityManager.DelegationMode d)
          If security is enabled, sets the desired level of encryption and the mode of credential delegation on the stub of a remote porttype.
 void setStatus(GCUBEServiceContext.Status status)
          Sets the current status of the service.
 void subscribe(GCUBEServiceSecurityManager.LifetimeConsumer c, GCUBEServiceSecurityManager.LifetimeTopic... topics)
          Subscribes a GCUBEServiceSecurityManager.LifetimeConsumer.
 void subscribeLifetTime(Consumer consumer, GCUBEServiceContext.RILifetimeTopic... topics)
          Subscribes a consumer to RI lifetime events for one or more RI lifetime topics.
 void unsubscribe(GCUBEServiceSecurityManager.LifetimeConsumer c, GCUBEServiceSecurityManager.LifetimeTopic... topics)
          Unsubscribes a GCUBEServiceSecurityManager.LifetimeConsumer.
 void unsubscribeLifetTime(Consumer consumer, GCUBEServiceContext.RILifetimeTopic... topics)
          Unsubscribes a consumer from RI lifetime events for one or more RI lifetime topics.
 void useCallerCredentials(Thread... thread)
          If security is enabled, it indicates that outgoing calls in a given thread must use the credentials associated with the incoming call.
 void useCredentials(GSSCredential credentials)
          Deprecated. 
 void useCredentials(SecurityCredentials credentials)
          If security is enabled, it sets given credentials for outgoing calls in the current thread.
 void useCredentials(Thread thread, SecurityCredentials... credentials)
          If security is enabled, it sets given credentials for outgoing calls in a given thread.
 void useServiceCredentials(Thread... thread)
          If security is enabled, it indicates that outgoing calls in the current thread must use service credentials.
 
Methods inherited from class org.gcube.common.core.contexts.GCUBEContext
debugContext, getJNDIContext, getResource, getTiming, printContext, resetTimer, setJNDIContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_DIR_JNDI_NAME

public static final String CONFIG_DIR_JNDI_NAME
Name of the configuration directory JNDI environment.

See Also:
Constant Field Values

PROFILE_FILE_NAME

public static final String PROFILE_FILE_NAME
Name of Service Profile JNDI environment.

See Also:
Constant Field Values

PERSISTENCE_MANAGER_JNDI_NAME

public static final String PERSISTENCE_MANAGER_JNDI_NAME
Name of Persistence Manager JNDI environment.

See Also:
Constant Field Values

PLUGIN_MANAGER_JNDI_NAME

public static final String PLUGIN_MANAGER_JNDI_NAME
Name of Plugin Manager JNDI environment.

See Also:
Constant Field Values

START_SCOPES_JNDI_NAME

public static final String START_SCOPES_JNDI_NAME
Name of Start Scopes JNDI environment.

See Also:
Constant Field Values

PUBLISHED_HOST_JNDI_NAME

public static final String PUBLISHED_HOST_JNDI_NAME
The name of the host to publish in the local profiles, if different from the container's one

See Also:
Constant Field Values

PUBLISHED_PORT_JNDI_NAME

public static final String PUBLISHED_PORT_JNDI_NAME
The name of the port to publish in the local profiles, if different from the container's one

See Also:
Constant Field Values

RIPROFILE_FILENAME

public static final String RIPROFILE_FILENAME
Name of the RI serialisation file.

See Also:
Constant Field Values

LISTENER_UPDATE_INTERVAL

protected static final long LISTENER_UPDATE_INTERVAL
Interval for the scheduling of the local credentials listener.

See Also:
Constant Field Values

SECURITY_MANAGER_JNDI_NAME

public static final String SECURITY_MANAGER_JNDI_NAME
Name of Security Manager JNDI environment.

See Also:
Constant Field Values

AUTHENTICATION_MANAGER_JNDI_NAME

public static final String AUTHENTICATION_MANAGER_JNDI_NAME
Name of Authentication Manager JNDI environment.

See Also:
Constant Field Values

AUTHORISATION_MANAGER_JNDI_NAME

public static final String AUTHORISATION_MANAGER_JNDI_NAME
Name of Authorisation Manager JNDI environment.

See Also:
Constant Field Values

PROPAGATE_CALLER_CREDENTIALS_JNDI_NAME

public static final String PROPAGATE_CALLER_CREDENTIALS_JNDI_NAME
Use Caller Credentials property JNDI environment.

See Also:
Constant Field Values

LTEventProducer

protected GCUBEProducer<GCUBEServiceContext.RILifetimeTopic,GCUBEServiceContext> LTEventProducer
Embedded GCUBEProducer for RI lifetime events.

Constructor Detail

GCUBEServiceContext

protected GCUBEServiceContext()
Creates and preinitialises an instance.

Method Detail

getLogger

public GCUBELog getLogger()
Returns the context's logger.

Returns:
the logger.

getJNDIName

protected abstract String getJNDIName()
Return the name of the port-type in the JNDI configuration

Returns:
the JNDI name.

getService

public GCUBEService getService()
Returns the GCUBEService resource of the service.

Returns:
the resource.

getInstance

public GCUBERunningInstance getInstance()
Returns the GCUBERunningInstance resource of the service.

Returns:
the resource.

getManagementBean

public RI getManagementBean()
Return the management bean of the Running Instance.

Returns:
the bean.

getFile

public File getFile(String path,
                    boolean... writeMode)
             throws IllegalArgumentException
Gives read or write access to a File. Write access induces backups and read access relies on backups to recover from failures.

Overrides:
getFile in class GCUBEContext
Parameters:
path - the file path.
writeMode - (optional) the access mode, true for write access and false for read access (default).
Returns:
the file.
Throws:
IllegalArgumentException - if access is in write mode and the path is to a folder.

getPersistentFile

public File getPersistentFile(String path,
                              boolean... writeMode)
                       throws IllegalArgumentException
Gives read or write access to a File that will persist across redployments of the Running Instance.

Parameters:
path - the file path.
writeMode - (optional) the access mode, true for write access and false for read access (default).
Returns:
the file.
Throws:
IllegalArgumentException - if access is in write mode and the path is to a folder.
See Also:
GCUBEContext.getFile(String, boolean...)

getPersistenceRoot

public File getPersistenceRoot()
Returns the root of persistence of the Running Instance on the local file system. Anything below it will be persisted across re-deployments of the Running Instance.

Returns:
the file representation

getProperty

public Object getProperty(String prop,
                          boolean... required)
                   throws RuntimeException
Resolve a configuration property against the naming service. Resolution is relative to the root JNDI context of the naming service and the JNDI name associated with the context.

Overrides:
getProperty in class GCUBEContext
Parameters:
prop - the property.
required - (optional) true if the property is required, false or omitted if property is optional. The only implication is a different handling of failure and logging. Failure in resolving optional properties results in a runtime exception and fatal log entry, whereas failure in resolving optional properties results in a null result and warning in the log.
Returns:
the value of the property, or null if the property was optional and could not be resolved.
Throws:
RuntimeException - if the property is required but cannot be resolved.

getID

public String getID()
Returns the service identifier.

Returns:
the identifier.

getServiceClass

public String getServiceClass()
Returns the name of the service.

Returns:
the name.

getName

public String getName()
Returns the name of the service.

Overrides:
getName in class GCUBEContext
Returns:
the name.

setStatus

public void setStatus(GCUBEServiceContext.Status status)
               throws GCUBEServiceContext.IllegalStateTransitionException,
                      GCUBEServiceContext.StateTransitionException
Sets the current status of the service.

Parameters:
status - the status.
Throws:
GCUBEServiceContext.IllegalStateTransitionException - if the transition from the current state to the required state is illegal.
GCUBEServiceContext.StateTransitionException

getServiceSecurityStatus

public GCUBEServiceContext.ServiceSecurityStatus getServiceSecurityStatus()

getStatus

public GCUBEServiceContext.Status getStatus()
Returns the current status of the service.

Returns:
the status.

getDefaultException

public GCUBEException getDefaultException(String msg,
                                          Throwable cause)
Returns the default exception

Parameters:
msg - the fault message.
cause - (optional) the cause of the fault.
Returns:
the default GCUBEFault.

getDefaultException

public GCUBEException getDefaultException(Throwable cause)
Returns the default exception

Parameters:
cause - the cause of the fault.
Returns:
the default GCUBEFault.

getSecurityManager

public GCUBEServiceSecurityManager getSecurityManager()
Returns the GCUBEServiceSecurityManager to which the context will delegate security-related functionality.

If not otherwise configured, it returns a GCUBESimpleServiceSecurityManager suitable for services which, when deployed in a secure environment, either propagate caller credentials or else do not use security altogether. Services which instead need to use their own credentials can configure the service to use a GCUBEServiceSecurityManagerImpl or, if available, an alternative implementation of the GCUBEServiceSecurityManager interface.

Returns:
the manager.

setSecurity

public void setSecurity(Remote s,
                        GCUBESecurityManager.AuthMode e,
                        GCUBESecurityManager.DelegationMode d)
                 throws Exception
If security is enabled, sets the desired level of encryption and the mode of credential delegation on the stub of a remote porttype. It has no effect otherwise.

Specified by:
setSecurity in interface GCUBESecurityManager
Parameters:
s - the stub.
e - the encryption level.
d - the delegation mode.
Throws:
Exception - if the settings could not be enforced.

isSecurityEnabled

public boolean isSecurityEnabled()
Indicates whether the manager is operating in a secure context. If not, invoking its methods will have no effect..

Specified by:
isSecurityEnabled in interface GCUBESecurityManager
Returns:
true if security is enabled, false otherwise.

getCredentials

public SecurityCredentials getCredentials()
It returns the credentials for outgoing calls currently set in the current thread..

Specified by:
getCredentials in interface GCUBESecurityManager
Returns:
the credentials.

getPolicy

public GCUBEAuthzPolicy getPolicy()
Returns the current authorisation policy..

Specified by:
getPolicy in interface GCUBEServiceSecurityManager
Returns:
the policy

initialise

public void initialise(GCUBEServiceContext ctxt)
                throws Exception
Initialise the manager with the context of the associated service..

Specified by:
initialise in interface GCUBEServiceSecurityManager
Parameters:
ctxt - the context.
Throws:
Exception

getServiceCredentials

public SecurityCredentials getServiceCredentials()
                                          throws Exception
If security is enabled, it returns the service credentials..

Specified by:
getServiceCredentials in interface GCUBEServiceSecurityManager
Returns:
the credentials, or null if security is not enabled.
Throws:
Exception - if security is enabled, but service credentials could not be produced.

getCallerCredentials

public SecurityCredentials getCallerCredentials()
                                         throws Exception
If security is enabled, it extracts credentials from the current request..

Specified by:
getCallerCredentials in interface GCUBEServiceSecurityManager
Returns:
the credentials, of null if security is not enabled.
Throws:
Exception - if security is enabled, but credentials could not be extracted from incoming call.

useCredentials

public void useCredentials(SecurityCredentials credentials)
                    throws Exception
If security is enabled, it sets given credentials for outgoing calls in the current thread. It has no effect otherwise..

Specified by:
useCredentials in interface GCUBESecurityManager
Parameters:
credentials - the credentials.
Throws:
Exception - if security is enabled, but credentials are corrupt.

useCredentials

public void useCredentials(Thread thread,
                           SecurityCredentials... credentials)
                    throws Exception
If security is enabled, it sets given credentials for outgoing calls in a given thread..

Specified by:
useCredentials in interface GCUBESecurityManager
Parameters:
thread - the thread.
credentials - (optional) the credentials. If omitted, it delegates the credentials used for the current thread to the given thread.
Throws:
Exception - if security is enabled, but credentials are corrupt.

needServiceCredentials

public boolean needServiceCredentials()
Indicates whether the service makes use of service credentials..

Specified by:
needServiceCredentials in interface GCUBEServiceSecurityManager
Returns:
true if it does, false if it does not.

propagateCallerCredentials

public void propagateCallerCredentials(boolean propagateCallerCredentials)
Indicates whether the service, without any further configurationm, makes use of caller credentials: by default is true and, if false, the service will use its own credentials (without further configuration) to perform calls.

Specified by:
propagateCallerCredentials in interface GCUBEServiceSecurityManager

setAuthMethod

public void setAuthMethod(GCUBESecurityManager.AuthMethod m)
Adds an authentication method to be used in this security context.

Specified by:
setAuthMethod in interface GCUBESecurityManager
Parameters:
m - the authentication method

useCredentials

@Deprecated
public void useCredentials(GSSCredential credentials)
                    throws Exception
Deprecated. 

.

Specified by:
useCredentials in interface GCUBESecurityManager
Parameters:
credentials - the credentials.
Throws:
Exception - if security is enabled, but credentials are corrupt.

subscribe

public void subscribe(GCUBEServiceSecurityManager.LifetimeConsumer c,
                      GCUBEServiceSecurityManager.LifetimeTopic... topics)
Subscribes a GCUBEServiceSecurityManager.LifetimeConsumer..

Specified by:
subscribe in interface GCUBEServiceSecurityManager
Parameters:
c - the consumer.

unsubscribe

public void unsubscribe(GCUBEServiceSecurityManager.LifetimeConsumer c,
                        GCUBEServiceSecurityManager.LifetimeTopic... topics)
Unsubscribes a GCUBEServiceSecurityManager.LifetimeConsumer..

Specified by:
unsubscribe in interface GCUBEServiceSecurityManager
Parameters:
c - the consumer.

getAuthenticationManager

public GCUBEServiceAuthenticationController getAuthenticationManager()

getAuthorizationManager

public GCUBEServiceAuthorizationController getAuthorizationManager()

useCallerCredentials

public void useCallerCredentials(Thread... thread)
                          throws Exception
If security is enabled, it indicates that outgoing calls in a given thread must use the credentials associated with the incoming call. It has no effect otherwise.

An invocation of this method is equivalent to: context.useCredentials(context.getCallerCredentials()) or context.useCredentials(thread, context.getCallerCredentials())

Parameters:
thread - (optional) the thread. If omitted, the current thread is assumed.
Throws:
Exception - if security is enabled but the caller credentials could not be used.

useServiceCredentials

public void useServiceCredentials(Thread... thread)
                           throws Exception
If security is enabled, it indicates that outgoing calls in the current thread must use service credentials. It has no effect otherwise.

An invocation of this method is equivalent to:

context.useCredentials(context.getServiceCredentials(name)) or context.useCredentials(thread,context.getServiceCredentials(name)) * @param thread (optional) the thread. If omitted, the current thread is assumed.

Throws:
Exception - if security is enabled but service credentials could not be produced.

getStartScopes

public GCUBEScope[] getStartScopes()
Gets the start scopes of the RI.

Returns:
the scopes.

getScopeManager

public GCUBEScopeManager getScopeManager()
Returns the inner scope manager used by the context.

Returns:
the scope manager.

getScope

public GCUBEScope getScope()
Gets the scope for outgoing calls in the current thread.

Specified by:
getScope in interface GCUBEScopeManager
Returns:
the scope;

prepareCall

public void prepareCall(Remote remote,
                        String clazz,
                        String name,
                        GCUBEScope... scope)
Sets the scope for an outgoing call to a target gCube service.

Specified by:
prepareCall in interface GCUBEScopeManager
Parameters:
remote - the stub of the target port-type.
clazz - the gCube class of the target service.
name - the gCube name of the target service.
scope - (optional) the scope of the call. If omitted, the scope associated with the current thread will be used.
See Also:
GCUBERemotePortTypeContext.getProxy(Remote, org.gcube.common.core.contexts.GCUBEServiceContext), GCUBERemotePortTypeContext.getProxy(Remote, GCUBEScope, org.gcube.common.core.security.GCUBESecurityManager...), GCUBERemotePortTypeContext.getProxy(Remote, GCUBEScopeManager, org.gcube.common.core.security.GCUBESecurityManager...)

setScope

public void setScope(GCUBEScope scope)
              throws GCUBEScopeManager.IllegalScopeException
Sets the scope of outgoing calls in the current thread.

Specified by:
setScope in interface GCUBEScopeManager
Parameters:
scope - the scope.
Throws:
GCUBEScopeManager.IllegalScopeException

setScope

@Deprecated
public void setScope(Thread thread,
                                GCUBEScope scope)
              throws GCUBEScopeManager.IllegalScopeException
Deprecated. 

Throws:
GCUBEScopeManager.IllegalScopeException

setScope

@Deprecated
public void setScope(Thread thread,
                                GCUBEScope... scope)
              throws GCUBEScopeManager.IllegalScopeException
Deprecated. 

Sets the scope of outgoing calls in a given thread.

Specified by:
setScope in interface GCUBEScopeManager
Parameters:
thread - the thread.
scope - (optional) the scope. If omitted, it defaults to the scope of the current thread.
Throws:
GCUBEScopeManager.IllegalScopeException

addScope

public Set<GCUBEScope> addScope(GCUBEScope... scopes)
Adds one or more scopes to the service instance. Only scopes which are enclosed in some scope of the GHN are actually added.

Parameters:
scopes - the scopes.
Returns:
the list of scopes actually added to the service instance.
Throws:
IllegalArgumentException - if no scopes are provided in input.

removeScope

public Set<GCUBEScope> removeScope(GCUBEScope... scopes)
Removes one or more scopes from the service instance. Only scopes currently associated with the instance are actually removed.

Parameters:
scopes - the scopes.
Returns:
the list of scopes actually removed from the service instance.
Throws:
IllegalArgumentException - if no scopes are provided in input.

getPluginManager

public GCUBEPluginManager<?> getPluginManager()
Returns the plugin manager.

Returns:
the manager.

subscribeLifetTime

public void subscribeLifetTime(Consumer consumer,
                               GCUBEServiceContext.RILifetimeTopic... topics)
                        throws Exception
Subscribes a consumer to RI lifetime events for one or more RI lifetime topics.

Parameters:
consumer - the consumer.
topics - the topics of interest.
Throws:
Exception - if the subscription could not be completed.

unsubscribeLifetTime

public void unsubscribeLifetTime(Consumer consumer,
                                 GCUBEServiceContext.RILifetimeTopic... topics)
Unsubscribes a consumer from RI lifetime events for one or more RI lifetime topics.

Parameters:
consumer - the consumer.
topics - the topics.

notifyStateChange

public void notifyStateChange()
Notifies of a change to the persistent state of the RI.


onInitialisation

protected void onInitialisation()
                         throws Exception
Invoked when the Running Instance has completed initialisation. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.

onReady

protected void onReady()
                throws Exception
Invoked when the Running Instance is ready to operate. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.

onShutdown

protected void onShutdown()
                   throws Exception
Invoked when the Running Instance is going down. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.

onFailure

protected void onFailure()
                  throws Exception
Invoked when the Running Instance fails. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.

onUpdate

protected void onUpdate()
                 throws Exception
Invoked when the Runnning Instance is updated. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.

onStateChange

protected void onStateChange()
                      throws Exception
Invoked upon a change to the RI's stateful resources, if any. If needed, override in accordance with service semantics.

Throws:
Exception - if the callback did not complete successfully.


Copyright © 2012. All Rights Reserved.