org.cafesip.jiplet
Class JipletContainer

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.cafesip.jiplet.JipletContainer
All Implemented Interfaces:
javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, JipletContainerMBean

public class JipletContainer
extends javax.management.NotificationBroadcasterSupport
implements JipletContainerMBean

This class represents the Jiplet Container. The jiplet container hosts multiple contexts. Each context is a separate application that has its own class loader and therefore completely isolated from each other. Each context may contain one or more jiplets. The container exposes a JMX management interface for managing the contexts. Using this interface, a context may be added or removed from the container. Alternatively, a container may be deployed by simply adding the content of the context to the deploy directory of the container and re-starting the jilet container application. Unlike most servlet container and J2EE server applications, the container does not periodically check its deploy directory to determine if a new context has been added.

The contexts may be deployed either in the "spr" format or in "exploded" format. The spr format consist of a single file that packs all the classes, data files and descriptors beloging to a context. The files are packed using the jar/zip utility. A custom ant task has been provided to zip the content of a context directory. A spr is equivalent to a "war" file in the servlet/JSP world. The jiplet container server application can either run as a Java standalone application similar to Apache Tomcat. But it can also be deployed as a JBOSS service (incidentally Tomcat can also be run as a JBOSS service). When running as a JBOSS service, it can be managed from the JBOSS management console and it also supports deployment of spr files using the JBOSS deployment infrastructure.


Field Summary
static javax.management.ObjectName MBEAN_NAME
           
 
Constructor Summary
JipletContainer()
          Constructor for the class.
 
Method Summary
 java.lang.String addContextMapping(java.lang.String context, java.lang.String mapping)
          This method adds a context mapping to the list of context mappings.
 java.lang.String createContext(java.lang.String path, java.lang.String overriddenName)
          Create a jiplet context.
 java.lang.String createJ2eeContext(java.lang.String path, java.lang.ClassLoader loader)
          Create a J2EE context.
 java.lang.String createJ2eeRealm(java.lang.String path, java.lang.ClassLoader loader)
          Create a J2EE realm.
 java.lang.String createRealm(java.lang.String path)
          Create a new realm.
 java.lang.String createRealmUser(java.lang.String name, java.lang.String user, java.lang.String password, java.lang.String[] roles)
          Create an user account for a given realm.
 java.lang.String deleteContext(java.lang.String name)
          Delete a context with a given name.
 java.lang.String deleteJ2eeContext(java.lang.String path)
          The JBOSS wrapper application uses this method to delete a context when it has been removed from the JBOSS deploy directory.
 java.lang.String deleteJ2eeRealm(java.lang.String path)
          The JBOSS wrapper application uses this method to delete a realm when it has been removed from the JBOSS deploy directory.
 java.lang.String deleteRealm(java.lang.String realmName)
          Delete an existing realm.
 java.lang.String deleteRealmUser(java.lang.String name, java.lang.String user)
          Delete an user account for a given realm
 void destroy()
          This method is called when the application disposes off the container.
 SipConnector findConnector(java.lang.String name)
          Returns a SipConnector object of a given connector name.
 Realm findRealm(java.lang.String name)
           
protected  long getAuthCachePeriod()
           
static java.io.File getConfDir()
           
 org.cafesip.jiplet.jmxbeans.ConnectorElement getConnectorProperty(java.lang.String connectorName)
          Returns the property of a connector.
 java.util.HashMap getConnectors()
          Returns a list of the connectors.
protected  java.util.ArrayList getContextMapping(java.lang.String context)
           
 org.cafesip.jiplet.jmxbeans.ContextElement getContextProperty(java.lang.String name)
          Return the property of a context specified by the name parameter.
 java.lang.String getDefaultConnectorName()
           
 java.lang.String getDefaultRealm()
           
 java.lang.String getDeployDir()
          return the deploy directory
static JipletContainer getInstance()
          The JipletContainer is a singleton class.
