Class JClient

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer

    public final class JClient
    extends javax.swing.JApplet
    This class is used to create a hosting VM to receive a Swing graphical proxy JComponent or and AWT Component, 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, if required. It will also use 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.

    Note: to use this Client, instead of the default one, requires use of the new three argument CodebaseServer constructor. In this case, he third argument would need to be: "gnu.cajo.invoke.JClient".
    Version:
    1.0, 20-Feb-06 Initial release
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JApplet

        javax.swing.JApplet.AccessibleJApplet
      • 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 
      Modifier and Type Field Description
      private static java.lang.Object proxy  
      private static long serialVersionUID  
      • Fields inherited from class javax.swing.JApplet

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • 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

      Constructors 
      Constructor Description
      JClient()
      The default constructor does nothing.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      This method is called from the AppleContext, when the JApplet is being disposed.
      java.lang.String getAppletInfo()
      This method provides the standard mechanism to identify this JApplet.
      java.lang.String[][] getParameterInfo()
      This method describes the optional client parameters.
      void init()
      This method connects back to its hosting server and requests the item from the server's rmiregistry.
      static void main​(java.lang.String[] args)
      The application creates a graphical Component proxy hosting VM.
      void start()
      This method is called from the AppleContext, each time the JApplet becomes visible.
      void stop()
      This method is called from the AppleContext, each time the JApplet becomes invisible.
      • Methods inherited from class javax.swing.JApplet

        addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.applet.Applet

        getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, isValidateRoot, 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, 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, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • proxy

        private static java.lang.Object proxy
    • Constructor Detail

      • JClient

        public JClient()
        The default constructor does nothing. Initialization is done when the JApplet is loaded into the browser.
    • Method Detail

      • getAppletInfo

        public java.lang.String getAppletInfo()
        This method provides the standard mechanism to identify this JApplet.
        Overrides:
        getAppletInfo in class java.applet.Applet
        Returns:
        The identification string for this JApplet.
      • getParameterInfo

        public java.lang.String[][] getParameterInfo()
        This method describes the optional client parameters. There are five such parameters which can be specified:
        • The proxyName parameter is the name of the proxy server item registered in the server's rmiregistry. Unspecified it will be "main".
        • The proxyPort parameter is the outbound port number on which to contact the proxy server. Unspecified it will be 1099. If the client is operating behind a firewall, the must be a permitted outbound port.
        • The clientHost parameter is the external domain name or IP address the server must use to callback its proxy. It may need to be specified if the client is operating behind a NAT router. Unspecified it will be the client's default host address.
        • The clientPort parameter is the external inbound port number on which the server can contact its proxy. It may need to be specified if the client is behind NAT, to map to the correct local port. If a firewall is being used, it must be a permitted inbound port. Unspecified, it will be the same as the local port value below.
        • The localPort parameter is the internal inbound port number on which the server can contact its proxy. It may need to be specified if the client is behind NAT, to map to the correct remote port. Unspecified, it will be anonymous.
        Overrides:
        getParameterInfo in class java.applet.Applet
        Returns:
        The parameter / information array.
      • init

        public void init()
        This method connects back to its hosting server and requests 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 Component representation, which will then be added into the JApplet via the Swing event dispatch thread. The proxy can pass this 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 JApplet 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 JApplet 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 JApplet 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
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        The application creates a graphical Component 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.

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

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

        Note: When running as an application (except via WebStart) it will load a NoSecurityManager, therefore, if no external SecurityManager is specified in the startup command line; the arriving proxies will have full permissions on this 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.JClient ...

        See the project client documentation, for more details.

        The startup requires one mandatory, and up to four 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).
        • 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