org.objectweb.jonas.server
Class J2EEServer

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject
              extended by org.objectweb.jonas.server.J2EEServer
All Implemented Interfaces:
java.util.EventListener, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.management.NotificationListener, ReconfigDispatcherMBean, TimerEventListener

public class J2EEServer
extends J2EEManagedObject
implements TimerEventListener, javax.management.NotificationListener

MBean class for Server management. Two classes are used to provide all management services : J2EEServer and J2EEServerMBean. This class provide the notification's process when add or remove resources.

Author:
Guillaume Riviere, Michel Bruno
contributors Adriana Danes, Michel-Ange Anton

Field Summary
 
Fields inherited from class org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject
J2EE_TYPE_APPLICATION, J2EE_TYPE_SERVER, NAME
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
J2EEServer(java.lang.String objectName, Server server, java.lang.String serverName, java.lang.String serverVersion, java.lang.String serverVendor, java.lang.String protocols, java.lang.String versions)
          MBean constructor
 
Method Summary
 void addDeployedObject(java.lang.String objectName)
          Add an object name to the deployedObjects list.
 void addJavaVM(java.lang.String objectName)
          Add an object name to the javaVMs list.
 void addNotificationListener(javax.management.NotificationListener listner, javax.management.NotificationFilter filter, java.lang.Object handback)
          Add a new listener.
 void addResource(java.lang.String pObjectName)
          Add an object name to the resources list.
 java.lang.String deployEar(java.lang.String fileName)
          Deploy a J2EE application packaged in a EAR file
 java.lang.String deployJar(java.lang.String fileName)
          Deploy a stand-alone J2EE module packaged in a JAR file
 java.lang.String deployRar(java.lang.String fileName)
          Deploy a J2EE application packaged in a RAR file
 void deployWar(java.lang.String fileName)
          Deploy a stand-alone J2EE module packaged in a WAR file
 long getCurrentTotalMemory()
          get jvm total memory
 long getCurrentUsedMemory()
          get jvm used memory
 java.util.List getDeployedObjects()
          Return the list of MBean names corresponding to the deployed J2EEModules and J2EEApplications
 java.util.List getJavaVMs()
          Return the list of MBean names corresponding to the JVMs on which this server has running threads
 java.lang.String getJonasBase()
           
 java.lang.String getProtocols()
          Protocols supported by this Server
 int getRange()
          get range
 java.util.List getResources()
          Return the list of MBean names corresponding to the resources available on this server
 java.lang.String getServerName()
          Server name
 java.lang.String getServerVendor()
          Server vendor
 java.lang.String getServerVersion()
          Server version
 int getSizeTableMeasures()
          Get the size of the table of measures
 java.lang.Long[] getTableMeasures()
          get the table of value
 java.lang.String getVersions()
           
 void handleNotification(javax.management.Notification notification, java.lang.Object handback)
          Treat the notifications emitted by the JMX server.
 boolean isActivated()
          get monitoring activation
 java.lang.Boolean isEarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 java.lang.Boolean isJarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 java.lang.Boolean isRarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 java.lang.Boolean isWarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 void removeDeployedObject(java.lang.String objectName)
          Remove an object name to the deployedObjects list.
 java.lang.String removeResource(java.lang.String pObjectName)
          Remove an object name from the resources list.
 void runGC()
          run the garbage collector
 void sendNotification(javax.management.Notification notification)
          Send a notification to the listener.
 void setActivated(boolean pActivated)
          set monitoring activation
 void setJonasBase(java.lang.String jonasBase)
           
 void setRange(int range)
          set range
 void setSizeTableMeasures(int sizeMeasuresTable)
          Set the size of the table of measures
 void stop()
          Stop server (with stopping the JVM)
 void timeoutExpired(java.lang.Object arg)
          The measures timeout has expired Do not synchronize this method to avoid deadlocks!
 void unDeployEar(java.lang.String fileName)
          undeploy a J2EE application packaged in a EAR file
 void unDeployJar(java.lang.String fileName)
          Uneploy a stand-alone J2EE module packaged in a JAR file
 void unDeployRar(java.lang.String fileName)
          undeploy a J2EE application packaged in a RAR file
 void unDeployWar(java.lang.String fileName)
          Uneploy a stand-alone J2EE module packaged in a WAR file
 
Methods inherited from class org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject
getObjectName, isEventProvider, isStateManageable, isStatisticsProvider
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

J2EEServer

