org.ow2.jonas.lib.jmbeans
Class J2EEServer

java.lang.Object
  extended by org.ow2.jonas.lib.management.javaee.ManagedObject
      extended by org.ow2.jonas.lib.management.javaee.J2EEManagedObject
          extended by org.ow2.jonas.lib.jmbeans.J2EEServer
All Implemented Interfaces:
EventListener, MBeanRegistration, NotificationListener, J2EEServerService

public class J2EEServer
extends J2EEManagedObject
implements J2EEServerService, NotificationListener, MBeanRegistration

The JSR77 J2EEServer MBean implementation. Implement the StateManagement and Events specified in the JSR77.

Author:
Adriana.Danes@bull.net, Francois Fornaciari

Field Summary
static String DEPL_EXTENSION
          file extension containing a deployment plan
 
Fields inherited from class org.ow2.jonas.lib.management.javaee.J2EEManagedObject
J2EE_TYPE_APPLICATION, J2EE_TYPE_SERVER, NAME
 
Constructor Summary
J2EEServer()
          MBean constructor.
 
Method Summary
 void addJavaVM(String objectName)
          Add an object name to the javaVMs list.
 void bindVersioningService(VersioningService versioningService)
           
 void deploy(String fileName)
          Deploy a file to a local deployer.
 String distribute(String fileName, byte[] fileContent)
          Dump the given bytes to a local file and then return the path to this file.
 Properties getConfigFileEnv()
           
 long getCurrentTotalMemory()
           
 long getCurrentUsedMemory()
           
protected  org.ow2.util.ee.deploy.api.deployable.IDeployable getDeployable(String fileName)
          Convert a ready to deploy file to a deployable object.
 ArrayList<String> getDeployableEars()
           
 ArrayList<String> getDeployableFiles()
           
 ArrayList<String> getDeployableJars()
           
 ArrayList<String> getDeployableRars()
           
 ArrayList<String> getDeployableWars()
           
 ArrayList<String> getDeployedEars()
           
 ArrayList<String> getDeployedFiles()
           
 ArrayList<String> getDeployedJars()
           
 List<String> getDeployedObjects()
           
 ArrayList<String> getDeployedRars()
           
 ArrayList<String> getDeployedWars()
           
 String getDomainName()
           
 String[] getEventTypes()
           
 String[] getJavaVMs()
           
 String getJonasBase()
           
 String getJonasRoot()
           
 String getJvmInfos()
           
 String getProtocols()
           
 int getRange()
           
 List<String> getResources()
           
 String getServerName()
           
 String getServerVendor()
           
 String getServerVersion()
           
 String getServiceDescription(String service)
          Get a service description.
 List<String> getServices()
          Return the all the services names, whatever their state is.
 String getServiceState(String service)
          Get a service state.
 int getSizeTableMeasures()
           
 long getStartTime()
           
 J2EEServerState getState()
           
 Long[] getTableMeasures()
           
 String getThreadStackDump()
          Return a JVM thread stack dump.
 TabularData getThreadStackDumpList()
          Return a TabularData containing a JVM thread stack dump.
 TimerManager getTimerManager()
           
 String getUploadDirectory()
          Get the directory in which J2EEServer uploads files
 String getVersions()
           
 void halt()
          Halt the server.
 void handleNotification(Notification notification, Object handback)
          Treat JMX notifications.
 boolean isActivated()
           
 boolean isDeployed(String fileName)
           
 boolean isFailed()
          Is the server FAILED.
 boolean isRunning()
          Is the server RUNNING.
 boolean isStarting()
          Is the server STARTING.
 boolean isStopped()
          Is the server STOPPED.
 boolean isStopping()
          Is the server STOPPING.
 void logThreadStackDump()
          Log a JVM thread stack dump in JOnAS log file (level : info).
 void postDeregister()
           
 void postRegister(Boolean registrationDone)
          After registering, add myself as listener to notifications emitted by: - the MBeanServerDelegate (to receive JMX registration/un-registration notifications).
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void printThreadStackDump(String filename)
          Print a JVM thread stack dump in a given file.
 boolean removeModuleFile(String fileName)
          Remove a specified J2EE module
 void runGC()
           
 String sendFile(byte[] fileContent, String fileName, boolean replaceExisting)
           
 void setActivated(boolean activated)
          Set memory monitoring activation.
 void setArchiveManager(org.ow2.util.archive.api.IArchiveManager archiveManager)
           
 void setConfigManager(ConfigurationManager configManager)
           
 void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
           
 void setEasyBeansService(IEasyBeansService easyBeansService)
           
 void setFailed()
          Set the server state to FAILED and perform a notification.
 void setRange(int range)
           
 void setRegistryService(RegistryService registryService)
           
 void setRepositoryManager(org.ow2.util.plan.repository.api.IRepositoryManager repositoryManager)
          Set the repository manager used by this service.
 void setRunning()
          Set the server state to RUNNING and perform a notification.
 void setServerProperties(ServerProperties serverProperties)
           
 void setServiceManager(ServiceManager serviceManager)
           
 void setSizeTableMeasures(int sizeTableMeasures)
           
 void setStarting()
          Set the server state to STARTING and perform a notification.
 void setStopped()
          Set the server state to STOPPED and perform a notification.
 void setStopping()
          Set the server state to STOPPING and perform a notification.
 void setTimerManager(TimerManager timerManager)
           
 void start()
          Start the server by starting all the non-mandatory services.
 void start(boolean standby)
          Start the server by starting all the non-mandatory services.
 void startJ2EEServer()
           
 void startRecursive(boolean standby)
          Start recursive.
 void startService(String service)
          Start a service.
 void stop()
          Stop the server by stopping all the non-mandatory services.
 void stopService(String service)
          Stop a service.
 void unbindVersioningService()
          Sets the versioning service to null.
 void undeploy(String fileName)
          Undeploy a file from a local deployer.
 
