|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gcube.common.core.utils.handlers.GCUBEHandler<CLIENT>
org.gcube.common.core.utils.handlers.GCUBEServiceHandler<CLIENT>
CLIENT - the type of the handled object. It must implement the GCUBEServiceClient interface.public abstract class GCUBEServiceHandler<CLIENT extends GCUBEServiceClient>
Abstract extension of GCUBEHandler which implements a best-attempt strategy
to interact with an instance of a port-type of a gCube service (the target port-type)
on behalf of the handled object (the client).
The strategy involves:
(1) Interacting with an instance of the target port-type, if its endpoint reference was previously cached within the client;
(2) Discovering suitable instances of the target port-type, if the cached instance fails or no such cache exists yet;
(3) Interacting with each instance of the target port-type, until the interaction is successful;
(4) Caching the endpoint reference of the instance of the target port-type with which interaction is successful;
To completely define strategy,concrete subclasses must implement the following abstract methods in accordance with the specific semantics of the interaction:
(a) findInstances() to discover suitable instances of the target port-type;
(b) interact(EndpointReferenceType) to interact with an instance of the target port-type;
They may and normally will also wish to implement the following method:
(c) getTargetPortTypeName() to return the name of the target port-type for customised logging and
to grant EPR reuse across all the handler types that target the same port-type and operate on behalf of the
same client. If the client is scope-sensitive (i.e. returns a non-null scope), then sharing
is further scope-qualified.
GCUBEServiceHandlers which
- in different ways and for different purposes - interact with the same port-type on behalf of the same client.
The cache is entirely managed by the GCUBEServiceHandler, but the client must implement the
GCUBEServiceClient interface (or else extend its base implementation GCUBEServiceClientImpl).
Before being cached, finally, endpoint references are also stored in the state of the GCUBEServiceHandler
with the name targetEPR, so as to be shared asynchronously with other GCUBEHandlers in
the context of a GCUBESequentialHandler.
| Nested Class Summary | |
|---|---|
static class |
GCUBEServiceHandler.NoQueryResultException
Characterises empty query results. |
| Field Summary |
|---|
| Fields inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler |
|---|
handled, logger, producer |
| Constructor Summary | |
|---|---|
GCUBEServiceHandler()
Creates an instance. |
|
GCUBEServiceHandler(CLIENT client)
Creates an instance to act on or on behalf of a service client. |
|
| Method Summary | |
|---|---|
protected void |
_interact(org.apache.axis.message.addressing.EndpointReferenceType epr)
Used internally to wrap interact(EndpointReferenceType) and handle its successes and failures. |
protected void |
cacheEPR(org.apache.axis.message.addressing.EndpointReferenceType epr)
Caches the EPR of an instance of the target port-type. |
protected void |
clearCachedEPR()
Clears the EPR of the instance of the target port-type which was last cached. |
protected abstract List<org.apache.axis.message.addressing.EndpointReferenceType> |
findInstances()
Discovers EPRs to suitable instances of the target port-type. |
int |
getAttempts()
Returns the number of times the handler tries to interact with instances of the target port-type which prove busy. |
protected org.apache.axis.message.addressing.EndpointReferenceType |
getCachedEPR()
Returns the EPR of the instance of the target port-type which was last cached. |
protected String |
getCacheKey()
Returns a key to store 'successful' endpoints of the target port-type in the cache provided by the service client. |
protected List<org.apache.axis.message.addressing.EndpointReferenceType> |
getInstances()
Returns a non-empty list of EPRs to suitable instances of the target port-type. |
protected String |
getTargetPortTypeName()
Returns the local name of the target port-type as the basis for a key to store 'successful' EPRs of the port-type in the cache provided by the service client (cf. |
protected abstract void |
interact(org.apache.axis.message.addressing.EndpointReferenceType epr)
Interacts with an instance of the target port-type. |
void |
run()
Executes the task implemented by the handler. |
void |
setAttempts(int attempts)
Sets how many times the handler should try to interact with instances of the target port-type which prove busy. |
protected org.apache.axis.message.addressing.EndpointReferenceType |
tryInstances(List<org.apache.axis.message.addressing.EndpointReferenceType> eprs)
Interacts with a list of instances of the target port-type, until one is successful. |
| 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 |
|---|
public GCUBEServiceHandler()
public GCUBEServiceHandler(CLIENT client)
client - the client.| Method Detail |
|---|
public void run()
throws Exception
run in interface GCUBEIHandler<CLIENT extends GCUBEServiceClient>run in class GCUBEHandler<CLIENT extends GCUBEServiceClient>Exception - if the execution of the task does not complete normally.
protected List<org.apache.axis.message.addressing.EndpointReferenceType> getInstances()
throws GCUBEServiceHandler.NoQueryResultException,
Exception
GCUBEServiceHandler.NoQueryResultException - if the EPRs cannot be returned.
GCUBEServiceHandler.NoQueryResultException - if suitable instances cannot be found.
Exception
protected void _interact(org.apache.axis.message.addressing.EndpointReferenceType epr)
throws Exception
interact(EndpointReferenceType) and handle its successes and failures.
interact(EndpointReferenceType) succeeds, it store the input EPR
in the handler's state. If interact(EndpointReferenceType) fails with a GCUBEFault,
it propagates the GCUBEException which models it most specifically.
epr - the EPR of an instance of the target port-type.
GCUBEServiceHandler.NoQueryResultException - if the interaction fails to complete successfully.
Exceptioninteract(EndpointReferenceType).
protected org.apache.axis.message.addressing.EndpointReferenceType tryInstances(List<org.apache.axis.message.addressing.EndpointReferenceType> eprs)
throws Exception
eprs - the instance EPRs.
GCUBEServiceHandler.NoQueryResultException - if no interactions completes successfully.
Exceptionpublic int getAttempts()
public void setAttempts(int attempts)
attempts - the number of attempts.protected void clearCachedEPR()
protected void cacheEPR(org.apache.axis.message.addressing.EndpointReferenceType epr)
epr - the EPR.protected org.apache.axis.message.addressing.EndpointReferenceType getCachedEPR()
protected String getCacheKey()
By default, the key is derived from the name of the port-type (cf. getTargetPortTypeName() so
as to reuse across endpoints across all handler types that target the same port-type and share the same client.
If the client is scope-sensitive, however, the key is further scope-qualified.
getTargetPortTypeName()protected String getTargetPortTypeName()
getCacheKey()).
By default, it returns the name of handler (cf. GCUBEHandler.getName()), which will not grant EPR reuse
across any other handler type that may target the same port-type. Override and return a specific port-type name
to grant EPR reuse across all handler types that target the same port-type and share the same client.
#getName()},
#getCacheKey()}.
protected abstract List<org.apache.axis.message.addressing.EndpointReferenceType> findInstances()
throws Exception
GCUBEServiceHandler.NoQueryResultException - if suitable instances cannot be found.
Exception
protected abstract void interact(org.apache.axis.message.addressing.EndpointReferenceType epr)
throws Exception
epr - the EPR of the instance.
GCUBEServiceHandler.NoQueryResultException - if the interaction does not complete successfully.
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||