protected static javax.management.MBeanServer getJmxAgent()
          Returns the JMX MBeanServer object.
 java.lang.String getRealmDirName(java.lang.String realmName)
          Returns the realm deployment directory name.
 org.cafesip.jiplet.jmxbeans.RealmElement getRealmProperty(java.lang.String realmName)
          Returns the property of a realm.
protected  java.util.ArrayList getRealms()
           
 java.lang.String[] getRealmUser(java.lang.String name, java.lang.String user)
          Returns the user account information for a given realm.
static VendorDescriptorFactory getVendorDeploymentFactory()
           
 void init()
           
protected  boolean isAuthOnLogout()
           
 java.lang.String[] listConnectors()
          Return a list of deployed connectors.
 java.lang.String[] listContexts()
          Return a list of deployed contexts.
 java.lang.String[] listRealms()
          Returns a list of realms configured for the system.
 java.lang.String modifyRealmUser(java.lang.String name, java.lang.String user, java.lang.String password, java.lang.String[] roles)
          Modify an user account for a given realm.
 java.lang.String removeContextMapping(java.lang.String context)
          Removes the entry for the context from the context mapping.
static void setConfDir(java.io.File confDir)
           
static void setDeployDir(java.io.File dir)
          Sets the deploy directory.
static void setJmxAgent(javax.management.MBeanServer jmxAgent)
           
static void setVendorDeploymentFactory(VendorDescriptorFactory vendorDeploymentFactory)
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MBEAN_NAME

public static javax.management.ObjectName MBEAN_NAME
Constructor Detail

JipletContainer

public JipletContainer()
                throws JipletException
Constructor for the class.

Throws:
JipletException
Method Detail

init

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

getInstance

public static JipletContainer getInstance()
                                   throws java.lang.Exception
The JipletContainer is a singleton class. This static method is used to get the instance of the class. If the class has not already been instantiated, the class is instantiated inside this method and the reference is returned.

Returns:
Returns the instance.
Throws:
java.lang.Exception

setDeployDir

public static void setDeployDir(java.io.File dir)
Sets the deploy directory. By default, the deploy directory is located under the home directory of the container. However, an application instantiating this class can set a different directory.

Parameters:
dir -

getConnectors

public java.util.HashMap getConnectors()
Returns a list of the connectors. Each element of the returned HashMap object contains a key-value pair. The key is the connector name and the value is an object of type SipConnector.

Returns:
Returns the connectors.
See Also:
for more details.

getDefaultConnectorName

public java.lang.String getDefaultConnectorName()
Specified by:
getDefaultConnectorName in interface JipletContainerMBean
Returns:
Returns the defaultConnectorName.

findConnector

public SipConnector findConnector(java.lang.String name)
Returns a SipConnector object of a given connector name.

Parameters:
name - name of the connector
Returns:
a SipConnector object, null if the name does not match.

destroy

public void destroy()
This method is called when the application disposes off the container.


createContext

public java.lang.String createContext(java.lang.String path,
                                      java.lang.String overriddenName)
Description copied from interface: JipletContainerMBean
Create a jiplet context.

Specified by:
createContext in interface JipletContainerMBean
Parameters:
path - full path name of the directory where a spr file or an exploded directory resides.
overriddenName - this is an optional parameter. If a non-null string is provided, the context name is set to this parameter. If null value is specified, the context is named based on the exploded directory name or the spr file name (the .spr extension is stripped).
Returns:
an empty string if the context was created successfully, an error message, otherwise.

deleteContext

public java.lang.String deleteContext(java.lang.String name)
Description copied from interface: JipletContainerMBean
Delete a context with a given name.

Specified by:
deleteContext in interface JipletContainerMBean
Parameters:
name - name of the context.
Returns:
an empty string if the context was created successfully, an error message, otherwise.

listContexts

public java.lang.String[] listContexts()
Description copied from interface: JipletContainerMBean
Return a list of deployed contexts.

Specified by:
listContexts in interface JipletContainerMBean
Returns:

getJmxAgent

protected static javax.management.MBeanServer getJmxAgent()
Returns the JMX MBeanServer object. Jiplet applications can call this method to retrieve the MBeanServer object. This object can then be used to provide management interface for the jiplet application.

