Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

junk.system.jvm
Class JXJvm  view JXJvm download JXJvm.java

java.lang.Object
  extended byjunk.system.jvm.JXJvm

public final class JXJvm
extends java.lang.Object

JXJvm is an abstract representation of a Java Virtual Machine running on a Linux process. It will provide all the JVM and class management features offered by Junk. In order to enhance the interaction between the desktop clients and the often neglected JVM, Junk provides a GUI interface to the features that the JXJvm offers. These features will allow multiple classes to be loaded into the JXJvm's runtime domain such that each JVM can host multiple programs using separate classloaders. Some basic JVM administration features will also be provided for the clients so that they can directly manipulate the JVM as desired such as killing, unloading of classloaders and etc. Clients should only attempt to load JD4X compliant applications into it, see the design and specification manuel for further details. The JXJvm also offers the option of loading and executing classes and jars without a GUI front end, however, when this option is selected, interaction can still take place with the JXJvm after it has started by activating its GUI front end.
Note: The JXJvm currently interacts with the client in 2 ways. The first way is through its GUI front end. The second way is to pass a valid JunkTask object through its standard input stream. The passed JunkTask object must be supported by the JvmSupportedTask class.

Since:
JD4X 1.0
Version:
0.1, 12/12/2002

Nested Class Summary
private  class JXJvm.ListClassListener
          Update listener for the loaded class list dialog function buttons.
private  class JXJvm.ListLoaderListener
          Update listener for the classloader list dialog function buttons.
 
Field Summary
private  javax.swing.JFileChooser chooser
          File chooser to select class/jar files
private  int CLASS_D
           
private  junk.gui.dialog.JXConfirmDialog confirm
          Cache the exit dialog.
private static java.lang.String getInvoke
          Optimize commonly used string
private static java.lang.String getParam
          Optimize commonly used string
private static java.lang.String getPkg
          Optimize commonly used string
private  junk.gui.dialog.JXInputDialog input
          Input dialog to get client information
private  junk.gui.dialog.JXSelectionDialog invoke
          Invoke dialog to get client information
private static java.lang.String[] invokeWays
          The list of ways to invoke a class
private  java.lang.String jxjvm
          Name of JXJvm
private  junk.gui.dialog.JXListDialog[] ldialog
          GUI dialog for the classloaders (ldialog[0]) and loaded classes (ldialog[1])
private  javax.swing.JButton[] listcb
          Function buttons for the loaded class dialog
private  javax.swing.JButton[] listclb
          Function buttons for the classloader dialog
private static java.lang.String[] listclbtips
          Tool tip text for the standard icons
private  JXClassLoader loader
          Client-suplier class loader (current referenced loader)
private  int LOADER_D
          Index to dialogs.
private  JXClassLoaderManager loaders
          Classloader manager utility
protected  javax.swing.JProgressBar memory
          Memory indicater
private  junk.util.JXConfigJButtonsParam param
          For configuring dialogs
private  boolean state
          Jvm status indicater
private  java.lang.String sysload
          System load path
 
Constructor Summary
JXJvm(java.lang.String name)
          Starts the JXJvm and initialize all neccessary parts.
 
Method Summary
private  void changeNewClassLoader(java.lang.String key, JXClassLoader value)
          Allow the flexibility of changing a classloader for different class or Jar file loadings, this ensures better security and class isolations on the JXJvm.
protected  void cleanupClassLoaders()
          Cleanup all invalid classloaders by removing their reference.
private  void customLoadFile(java.io.File f)
          To use JXJvm's classloader to load the class file into memory.
protected  void displayClasses()
          To show the loaded classes in a list dialog according to the selection.
protected  void displayClassLoaders()
          Display the classloaders currently in the JXJvm.
protected  void execClass()
          Execute a selected class loaded into a specific classloader.
protected  void execLoader()
          Executes a selected application class or jar file of a classloader.
private  void execute(java.lang.Class lc, int d)
          Execute the class according to the available methods.
private  java.lang.String getClientInput(java.lang.String msg)
          Interact with client and get input information.
 long[] getJvmMemory()
          Get the desired memory status of the Jvm.
protected  void init()
          Initializes the Jvm to take commands from standard input.
