org.jwarp.service
Class Context

java.lang.Object
  |
  +--org.jwarp.service.Context
All Implemented Interfaces:
IContext

public class Context
extends java.lang.Object
implements IContext

This implements a basic application context. An application context provides a runtime environment controlling processes, threads and security of application services. All JWeb components actually are built on top of these services.

Version:
1.0
Author:
ORCA Systems GmbH, Martin Schäfer, ORCA Systems GmbH, Anatole Tresch

Field Summary
(package private)  ILogWriter log
           
 
Fields inherited from interface org.jwarp.service.IContext
CONTEXT_STATUS_CREATED, CONTEXT_STATUS_NOT_AVAILABLE, CONTEXT_STATUS_RUNNING, CONTEXT_STATUS_STARTING, CONTEXT_STATUS_STOPPED, CONTEXT_STATUS_STOPPING, ELEM_CONTEXT
 
Constructor Summary
Context(org.jdom.Element configuration)
          Creates the context with the given element
 
Method Summary
 void addService(org.jdom.Element config, ITicket ticket)
          Add dynamically a new service.
 void addService(IService service, java.lang.String serviceName, ITicket ticket)
          Add dynamically a new service.
 void checkAccess(java.lang.String op, int level, ITicket ticket)
          Direct access to the security service for right authorization.
 IService connectService(org.jdom.Element tree, ITicket ticket)
          This method is used for reusal of the service intitialization and reference code.
 ILogWriter getLog()
          Returns the context's default log writer object.
 java.lang.String getName()
          Returns the context's name
 IReferenceResolver getResolver()
           
 IService getService(java.lang.String serviceName, ITicket ticket)
          Return the service with the given name
 int getStatus()
          Returns the current status of the context
 ITicket getSystemTicket()
          Returns the context's system ticket EXACTLY once after initialization.
 ITicket login(java.lang.String user, java.lang.String pwd)
          Login to this context.
 ILogWriter makeLog(org.jdom.Element tree, ITicket ticket)
          This method is used for reusal of the log intitialization and reference code.
 void removeService(java.lang.String serviceName, ITicket ticket)
          Add dynamically a new service.
 void start(ITicket ticket)
           
 void stop(ITicket ticket)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

ILogWriter log
Constructor Detail

Context

public Context(org.jdom.Element configuration)
        throws ConfigurationException
Creates the context with the given element
Parameters:
configuration - The XML configuration of the context
Method Detail

getSystemTicket

public final ITicket getSystemTicket()
                              throws java.lang.SecurityException
Returns the context's system ticket EXACTLY once after initialization. If a security context was configured then the security context is called to set the contexts system ticket.

getResolver

public IReferenceResolver getResolver()
Specified by:
getResolver in interface IContext

login

public ITicket login(java.lang.String user,
                     java.lang.String pwd)
              throws java.lang.SecurityException
Login to this context. This method is called by the contextFactory for logging in.
Specified by:
login in interface IContext
Parameters:
user - The user id,
pwd - The user password
Throws:
java.lang.SecurityException - When access to the context was denied.

addService

public void addService(IService service,
                       java.lang.String serviceName,
                       ITicket ticket)
                throws java.lang.SecurityException
Add dynamically a new service.
Specified by:
addService in interface IContext
Parameters:
service - The new service
serviceName - The service name under which the service should registered
ticket - The system user who must WRITE access to the factory
Throws:
java.lang.SecurityException - If access was denied or a service with the same name is running yet

addService

public void addService(org.jdom.Element config,
                       ITicket ticket)
                throws java.lang.SecurityException
Add dynamically a new service.
Specified by:
addService in interface IContext
Parameters:
service - The new service
serviceName - The service name under which the service should registered
ticket - The system user who must WRITE access to the factory
Throws:
java.lang.SecurityException - If access was denied or a service with the same name is running yet

removeService

public void removeService(java.lang.String serviceName,
                          ITicket ticket)
                   throws java.lang.SecurityException,
                          ServiceNotFoundException
Add dynamically a new service.
Specified by:
removeService in interface IContext
Parameters:
serviceName - The service name under which the service should registered
ticket - The system user who must WRITE access to the factory
Throws:
java.lang.SecurityException - If access was denied or a service with the same name is running yet
ServiceNotFoundException - If the service could not be found

getName

public java.lang.String getName()
Returns the context's name
Specified by:
getName in interface IContext
Returns:
The name

getService

public IService getService(java.lang.String serviceName,
                           ITicket ticket)
                    throws java.lang.SecurityException
Return the service with the given name
Specified by:
getService in interface IContext
Parameters:
serviceName - The name of the service to return
The - user ticket
Returns:
The service instance of the requested service
Throws:
ServiceNotFoundException - If the service could not be located
java.lang.SecurityException - If access was denied.

getStatus

public int getStatus()
Returns the current status of the context
Specified by:
getStatus in interface IContext

start

public void start(ITicket ticket)
           throws java.lang.SecurityException,
                  ServiceRuntimeException,
                  ServiceInitializationException
Specified by:
start in interface IContext

stop

public void stop(ITicket ticket)
          throws java.lang.SecurityException,
                 ServiceRuntimeException
Specified by:
stop in interface IContext

checkAccess

public void checkAccess(java.lang.String op,
                        int level,
                        ITicket ticket)
                 throws java.lang.SecurityException
Description copied from interface: IContext
Direct access to the security service for right authorization.
Specified by:
checkAccess in interface IContext
Following copied from interface: org.jwarp.service.IContext
Parameters:
object - The object
level - The access level
ticket - The user to access the object

getLog

public ILogWriter getLog()
Description copied from interface: IContext
Returns the context's default log writer object. Use this object for writing down any general exceptions and messages.
Specified by:
getLog in interface IContext
Following copied from interface: org.jwarp.service.IContext
Returns:
The log

connectService

public IService connectService(org.jdom.Element tree,
                               ITicket ticket)
                        throws java.lang.SecurityException
This method is used for reusal of the service intitialization and reference code. Service that parse their configuration can call this method for accessing an existing service (reference) or creating one.
Specified by:
connectService in interface IContext
Parameters:
tree - The service or reference jdom tree
ticket - The system ticket

makeLog

public ILogWriter makeLog(org.jdom.Element tree,
                          ITicket ticket)
                   throws java.lang.SecurityException,
                          ConfigurationException
This method is used for reusal of the log intitialization and reference code. Service that parse their configuration can call this method for accessing an existing log (reference) or creating a new one.
Specified by:
makeLog in interface IContext
Parameters:
tree - The log or reference jdom tree
logName - The name of the log
ticket - The system ticket

©   O R C A   S y s t e m s