Methods inherited from class org.ow2.jonas.lib.management.javaee.J2EEManagedObject
getObjectName, isEventProvider, isStateManageable, isStatisticsProvider, setEventProvider, setObjectName, setStateManageable, setStatisticsProvider
 
Methods inherited from class org.ow2.jonas.lib.management.javaee.ManagedObject
sendNotification, sendReconfigNotification, sendSaveNotification, setModelMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPL_EXTENSION

public static final String DEPL_EXTENSION
file extension containing a deployment plan

See Also:
Constant Field Values
Constructor Detail

J2EEServer

public J2EEServer()
MBean constructor.

Method Detail

startJ2EEServer

public void startJ2EEServer()
                     throws Exception
Throws:
Exception

getEventTypes

public String[] getEventTypes()

getStartTime

public long getStartTime()

getServerVendor

public String getServerVendor()

getServerVersion

public String getServerVersion()

getServerName

public String getServerName()

getJonasBase

public String getJonasBase()
Returns:
jonas.base

getJonasRoot

public String getJonasRoot()
Returns:
jonas.root

getProtocols

public String getProtocols()

getVersions

public String getVersions()

isActivated

public boolean isActivated()

setActivated

public void setActivated(boolean activated)
Set memory monitoring activation.

Parameters:
activated -

getCurrentUsedMemory

public long getCurrentUsedMemory()

getCurrentTotalMemory

public long getCurrentTotalMemory()

getRange

public int getRange()

setRange

public void setRange(int range)

getSizeTableMeasures

public int getSizeTableMeasures()

setSizeTableMeasures

public void setSizeTableMeasures(int sizeTableMeasures)

getTableMeasures

public Long[] getTableMeasures()

getResources

public List<String> getResources()
Returns:
The resources list.

getDeployedObjects

public List<String> getDeployedObjects()
Returns:
The deployed list.

getDomainName

public String getDomainName()
Returns:
The current domain name.

getJavaVMs

public String[] getJavaVMs()
Returns:
the list of MBean names corresponding to the JVMs on which this server has running threads

addJavaVM

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

Parameters:
objectName - Object name corresponding to a JVM MBean

bindVersioningService