public J2EEServer(java.lang.String objectName,
                  Server server,
                  java.lang.String serverName,
                  java.lang.String serverVersion,
                  java.lang.String serverVendor,
                  java.lang.String protocols,
                  java.lang.String versions)
MBean constructor

Parameters:
objectName - object name of the managed object
server - Server object
serverName - server name
serverVersion - JOnAS version
serverVendor - is JOnAS
protocols - protocols supported
Method Detail

getServerName

public java.lang.String getServerName()
Server name

Returns:
String JOnAS server name

getServerVersion

public java.lang.String getServerVersion()
Server version

Returns:
String JOnAS server version

getServerVendor

public java.lang.String getServerVendor()
Server vendor

Returns:
String JOnAS server version

getDeployedObjects

public java.util.List getDeployedObjects()
Return the list of MBean names corresponding to the deployed J2EEModules and J2EEApplications

Returns:
java.util.ArrayList list of the deployed objects' MBean names

addDeployedObject

public void addDeployedObject(java.lang.String objectName)
Add an object name to the deployedObjects list.

Parameters:
objectName - Object name corresponding to a J2EEDeployedObject MBean

removeDeployedObject

public void removeDeployedObject(java.lang.String objectName)
Remove an object name to the deployedObjects list.

Parameters:
objectName - Object name corresponding to a J2EEDeployedObject MBean

getResources

public java.util.List getResources()
Return the list of MBean names corresponding to the resources available on this server

Returns:
java.util.ArrayList list of the resources' MBean names

getJavaVMs

public java.util.List getJavaVMs()
Return the list of MBean names corresponding to the JVMs on which this server has running threads

Returns:
java.util.ArrayList list of the JVMs' MBean names

addJavaVM

public void addJavaVM(java.lang.String objectName)
Add an object name to the javaVMs list.

Parameters:
objectName - Object name correspondig to a JVM MBean

getProtocols

public java.lang.String getProtocols()
Protocols supported by this Server

Returns:
String protocols supported

stop

public void stop()
          throws java.lang.Exception
Stop server (with stopping the JVM)

Throws:
java.lang.Exception

runGC

public void runGC()
run the garbage collector


getCurrentUsedMemory

public long getCurrentUsedMemory()
get jvm used memory

Returns:
Long - current used memory

getCurrentTotalMemory

public long getCurrentTotalMemory()
get jvm total memory

Returns:
Long - current total memory

setRange

public void setRange(int range)
set range

Parameters:
range - range for free memory measurement

getRange

public int getRange()
get range

Returns:
Integer - range

setSizeTableMeasures

public void setSizeTableMeasures(int sizeMeasuresTable)
Set the size of the table of measures

Parameters:
sizeMeasuresTable - Number of measures

getSizeTableMeasures

public int getSizeTableMeasures()
Get the size of the table of measures

Returns:
Number of measures

getTableMeasures

public java.lang.Long[] getTableMeasures()
get the table of value

Returns:
Long[] measures table

timeoutExpired

public void timeoutExpired(java.lang.Object arg)
The measures timeout has expired Do not synchronize this method to avoid deadlocks!

Specified by:
timeoutExpired in interface TimerEventListener
Parameters:
arg - Object

setActivated

public void setActivated(boolean pActivated)
set monitoring activation

Parameters:
pActivated - true is activated

isActivated

public boolean isActivated()
get monitoring activation

Returns:
Boolean is activated

deployJar

public java.lang.String deployJar(java.lang.String fileName)
                           throws java.lang.Exception
Deploy a stand-alone J2EE module packaged in a JAR file

Parameters:
fileName - the file name of the JAR to be be deployed.
Returns:
The ObjectName of the MBean associated to the deployed module
Throws:
java.lang.Exception - Management operation could not be executed or failed

isJarDeployed

public java.lang.Boolean isJarDeployed(java.lang.String fileName)
                                throws java.lang.Exception
Test if the specified filename is already deployed or not.

Parameters:
fileName - the name of the jar file.
Returns:
true if the jar is deployed, otherwise false.
Throws:
java.lang.Exception - Management operation could not be executed

unDeployJar

public void unDeployJar(java.lang.String fileName)
                 throws java.lang.Exception
Uneploy a stand-alone J2EE module packaged in a JAR file

Parameters:
fileName - the file name of the JAR to be be undeployed.
Throws:
java.lang.Exception - Management operation could not be executed or failed

isWarDeployed

public java.lang.Boolean isWarDeployed(java.lang.String fileName)
                                throws java.lang.Exception
