org.objectweb.joram.client.jms.admin
Class JoramAdmin

java.lang.Object
  extended by org.objectweb.joram.client.jms.admin.JoramAdmin
All Implemented Interfaces:
JoramAdminMBean

public class JoramAdmin
extends java.lang.Object
implements JoramAdminMBean

JoramAdmin is the implementation of the interface JoramAdminMBean. It must only be used to allow administration through JMX.

See Also:
AdminModule, AdminWrapper

Field Summary
protected  java.lang.String JMXBaseName
           
static org.objectweb.util.monolog.api.Logger logger
           
 AdminWrapper wrapper
           
 
Constructor Summary
JoramAdmin(javax.jms.Connection cnx)
          Creates a MBean to administer Joram using the default basename for JMX registering (JoramAdmin(Connection, String)).
JoramAdmin(javax.jms.Connection cnx, java.lang.String base)
          Creates a MBean to administer Joram using the given basename for JMX registering.
 
Method Summary
 void addDomain(java.lang.String domain, int sid, int port)
          Adds a domain to the platform.
 void addDomain(java.lang.String domain, java.lang.String network, int sid, int port)
          Adds a domain to the platform using a specific network component.
 void addServer(int sid, java.lang.String host, java.lang.String domain, int port, java.lang.String server)
          Adds a server to the platform.
 void createQueue(int serverId, java.lang.String name)
          Creates or retrieves a queue destination on the underlying JORAM server, (re)binds the corresponding Queue instance.
 void createQueue(java.lang.String name)
          Creates or retrieves a queue destination on the underlying JORAM server, (re)binds the corresponding Queue instance.
 void createTopic(int serverId, java.lang.String name)
          Creates or retrieves a topic destination on the underlying JORAM server, (re)binds the corresponding Topic instance.
 void createTopic(java.lang.String name)
          Creates or retrieves a topic destination on the underlying JORAM server, (re)binds the corresponding Topic instance.
 void createUser(java.lang.String name, java.lang.String password)
          Creates or retrieves a user on the underlying JORAM server.
 void createUser(java.lang.String name, java.lang.String password, int serverId)
          Creates or retrieves a user on the given JORAM server.
 void createUser(java.lang.String name, java.lang.String password, int serverId, java.lang.String identityClass)
          Creates or retrieves a user on the underlying JORAM server.
 void createUser(java.lang.String name, java.lang.String password, java.lang.String identityClass)
          Creates or retrieves a user on the underlying JORAM server.
static JoramAdmin doCreate(AbstractConnectionFactory cf, java.lang.String name, java.lang.String password, java.lang.String identityClass)
          Opens a connection dedicated to administering with the Joram server which parameters are wrapped by a given ConnectionFactory.
 void executeXMLAdmin(java.lang.String path)
          This method execute the XML script file that the pathname is given in parameter.
 void executeXMLAdmin(java.lang.String cfgDir, java.lang.String cfgFileName)
          This method execute the XML script file that the location is given in parameter.
 void exit()
          Closes the administration connection and unregister the MBean.
 void exportRepositoryToFile(java.lang.String exportDir, java.lang.String exportFilename)
          Export the repository content to an XML file - only the destinations objects are retrieved in this version - xml script format of the admin objects (joramAdmin.xml) Be careful, currently this method use the static administration connection through the AdminModule Class.
 java.lang.String getConfiguration()
          Returns the current servers configuration (equivalent to the a3servers.xml file).
 java.lang.String getDefaultDMQId()
          Returns the unique identifier of the default dead message queue for the local server, null if not set.
 java.lang.String getDefaultDMQId(int serverId)
          Returns the unique identifier of the default dead message queue for the local server, null if not set.
 int getDefaultThreshold()
          Returns the default threshold value for the local server, -1 if not set.
 int getDefaultThreshold(int serverId)
          Returns the default threshold value for a given server, -1 if not set.
 void getDestinations()
          This method creates and registers MBeans for all the destinations on the local server.
 void getDestinations(int serverId)
          This method creates and registers MBeans for all the destinations of the selected server.
 java.lang.String[] getDomainNames(int serverId)
          Returns the list of the domain names that contains the specified server.
 int[] getServersIds()
          Returns the list of the platform's servers' identifiers.
 int[] getServersIds(java.lang.String domain)
          Returns the list of the servers' identifiers that belong to the specified domain
 long getTimeOutToAbortRequest()
          Gets the maximum time a command has to complete before it is canceled.
 void getUsers()
          This method creates and registers MBeans for all the users on the local server.
 void getUsers(int serverId)
          This method creates and registers MBeans for all the users of the selected server.
 AdminReply processAdmin(java.lang.String targetId, int command, java.util.Properties prop)
          The method send the admin JMS message on JORAM server (AdminTopic).
 void registerMBean(java.lang.String base)
           
 void removeDomain(java.lang.String domain)
          Removes a domain from the platform.
 void removeServer(int sid)
          Removes a server from the platform.
 void setDefaultDMQId(int serverId, java.lang.String dmqId)
          Sets a given dead message queue as the default DMQ for a given server (null for unsetting previous DMQ).
 void setDefaultDMQId(java.lang.String dmqId)
          Sets a given dead message queue as the default DMQ for the local server (null for unsetting previous DMQ).
 void setDefaultThreshold(int threshold)
          Sets a given value as the default threshold for the local server (-1 for unsetting previous value).
 void setDefaultThreshold(int serverId, int threshold)
          Sets a given value as the default threshold for a given server (-1 for unsetting previous value).
 void setTimeOutToAbortRequest(long timeOut)
          Specifies how much time a command has to complete before If the command does not complete within the specified time, it is canceled and an exception is generated.
 void stopServer()
          Stops the platform local server.
 void stopServer(int serverId)
          Stops a given server of the platform.
 void unregisterMBean()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static org.objectweb.util.monolog.api.Logger logger

