com.neeve.server.app
Class SrvAppManager

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.server.app.SrvAppManager

public final class SrvAppManager
extends RootObject

Manages the lifecycle of platform managed applications.

Threading:
This class is safe for concurrent access by multiple threads.

Method Summary
static SrvAppManager create(SrvConfigDescriptor configDescriptor, com.neeve.server.thread.SrvThreadManager threadManager, ISrvAppWatcher appWatcher, ISrvAppServerStopper serverStopper)
          Create an application manager.
 void dispatchEventToApp(String name, Object event)
          Dispatch an event to an application.
 SrvAppLoader getAppLoader(String name)
          Get an application loader.
 MessageBusBinding getAppServerBusBinding(String appName, String busName)
          Get an application's 'server' bus binding
 void installApp(String name, File dir)
          Install/upgrade an application.
 boolean isAppLoaded(String name)
          Check if an application is loaded.
 boolean isStarted()
          Check if the application manager is started.
 String issueAppCommand(String name, String command, String[] args)
          Issue a command to an application.
 void issueAppCommand(String name, String command, String[] args, SrvMonInvokeCommandResponse response)
          Issue a command to an application.
 SrvMonListCommandsResponse issueGetCommands(SrvMonListCommandsRequest request)
          Issue a request to get an apps commands.
 List<String> listApps()
          List the set of loaded apps
 void loadApp(String name)
          Load an application.
 void reloadApp(String name)
          Reload an application.
 void scheduleAppEvent(String name, Object event)
          Schedule an application event.
 void scheduleAppReload(String name)
          Schedule an application reload.
 void scheduleAppUnload(String name)
          Schedule an application unload.
 void setAppMessageHandlingPolicy(String name, AepEngine.MessageHandlingPolicy policy)
          Set an application's message handling policy.
 void setAppVersion(String name, int version)
          Set an application's current version.
 void start()
          Start an application manager.
 void startApp(String name, boolean async)
          Start an application.
 void stop()
          Stop the application manager.
 void stopApp(String name)
          Stop an application.
 void unloadApp(String name)
          Unload an application.
 
Methods inherited from class com.neeve.root.RootObject
getChecked, getThreaded, getTracer, setChecked, setTracer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static final SrvAppManager create(SrvConfigDescriptor configDescriptor,
                                         com.neeve.server.thread.SrvThreadManager threadManager,
                                         ISrvAppWatcher appWatcher,
                                         ISrvAppServerStopper serverStopper)
Create an application manager.

Parameters:
configDescriptor - The server's configuration descriptor.
threadManager - The server's thread manager.
appWatcher - The interface through which app status is communicated.
Returns:
Returns the created application manager.
Threading:
This method is safe for concurrent access by multiple threads

start

public final void start()
                 throws ESrvAppException
Start an application manager.

Throws:
IllegalStateException - Thrown if the application manager has already been started (or started and stopped).
ESrvAppException
Threading:
This method is not safe for concurrent access by multiple threads

listApps

public final List<String> listApps()
                            throws Exception
List the set of loaded apps

Throws:
Exception - Thrown if an error was encountered while preparing the list of loaded apps.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Threading:
This method is safe for concurrent access by multiple threads

installApp

public final void installApp(String name,
                             File dir)
                      throws Exception
Install/upgrade an application.

Parameters:
name - The name of the application to be installed/upgraded.
dir - The name of the directory where the new application's files (jar files etc) are located.
Throws:
Exception - Thrown if an error was encountered while installing the application.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method installs/upgrades an application. The method copies the application's files into the application specific repository and increments the application's latest version.

Threading:
This method is safe for concurrent access by multiple threads

setAppVersion

public final void setAppVersion(String name,
                                int version)
                         throws Exception
Set an application's current version.

Parameters:
name - The application whose current version is to be set.
version - The version to set.
Throws:
Exception - Thrown in case an error is encountered during setting the application's current version.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method updates the current version setting for an application. Specifying a version of 0 will set the current version to the latest installed version.

Threading:
This method is safe for concurrent access by multiple threads

loadApp

public final void loadApp(String name)
                   throws Exception
Load an application.

Parameters:
name - The name of the application to load.
Throws:
Exception - Thrown in case an error is encountered during loading of the application.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method loads an application. It looks up the application of the supplied name, loads an instance of and starts the application.

Threading:
This method is safe for concurrent access by multiple threads

getAppLoader

public final SrvAppLoader getAppLoader(String name)
Get an application loader.

Parameters:
name - The name of the application whose loader to retrieve.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method returns an application's loader. A null value is returned if there is no application loaded with the supplied name.

Threading:
This method is safe for concurrent access by multiple threads

isStarted

public final boolean isStarted()
Check if the application manager is started.

Returns:
true if the app manage is started.
Threading:
This method is safe for concurrent access by multiple threads

isAppLoaded

public final boolean isAppLoaded(String name)
Check if an application is loaded.

Parameters:
name - The name of the application to check for.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Threading:
This method is safe for concurrent access by multiple threads

issueAppCommand

public final String issueAppCommand(String name,
                                    String command,
                                    String[] args)
                             throws Exception
Issue a command to an application.

Parameters:
name - The application to issue the command to.
command - The command to issue
args - The command arguments
Returns:
Returns the command processing status.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Exception
Threading:
This method is safe for concurrent access by multiple threads