private  void initChooser()
          To initialize the file chooser.
private  void initLoaderDialog()
          To initialize the class loader dialog.
 boolean isIsolated()
          Get the state of the Jvm.
private  java.lang.Class jsloadJar(java.lang.String jarPath)
          Load the main class attribute defined in the Manifest file from a given Jar by the system classloader.
private  java.lang.Class jsloadWithBase(java.lang.String name)
          Load a specific fully qualified class from the system class path by the system classloader.
private  java.lang.Class jxloadJar(java.lang.String jarPath)
          Load the main class attribute defined in the Manifest file from a given Jar by a custom classloader.
private  java.lang.Class jxloadWithBase(java.lang.String className, java.lang.String basePath)
          Load a specific fully qualified class from a given home directory by a custom classloader.
protected  void load()
          The GUI to get client defined class and package to load into JXJvm.
static void main(java.lang.String[] arg)
          Default invokation method to start and test the JXJvm.
protected  void reflect()
          To obtain the detail class break down such as constructors, methods, fields and etc.
private  void reflectExtraction(javax.swing.JTextArea text, java.lang.Class lc)
          Extract all details of a class into a JTextArea.
private  void systemLoadFile(java.io.File f)
          To use the system classloader to load the class file into memory.
private  void terminate()
          To terminate the existing Jvm and all Java applications running in it.
 java.lang.String toString()
          A string representation of this JXJvm.
protected  void unloadClassLoaders()
          To unload a classloader or a set of classloaders according to the current selections.
 void updateMemory()
          Update the current memory used by the JVM.
 void updateTheme()
          Set the default icon and color theme of the JXJvm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loaders

private JXClassLoaderManager loaders
Classloader manager utility


loader

private JXClassLoader loader
Client-suplier class loader (current referenced loader)


jxjvm

private java.lang.String jxjvm
Name of JXJvm


ldialog

private junk.gui.dialog.JXListDialog[] ldialog
GUI dialog for the classloaders (ldialog[0]) and loaded classes (ldialog[1])


listclb

private javax.swing.JButton[] listclb
Function buttons for the classloader dialog


listcb

private javax.swing.JButton[] listcb
Function buttons for the loaded class dialog


listclbtips

private static final java.lang.String[] listclbtips
Tool tip text for the standard icons


invokeWays

private static final java.lang.String[] invokeWays
The list of ways to invoke a class


chooser

private javax.swing.JFileChooser chooser
File chooser to select class/jar files


confirm

private junk.gui.dialog.JXConfirmDialog confirm
Cache the exit dialog.


input

private junk.gui.dialog.JXInputDialog input
Input dialog to get client information


invoke

private junk.gui.dialog.JXSelectionDialog invoke
Invoke dialog to get client information


getPkg

private static final java.lang.String getPkg
Optimize commonly used string

See Also:
Constant Field Values

getParam

private static final java.lang.String getParam
Optimize commonly used string

See Also:
Constant Field Values

getInvoke

private static final java.lang.String getInvoke
Optimize commonly used string

See Also:
Constant Field Values

sysload

private java.lang.String sysload
System load path


memory

protected javax.swing.JProgressBar memory
Memory indicater


state

private boolean state
Jvm status indicater


param

private junk.util.JXConfigJButtonsParam param
For configuring dialogs


LOADER_D

private final int LOADER_D
Index to dialogs.

See Also:
Constant Field Values

CLASS_D

private final int CLASS_D
See Also:
Constant Field Values
Constructor Detail

JXJvm

public JXJvm(java.lang.String name)
Starts the JXJvm and initialize all neccessary parts. This constuctor is the default that does not initialized the system with any preloaded client start classes. In other words, its an application empty JVM.

Method Detail

changeNewClassLoader

private void changeNewClassLoader(java.lang.String key,
                                  JXClassLoader value)
Allow the flexibility of changing a classloader for different class or Jar file loadings, this ensures better security and class isolations on the JXJvm. It also updates the GUI.


cleanupClassLoaders

protected void cleanupClassLoaders()
Cleanup all invalid classloaders by removing their reference. Invalid classloaders can result when an exception occurred while executing any class.