wrapper

public AdminWrapper wrapper

JMXBaseName

protected transient java.lang.String JMXBaseName
Constructor Detail

JoramAdmin

public JoramAdmin(javax.jms.Connection cnx)
           throws java.net.ConnectException,
                  AdminException,
                  javax.jms.JMSException
Creates a MBean to administer Joram using the default basename for JMX registering (JoramAdmin(Connection, String)). Be careful, if the connection is not started this method will failed with a ConnectException.

Parameters:
cnx - A valid connection to the Joram server.
Throws:
javax.jms.JMSException - A problem occurs during initialization.
java.net.ConnectException
AdminException
See Also:
AdminWrapper.AdminWrapper(Connection)

JoramAdmin

public JoramAdmin(javax.jms.Connection cnx,
                  java.lang.String base)
           throws java.net.ConnectException,
                  AdminException,
                  javax.jms.JMSException
Creates a MBean to administer Joram using the given basename for JMX registering. Be careful, if the connection is not started this method will failed with a ConnectException.

Parameters:
cnx - A valid connection to the Joram server.
base - the basename for registering the MBean.
Throws:
javax.jms.JMSException - A problem occurs during initialization.
java.net.ConnectException
AdminException
See Also:
AdminWrapper.AdminWrapper(Connection)
Method Detail

exit

public void exit()
Closes the administration connection and unregister the MBean.

Specified by:
exit in interface JoramAdminMBean

setTimeOutToAbortRequest

public void setTimeOutToAbortRequest(long timeOut)
                              throws java.net.ConnectException
Specifies how much time a command has to complete before If the command does not complete within the specified time, it is canceled and an exception is generated.

Be careful, the value can be changed prior to the connection only using the AdminRequestor.REQUEST_TIMEOUT_PROP property.

Specified by:
setTimeOutToAbortRequest in interface JoramAdminMBean
Parameters:
timeOut - the maximum time before a command is canceled.
Throws:
java.net.ConnectException - if the connection is not established.

getTimeOutToAbortRequest

public long getTimeOutToAbortRequest()
                              throws java.net.ConnectException
Gets the maximum time a command has to complete before it is canceled.

Specified by:
getTimeOutToAbortRequest in interface JoramAdminMBean
Returns:
the maximum time before a command is canceled
Throws:
java.net.ConnectException - if the connection is not established.

stopServer

public void stopServer()
                throws java.net.ConnectException,
                       AdminException
Stops the platform local server.

Specified by:
stopServer in interface JoramAdminMBean
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.
See Also:
stopServer(int)

stopServer

public void stopServer(int serverId)
                throws java.net.ConnectException,
                       AdminException
Stops a given server of the platform.

The request fails if the target server does not belong to the platform.

Specified by:
stopServer in interface JoramAdminMBean
Parameters:
serverId - Identifier of the server to stop.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

addServer

public void addServer(int sid,
                      java.lang.String host,
                      java.lang.String domain,
                      int port,
                      java.lang.String server)
               throws java.net.ConnectException,
                      AdminException
Adds a server to the platform.

The server is configured without any service.