issueAppCommand

public final void issueAppCommand(String name,
                                  String command,
                                  String[] args,
                                  SrvMonInvokeCommandResponse response)
                           throws Exception
Issue a command to an application.

Parameters:
name - The application to issue the command to.
command - The command to issue
args - The command arguments
response - The command response
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Exception
Threading:
This method is safe for concurrent access by multiple threads

issueGetCommands

public final SrvMonListCommandsResponse issueGetCommands(SrvMonListCommandsRequest request)
                                                  throws Exception
Issue a request to get an apps commands.

Parameters:
request - The request.
Returns:
Returns The response.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Exception
Threading:
This method is safe for concurrent access by multiple threads

startApp

public final void startApp(String name,
                           boolean async)
                    throws Exception
Start an application.

Parameters:
name - The name of the application to start.
async - Indicates whether to wait or nor to wait for the start to complete. If async start is elected, then the start is initiated in the background using a separate thread.
Throws:
Exception - Thrown in case an error is encountered during starting of the application.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method starts an application. It looks up the application of the supplied name and starts it if not already started. An exeption is thrown if the app being started is already started

Threading:
This method is safe for concurrent access by multiple threads

stopApp

public final void stopApp(String name)
                   throws Exception
Stop an application.

Parameters:
name - The name of the application to stop.
Throws:
Exception - Thrown in case an error is encountered during stoping of the application.
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method stops an application. It looks up the application of the supplied name and stops it if started. An exception is thrown if the application being stopped is not started

Threading:
This method is safe for concurrent access by multiple threads

unloadApp

public final void unloadApp(String name)
Unload an application.

Parameters:
name - The name of the application to unload.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method unloads an application. It looks up if an application of the supplied name has been loaded and unloads it if it is. Upon successful completion of this method, the application has been stopped and unloaded. This method does invoke GC before returning to unload the application and classloader from memory. However, due to compiler inlining and other optimizations, it is still not guaranteed that this would happen. Therefore, the caller should also invoke GC in case it needs the application and/or classloader to be removed from memory.

Threading:
This method is safe for concurrent access by multiple threads

reloadApp

public final void reloadApp(String name)
                     throws Exception
Reload an application.

Parameters:
name - The name of the application to reload.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Exception - Thrown in case an error in encountered reloading the application.

This method unloads and then reloads an application.

Threading:
This method is safe for concurrent access by multiple threads

dispatchEventToApp

public final void dispatchEventToApp(String name,
                                     Object event)
                              throws Exception
Dispatch an event to an application.

Parameters:
name - The name of the application to dispatch the even to.
event - The event to dispatch.
Throws:
Exception - Thrown in case an error is encountered during dispatch
IllegalStateException - Thrown if the application manager has not been started or has been stopped.

This method dispatched an event to an application. It looks up the application by the supplied name and dispatches the supplied event to it.

Threading:
This method is safe for concurrent access by multiple threads

scheduleAppUnload

public final void scheduleAppUnload(String name)
                             throws ESrvAppException
Schedule an application unload.

Parameters:
name - The name of the application to unload.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
ESrvAppException - Thrown in case an error was encountered in scheduling the background task.

This method schedules the unload of a running application, It first checks if an application of the specified name is currently loaded. If so, it schedules the unload of the application to complete in the background and returns immediately. The method just returns if no application of the specified name is loaded.

Threading:
This method is safe for concurrent access by multiple threads

scheduleAppReload

public final void scheduleAppReload(String name)
                             throws ESrvAppException
Schedule an application reload.

Parameters:
name - The name of the application to reload.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
ESrvAppException - Thrown in case an error was encountered in scheduling the background task.

This method schedules the unload and reload of an application in the background and immediately returns. The background task just loads the application if no application of the specified name is loaded.

Threading:
This method is safe for concurrent access by multiple threads

scheduleAppEvent

public final void scheduleAppEvent(String name,
                                   Object event)
                            throws ESrvAppException
Schedule an application event.

Parameters:
name - The name of the application to schedule the event to.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
IllegalArgumentException - Thrown if no application of the supplied name has been loaded.
ESrvAppException - Thrown in case an error was encountered in scheduling the background task.

This method schedules an event to be dispatched to a running application. It first checks if an application of the specified name is currently loaded. If so, it schedules the event to be dispatched to the application in the background and returns immediately. The method just returns if no application of the specified name is loaded.

Threading:
This method is safe for concurrent access by multiple threads

setAppMessageHandlingPolicy

public final void setAppMessageHandlingPolicy(String name,
                                              AepEngine.MessageHandlingPolicy policy)
Set an application's message handling policy.

Parameters:
name - The name of the application whose policy to update.
policy - The new policy to set.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Threading:
This method is safe for concurrent access by multiple threads

getAppServerBusBinding

public final MessageBusBinding getAppServerBusBinding(String appName,
                                                      String busName)
Get an application's 'server' bus binding

Parameters:
appName - The name of the application whose binding to return.
busName - The name of the bus whose binding to return.
Throws:
IllegalStateException - Thrown if the application manager has not been started or has been stopped.
Threading:
This method is safe for concurrent access by multiple threads

stop

public final void stop()
Stop the application manager.

Threading:
This method is not safe for concurrent access by multiple threads


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.