gnu.cajo.invoke
Class Client

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by gnu.cajo.invoke.Client
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public final class Client
extends java.applet.Applet

This class is used to create a hosting VM to receive a graphical proxy object, from a remote VM. The client will require one outbound port, on which to commuinicate with its proxy server and one on inbound, on which to receive asynchronous callbacks from the server. It will also require one short-term inbound port on which to receive the proxy class files. If the client is behind a firewall, these will have to be open.

Version:
1.0, 01-Nov-99 Initial release
Author:
John Catherino
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Client()
          The default constructor does nothing.
 
Method Summary
 void destroy()
          This method is called from the AppleContext, when the applet is being disposed.
static java.awt.Frame frame(java.awt.Component component, java.lang.String title)
          This method is used by items to create a frame containing the AWT or Swing component.
 java.lang.String getAppletInfo()
          This method provides the standard mechanism to identify this applet.
 java.lang.String[][] getParameterInfo()
          When running as an applet, this method describes the optional client parameters.
 void init()
          When running as an applet, this method will connect back to its hosting server and request the item from the server's rmiregistry.
static void main(java.lang.String[] args)
          The application creates a graphical proxy hosting VM.
 void start()
          This method is called from the AppleContext, each time the applet becomes visible.
 void stop()
          This method is called from the AppleContext, each time the applet becomes invisible.
 void update(java.awt.Graphics g)
          The update method double buffers the applet's paint method, to reduce flicker from the default background repainting.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Client

public Client()
The default constructor does nothing. Initialization is done when the applet is loaded into the browser, or when it is instantiated as an application.

Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
This method provides the standard mechanism to identify this applet.

Overrides:
getAppletInfo in class java.applet.Applet
Returns:
The identification string for this applet.

getParameterInfo

public java.lang.String[][] getParameterInfo()
When running as an applet, this method describes the optional client parameters. There are five such parameters which can be specified:

Overrides:
getParameterInfo in class java.applet.Applet
Returns:
The parameter / information array.

init

public void init()
When running as an applet, this method will connect back to its hosting server and request the item from the server's rmiregistry. Next it will invoke a getProxy(null) on the remote reference to request its proxy item. If the item returns the proxy in a MarshalledObject, it will be extracted automatically. If the returned object is a proxy, the client will invoke its init method, passing it a remote reference itself, and to obtain its primary graphical representation, which will then be added into the applet's panel. The proxy can pass its remote reference back to its hosting item, or to other remote items, on which they can asynchronously call it back.

Overrides:
init in class java.applet.Applet

start

public void start()
This method is called from the AppleContext, each time the applet becomes visible. It will attempt to invoke a no-arg start method on the proxy, in the event that it supports one. Support of the method by the proxy is optional.

Overrides:
start in class java.applet.Applet

stop

public void stop()
This method is called from the AppleContext, each time the applet becomes invisible. It will attempt to invoke a no-arg stot method on the proxy, in the event that it supports one. Support of the method by the proxy is optional.

Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
This method is called from the AppleContext, when the applet is being disposed. It will attempt to invoke a no-arg destroy method on the proxy, in the event that it supports one. Support of the method by the proxy is optional.

Overrides:
destroy in class java.applet.Applet

update

public void update(java.awt.Graphics g)
The update method double buffers the applet's paint method, to reduce flicker from the default background repainting.

Overrides:
update in class java.awt.Container

frame

public static java.awt.Frame frame(java.awt.Component component,
                                   java.lang.String title)
This method is used by items to create a frame containing the AWT or Swing component. If the component implements WindowListener, it will be added to its display frame, before being made visible. For AWT components, the frame will be automatically double buffered, for JComponents.

Parameters:
component - The AWT/Swing component, typically returned from a proxy initialization, to be framed.
Returns:
the AWT Frame or Swing JFrame containing the component, already visible.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
The application creates a graphical proxy hosting VM. With the URL argument provided, it will use the static getItem method of the Remote class to contact the server. It will then invoke a null-argument getProxy on the resulting reference to request the primary proxy object of the item. If the proxy is a Swing JComponent, it will be displayed in a JFrame. If it is an AWT Component, it will be displayed in a Frame.

When using Client from the command line, it is possible to set the Client frame explicitly. To do this, simply type:

java -cp cajo.jar -Dgnu.cajo.invoke.Client.title="My Frame Title" gnu.cajo.invoke.Client //myHost:1198/test

Note: When running as an application (except via WebStart) it will load no security manager, therefore, if no external SecurityManager is specified in the startup command line; the arriving proxies will have full permissions on this machine! This can be helpful however, if the proxy is intended to reconfigure the machine.

To restrict client proxies permissions, use a startup invocation similar to the following:

java -cp cajo.jar -Djava.security.manager -Djava.security.policy=client.policy ... gnu.cajo.invoke.Client ...

See the project client documentation, for more details.

Parameters:
args - The startup can take up to five additional optional configuration parameters, in this order:
  • args[0] - The URL where to get the graphical proxy item:
    file:// http:// ftp:// ..., //host:port/name (rmiregistry), /path/name (serialized), or path/name (class).
    If unspecified, a graphical loader utility will be launched.
  • args[1] - The optional external client port number, if using NAT.
  • args[2] - The optional external client host name, if using NAT.
  • args[3] - The optional internal client port number, if using NAT.
  • args[4] - The optional internal client host name, if multi home/NIC.
Throws:
java.lang.Exception