org.objectweb.easybeans.client
Class ClientContainer

java.lang.Object
  extended by org.objectweb.easybeans.client.ClientContainer

public final class ClientContainer
extends java.lang.Object

Defines the class use for the client container This class analyze the ear or the jar client and launch the client.

Author:
Florent Benoit

Field Summary
private  java.util.List<java.lang.String> appArgs
          Extra Arguments.
private  ApplicationClient applicationClient
          XML Struct representing application-client.xml file.
private  java.lang.String[] args
          Arguments used by the client.
private  java.lang.String classpath
          Classpath for the application client.
private static java.lang.String DEFAULT_FOLDER
          Folder to create in tmp folder.
private  java.net.URL[] extensionsURLs
          URLs resolved in the case of the extension mechanism in the Ear case.
private  java.lang.String jarClient
          Jar client to use (if many).
private  JNDIResolver jndiResolver
          Reference to a JNDIResolver.
private  JLog logger
          Logger.
private  java.lang.String mainClass
          Main class to use to launch the application client.
private  java.lang.String tmpDir
          Temporary directory.
 
Constructor Summary
private ClientContainer(java.lang.String[] args)
          Constructor for a Client container.
 
Method Summary
private  void analyzeArgs()
          Analyze arguments and extract parameters for the client container.
private  void buildENC()
          Build ENC environment used by this client.
private  java.io.File extractAndAnalyzeEar(java.io.File earFile)
          Extract the client of an ear and analyze ear too.
private  java.net.URL[] getUserClasspathUrls()
          Gets the URL of user classpath (can be empty).
private  void invokeClient()
          Start the client on its main class with the thread class loader.
static void main(java.lang.String[] args)
          Main method of the Client container.
private  void start()
          Start the client container.
private  void usage()
          Print the usage of this client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FOLDER

private static final java.lang.String DEFAULT_FOLDER
Folder to create in tmp folder.

See Also:
Constant Field Values

mainClass

private java.lang.String mainClass
Main class to use to launch the application client.


tmpDir

private java.lang.String tmpDir
Temporary directory.


classpath

private java.lang.String classpath
Classpath for the application client.


args

private java.lang.String[] args
Arguments used by the client.


appArgs

private java.util.List<java.lang.String> appArgs
Extra Arguments.


extensionsURLs

private java.net.URL[] extensionsURLs
URLs resolved in the case of the extension mechanism in the Ear case.


logger

private JLog logger
Logger.


jndiResolver

private JNDIResolver jndiResolver
Reference to a JNDIResolver.


jarClient

private java.lang.String jarClient
Jar client to use (if many).


applicationClient

private ApplicationClient applicationClient
XML Struct representing application-client.xml file.

Constructor Detail

ClientContainer

private ClientContainer(java.lang.String[] args)
Constructor for a Client container.

Parameters:
args - the arguments of the instance of the client container
Method Detail

main

public static void main(java.lang.String[] args)
Main method of the Client container.

Parameters:
args - the arguments of the client container

start

private void start()
            throws java.lang.Exception
Start the client container.

Throws:
java.lang.Exception - if it fails

invokeClient

private void invokeClient()
                   throws java.lang.ClassNotFoundException,
                          java.lang.NoSuchMethodException,
                          java.lang.IllegalAccessException,
                          java.lang.reflect.InvocationTargetException,
                          EnhancerException
Start the client on its main class with the thread class loader.

Throws:
java.lang.ClassNotFoundException - if class is not found
java.lang.NoSuchMethodException - if method (main) is not found
java.lang.IllegalAccessException - if access is illegal
java.lang.reflect.InvocationTargetException - if invocation failed
EnhancerException - if enhancement fails.

analyzeArgs

private void analyzeArgs()
                  throws java.lang.Exception
Analyze arguments and extract parameters for the client container.

Throws:
java.lang.Exception - if there is an error when analyzing arguments

usage

private void usage()
Print the usage of this client.


extractAndAnalyzeEar

private java.io.File extractAndAnalyzeEar(java.io.File earFile)
                                   throws java.lang.Exception
Extract the client of an ear and analyze ear too.

Parameters:
earFile - ear to be analyzed
Returns:
the file of the client which was extracted
Throws:
java.lang.Exception - if the analyze and/or extract fails

getUserClasspathUrls

private java.net.URL[] getUserClasspathUrls()
Gets the URL of user classpath (can be empty).

Returns:
URL of user classpath (-cp arg)

buildENC

private void buildENC()
               throws ClientContainerException
Build ENC environment used by this client.

Throws:
ClientContainerException - if the ENC environment is not built.