Specified by:
addServer in interface JoramAdminMBean
Parameters:
sid - Id of the added server
host - Address of the host where the added server is started
domain - Name of the domain where the server is added
port - Listening port of the server in the specified domain
server - Name of the added server
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

removeServer

public void removeServer(int sid)
                  throws java.net.ConnectException,
                         AdminException
Removes a server from the platform.

Specified by:
removeServer in interface JoramAdminMBean
Parameters:
sid - Id of the removed server
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

addDomain

public void addDomain(java.lang.String domain,
                      int sid,
                      int port)
               throws java.net.ConnectException,
                      AdminException
Adds a domain to the platform.

The domain will use the default network component "Simplenetwork".

Specified by:
addDomain in interface JoramAdminMBean
Parameters:
domain - Name of the added domain.
sid - Id of the router server that gives access to the added domain.
port - Listening port in the added domain of the router server.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

addDomain

public void addDomain(java.lang.String domain,
                      java.lang.String network,
                      int sid,
                      int port)
               throws java.net.ConnectException,
                      AdminException
Adds a domain to the platform using a specific network component.

Specified by:
addDomain in interface JoramAdminMBean
Parameters:
domain - Name of the added domain.
network - Classname of the network component to use.
sid - Id of the router server that gives access to the added domain.
port - Listening port in the added domain of the router server.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

removeDomain

public void removeDomain(java.lang.String domain)
                  throws java.net.ConnectException,
                         AdminException
Removes a domain from the platform.

Specified by:
removeDomain in interface JoramAdminMBean
Parameters:
domain - Name of the domain to remove
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

getConfiguration

public java.lang.String getConfiguration()
                                  throws java.net.ConnectException,
                                         AdminException
Returns the current servers configuration (equivalent to the a3servers.xml file).

Specified by:
getConfiguration in interface JoramAdminMBean
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

getServersIds

public int[] getServersIds()
                    throws java.net.ConnectException,
                           AdminException
Returns the list of the platform's servers' identifiers.

Specified by:
getServersIds in interface JoramAdminMBean
Returns:
An array containing the list of server's identifiers.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
getServersIds(String)

getServersIds

public int[] getServersIds(java.lang.String domain)
                    throws java.net.ConnectException,
                           AdminException
Returns the list of the servers' identifiers that belong to the specified domain

Specified by:
getServersIds in interface JoramAdminMBean
Parameters:
domain - Name of the domain.
Returns:
An array containing the list of server's identifiers of the specified domain.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.

getDomainNames

public java.lang.String[] getDomainNames(int serverId)
                                  throws java.net.ConnectException,
                                         AdminException
Returns the list of the domain names that contains the specified server.

Specified by:
getDomainNames in interface JoramAdminMBean
Parameters:
serverId - Unique identifier of the server.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.

getDefaultDMQId

public java.lang.String getDefaultDMQId()
                                 throws java.net.ConnectException,
                                        AdminException
Returns the unique identifier of the default dead message queue for the local server, null if not set.

Specified by:
getDefaultDMQId in interface JoramAdminMBean
Returns:
The unique identifier of the default dead message queue for the local server, null if not set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
getDefaultDMQId(int)

getDefaultDMQId

public java.lang.String getDefaultDMQId(int serverId)
                                 throws java.net.ConnectException,
                                        AdminException
Returns the unique identifier of the default dead message queue for the local server, null if not set.

The request fails if the target server does not belong to the platform.

Specified by:
getDefaultDMQId in interface JoramAdminMBean
Parameters:
serverId - Unique identifier of the server.
Returns:
The unique identifier of the default dead message queue for the local server, null if not set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

setDefaultDMQId

public void setDefaultDMQId(java.lang.String dmqId)
                     throws java.net.ConnectException,
                            AdminException
Sets a given dead message queue as the default DMQ for the local server (null for unsetting previous DMQ).

Specified by:
setDefaultDMQId in interface JoramAdminMBean
Parameters:
dmqId - The dmqId (AgentId) to be set as the default one.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
setDefaultDMQId(int, String)

setDefaultDMQId

public void setDefaultDMQId(int serverId,
                            java.lang.String dmqId)
                     throws java.net.ConnectException,
                            AdminException
Sets a given dead message queue as the default DMQ for a given server (null for unsetting previous DMQ).

The request fails if the target server does not belong to the platform.

Specified by:
setDefaultDMQId in interface JoramAdminMBean
Parameters:
serverId - The identifier of the server.
dmqId - The dmqId (AgentId) to be set as the default one.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