public void bindVersioningService(VersioningService versioningService)
Parameters:
versioningService - The versioning service to set.

unbindVersioningService

public void unbindVersioningService()
Sets the versioning service to null.


start

public void start()
           throws Exception
Start the server by starting all the non-mandatory services.

Throws:
Exception

start

public void start(boolean standby)
           throws Exception
Start the server by starting all the non-mandatory services.

Parameters:
standby - true to activate standby mode.
Throws:
Exception - any.

startRecursive

public void startRecursive(boolean standby)
                    throws Exception
Start recursive. Check if standby mode is enabled.

Parameters:
standby - true to activate standby mode.
Throws:
Exception - any.

stop

public void stop()
          throws Exception
Stop the server by stopping all the non-mandatory services.

Throws:
Exception

halt

public void halt()
          throws Exception
Halt the server.

Throws:
Exception

handleNotification

public void handleNotification(Notification notification,
                               Object handback)
Treat JMX notifications.

Specified by:
handleNotification in interface NotificationListener
Parameters:
notification - received notification
handback - hand back object

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

postRegister

public void postRegister(Boolean registrationDone)
After registering, add myself as listener to notifications emitted by: - the MBeanServerDelegate (to receive JMX registration/un-registration notifications).

Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

setStarting

public void setStarting()
Description copied from interface: J2EEServerService
Set the server state to STARTING and perform a notification.

Specified by:
setStarting in interface J2EEServerService

setRunning

public void setRunning()
Description copied from interface: J2EEServerService
Set the server state to RUNNING and perform a notification.

Specified by:
setRunning in interface J2EEServerService

setStopping

public void setStopping()
Description copied from interface: J2EEServerService
Set the server state to STOPPING and perform a notification.

Specified by:
setStopping in interface J2EEServerService

setStopped

public void setStopped()
Description copied from interface: J2EEServerService
Set the server state to STOPPED and perform a notification.

Specified by:
setStopped in interface J2EEServerService

setFailed

public void setFailed()
Description copied from interface: J2EEServerService
Set the server state to FAILED and perform a notification.

Specified by:
setFailed in interface J2EEServerService

getState

public J2EEServerState getState()

isStarting

public boolean isStarting()
Description copied from interface: J2EEServerService
Is the server STARTING.

Specified by:
isStarting in interface J2EEServerService

isRunning

public boolean isRunning()
Description copied from interface: J2EEServerService
Is the server RUNNING.

Specified by:
isRunning in interface J2EEServerService

isFailed

public boolean isFailed()
Description copied from interface: J2EEServerService
Is the server FAILED.

Specified by:
isFailed in interface J2EEServerService

isStopping

public boolean isStopping()
Description copied from interface: J2EEServerService
Is the server STOPPING.

Specified by:
isStopping in interface J2EEServerService

isStopped

public boolean isStopped()
Description copied from interface: J2EEServerService
Is the server STOPPED.

Specified by:
isStopped in interface J2EEServerService

setDeployerManager

public void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
Parameters:
deployerManager - reference to the deployerManager

setRepositoryManager

public void setRepositoryManager(org.ow2.util.plan.repository.api.IRepositoryManager repositoryManager)
Set the repository manager used by this service.

Parameters:
repositoryManager - the new repository manager.

setArchiveManager

public void setArchiveManager(org.ow2.util.archive.api.IArchiveManager archiveManager)
Parameters:
archiveManager - reference to the archiveManager

setServiceManager

public void setServiceManager(ServiceManager serviceManager)
Parameters:
serviceManager - reference to the serviceManager

deploy

public void deploy(String fileName)
Deploy a file to a local deployer.

Parameters:
fileName - the name of the file to deploy

undeploy

public void undeploy(String fileName)
Undeploy a file from a local deployer.

Parameters:
fileName - the name of the file to undeploy

getDeployable

protected org.ow2.util.ee.deploy.api.deployable.IDeployable getDeployable(String fileName)
Convert a ready to deploy file to a deployable object.

Parameters:
fileName - the name of the file
Returns:
the deployable object

isDeployed

