public class LocalServer
extends java.lang.Object
HttpServer
or ESB
. These are both
admin key protected now and so direct access is more difficult.Modifier | Constructor and Description |
---|---|
protected |
LocalServer()
Create a new instance of LocalServer
|
Modifier and Type | Method and Description |
---|---|
boolean |
addRootNode(java.lang.String theRootNode,
java.lang.String adminKey)
Add a service uuid to the list of root nodes.
|
boolean |
addService(java.lang.String thePassword,
java.lang.String serviceName,
java.lang.String serviceType,
java.lang.Object theService)
Add a new service to the ESB but do not start its thread.
|
boolean |
addServiceMeta(java.lang.String thePassword,
java.lang.String theAdminKey,
ServiceMeta theServiceMeta)
Add the metadata for the service.
|
boolean |
allowAddService(java.lang.String adminKey,
boolean allow)
Set the
allowAddService variable to allow services to be added. |
java.util.HashMap<java.lang.String,Metrics> |
allServiceMetrics(java.lang.String adminKey)
Get a list of all available services' metrics.
|
boolean |
canAccess(java.lang.String thePassword,
java.lang.reflect.Method theMethod)
Return true if the password allows the calling component to access this component.
|
boolean |
canAccess(java.lang.String thePassword,
java.lang.String methodName)
Return true if the password allows the calling component to access this component.
|
boolean |
cancelMessage(java.lang.String ticket,
java.lang.String adminKey)
Remove the message with the specified ticket number from the queue.
|
static boolean |
checkAddress(java.lang.String host,
int port)
Return true if the ip address and port compares to the address the server is running on.
|
static java.lang.String |
contactInfo()
Get a server administrator contact address, email or something.
|
java.lang.Object |
execute(MethodInfo methodInfo)
Execute the specified method and return the result.
|
boolean |
getAllowAddService(java.lang.String adminKey)
Return true if the ESB allows adding services.
|
static LocalServer |
getApi(java.lang.String serverPassword)
Get the local server instance.
|
Link_NM |
getFaultsTree(java.lang.String adminKey)
Get the faults list tree, for display purposes.
|
FileObject |
getJarForService(java.lang.String jarName)
Load a jar file into a file object and return.
|
java.lang.String |
getPassword(java.lang.String clientID,
Contract clientContract)
Get this service's password, depending on the calling component's contract description.
|
static org.licas_xml.abs.Element |
getServerHandle()
Return the server handle of the static http server.
|
boolean |
getServerShutDown()
Return a value indicating if the static http server should be shut down.
|
static java.lang.String |
getServerURL()
Return the http address of the static http server.
|
java.lang.Object |
getService(java.lang.String serviceName,
java.lang.String thePassword,
java.lang.String adminKey)
Return the service for the related service name.
|
org.licas_xml.abs.Element |
getServiceMeta(java.lang.String theServiceID)
Get the metadata for the service from the server repository.
|
ServiceMeta |
getServiceMeta(java.lang.String theServiceID,
java.lang.String theAdminKey)
Get the service metadata from the server repository.
|
java.util.ArrayList<java.lang.String> |
getServiceNames()
Get a list of services running on the ESB.
|
java.util.ArrayList<java.lang.String> |
getServiceNames(java.util.ArrayList<java.lang.String> thisServiceTypes)
Return all child service names for a list of service types.
|
java.util.ArrayList<java.lang.String> |
getServiceNames(java.util.ArrayList<java.lang.String> thisServiceTypes,
boolean reciprocal)
Return all child service names for a list of service types.
|
java.lang.String |
getServiceType(java.lang.String serviceID)
Get the service type for the specified service.
|
java.util.ArrayList<java.lang.String> |
getServiceTypes()
Get a list of all of the service types in the network.
|
java.util.ArrayList<java.lang.String> |
getServiceTypes(java.lang.String category)
Get a list of all of the service types in the network for a
particular category.
|
ServiceWrapperDef |
getServiceWrapper(java.lang.String serviceName,
java.lang.String thePassword,
java.lang.String adminKey)
Return the service wrapper for the related service name.
|
boolean |
hasESB(java.lang.String thePassword)
Return true if an enterprise service bus is running on this server.
|
boolean |
hasJarFactory(java.lang.String thePassword)
Return true if this server is running a jar factory.
|
static boolean |
hasServer()
Return true if an
HttpServer instance is created. |
static boolean |
isAdminKey(java.lang.String theAdminKey)
Return true if the correct admin key.
|
boolean |
isBlockedService(java.lang.String serviceID)
Return true if the service is a blocked service.
|
static boolean |
isLocalIPAddress(java.lang.String theIPAddress)
Return true if the ip address represents a local server.
|
static boolean |
isPassword(java.lang.String theServerPassword)
Return true if the correct password.
|
static boolean |
isRunning()
Return true if an enterprise service bus is stored and running in this server.
|
boolean |
isStoredService(java.lang.String serviceID)
Return true if the service id entered relates to a stored service.
|
boolean |
messageToBus(MessageInfo ro,
java.lang.String adminKey)
Add the next message to the message bus, to be returned in order for processing by a service.
|
void |
notifyOfFault(FaultDetails fault,
java.lang.String adminKey)
This method should be called to notify the server about a problem or fault.
|
org.licas_xml.abs.Element |
passwordsStateToXml(java.lang.String adminKey)
Serialize the stored ESB passwords list and return as an XML-based description.
|
boolean |
removeServiceMeta(java.lang.String theServiceID,
java.lang.String theAdminKey)
Remove the service metadata from the server repository.
|
boolean |
serverHasService(java.lang.String serviceID)
Return true if a service with the specified id is running on this server.
|
boolean |
serverHasServiceType(java.lang.String serviceType)
Return true if a service with the specified type is running on this server.
|
boolean |
setESB(java.lang.String serviceName,
java.lang.String serviceType,
java.util.ArrayList<java.lang.String> jarFile,
java.lang.String className,
java.util.ArrayList<java.lang.Object> params)
Creates a user-defined instance of ESB and set with the config values.
|
boolean |
setESB(java.lang.String serviceName,
java.lang.String serviceType,
org.licas_xml.abs.Element adminXml)
Creates a default instance of ESB and set with the config values.
|
protected static void |
setPasswords(java.lang.String thePassword,
java.lang.String theAdminKey)
Set the password and admin key for accessing the server.
|
boolean |
shutDown(java.lang.String theAdminKey)
Shut down the server and stop the request thread.
|
void |
startRequestThread(java.lang.String adminKey)
Start the server request thread.
|
public static LocalServer getApi(java.lang.String serverPassword)
serverPassword
- the server password or admin key.null
if there is an error.protected static void setPasswords(java.lang.String thePassword, java.lang.String theAdminKey)
thePassword
- the password for accessing the server.theAdminKey
- the admin key for accessing the server.public static boolean hasServer()
HttpServer
instance is created.public static boolean isRunning()
public static java.lang.String contactInfo()
public static boolean isLocalIPAddress(java.lang.String theIPAddress)
theIPAddress
- the ip address to compare, 127.0.0.1, for example.public boolean canAccess(java.lang.String thePassword, java.lang.String methodName)
thePassword
- the password to use.methodName
- the method name that needs to be called.public boolean canAccess(java.lang.String thePassword, java.lang.reflect.Method theMethod)
thePassword
- the password to use.theMethod
- the method that needs to be called.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.ESB
object
that also uses the same password set. The server by default will always or
never return its password.java.lang.Exception
- any error.public static boolean checkAddress(java.lang.String host, int port)
host
- the host address. Can include 'localhost' or '127.0.0.1'.port
- the port.public static java.lang.String getServerURL()
public static org.licas_xml.abs.Element getServerHandle()
Handle
.getLocalServerURI()
.public boolean setESB(java.lang.String serviceName, java.lang.String serviceType, org.licas_xml.abs.Element adminXml)
serviceName
- the service name.serviceType
- the service type.adminXml
- the admin info or description of this service.public boolean setESB(java.lang.String serviceName, java.lang.String serviceType, java.util.ArrayList<java.lang.String> jarFile, java.lang.String className, java.util.ArrayList<java.lang.Object> params)
serviceName
- the name of the service.serviceType
- the type of the service.jarFile
- the jar files for a remote loading. Values are jar paths
of type String.className
- the name of the service class.params
- a list of initialisation parameters.public void startRequestThread(java.lang.String adminKey) throws java.lang.Exception
adminKey
- the server admin key.java.lang.Exception
- any error.public boolean messageToBus(MessageInfo ro, java.lang.String adminKey)
ro
- the message to add, as the whole request object, that then executes itself and returns the result.adminKey
- admin key to access the server.public boolean cancelMessage(java.lang.String ticket, java.lang.String adminKey)
ticket
- unique ticket number, equivalent to a communication ID.adminKey
- the server admin key.public java.lang.Object execute(MethodInfo methodInfo) throws java.lang.Exception
methodInfo.serviceURI
to be something like Handle
.createServiceHandle(serviceType)
.methodInfo
- the method call description with all of the required information.ServiceException
- for non-critical service related problems,
such as if the method password is incorrect.java.lang.Exception
- any error.public boolean isBlockedService(java.lang.String serviceID)
serviceID
- the service uuid.public boolean allowAddService(java.lang.String adminKey, boolean allow)
allowAddService
variable to allow services to be added.adminKey
- the admin key for this service.allow
- true if reset to allow adding of services, false to reset
to block of adding services.public boolean getAllowAddService(java.lang.String adminKey)
adminKey
- the admin key for the server.public boolean addRootNode(java.lang.String theRootNode, java.lang.String adminKey)
theRootNode
- the uuid of the root service to add.adminKey
- the server admin key.public java.lang.Object getService(java.lang.String serviceName, java.lang.String thePassword, java.lang.String adminKey) throws ServiceException, java.lang.Exception
serviceName
- the name of the service you want to retrieve.thePassword
- the password for the service you want to retrieve.adminKey
- the admin key for the service you want to retrieve.ServiceException
- for service specific error.java.lang.Exception
- any other error.public boolean addService(java.lang.String thePassword, java.lang.String serviceName, java.lang.String serviceType, java.lang.Object theService) throws java.lang.Exception
thePassword
- the password to protect access to this component.serviceName
- the name of the service.serviceType
- the type of the service.theService
- the service.java.lang.Exception
- any error.public boolean addServiceMeta(java.lang.String thePassword, java.lang.String theAdminKey, ServiceMeta theServiceMeta)
thePassword
- the service password. Register if not already added.theAdminKey
- the admin key for the service. Register if not already added.theServiceMeta
- the metadata for the service.public org.licas_xml.abs.Element getServiceMeta(java.lang.String theServiceID) throws java.lang.Exception
theServiceID
- the unique id to define the service.java.lang.Exception
- any error.public ServiceMeta getServiceMeta(java.lang.String theServiceID, java.lang.String theAdminKey) throws java.lang.Exception
theServiceID
- the unique id to define the service.theAdminKey
- the unique admin key for the service.java.lang.Exception
- any error.public boolean removeServiceMeta(java.lang.String theServiceID, java.lang.String theAdminKey) throws java.lang.Exception
theServiceID
- the unique id of the service to remove.theAdminKey
- the unique admin key for the service.java.lang.Exception
- any error.public ServiceWrapperDef getServiceWrapper(java.lang.String serviceName, java.lang.String thePassword, java.lang.String adminKey) throws ServiceException, java.lang.Exception
serviceName
- the name of the service you want to retrieve.thePassword
- the password to access the service you want to retrieve.adminKey
- the admin key for the service you want to retrieve.ServiceException
- for service specific error.java.lang.Exception
- any other error.public java.util.ArrayList<java.lang.String> getServiceNames()
public java.util.ArrayList<java.lang.String> getServiceNames(java.util.ArrayList<java.lang.String> thisServiceTypes) throws LicasException
thisServiceTypes
- the service types list.LicasException
- if the service types input is null
.public java.util.ArrayList<java.lang.String> getServiceNames(java.util.ArrayList<java.lang.String> thisServiceTypes, boolean reciprocal) throws LicasException
thisServiceTypes
- the service types list.reciprocal
- is false return all service names of the service types,
if true return all service names of all other types.LicasException
- if the service types input is null
.public java.lang.String getServiceType(java.lang.String serviceID)
serviceID
- id of the service to retrieve.public java.util.ArrayList<java.lang.String> getServiceTypes()
public java.util.ArrayList<java.lang.String> getServiceTypes(java.lang.String category)
category
- the category to return service types for.public org.licas_xml.abs.Element passwordsStateToXml(java.lang.String adminKey)
adminKey
- the ESB admin key.public java.util.HashMap<java.lang.String,Metrics> allServiceMetrics(java.lang.String adminKey)
adminKey
- the admin key for the server.public void notifyOfFault(FaultDetails fault, java.lang.String adminKey)
fault
- a description of the fault.adminKey
- server admin key. If this is incorrect, then the fault is not recorded.public Link_NM getFaultsTree(java.lang.String adminKey)
adminKey
- the admin key for the server.public static boolean isPassword(java.lang.String theServerPassword)
theServerPassword
- the password to check for.public static boolean isAdminKey(java.lang.String theAdminKey)
theAdminKey
- the admin key to check for.public boolean hasESB(java.lang.String thePassword)
thePassword
- the password for this server.public boolean hasJarFactory(java.lang.String thePassword)
thePassword
- the password for this server.public boolean serverHasService(java.lang.String serviceID) throws java.lang.Exception
serviceID
- the service uuid to check for.java.lang.Exception
- any error.public boolean serverHasServiceType(java.lang.String serviceType)
serviceType
- the service type to check for.public boolean isStoredService(java.lang.String serviceID)
serverHasService
method.serviceID
- the unique service id.public FileObject getJarForService(java.lang.String jarName)
jarName
- the name of the jar file.public boolean getServerShutDown()
public boolean shutDown(java.lang.String theAdminKey)
theAdminKey
- the unique key to protect loading/removal of the server.