com.sun.grizzly.standalone
Class StandaloneMainUtil

java.lang.Object
  extended by com.sun.grizzly.standalone.StandaloneMainUtil
Direct Known Subclasses:
Cometd, Main, ServletLauncher, WebServer

public abstract class StandaloneMainUtil
extends Object

Abstract class that can be extended when Main/Launcher class are required. Invoking the start(java.lang.String[]) method of this class will properly parse the command line, set the appropriate ClassLoader and if a war/jar is passed as argument, explode it and happens its WEB-INF/classes to the context Classloader and finally start a configured instance of SelectorThread

Author:
Jeanfrancois Arcand

Field Summary
static String ADAPTER
           
static String SELECTOR_THREAD
          System property for the SelectorThread value.
 
Constructor Summary
StandaloneMainUtil()
           
 
Method Summary
 String appendWarContentToClassPath(String appliPath)
          Make available the content of a War file to the current Thread Context Classloader.
abstract  Adapter configureAdapter(SelectorThread st)
          Configure the SelectorThread.setAdapter(com.sun.grizzly.tcp.Adapter)
 SelectorThread createSelectorThread(String[] args)
          Create a single SelectorThread and configure it using the command line passed arguments.
abstract  String parseApplicationLocation(String[] args)
          Parse the current command line, and return the location of the war/jar/static resource location file passed as argument.
abstract  boolean parseOptions(String[] args)
          Validate the command line options.
abstract  void printHelpAndExit()
          This method will be invoked when unexpected arguments are passed to the createSelectorThread(java.lang.String[]).
 void setPort(String num)
          Set the port the SelectorThread will listen.
 void start(String[] args)
          Configure and start a SelectorThread
 void startSelectorThread(SelectorThread st)
          Start a SelectorThread.
 void stop()
          Stop SelectorThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTOR_THREAD

public static final String SELECTOR_THREAD
System property for the SelectorThread value.

See Also:
Constant Field Values

ADAPTER

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

StandaloneMainUtil

public StandaloneMainUtil()
Method Detail

start

public void start(String[] args)
           throws Exception
Configure and start a SelectorThread

Parameters:
args - the command line arguments.
Throws:
Exception

stop

public void stop()
          throws Exception
Stop SelectorThread

Throws:
Exception

createSelectorThread

public SelectorThread createSelectorThread(String[] args)
                                    throws Exception
Create a single SelectorThread and configure it using the command line passed arguments. This method will invoke parseOptions(java.lang.String[]), then parseApplicationLocation(java.lang.String[]), appendWarContentToClassPath(java.lang.String) and finally configureAdapter(com.sun.grizzly.http.SelectorThread)

Parameters:
args - The command line arguments.
Returns:
An instance of ready to start SelectorThread
Throws:
Exception

appendWarContentToClassPath

public String appendWarContentToClassPath(String appliPath)
                                   throws IOException
Make available the content of a War file to the current Thread Context Classloader.

Returns:
the exploded war file location.
Throws:
IOException

startSelectorThread

public void startSelectorThread(SelectorThread st)
                         throws IOException,
                                InstantiationException
Start a SelectorThread.

Parameters:
st -
Throws:
IOException
InstantiationException

setPort

public void setPort(String num)
Set the port the SelectorThread will listen.

Parameters:
num -

printHelpAndExit

public abstract void printHelpAndExit()
This method will be invoked when unexpected arguments are passed to the createSelectorThread(java.lang.String[]).


parseOptions

public abstract boolean parseOptions(String[] args)
Validate the command line options.

Parameters:
args - the command line arguments.
Returns:
true if the options are well formed.

configureAdapter

public abstract Adapter configureAdapter(SelectorThread st)
Configure the SelectorThread.setAdapter(com.sun.grizzly.tcp.Adapter)

Parameters:
st - #return an instance of an Adapter.

parseApplicationLocation

public abstract String parseApplicationLocation(String[] args)
Parse the current command line, and return the location of the war/jar/static resource location file passed as argument.

Parameters:
args - the command line arguments.
Returns:
the application path, or null if not defined.


Copyright © 2012 Oracle Corporation. All Rights Reserved.