public boolean isDeployed(String fileName)
                   throws Exception
Throws:
Exception

getJvmInfos

public String getJvmInfos()

runGC

public void runGC()
           throws RemoteException
Throws:
RemoteException

getConfigFileEnv

public Properties getConfigFileEnv()

setConfigManager

public void setConfigManager(ConfigurationManager configManager)

getTimerManager

public TimerManager getTimerManager()

setTimerManager

public void setTimerManager(TimerManager timerManager)

setServerProperties

public void setServerProperties(ServerProperties serverProperties)

setRegistryService

public void setRegistryService(RegistryService registryService)

setEasyBeansService

public void setEasyBeansService(IEasyBeansService easyBeansService)

getDeployableFiles

public ArrayList<String> getDeployableFiles()

getDeployableJars

public ArrayList<String> getDeployableJars()

getDeployableEars

public ArrayList<String> getDeployableEars()

getDeployableWars

public ArrayList<String> getDeployableWars()

getDeployableRars

public ArrayList<String> getDeployableRars()

getDeployedWars

public ArrayList<String> getDeployedWars()
                                  throws Exception
Returns:
List of deployed WAR files.
Throws:
NullPointerException
MalformedObjectNameException
ReflectionException
MBeanException
InstanceNotFoundException
AttributeNotFoundException
Exception

getDeployedJars

public ArrayList<String> getDeployedJars()
                                  throws Exception
Returns:
List of deployed JAR files.
Throws:
Exception

getDeployedRars

public ArrayList<String> getDeployedRars()
                                  throws Exception
Returns:
List of deployed RAR files.
Throws:
Exception

getDeployedEars

public ArrayList<String> getDeployedEars()
                                  throws Exception
Returns:
List of deployed EAR files.
Throws:
Exception

getDeployedFiles

public ArrayList<String> getDeployedFiles()
                                   throws Exception
Throws:
Exception

sendFile

public String sendFile(byte[] fileContent,
                       String fileName,
                       boolean replaceExisting)
                throws Exception
Throws:
Exception

distribute

public String distribute(String fileName,
                         byte[] fileContent)
                  throws Exception
Dump the given bytes to a local file and then return the path to this file.

Parameters:
fileName - the name of the file to distribute
fileContent - the content of the given file
Returns:
the path of the distributed file
Throws:
Exception

removeModuleFile

public boolean removeModuleFile(String fileName)
                         throws Exception
Remove a specified J2EE module

Parameters:
fileName - Name of file to remove
Returns:
true if file has been removed
Throws:
Exception - if remove fails

getUploadDirectory

public String getUploadDirectory()
Get the directory in which J2EEServer uploads files

Specified by:
getUploadDirectory in interface J2EEServerService
Returns:
directory in which J2EEServer uploads files

getServices

public List<String> getServices()
Return the all the services names, whatever their state is.

Returns:
list of services names.

getServiceDescription

public String getServiceDescription(String service)
Get a service description.

Parameters:
service - the service name.
Returns:
the service description

getServiceState

public String getServiceState(String service)
Get a service state.

Parameters:
service - the service name.
Returns:
the service state.

startService

public void startService(String service)
                  throws Exception
Start a service.

Parameters:
service - the service name.
Throws:
Exception - If the startup of the service fails

stopService

public void stopService(String service)
                 throws Exception
Stop a service.

Parameters:
service - the service name.
Throws:
Exception - If the stop of the service fails

getThreadStackDump

public String getThreadStackDump()
Return a JVM thread stack dump.

Returns:
A String containing the thread stack dump

printThreadStackDump

public void printThreadStackDump(String filename)
Print a JVM thread stack dump in a given file.

Parameters:
filename - the file name

logThreadStackDump

public void logThreadStackDump()
Log a JVM thread stack dump in JOnAS log file (level : info).


getThreadStackDumpList

public TabularData getThreadStackDumpList()
Return a TabularData containing a JVM thread stack dump.

Returns:
A TabularData containing the thread stack dump


Copyright © 2010 OW2 Consortium. All Rights Reserved.