setDefaultThreshold

public void setDefaultThreshold(int threshold)
                         throws java.net.ConnectException,
                                AdminException
Sets a given value as the default threshold for the local server (-1 for unsetting previous value).

Specified by:
setDefaultThreshold in interface JoramAdminMBean
Parameters:
threshold - The threshold value to be set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
setDefaultThreshold(int, int)

setDefaultThreshold

public void setDefaultThreshold(int serverId,
                                int threshold)
                         throws java.net.ConnectException,
                                AdminException
Sets a given value as the default threshold for a given server (-1 for unsetting previous value).

The request fails if the target server does not belong to the platform.

Specified by:
setDefaultThreshold in interface JoramAdminMBean
Parameters:
serverId - The identifier of the server.
threshold - The threshold value to be set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

getDefaultThreshold

public int getDefaultThreshold()
                        throws java.net.ConnectException,
                               AdminException
Returns the default threshold value for the local server, -1 if not set.

Specified by:
getDefaultThreshold in interface JoramAdminMBean
Returns:
The default threshold value for the local server, -1 if not set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
getDefaultThreshold(int)

getDefaultThreshold

public int getDefaultThreshold(int serverId)
                        throws java.net.ConnectException,
                               AdminException
Returns the default threshold value for a given server, -1 if not set.

The request fails if the target server does not belong to the platform.

Specified by:
getDefaultThreshold in interface JoramAdminMBean
Returns:
The default threshold value for the local server, -1 if not set.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

getDestinations

public void getDestinations()
                     throws java.net.ConnectException,
                            AdminException
This method creates and registers MBeans for all the destinations on the local server.

Specified by:
getDestinations in interface JoramAdminMBean
Throws:
java.net.ConnectException - If the connection is closed or broken.
AdminException - Never thrown.
See Also:
getDestinations(int)

getDestinations

public void getDestinations(int serverId)
                     throws java.net.ConnectException,
                            AdminException
This method creates and registers MBeans for all the destinations of the selected server.

The request fails if the target server does not belong to the platform.

Specified by:
getDestinations in interface JoramAdminMBean
Throws:
java.net.ConnectException - If the connection is closed or broken.
AdminException - Never thrown.
See Also:
getDestinations()

createQueue

public void createQueue(java.lang.String name)
                 throws AdminException,
                        java.net.ConnectException
Creates or retrieves a queue destination on the underlying JORAM server, (re)binds the corresponding Queue instance.

Specified by:
createQueue in interface JoramAdminMBean
Parameters:
name - The name of the queue.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - if the connection is closed or broken
See Also:
createQueue(int, String)

createQueue

public void createQueue(int serverId,
                        java.lang.String name)
                 throws AdminException,
                        java.net.ConnectException
Creates or retrieves a queue destination on the underlying JORAM server, (re)binds the corresponding Queue instance.

Specified by:
createQueue in interface JoramAdminMBean
Parameters:
serverId - The identifier of the server where deploying the queue.
name - The name of the queue.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - if the connection is closed or broken

createTopic

public void createTopic(java.lang.String name)
                 throws AdminException,
                        java.net.ConnectException
Creates or retrieves a topic destination on the underlying JORAM server, (re)binds the corresponding Topic instance.

Specified by:
createTopic in interface JoramAdminMBean
Parameters:
name - The name of the topic.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - if the connection is closed or broken
See Also:
createTopic(int, String)

createTopic

public void createTopic(int serverId,
                        java.lang.String name)
                 throws AdminException,
                        java.net.ConnectException
Creates or retrieves a topic destination on the underlying JORAM server, (re)binds the corresponding Topic instance.

Specified by:
createTopic in interface JoramAdminMBean
Parameters:
serverId - The identifier of the server where deploying the topic.
name - The name of the topic.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - if the connection is closed or broken

getUsers

public void getUsers()
              throws java.net.ConnectException,
                     AdminException
This method creates and registers MBeans for all the users on the local server.

Specified by:
getUsers in interface JoramAdminMBean
Throws:
java.net.ConnectException - If the connection fails.
AdminException - Never thrown.
See Also:
getUsers(int)

getUsers

public void getUsers(int serverId)
              throws java.net.ConnectException,
                     AdminException
This method creates and registers MBeans for all the users of the selected server.

The request fails if the target server does not belong to the platform.

Specified by:
getUsers in interface JoramAdminMBean
Parameters:
serverId - Unique identifier of the given server.
Throws:
java.net.ConnectException - If the connection fails.
AdminException - If the request fails.

