org.ow2.jasmine.jadort.service.action
Class ServerAction

java.lang.Object
  extended by org.ow2.jasmine.jadort.service.action.AbstractAction
      extended by org.ow2.jasmine.jadort.service.action.AbstractJMXAction
          extended by org.ow2.jasmine.jadort.service.action.ServerAction
Direct Known Subclasses:
DummyServerAction, GlassFishServerAction, JBossServerAction, JonasServerAction, OSGiServerAction, WebLogicServerAction, WebSphereServerAction

public abstract class ServerAction
extends AbstractJMXAction

Action for a server (JOnAS or other)

Author:
Malek Chahine, Remy Bresson, S. Ali Tokmen

Field Summary
static String STATE_DEPLOYED
           
static String STATE_PRESENT
           
 
Fields inherited from class org.ow2.jasmine.jadort.service.action.AbstractJMXAction
connector, JMX_CHECK_TIMEOUT, JMX_CONNECT_TIMEOUT, mbscnx
 
Constructor Summary
ServerAction()
           
 
Method Summary
abstract  boolean canDeployApplications()
           
 boolean canDeployApplicationsOfType(ApplicationBean.ApplicationType applicationType)
           
abstract  boolean canStartStopServer()
           
abstract  void deploy(String appName)
           
abstract  boolean enableOrDisableApplications(boolean enable)
          Enable or disable or enable all applications in this server.
abstract  void erase(String appName)
           
abstract  int getActiveSessions()
           
abstract  int getActiveSessions(String appName)
           
abstract  ApplicationBean getApplicationBean(String appName)
           
protected static Constructor<? extends ServerAction> getConstructor(Class<? extends ServerAction> actionType)
           
static ServerAction getServerAction(ServerBean server)
           
abstract  boolean isStarted()
           
abstract  List<ApplicationBean> listOfApplications()
           
protected static ServerAction newInstance(ServerBean server)
           
protected static byte[] obtainByteData(File file)
          Reads bytes of a file
abstract  String setDefault(String appName)
           
abstract  void start()
          Start server
abstract  void stop()
          Stop server
abstract  void undeploy(String appName)
           
abstract  String upload(ApplicationBean application)
           
 
Methods inherited from class org.ow2.jasmine.jadort.service.action.AbstractJMXAction
checkJMXConnection, connectViaJMX, disconnectJMX, establishJMXConnection
 
Methods inherited from class org.ow2.jasmine.jadort.service.action.AbstractAction
appendToLog, flushLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_PRESENT

public static final String STATE_PRESENT
See Also:
Constant Field Values

STATE_DEPLOYED

public static final String STATE_DEPLOYED
See Also:
Constant Field Values
Constructor Detail

ServerAction

public ServerAction()
Method Detail

getServerAction

public static ServerAction getServerAction(ServerBean server)

newInstance

protected static ServerAction newInstance(ServerBean server)

getConstructor

protected static Constructor<? extends ServerAction> getConstructor(Class<? extends ServerAction> actionType)
                                                             throws Exception
Throws:
Exception

listOfApplications

public abstract List<ApplicationBean> listOfApplications()
                                                  throws Exception
Returns:
List of applications currently present on this server, reformatted as ApplicationBean objects.
Throws:
Exception

canDeployApplications

public abstract boolean canDeployApplications()
                                       throws Exception
Returns:
true if this ServerAction can deploy applications, false otherwise.
Throws:
Exception

canDeployApplicationsOfType

public boolean canDeployApplicationsOfType(ApplicationBean.ApplicationType applicationType)
                                    throws Exception
Parameters:
applicationType - Type of application to check for.
Returns:
true if this ServerAction can deploy applications of type applicationType, false otherwise.
Throws:
Exception

canStartStopServer

public abstract boolean canStartStopServer()
                                    throws Exception
Returns:
true if this ServerAction can start/stop the server, false otherwise.
Throws:
Exception

upload

public abstract String upload(ApplicationBean application)
                       throws Exception
Parameters:
application - ApplicationBean to upload.
Returns:
Name of the application as saved by the server, to use in the deploy(String) and setDefault(String), undeploy(String) and erase(String) methods.
Throws:
Exception

getApplicationBean

public abstract ApplicationBean getApplicationBean(String appName)
                                            throws Exception
Parameters:
appName - Name of the application, as returned by upload(ApplicationBean) or setDefault(String), for which to obtain an ApplicationBean.
Returns:
ApplicationBean corresponding to appName, null if nothing matches.
Throws:
Exception

deploy

public abstract void deploy(String appName)
                     throws Exception
Parameters:
appName - Name of the application to deploy, as returned by upload(ApplicationBean) or setDefault(String).
Throws:
Exception

setDefault

public abstract String setDefault(String appName)
                           throws Exception
Parameters:
appName - Name of the application to set as default version (previous Default version will become Disabled), as returned by upload(ApplicationBean) or setDefault(String).
Returns:
Old application that was default.
Throws:
Exception

undeploy

public abstract void undeploy(String appName)
                       throws Exception
Parameters:
appName - Name of the application to undeploy, as returned by upload(ApplicationBean) or setDefault(String).
Throws:
Exception

erase

public abstract void erase(String appName)
                    throws Exception
Parameters:
appName - Name of the application to erase, as returned by upload(ApplicationBean) or setDefault(String).
Throws:
Exception

getActiveSessions

public abstract int getActiveSessions(String appName)
                               throws Exception
Parameters:
appName - Name of the application for which to get the number of active sessions, as returned by upload(ApplicationBean) or setDefault(String).
Returns:
Number of active sessions on application named appName.
Throws:
Exception

getActiveSessions

public abstract int getActiveSessions()
                               throws Exception
Returns:
Number of active sessions on all applications of this server.
Throws:
Exception

start

public abstract void start()
                    throws Exception
Start server

Throws:
Exception

stop

public abstract void stop()
                   throws Exception
Stop server

Throws:
Exception

isStarted

public abstract boolean isStarted()
Returns:
true if server started, false otherwise.

enableOrDisableApplications

public abstract boolean enableOrDisableApplications(boolean enable)
                                             throws Exception
Enable or disable or enable all applications in this server.

Parameters:
enable - true to enable all applications, false to disable all applications.
Returns:
true if disabling all applications has succeeded, false otherwise. An exception should only be thrown if a real error occurs.
Throws:
Exception

obtainByteData

protected static byte[] obtainByteData(File file)
                                throws IOException
Reads bytes of a file

Parameters:
file - File to read.
Returns:
byte contents of the file.
Throws:
IOException


Copyright © 2012 OW2 Consortium. All Rights Reserved.