Returns:
Returns the jmxAgent.

setJmxAgent

public static void setJmxAgent(javax.management.MBeanServer jmxAgent)
Parameters:
jmxAgent - The jmxAgent to set.

getContextProperty

public org.cafesip.jiplet.jmxbeans.ContextElement getContextProperty(java.lang.String name)
Description copied from interface: JipletContainerMBean
Return the property of a context specified by the name parameter.

Specified by:
getContextProperty in interface JipletContainerMBean
Parameters:
name - name of the context.
Returns:
null if the context is not found. Otherwise, it returns an object of type ContextElement that contains information on the context. @see org.cafesip.jiplet.jmxbeans.ContextElement for details.

getDeployDir

public java.lang.String getDeployDir()
Description copied from interface: JipletContainerMBean
return the deploy directory

Specified by:
getDeployDir in interface JipletContainerMBean
Returns:

createJ2eeContext

public java.lang.String createJ2eeContext(java.lang.String path,
                                          java.lang.ClassLoader loader)
Create a J2EE context. The Jboss wrapper application for the jiplet container uses this method to register spr files deployed in the JBOSS deploy directory.

Parameters:
path - the path of the SPR file
loader - - the J2EE classloader
Returns:

deleteJ2eeContext

public java.lang.String deleteJ2eeContext(java.lang.String path)
The JBOSS wrapper application uses this method to delete a context when it has been removed from the JBOSS deploy directory.

Parameters:
path -
Returns:

getRealms

protected java.util.ArrayList getRealms()
Returns:
Returns the realms.

findRealm

public Realm findRealm(java.lang.String name)

getDefaultRealm

public java.lang.String getDefaultRealm()
Returns:
Returns the defaultRealm.

getAuthCachePeriod

protected long getAuthCachePeriod()
Returns:
Returns the authCachePeriod.

listRealms

public java.lang.String[] listRealms()
Description copied from interface: JipletContainerMBean
Returns a list of realms configured for the system.

Specified by:
listRealms in interface JipletContainerMBean
Returns:

createRealmUser

public java.lang.String createRealmUser(java.lang.String name,
                                        java.lang.String user,
                                        java.lang.String password,
                                        java.lang.String[] roles)
Description copied from interface: JipletContainerMBean
Create an user account for a given realm.

Specified by:
createRealmUser in interface JipletContainerMBean
Parameters:
name - realm name
user - user name
password - password
roles - roles authorized for this user.
Returns:
an empty string if the operation was successful, an error message otherwise

modifyRealmUser

public java.lang.String modifyRealmUser(java.lang.String name,
                                        java.lang.String user,
                                        java.lang.String password,
                                        java.lang.String[] roles)
Description copied from interface: JipletContainerMBean
Modify an user account for a given realm.

Specified by:
modifyRealmUser in interface JipletContainerMBean
Parameters:
name - realm name
user - user name
password - password. If null, the password is not modified
roles - roles authorized for this user. If null, the roles are not modified.
Returns:
an empty string if the operation was successful, an error message otherwise

deleteRealmUser

public java.lang.String deleteRealmUser(java.lang.String name,
                                        java.lang.String user)
Description copied from interface: JipletContainerMBean
Delete an user account for a given realm

Specified by:
deleteRealmUser in interface JipletContainerMBean
Parameters:
name - realm name
user - user name
Returns:
an empty string if the operation was successful, an error message otherwise

getRealmUser

public java.lang.String[] getRealmUser(java.lang.String name,
                                       java.lang.String user)
Description copied from interface: JipletContainerMBean
Returns the user account information for a given realm. A null is returned if the user is not found.

Specified by:
getRealmUser in interface JipletContainerMBean
Parameters:
name - realm name
user - user name

isAuthOnLogout

protected boolean isAuthOnLogout()

createJ2eeRealm

public java.lang.String createJ2eeRealm(java.lang.String path,
                                        java.lang.ClassLoader loader)
