org.gcube.common.core.utils.handlers
Class GCUBEStagingServiceHandler<CLIENT extends GCUBEServiceClient>

java.lang.Object
  extended by org.gcube.common.core.utils.handlers.GCUBEHandler<CLIENT>
      extended by org.gcube.common.core.utils.handlers.GCUBEServiceHandler<CLIENT>
          extended by org.gcube.common.core.utils.handlers.GCUBEStatefulServiceHandler<CLIENT>
              extended by org.gcube.common.core.utils.handlers.GCUBEStagingServiceHandler<CLIENT>
Type Parameters:
CLIENT - the type of the handled object. It must implement the GCUBEServiceClient interface.
All Implemented Interfaces:
GCUBEIHandler<CLIENT>, Lifetime<CLIENT>
Direct Known Subclasses:
StagingCall.StagingHandler

public abstract class GCUBEStagingServiceHandler<CLIENT extends GCUBEServiceClient>
extends GCUBEStatefulServiceHandler<CLIENT>

Abstract extension of GCUBEStatefulServiceHandler which extends its best-attempt strategy to the case in which instances of the target port-type can be created through factory port-types. The strategy extends GCUBEStatefulServiceHandler's by:

(1) Discovering factories whenever no instance can be found of the target port-type;
(2) Interacting with each factory to create an instance of the target port-type, until one instance has been created;
(3) Interacting with the created instance of the target port-type.

To completely define strategy, subclasses must implement the abstract methods required by GCUBEStatefulServiceHandler as well as the following abstract methods:

(a) findFactories() to discover factories;
(b) createInstance(EndpointReferenceType) to interact with a factory to create an instance of the target port-type;

Author:
Fabio Simeoni (University of Strathclyde)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.common.core.utils.handlers.GCUBEServiceHandler
GCUBEServiceHandler.NoQueryResultException
 
Field Summary
 
Fields inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler
handled, logger, producer
 
Constructor Summary
GCUBEStagingServiceHandler()
          Creates an instance.
GCUBEStagingServiceHandler(CLIENT client)
          Creates an instance to act on or on behalf of a service client.
 
Method Summary
protected  org.apache.axis.message.addressing.EndpointReferenceType _createInstance(org.apache.axis.message.addressing.EndpointReferenceType epr)
          Used internally to wrap createInstance(EndpointReferenceType) and handle its failures.
If createInstance(EndpointReferenceType) fails with a GCUBEFault, it propagates the GCUBEException which models the fault most specifically.
protected abstract  org.apache.axis.message.addressing.EndpointReferenceType createInstance(org.apache.axis.message.addressing.EndpointReferenceType epr)
          Interacts with a factory to create an instance of the target port-type.
protected abstract  List<org.apache.axis.message.addressing.EndpointReferenceType> findFactories()
          Returns a list of EPRs to factories.
protected  List<org.apache.axis.message.addressing.EndpointReferenceType> getFactories()
          Returns a non-empty list of EPRs to factories.
protected  List<org.apache.axis.message.addressing.EndpointReferenceType> getInstances()
          Returns a non-empty list of EPRs to instances of the target port-type.
protected  org.apache.axis.message.addressing.EndpointReferenceType tryFactories(List<org.apache.axis.message.addressing.EndpointReferenceType> eprs)
          Interacts with a list of factories to spawn an instance of the target port-type.
 
Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEStatefulServiceHandler
findInstances, findWSResources
 
Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEServiceHandler
_interact, cacheEPR, clearCachedEPR, getAttempts, getCachedEPR, getCacheKey, getTargetPortTypeName, interact, run, setAttempts, tryInstances
 
Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler
clearBlackboard, getBlackboard, getHandled, getId, getLogger, getName, getScopeManager, getSecurityManager, getState, notify, setBlackboard, setHandled, setLogger, setName, setScopeManager, setSecurityManager, setState, subscribe, undo, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gcube.common.core.utils.handlers.lifetime.Lifetime
getState
 
Methods inherited from interface org.gcube.common.core.utils.handlers.GCUBEIHandler
clearBlackboard, getBlackboard, getHandled, getId, getLogger, getName, getScopeManager, getSecurityManager, setBlackboard, setHandled, setLogger, setName, setScopeManager, setSecurityManager, subscribe, undo, unsubscribe
 

Constructor Detail

GCUBEStagingServiceHandler

public GCUBEStagingServiceHandler()
Creates an instance.


GCUBEStagingServiceHandler

public GCUBEStagingServiceHandler(CLIENT client)
Creates an instance to act on or on behalf of a service client.

Parameters:
client - the client.
Method Detail

getInstances

protected List<org.apache.axis.message.addressing.EndpointReferenceType> getInstances()
                                                                               throws Exception
Returns a non-empty list of EPRs to instances of the target port-type. The list contains either all the instances returned by getInstances() or, if none is returned, the single instance spawned as the result of the first successful interaction with a factory returned by getFactories().

Overrides:
getInstances in class GCUBEServiceHandler<CLIENT extends GCUBEServiceClient>
Returns:
the list of EPRs.
Throws:
Exception - if no EPRs can be returned.

tryFactories

protected org.apache.axis.message.addressing.EndpointReferenceType tryFactories(List<org.apache.axis.message.addressing.EndpointReferenceType> eprs)
                                                                         throws Exception
Interacts with a list of factories to spawn an instance of the target port-type.

Parameters:
eprs - the EPRs of the factories.
Returns:
the EPR of the spawned instance.
Throws:
Exception - if no interaction is successful.

getFactories

protected List<org.apache.axis.message.addressing.EndpointReferenceType> getFactories()
                                                                               throws Exception,
                                                                                      GCUBEServiceHandler.NoQueryResultException
Returns a non-empty list of EPRs to factories.

Returns:
the list of EPRs.
Throws:
NoQueryResultException - if no factory can be found.
Exception - if no EPR can be returned.
GCUBEServiceHandler.NoQueryResultException

_createInstance

protected org.apache.axis.message.addressing.EndpointReferenceType _createInstance(org.apache.axis.message.addressing.EndpointReferenceType epr)
                                                                            throws Exception
Used internally to wrap createInstance(EndpointReferenceType) and handle its failures.
If createInstance(EndpointReferenceType) fails with a GCUBEFault, it propagates the GCUBEException which models the fault most specifically.

Parameters:
epr - the EPR of a factory.
Throws:
Exception - if no instance could be created.
See Also:
createInstance(EndpointReferenceType)

findFactories

protected abstract List<org.apache.axis.message.addressing.EndpointReferenceType> findFactories()
                                                                                         throws Exception
Returns a list of EPRs to factories.

Returns:
the list of EPRs.
Throws:
Exception - if no EPR can be returned.

createInstance

protected abstract org.apache.axis.message.addressing.EndpointReferenceType createInstance(org.apache.axis.message.addressing.EndpointReferenceType epr)
                                                                                    throws Exception
Interacts with a factory to create an instance of the target port-type.

Parameters:
epr - the EPR of the factory.
Returns:
the EPR of the instance.
Throws:
Exception - if the interaction does not complete successfully.


Copyright © 2013. All Rights Reserved.