customLoadFile

private void customLoadFile(java.io.File f)
To use JXJvm's classloader to load the class file into memory. This method has been known to cause programs that depend on the system classloader to fail but it catches more unseen errors cause by poor programming. Custom loaded class or jar files can be traced and allow fine tuned control.


displayClasses

protected void displayClasses()
To show the loaded classes in a list dialog according to the selection. Only one selection is allowed for this function because of the efficient re-use of the existing loaded class dialog. The list is only updated when the dialog is activated, after which the list remains unchanged as long as the dialog is visible.


displayClassLoaders

protected void displayClassLoaders()
Display the classloaders currently in the JXJvm. Once an appropriate classloader is selected, the Jvm features can be use to manipulate the classes as desired.
Postcondition:
A dialog containing all the current classloaders in the JXJvm is displayed.


execClass

protected void execClass()
Execute a selected class loaded into a specific classloader.


execLoader

protected void execLoader()
Executes a selected application class or jar file of a classloader.


execute

private void execute(java.lang.Class lc,
                     int d)
Execute the class according to the available methods.


getClientInput

private java.lang.String getClientInput(java.lang.String msg)
Interact with client and get input information.


getJvmMemory

public long[] getJvmMemory()
Get the desired memory status of the Jvm. This method returns 3 different values of the Jvm's memory depending on its current memory usage.


isIsolated

public boolean isIsolated()
Get the state of the Jvm. There are only 2 states that a Jvm can be in. State 1 is a shared Jvm, which means that it is interactive, state 2 is an isolated Jvm, which means it is non-interactive. A non-interactive Jvm can nolonger add or remove any of its classes and its GUI is nolonger available for use.


init

protected void init()
Initializes the Jvm to take commands from standard input. It assumes that a valid JunkTask object is passed to it with a range value supported by JvmSupportedTask


initChooser

private void initChooser()
To initialize the file chooser.


initLoaderDialog

private void initLoaderDialog()
To initialize the class loader dialog.


jxloadWithBase

private java.lang.Class jxloadWithBase(java.lang.String className,
                                       java.lang.String basePath)
Load a specific fully qualified class from a given home directory by a custom classloader.


jxloadJar

private java.lang.Class jxloadJar(java.lang.String jarPath)
Load the main class attribute defined in the Manifest file from a given Jar by a custom classloader. It assumes that the Manifest file holds all the valid information.


jsloadWithBase

private java.lang.Class jsloadWithBase(java.lang.String name)
Load a specific fully qualified class from the system class path by the system classloader.


jsloadJar

private java.lang.Class jsloadJar(java.lang.String jarPath)
Load the main class attribute defined in the Manifest file from a given Jar by the system classloader. It assumes that the Manifest file holds all the valid information.


load

protected void load()
The GUI to get client defined class and package to load into JXJvm. Does the required parameter extraction and then call the appropriate function to load the class. Clients can system load or custom load the class or jar files according to their programming need. It automatically handles which mode of loading to use by checking the loading path.


reflect

protected void reflect()
To obtain the detail class break down such as constructors, methods, fields and etc. To be improved in future releases, for now it will do.


reflectExtraction

private void reflectExtraction(javax.swing.JTextArea text,
                               java.lang.Class lc)
Extract all details of a class into a JTextArea. Keep it simple for now.


systemLoadFile

private void systemLoadFile(java.io.File f)
To use the system classloader to load the class file into memory. This method works on all class or jar files as long as the system class path has been correctly defined. It does not allow any control or class tracing at all.


terminate

private void terminate()
To terminate the existing Jvm and all Java applications running in it. Client will be asked to confirm the termination.
Postcondition:
Jvm shuts down and exist, if confirmed.


toString

public java.lang.String toString()
A string representation of this JXJvm. This method merely returns the name of the JXJvm.


unloadClassLoaders

protected void unloadClassLoaders()
To unload a classloader or a set of classloaders according to the current selections.


updateTheme

public void updateTheme()
Set the default icon and color theme of the JXJvm.


updateMemory

public void updateMemory()
Update the current memory used by the JVM.


main

public static void main(java.lang.String[] arg)
Default invokation method to start and test the JXJvm.