Test if the specified filename is already deployed or not.

Parameters:
fileName - the name of the war file.
Returns:
true if the war is deployed, otherwise false.
Throws:
java.lang.Exception - Management operation could not be executed

deployWar

public void deployWar(java.lang.String fileName)
               throws java.lang.Exception
Deploy a stand-alone J2EE module packaged in a WAR file

Parameters:
fileName - the file name of the WAR to be be deployed.
Throws:
java.lang.Exception - Management operation could not be executed or failed

unDeployWar

public void unDeployWar(java.lang.String fileName)
                 throws java.lang.Exception
Uneploy a stand-alone J2EE module packaged in a WAR file

Parameters:
fileName - the file name of the WAR to be be undeployed.
Throws:
java.lang.Exception - Management operation could not be executed or failed

deployEar

public java.lang.String deployEar(java.lang.String fileName)
                           throws java.lang.Exception
Deploy a J2EE application packaged in a EAR file

Parameters:
fileName - the file name of the EAR to be be deployed.
Returns:
The ObjectName of the MBean associated to the deployed J2EE Application
Throws:
java.lang.Exception - Management operation could not be executed or failed

isEarDeployed

public java.lang.Boolean isEarDeployed(java.lang.String fileName)
                                throws java.lang.Exception
Test if the specified filename is already deployed or not. This method is defined in the EarService interface.

Parameters:
fileName - the name of the ear file.
Returns:
true if the ear is deployed, else false.
Throws:
java.lang.Exception - Management operation could not be executed or failed

unDeployEar

public void unDeployEar(java.lang.String fileName)
                 throws java.lang.Exception
undeploy a J2EE application packaged in a EAR file

Parameters:
fileName - the file name of the EAR to be be undeployed.
Throws:
java.lang.Exception - Management operation could not be executed or failed

deployRar

public java.lang.String deployRar(java.lang.String fileName)
                           throws java.lang.Exception
Deploy a J2EE application packaged in a RAR file

Parameters:
fileName - the file name of the RAR to be be deployed.
Returns:
The ObjectName of the MBean associated to the deployed J2EE Application
Throws:
java.lang.Exception - Management operation could not be executed or failed

isRarDeployed

public java.lang.Boolean isRarDeployed(java.lang.String fileName)
                                throws java.lang.Exception
Test if the specified filename is already deployed or not.

Parameters:
fileName - the name of the rar file.
Returns:
true if the rar is deployed, else false.
Throws:
java.lang.Exception - Management operation could not be executed or failed

unDeployRar

public void unDeployRar(java.lang.String fileName)
                 throws java.lang.Exception
undeploy a J2EE application packaged in a RAR file

Parameters:
fileName - the file name of the RAR to be be undeployed.
Throws:
java.lang.Exception - Management operation could not be executed or failed

addResource

public void addResource(java.lang.String pObjectName)
Add an object name to the resources list.

Parameters:
pObjectName - Object name correspondig to a J2EEResource MBean

removeResource

public java.lang.String removeResource(java.lang.String pObjectName)
Remove an object name from the resources list.

Parameters:
pObjectName - Object name correspondig to a J2EEResource MBean
Returns:
Object name to the removed J2EEResource MBean

sendNotification

public void sendNotification(javax.management.Notification notification)
Send a notification to the listener.

Overrides:
sendNotification in class javax.management.NotificationBroadcasterSupport
Parameters:
notification - The notification to send

addNotificationListener

public void addNotificationListener(javax.management.NotificationListener listner,
                                    javax.management.NotificationFilter filter,
                                    java.lang.Object handback)
                             throws java.lang.IllegalArgumentException
Add a new listener.

Specified by:
addNotificationListener in interface javax.management.NotificationBroadcaster
Overrides:
addNotificationListener in class ReconfigDispatcher
Parameters:
listner - Listener to notify
filter - Notification filter
handback - ??
Throws:
java.lang.IllegalArgumentException

handleNotification

public void handleNotification(javax.management.Notification notification,
                               java.lang.Object handback)
Treat the notifications emitted by the JMX server. This method determines the type of the notification and calls the specific treatement.

Specified by:
handleNotification in interface javax.management.NotificationListener
Parameters:
notification - received notification
handback - received handback object

getVersions

public java.lang.String getVersions()
Returns:
Returns the versions.

getJonasBase

public java.lang.String getJonasBase()

setJonasBase

public void setJonasBase(java.lang.String jonasBase)