createUser

public void createUser(java.lang.String name,
                       java.lang.String password)
                throws AdminException,
                       java.net.ConnectException
Creates or retrieves a user on the underlying JORAM server.

Specified by:
createUser in interface JoramAdminMBean
Parameters:
name - The login name of the user.
password - The password of the user.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - If the connection fails.
See Also:
createUser(String, String, int, String)

createUser

public void createUser(java.lang.String name,
                       java.lang.String password,
                       java.lang.String identityClass)
                throws AdminException,
                       java.net.ConnectException
Creates or retrieves a user on the underlying JORAM server.

Specified by:
createUser in interface JoramAdminMBean
Parameters:
name - The login name of the user.
password - The password of the user.
identityClass - The identity class used for authentication.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - If the connection fails.
See Also:
createUser(String, String, int, String)

createUser

public void createUser(java.lang.String name,
                       java.lang.String password,
                       int serverId)
                throws AdminException,
                       java.net.ConnectException
Creates or retrieves a user on the given JORAM server.

Specified by:
createUser in interface JoramAdminMBean
Parameters:
name - The login name of the user.
password - The password of the user.
serverId - The unique identifier of the Joram server.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - If the connection fails.
See Also:
createUser(String, String, int, String)

createUser

public void createUser(java.lang.String name,
                       java.lang.String password,
                       int serverId,
                       java.lang.String identityClass)
                throws java.net.ConnectException,
                       AdminException
Creates or retrieves a user on the underlying JORAM server.

Specified by:
createUser in interface JoramAdminMBean
Parameters:
name - The login name of the user.
password - The password of the user.
serverId - The unique identifier of the Joram server.
identityClass - The identity class used for authentication.
Throws:
AdminException - If the creation fails.
java.net.ConnectException - If the connection fails.

registerMBean

public void registerMBean(java.lang.String base)

unregisterMBean

public void unregisterMBean()

doCreate

public static JoramAdmin doCreate(AbstractConnectionFactory cf,
                                  java.lang.String name,
                                  java.lang.String password,
                                  java.lang.String identityClass)
                           throws java.net.ConnectException,
                                  AdminException
Opens a connection dedicated to administering with the Joram server which parameters are wrapped by a given ConnectionFactory.

Parameters:
cf - The Joram's ConnectionFactory to use for connecting.
name - Administrator's name.
password - Administrator's password.
identityClass - identity class name.
Throws:
java.net.ConnectException - If connecting fails.
AdminException - If the administrator identification is incorrect.

executeXMLAdmin

public void executeXMLAdmin(java.lang.String cfgDir,
                            java.lang.String cfgFileName)
                     throws java.lang.Exception
This method execute the XML script file that the location is given in parameter.

Be careful, currently this method use the static administration connection through the AdminModule Class.

Specified by:
executeXMLAdmin in interface JoramAdminMBean
Parameters:
cfgDir - The directory containing the file.
cfgFileName - The script filename.
Throws:
java.lang.Exception

executeXMLAdmin

public void executeXMLAdmin(java.lang.String path)
                     throws java.lang.Exception
This method execute the XML script file that the pathname is given in parameter.

Be careful, currently this method use the static administration connection through the AdminModule Class.

Specified by:
executeXMLAdmin in interface JoramAdminMBean
Parameters:
path - The script pathname.
Throws:
java.lang.Exception

exportRepositoryToFile

public void exportRepositoryToFile(java.lang.String exportDir,
                                   java.lang.String exportFilename)
                            throws AdminException
Export the repository content to an XML file - only the destinations objects are retrieved in this version - xml script format of the admin objects (joramAdmin.xml)

Be careful, currently this method use the static administration connection through the AdminModule Class.

Specified by:
exportRepositoryToFile in interface JoramAdminMBean
Parameters:
exportDir - target directory where the export file will be put
exportFilename - filename of the export file
Throws:
AdminException - if an error occurs

processAdmin

public AdminReply processAdmin(java.lang.String targetId,
                               int command,
                               java.util.Properties prop)
                        throws java.net.ConnectException,
                               AdminException
The method send the admin JMS message on JORAM server (AdminTopic).

Specified by:
processAdmin in interface JoramAdminMBean
Parameters:
targetId - agent Id target.
command - the command to execute.
prop - the properties.
Returns:
the reply.
Throws:
AdminException
java.net.ConnectException - If the connection fails.


Copyright © 2011 ScalAgent D.T.. All Rights Reserved.