Package java.rmi.server

Examples of java.rmi.server.RemoteRef


    private void writeObject(ObjectOutputStream out)
  throws IOException, ClassNotFoundException
    {
  out.writeObject(uid);

  RemoteRef ref;
  if (activator instanceof RemoteObject) {
      ref = ((RemoteObject) activator).getRef();
  } else if (Proxy.isProxyClass(activator.getClass())) {
      InvocationHandler handler = Proxy.getInvocationHandler(activator);
      if (!(handler instanceof RemoteObjectInvocationHandler)) {
    throw new InvalidObjectException(
        "unexpected invocation handler");
      }
      ref = ((RemoteObjectInvocationHandler) handler).getRef();
     
  } else {
      throw new InvalidObjectException("unexpected activator type");
  }
  out.writeUTF(ref.getRefClass(out));
  ref.writeExternal(out);
    }
View Full Code Here


 
  try {
      Class<? extends RemoteRef> refClass =
    Class.forName(RemoteRef.packagePrefix + "." + in.readUTF())
    .asSubclass(RemoteRef.class);
      RemoteRef ref = refClass.newInstance();
      ref.readExternal(in);
      activator = (Activator)
    Proxy.newProxyInstance(null,
               new Class<?>[] { Activator.class },
               new RemoteObjectInvocationHandler(ref));
View Full Code Here

     * ActivationID.activate() methiod. After that the remote call is delegated to the ref, by means of calling its 'invoke' method.
     */
    public Object invoke(Remote obj, Method method, Object[] params, long opnum)
            throws Exception {
        Exception signal_exception  = null;
        RemoteRef rref;

        // rmi.log.106=$$$$$$$$$ ActivatableRef.invoke:
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.106")+obj+", "+method+";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

        if(ref == null) {
            // rmi.log.107=ref == null
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.107")); //$NON-NLS-1$

            RemoteStub stub = (RemoteStub)id.activate(false); //ToDo Check whether it returns Remote or RemoteStub
            // rmi.log.3C=Stub = {0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.3C", stub)); //$NON-NLS-1$

            ActivatableRef aref = (ActivatableRef)stub.getRef();
            // rmi.log.108=aref = {0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.108", aref)); //$NON-NLS-1$

            ref = aref.ref; // Global variable stored for next calls
            rref = aref.ref; // local variable
        } else {
            rref = ref;
        }

        /*
         * If the group's VM was killed(or something bad happened to it) we may have stale activatable reference to the object.
         * In this case rref.invoke() will throw 3 types of Exceptions: ConnectException, ConnectIOException and UnknownObjectException
         * which should be catched and activation group should be activated again.
         */
        try {
            return rref.invoke(obj, method, params, opnum);
        }
        catch(ConnectException ce) {
        }
        catch(ConnectIOException cioe) {
        }
        catch(UnknownObjectException uoe) {
        }
        catch(Exception t) {
            signal_exception = t;
        }

        // rmi.log.109=signal_exception = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.109", signal_exception)); //$NON-NLS-1$

        if (signal_exception == null) {
            RemoteStub stub = (RemoteStub)id.activate(true);
            ActivatableRef aref = (ActivatableRef) stub.getRef();
            ref = aref.ref;
            rref = aref.ref;
            return rref.invoke(obj, method, params, opnum);
        }
        else {
            throw signal_exception;
        }
    }
View Full Code Here

            // rmi.log.08=refType={0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.08", refType)); //$NON-NLS-1$

            Class cl = Class.forName("org.apache.harmony.rmi.remoteref." //$NON-NLS-1$
                    + refType);
            RemoteRef ref = (RemoteRef) cl.newInstance();
            // rmi.log.09=ref = {0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.09", ref)); //$NON-NLS-1$
            ref.readExternal(in);
            // rmi.log.0A=readExternal finished successfully.
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.0A")); //$NON-NLS-1$

            Class activator_class = RMIClassLoader.loadClass((String) null,
                    "org.apache.harmony.rmi.activation.Rmid_Stub"); //$NON-NLS-1$
View Full Code Here

        try {
            out.writeObject(uid);
            // rmi.log.0D=activator = {0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.0D", activator)); //$NON-NLS-1$

            RemoteRef ref = ((RemoteObject) activator).getRef();
            // rmi.log.09=ref = {0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.09", ref)); //$NON-NLS-1$

            String refType = ref.getRefClass(out);
            // rmi.log.08=refType={0}
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.08", refType)); //$NON-NLS-1$
            out.writeUTF(refType);
            ref.writeExternal(out);
            // rmi.log.04=ActivationID.writeObject COMPLETED.
            rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.04")); //$NON-NLS-1$

        } catch (Throwable t) {
            // rmi.0A=Unable to serialize ActivationID: {0}
View Full Code Here

      // Print it.
      if (Boolean.getBoolean(PRINT_IOR_PROPERTY)) {
        if (server.getServant() instanceof RemoteObject) {
          RemoteObject remoteObject = (RemoteObject) server.getServant();
          RemoteStub remoteStub = (RemoteStub) RemoteObject.toStub(remoteObject);
          RemoteRef ref = remoteStub.getRef();
          System.out.print("RMI:");
          System.out.flush();
          ObjectOutputStream objOut
            = new ObjectOutputStream(new Base64EncodingOutputStream(System.out));
          objOut.writeObject(ref);
View Full Code Here

        }

        // Check RemoteRef in stub is from the expected class
        // "sun.rmi.server.UnicastRef2".
        //
        RemoteRef ref = ((RemoteObject)stub).getRef();
        if (ref.getClass() != UnicastRef2.class)
            throw new SecurityException(
                    "Expecting a " + UnicastRef2.class.getName() +
                    " remote reference in stub!");

        // Check RMIClientSocketFactory in stub is from the expected class
View Full Code Here

    private static RMIConnection shadowJrmpStub(RemoteObject stub)
    throws InstantiationException, IllegalAccessException,
            InvocationTargetException, ClassNotFoundException,
            NoSuchMethodException {
        RemoteRef ref = stub.getRef();
        RemoteRef proxyRef = (RemoteRef)
            proxyRefConstructor.newInstance(new Object[] {ref});
        final Constructor<?> rmiConnectionImplStubConstructor =
            rmiConnectionImplStubClass.getConstructor(RemoteRef.class);
        Object[] args = {proxyRef};
        RMIConnection proxyStub = (RMIConnection)
View Full Code Here

        try {
            Class<? extends RemoteRef> refClass =
                Class.forName(RemoteRef.packagePrefix + "." + in.readUTF())
                .asSubclass(RemoteRef.class);
            RemoteRef ref = refClass.newInstance();
            ref.readExternal(in);
            activator = (Activator)
                Proxy.newProxyInstance(null,
                                       new Class<?>[] { Activator.class },
                                       new RemoteObjectInvocationHandler(ref));
View Full Code Here

         **/
        LiveRef liveRef =
            new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                        new TCPEndpoint(host, port, csf, null),
                        false);
        RemoteRef ref =
            (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

        return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
    }
View Full Code Here

TOP

Related Classes of java.rmi.server.RemoteRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.