Create a J2EE realm. The Jboss wrapper application for the jiplet container uses this method to register srr files deployed in the JBOSS deploy directory.

Parameters:
path -
loader -
Returns:

deleteJ2eeRealm

public java.lang.String deleteJ2eeRealm(java.lang.String path)
The JBOSS wrapper application uses this method to delete a realm when it has been removed from the JBOSS deploy directory.

Parameters:
path -
Returns:

createRealm

public java.lang.String createRealm(java.lang.String path)
Description copied from interface: JipletContainerMBean
Create a new realm.

Specified by:
createRealm in interface JipletContainerMBean
Parameters:
path - path containing the exploded SRR entry or a SRR file.
Returns:
an empty string if the realm was created successfully, an error message otherwise.

deleteRealm

public java.lang.String deleteRealm(java.lang.String realmName)
Description copied from interface: JipletContainerMBean
Delete an existing realm.

Specified by:
deleteRealm in interface JipletContainerMBean
Parameters:
realmName - name of the realm
Returns:
an empty string if the realm was deleted successfully, an error message otherwise.

getRealmDirName

public java.lang.String getRealmDirName(java.lang.String realmName)
Description copied from interface: JipletContainerMBean
Returns the realm deployment directory name.

Specified by:
getRealmDirName in interface JipletContainerMBean
Returns:
the directory name for the realm. This method returns null if the realm is not found or if the realm is not a deplyed realm (was included in server.xml).

getRealmProperty

public org.cafesip.jiplet.jmxbeans.RealmElement getRealmProperty(java.lang.String realmName)
Description copied from interface: JipletContainerMBean
Returns the property of a realm.

Specified by:
getRealmProperty in interface JipletContainerMBean
Returns:
a RealmElement object, null if the realm was not found

getContextMapping

protected java.util.ArrayList getContextMapping(java.lang.String context)

addContextMapping

public java.lang.String addContextMapping(java.lang.String context,
                                          java.lang.String mapping)
Description copied from interface: JipletContainerMBean
This method adds a context mapping to the list of context mappings. The jiplet container uses this context mapping for the context(s) instead of the context mappings specified in the jip.xml.

Specified by:
addContextMapping in interface JipletContainerMBean
Parameters:
context - name of the context.
mapping - The mapping must be specified using the XML descriptor as described by $JIPLET_HOME/conf/context-mappings_x.y.xsd, where x.y is the current version of the descriptor file. For each context mapping, the context name and the connector name is mandatory.
Returns:
an empty string if the mapping was added successfully, an error message otherwise.

removeContextMapping

public java.lang.String removeContextMapping(java.lang.String context)
Description copied from interface: JipletContainerMBean
Removes the entry for the context from the context mapping.

Specified by:
removeContextMapping in interface JipletContainerMBean
Parameters:
context - name of the context.
Returns:
an empty string if the mapping was removed successfully, an error message otherwise.

listConnectors

public java.lang.String[] listConnectors()
Description copied from interface: JipletContainerMBean
Return a list of deployed connectors.

Specified by:
listConnectors in interface JipletContainerMBean
Returns:

getConnectorProperty

public org.cafesip.jiplet.jmxbeans.ConnectorElement getConnectorProperty(java.lang.String connectorName)
Description copied from interface: JipletContainerMBean
Returns the property of a connector.

Specified by:
getConnectorProperty in interface JipletContainerMBean
Returns:
a ConnectorElement object, null if the connector was not found

getConfDir

public static java.io.File getConfDir()
Returns:
Returns the confDir.

setConfDir

public static void setConfDir(java.io.File confDir)
Parameters:
confDir - The confDir to set.

getVendorDeploymentFactory

public static VendorDescriptorFactory getVendorDeploymentFactory()
Returns:
Returns the vendorDeploymentFactory.

setVendorDeploymentFactory

public static void setVendorDeploymentFactory(VendorDescriptorFactory vendorDeploymentFactory)
Parameters:
vendorDeploymentFactory - The vendorDeploymentFactory to set.


http://www.cafesip.org