com.creamtec.ajaxswing.core
Class JVMFactory

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by com.creamtec.ajaxswing.core.JVMFactory
All Implemented Interfaces:
JVMFactoryRemote, java.io.Serializable, java.rmi.Remote
Direct Known Subclasses:
AjaxSwingRouter.InProcessJVMFactory

public class JVMFactory
extends java.rmi.server.UnicastRemoteObject
implements JVMFactoryRemote

Creates and manages external JVMs.

See Also:
Serialized Form

Constructor Summary
JVMFactory()
          Initializes the factory and starts in-process RMI registry
 
Method Summary
 java.lang.String execJVMProcess(java.lang.String appName)
          Executes a JVM process for given application name and returns a ClientAgent unique ID
 JVMProcessContext findFreeJVM(java.lang.String appName, java.lang.String locale)
          Returns a JVM that can execute another virtual client for a given application
 java.util.List getAppJvms(java.lang.String appName)
          Returns all JVMs for the given application
 JVMProcessContext getAvailableJVM(java.lang.String appName, java.lang.String locale)
          If there's already a warmed up JVM, returns it.
 void initRegistry(int registryPort, int portRange)
           
 JVMProcessContext launchJVM(java.lang.String appName, java.lang.String locale)
          Launches a new JVM for a given application and waits for it to become available
 void ping()
          Used by JVMProcesses to check if the server is still running
 void registerJVM(java.lang.String appName, JVMProcessRemote jvmProcess)
          Registers external JVM with the factory.
 void shutdown()
          Shuts down all registered external JVMs
 void shutdownJVM(JVMProcessContext jvmContext, java.lang.String appName)
          Shuts down the JVM identified by the JVM context and the application name
 void unregisterJVM(JVMProcessContext jvmContext, java.lang.String appName)
          Unregisteres external JVM with the factory
 JVMProcessContext waitForJVM(java.lang.String appName, java.lang.String clientAgentId, java.lang.String locale)
          Waits until a JVM for a given application becomes available
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JVMFactory

public JVMFactory()
           throws java.lang.Exception
Initializes the factory and starts in-process RMI registry

Throws:
java.lang.Exception
Method Detail

initRegistry

public void initRegistry(int registryPort,
                         int portRange)
                  throws java.lang.Exception
Throws:
java.lang.Exception

getAvailableJVM

public JVMProcessContext getAvailableJVM(java.lang.String appName,
                                         java.lang.String locale)
                                  throws java.lang.Exception
If there's already a warmed up JVM, returns it. Othewise lauches a new JVM and waits for it to register with the server process. The method is synchronized to prevent a second thread from stealing a JVM launched by the first thread without launching its own JVM

Throws:
java.lang.Exception

findFreeJVM

public JVMProcessContext findFreeJVM(java.lang.String appName,
                                     java.lang.String locale)
                              throws java.lang.Exception
Returns a JVM that can execute another virtual client for a given application

Parameters:
appName - String
Returns:
JVMProcessContext
Throws:
java.lang.Exception

getAppJvms

public java.util.List getAppJvms(java.lang.String appName)
Returns all JVMs for the given application

Parameters:
appName - application name
Returns:
List

launchJVM

public JVMProcessContext launchJVM(java.lang.String appName,
                                   java.lang.String locale)
                            throws java.lang.Exception
Launches a new JVM for a given application and waits for it to become available

Parameters:
appName - application name
Returns:
JVMProcessContext
Throws:
java.lang.Exception

execJVMProcess

public java.lang.String execJVMProcess(java.lang.String appName)
                                throws java.lang.Exception
Executes a JVM process for given application name and returns a ClientAgent unique ID

Parameters:
appName - application name
Returns:
ClientAgent unique ID
Throws:
java.lang.Exception

waitForJVM

public JVMProcessContext waitForJVM(java.lang.String appName,
                                    java.lang.String clientAgentId,
                                    java.lang.String locale)
                             throws java.lang.Exception
Waits until a JVM for a given application becomes available

Parameters:
appName - application name
Returns:
JVMProcessContext
Throws:
java.lang.Exception

registerJVM

public void registerJVM(java.lang.String appName,
                        JVMProcessRemote jvmProcess)
                 throws java.lang.Exception
Registers external JVM with the factory. This method is called by the external JVM process when it's initialized.

Specified by:
registerJVM in interface JVMFactoryRemote
Parameters:
appName - application name
jvmProcess - JVMProcessRemote
Throws:
java.lang.Exception

shutdownJVM

public void shutdownJVM(JVMProcessContext jvmContext,
                        java.lang.String appName)
Shuts down the JVM identified by the JVM context and the application name

Parameters:
jvmContext - JVMProcessContext
appName - application name

unregisterJVM

public void unregisterJVM(JVMProcessContext jvmContext,
                          java.lang.String appName)
Unregisteres external JVM with the factory

Parameters:
jvmContext - JVMProcessContext
appName - String

shutdown

public void shutdown()
Shuts down all registered external JVMs


ping

public void ping()
Used by JVMProcesses to check if the server is still running

Specified by:
ping in interface JVMFactoryRemote


Copyright © 2000-2012 CreamTec LLC. All Rights Reserved.