public class ServiceWrapper extends ServiceModule implements ServiceWrapperDef
Service
object and a ServiceWrapperLegacy
stores a Legacy
object.
The autonomic manager is also an extension of this wrapper, but it only stores an
Auto
-derived object and would also allow for autonomic monitoring capabilities.
This means that any object can actually be loaded and stored as a service. The wrapper
class extends either a FrameworkModule
or a full Service
, depending on
what additional functionality is required. This would mean that any object can be
used as part of the licas system and the object methods can be found and invoked.Modifier and Type | Field and Description |
---|---|
protected Metrics |
metrics
Measurements of general message/transaction numbers
|
protected boolean |
setStructures
True if structures for enclosed service object already set
|
shutDown
passwordHandler, service, serviceType
jarFile, syncOn, uuid
Constructor and Description |
---|
ServiceWrapper(Service theService)
Creates a new instance of ServiceWrapper.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
addCommunicationID(java.lang.String commID,
java.lang.Object clientURI)
Store the commID with the related client URI, on the embedded service.
|
void |
addMetrics(MethodInfo messageObj,
java.lang.String theAdminKey)
Add some metrics values relating to the current message.
|
boolean |
canAccess(java.lang.String thePassword)
Return true if the wrapped object can be accessed by the password.
|
boolean |
canAccess(java.lang.String thePassword,
java.lang.reflect.Method theMethod)
Return true if the method on the wrapped object can be accessed by the password.
|
boolean |
canAccess(java.lang.String thePassword,
java.lang.String theMethod)
Return true if the method on the wrapped object can be accessed by the password.
|
boolean |
canAccessTemp(java.lang.String thePassword)
Return true if the password allows the calling component
to access this component by a temp password.
|
void |
copyFromService()
Reset the wrapper settings based on the wrapped object if a service.
|
void |
copyToService(java.lang.Object parent)
Copy and set certain settings between the service object and the wrapper.
|
java.lang.Object |
execute(MethodInfo methodInfo,
boolean addTempPassword)
Execute the specified method and return the result.
|
org.licas_xml.abs.Element |
getDescription()
Get the description value.
|
org.licas_xml.abs.Element |
getFullPath()
Get the fully qualified uuid path back to the first parent object and server.
|
Metrics |
getMetrics()
Get the default message/transaction metrics.
|
java.lang.Class |
getObjClass()
Get the class type of the stored object.
|
java.lang.Object |
getObjService(java.lang.String adminKey)
Get the stored object service.
|
java.lang.String |
getPassword(java.lang.String theAdminKey)
Get the password for this service.
|
java.lang.String |
getPassword(java.lang.String clientID,
Contract clientContract)
Get this service's password, depending on the calling component's contract description.
|
java.lang.String |
getPassword(java.lang.String serviceUuid,
java.lang.String theAdminKey)
Get the password for the specified service.
|
ServiceWrapperDef |
getService(java.lang.String serviceName,
java.lang.String thePassword)
Return the service for the related service name.
|
java.lang.Object |
getService(java.lang.String serviceName,
java.lang.String thePassword,
java.lang.String adminKey)
Return the service for the related service name.
|
java.lang.String |
getServiceGrade()
Get the grade for this service.
|
WorkInfo |
getWorkInfo()
Get the work protocol details for the service.
|
boolean |
interrupt(java.lang.String adminKey)
You must call this method to interrupt the thread.
|
java.lang.Object |
invokeObj(java.lang.reflect.Method theMethod,
java.lang.Object[] params)
Invoke the method on the stored object with the specified parameters.
|
java.util.ArrayList<java.lang.reflect.Method> |
reflectionMethods()
Get a list of public methods that can be accessed through the service, not this wrapper.
|
void |
run()
This run method tries to start the run method on the embedded object.
|
void |
setObjService(java.lang.Object theObj)
Set the wrapped object that is typically derived from
Service ,
but can be a legacy object of any type. |
protected boolean |
setParent(Service thisParent)
Set the parent component value.
|
protected void |
setServerPassword(java.lang.String thePassword)
Set the password that will allow this service to access the server it runs on.
|
void |
setServiceGrade(java.lang.String thisServiceGrade)
Set the service grade or function class.
|
boolean |
storesLegacy()
Return true if the stored object is legacy code, false if a licas service.
|
java.lang.String |
threadAliveState()
Return the thread state of the embedded object.
|
getShutDown, setShutDown, setShutDown
getPasswordHandler, getPasswordHandler, getServerPassword, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType
getJarFile, getUUID, loadObject, setJarFile, setUUID
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getServiceType, getUUID, isAdminKey, setJarFile, setServiceType, setUUID
protected boolean setStructures
protected Metrics metrics
public ServiceWrapper(Service theService) throws java.lang.Exception
theService
- the service to monitor.java.lang.Exception
- any error.public boolean storesLegacy()
storesLegacy
in interface ServiceWrapperDef
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public final void copyToService(java.lang.Object parent) throws java.lang.Exception
copyToService
in interface ServiceWrapperDef
parent
- the parent of the wrapper.java.lang.Exception
- any error.public final void copyFromService()
copyFromService
in interface ServiceWrapperDef
public boolean canAccessTemp(java.lang.String thePassword)
canAccessTemp
in interface ServiceDef
canAccessTemp
in class FrameworkModule
thePassword
- the password to use.public boolean canAccess(java.lang.String thePassword)
Service
then its canAccess
method is called,
otherwise true is automatically returned.canAccess
in interface ServiceDef
canAccess
in class FrameworkModule
thePassword
- the password to use.public boolean canAccess(java.lang.String thePassword, java.lang.String theMethod) throws java.lang.Exception
Service
then its canAccess
method is called,
otherwise true is automatically returned.thePassword
- the password to use.theMethod
- the name of the method to call.java.lang.Exception
- nay error.public boolean canAccess(java.lang.String thePassword, java.lang.reflect.Method theMethod) throws java.lang.Exception
Service
then its canAccess
method is called,
otherwise true is automatically returned.thePassword
- the password to use.theMethod
- the method reflection description.java.lang.Exception
- nay error.public java.lang.String getPassword(java.lang.String clientID, Contract clientContract) throws java.lang.Exception
clientID
- the clientID of the calling component.clientContract
- the description of the calling component's contract proposal.java.lang.Exception
- any error.public java.lang.String getPassword(java.lang.String theAdminKey)
getPassword
method is called,
otherwise this wrapper's getPassword method is called.theAdminKey
- the service key.public java.lang.String getPassword(java.lang.String serviceUuid, java.lang.String theAdminKey) throws java.lang.Exception
getPassword
method is called,
otherwise this wrapper's getPassword method is called.serviceUuid
- the id of the service to ask the password for.theAdminKey
- the service key.java.lang.Exception
- any error.public void addMetrics(MethodInfo messageObj, java.lang.String theAdminKey)
addMetrics
in interface ServiceWrapperDef
messageObj
- the message object.theAdminKey
- the admin key for the parent service.public Metrics getMetrics()
getMetrics
in interface ServiceWrapperDef
protected boolean addCommunicationID(java.lang.String commID, java.lang.Object clientURI) throws java.lang.Exception
MessageInfo
objects with timestamps. The method now also checks the timestamps and removes any communicationIDs
that are older than 3 days.commID
- the communication id.clientURI
- the URI/reference for the calling client. If null
or a server URI,
then it is set to Const
.ANON
and only the commID is subsequently checked for.java.lang.Exception
- any error.public void setServiceGrade(java.lang.String thisServiceGrade)
thisServiceGrade
- the service grade.public java.lang.String getServiceGrade()
getServiceGrade
in interface ServiceWrapperDef
public org.licas_xml.abs.Element getDescription()
getDescription
in interface ServiceWrapperDef
public WorkInfo getWorkInfo()
getWorkInfo
in interface ServiceWrapperDef
workInfo
details.protected void setServerPassword(java.lang.String thePassword) throws java.lang.Exception
thePassword
- the server password.java.lang.Exception
- any error.protected boolean setParent(Service thisParent)
thisParent
- the parent component representation.public org.licas_xml.abs.Element getFullPath() throws java.lang.Exception
getFullPath
in interface ServiceWrapperDef
java.lang.Exception
- any error.public ServiceWrapperDef getService(java.lang.String serviceName, java.lang.String thePassword) throws ServiceException, java.lang.Exception
getService
method is called,
otherwise this wrapper's getService method is called.serviceName
- the name of the service.thePassword
- the password to access the service to retrieve.ServiceException
- is access to any nested services is blocked.java.lang.Exception
- any other error.public java.lang.Object getService(java.lang.String serviceName, java.lang.String thePassword, java.lang.String adminKey) throws ServiceException, java.lang.Exception
getService
method is called,
otherwise this wrapper's execute method is called.
This method requires the service key as well, but then returns a direct reference.serviceName
- the name of the service.thePassword
- the password to access the service.adminKey
- the service key for this server.ServiceException
- for service specific error.java.lang.Exception
- any other error.public void setObjService(java.lang.Object theObj)
Service
,
but can be a legacy object of any type.setObjService
in interface ServiceWrapperDef
theObj
- the value of obj.public java.lang.Object getObjService(java.lang.String adminKey)
getObjService
in interface ServiceWrapperDef
adminKey
- the admin key for the object or wrapper.public java.lang.Class getObjClass()
getObjClass
in interface ServiceWrapperDef
public java.lang.Object execute(MethodInfo methodInfo, boolean addTempPassword) throws ServiceException, java.lang.Exception
methodInfo
- the method call description with all of the required information.addTempPassword
- if true add a temporary password to allow traversal
through this service. If the service is referenced directly as an object
then set this to false so that the caller must know this service's password.ServiceException
- any service specific error.java.lang.Exception
- any other error.public java.util.ArrayList<java.lang.reflect.Method> reflectionMethods()
reflectionMethods
in interface ServiceWrapperDef
public java.lang.Object invokeObj(java.lang.reflect.Method theMethod, java.lang.Object[] params) throws java.lang.Exception
invokeObj
in interface ServiceWrapperDef
theMethod
- the method to invoke.params
- the parameter list.java.lang.Exception
- any error.public boolean interrupt(java.lang.String adminKey)
interrupt
in class ServiceModule
adminKey
- the key to identify unique loading of the service.public java.lang.String threadAliveState()
threadAliveState
in class LicasModule