org.cafesip.jiplet
Class JipletContext

java.lang.Object
  extended by org.cafesip.jiplet.ScopedVariables
      extended by org.cafesip.jiplet.JipletContext
All Implemented Interfaces:
JipletContextMBean

public class JipletContext
extends ScopedVariables
implements JipletContextMBean

This class encapsulates the functions of a jiplet context. A context is a SIP application consisting of one or more jiplets, supporting classes and a descriptor (jip.xml). The jiplet container can host multiple contexts. Each context runs in its own "object space" and is completely isolated from other contexts. It is analogous to the web context in the servlet world. A context can be deployed as a single spr file or in exploded format. For more details,

See Also:
description.

The jiplet context also provides support for application-scope variables. Application scope variables remain active during the life-time of the context. Using the methods provided by the ScopedVariable class (that this class extends), jiplets can create, remove and retrieve application-scope variables.


Field Summary
static int CONTEXT_DEPLOYED
           
static int CONTEXT_J2EE
           
static int CONTEXT_UNKNOWN
           
 javax.management.ObjectName MBEAN_NAME
           
 
Constructor Summary
JipletContext(java.lang.String context, java.io.File contextRoot, int type, java.lang.ClassLoader loader)
          Constructor for this class.
 
Method Summary
protected  JipletSession addSession(SessionInfo session)
           
protected  Jiplet[] criteriaMatch(javax.sip.RequestEvent event)
           
 void destroy()
          This method is called by the container when the context is being removed.
 Jiplet findJiplet(java.lang.String name)
          Find a jiplet belonging to this context given its name.
protected  JipletSession findSession(SessionInfo session)
           
 java.lang.ClassLoader getClassLoader()
          This method returns the class loader for this context
 JipApplication getConfig()
           
 java.lang.String getContext()
           
 java.io.File getContextRoot()
           
 java.util.ArrayList getContextSelectionCriteria()
           
 int getContextType()
           
protected  java.lang.String getContextTypeDescription()
           
 java.lang.String getDisplayName()
           
 org.cafesip.jiplet.jmxbeans.JipletElement getJipletProperty(java.lang.String name)
          Returns the property of the jiplet specified by the name parameter.
 javax.management.MBeanServer getJmxAgent()
           
 java.lang.String getRealPath(java.lang.String path)
           
protected  org.cafesip.jiplet.cma.SecurityConstraintManager getSecurityManager()
           
protected  void init()
           
 java.lang.String[] listJiplets()
           
protected  void removeSession(SessionInfo session)
           
 boolean sendSignal(java.lang.String jiplet, JipletSignal signal)
          This method is used to send a signal to a jiplet.
 java.lang.String toString()
           
 
Methods inherited from class org.cafesip.jiplet.ScopedVariables
getAttribute, getAttributeNames, removeAttribute, setAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTEXT_UNKNOWN

public static final int CONTEXT_UNKNOWN
See Also:
Constant Field Values

CONTEXT_DEPLOYED

public static final int CONTEXT_DEPLOYED
See Also:
Constant Field Values

CONTEXT_J2EE

public static final int CONTEXT_J2EE
See Also:
Constant Field Values

MBEAN_NAME

public javax.management.ObjectName MBEAN_NAME
Constructor Detail

JipletContext

public JipletContext(java.lang.String context,
                     java.io.File contextRoot,
                     int type,
                     java.lang.ClassLoader loader)
              throws java.lang.Exception
Constructor for this class. The jiplet container instantiates this class when a new context is deployed.

Parameters:
context - name of the context
contextRoot - root directory for the context
type - whether it is a J2EE context (deployed by JBOSS) or a context deployed using the JMX interface. The deployment of J2EE context is managed by the J2EE server (JBOSS) whereas the contexts deployed by the JMX interface is fully managed by the container
loader - classloader for this context.
Throws:
java.lang.Exception
Method Detail

getRealPath

public java.lang.String getRealPath(java.lang.String path)

getContextRoot

public java.io.File getContextRoot()
Returns:
Returns the contextRoot.

getContext

public java.lang.String getContext()
Returns:
Returns the context name.

getDisplayName

public java.lang.String getDisplayName()
Returns:
the display name of the context.

init

protected void init()
             throws java.lang.Exception
Throws:
java.lang.Exception

getJmxAgent

public javax.management.MBeanServer getJmxAgent()
Returns:
the MBeanServer object.

getConfig

public JipApplication getConfig()
Returns:
Returns the context configuration in the form of a JipApplication object.

findSession

protected JipletSession findSession(SessionInfo session)

addSession

protected JipletSession addSession(SessionInfo session)

removeSession

protected void removeSession(SessionInfo session)

findJiplet

public Jiplet findJiplet(java.lang.String name)
Find a jiplet belonging to this context given its name.

Parameters:
name - name of the context
Returns:
The jiplet object, null if the jiplet with the given name was not found.

destroy

public void destroy()
This method is called by the container when the context is being removed.


getContextType

public int getContextType()
Returns:
Returns the contextType.

getContextTypeDescription

protected java.lang.String getContextTypeDescription()

listJiplets

public java.lang.String[] listJiplets()
Specified by:
listJiplets in interface JipletContextMBean
Returns:
names of the jiplets belonging to a context.
See Also:
JipletContextMBean.listJiplets()

getJipletProperty

public org.cafesip.jiplet.jmxbeans.JipletElement getJipletProperty(java.lang.String name)
Description copied from interface: JipletContextMBean
Returns the property of the jiplet specified by the name parameter.

Specified by:
getJipletProperty in interface JipletContextMBean
Parameters:
name - name of the jiplet
Returns:
the property of the jiplet encapsulated by the JipletElement object. A null value is returned if the jiplet is not found.
See Also:
JipletContextMBean.getJipletProperty(java.lang.String)

criteriaMatch

protected Jiplet[] criteriaMatch(javax.sip.RequestEvent event)

getContextSelectionCriteria

public java.util.ArrayList getContextSelectionCriteria()
Returns:
Returns the contextSelectionCriteria.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSecurityManager

protected org.cafesip.jiplet.cma.SecurityConstraintManager getSecurityManager()
Returns:
Returns the securityManager.

getClassLoader

public java.lang.ClassLoader getClassLoader()
This method returns the class loader for this context

Returns:

sendSignal

public boolean sendSignal(java.lang.String jiplet,
                          JipletSignal signal)
This method is used to send a signal to a jiplet. A signal is sent by an external entity to notify a jiplet of an external event. For more details, see the documentation for the class org.cafesip.jiplet.JipletSignal

Parameters:
jiplet - name of the jiplet
signal - event information
Returns:
true if the signal was delivered successfully, false otherwise.
See Also:
JipletSignal


http://www.cafesip.org