Package java.rmi.server

Examples of java.rmi.server.RemoteRef


                         long opnum)
        throws Exception
    {

        boolean force = false;
        RemoteRef localRef;
        Exception exception = null;

        /*
         * Attempt object activation if active ref is unknown.
         * Throws a RemoteException if object can't be activated.
         */
        synchronized (this) {
            if (ref == null) {
                localRef = activate(force);
                force = true;
            } else {
                localRef = ref;
            }
        }

        for (int retries = MAX_RETRIES; retries > 0; retries--) {

            try {
                return localRef.invoke(obj, method, params, opnum);
            } catch (NoSuchObjectException e) {
                /*
                 * Object is not active in VM; retry call
                 */
                exception = e;
            } catch (ConnectException e) {
                /*
                 * Failure during connection setup; retry call
                 */
                exception = e;
            } catch (UnknownHostException e) {
                /*
                 * Failure during connection setup; retry call.
                 */
                exception = e;
            } catch (ConnectIOException e) {
                /*
                 * Failure setting up multiplexed connection or reusing
                 * cached connection; retry call
                 */
                exception = e;
            } catch (MarshalException e) {
                /*
                 * Failure during parameter serialization; call may
                 * have reached server, so call retry not possible.
                 */
                throw e;
            } catch (ServerError e) {
                /*
                 * Call reached server; propagate remote exception.
                 */
                throw e;
            } catch (ServerException e) {
                /*
                 * Call reached server; propagate remote exception
                 */
                throw e;
            } catch (RemoteException e) {
                /*
                 * This is a catch-all for other RemoteExceptions.
                 * UnmarshalException being the only one relevant.
                 *
                 * StubNotFoundException should never show up because
                 * it is generally thrown when attempting to locate
                 * a stub.
                 *
                 * UnexpectedException should never show up because
                 * it is only thrown by a stub and would be wrapped
                 * in a ServerException if it was propagated by a
                 * remote call.
                 */
                synchronized (this) {
                    if (localRef == ref) {
                        ref = null;     // this may be overly conservative
                    }
                }

                throw e;
            }

            if (retries > 1) {
                /*
                 * Activate object, since object could not be reached.
                 */
                synchronized (this) {
                    if (localRef.remoteEquals(ref) || ref == null) {
                        RemoteRef newRef = activate(force);

                        if (newRef.remoteEquals(localRef) &&
                            exception instanceof NoSuchObjectException &&
                            force == false) {
                            /*
                             * If last exception was NoSuchObjectException,
                             * then old value of ref is definitely wrong,
View Full Code Here


    /**
     * Write out external representation for remote ref.
     */
    public void writeExternal(ObjectOutput out) throws IOException
    {
        RemoteRef localRef = ref;

        out.writeObject(id);
        if (localRef == null) {
            out.writeUTF("");
        } else {
            out.writeUTF(localRef.getRefClass(out));
            localRef.writeExternal(out);
        }
    }
View Full Code Here

            "\ncorrect interface hash and operation numbers:");

        Registry testImpl = LocateRegistry.createRegistry(PORT);
        System.err.println("created test registry on port " + PORT);

        RemoteRef ref = new UnicastRef(
            new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                        new TCPEndpoint("", PORT), false));
        Registry referenceStub = new ReferenceRegistryStub(ref);
        System.err.println("created reference registry stub: " +
                           referenceStub);
View Full Code Here

        }

        try {
            Class regClass = Class.forName(
                    "org.apache.harmony.rmi.registry.RegistryImpl_Stub"); //$NON-NLS-1$
            RemoteRef ref;

            if (csf == null) {
                ref = new UnicastRef(host, port, new ObjID(ObjID.REGISTRY_ID));
            } else {
                ref = new UnicastRef2(host, port, csf,
View Full Code Here

     * ActivationID.activate() method. 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 caught 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

            String refType = in.readUTF();
            // 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$
            Class[] constructor_parameter_classes = { RemoteRef.class };
View Full Code Here

        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.0C")); //$NON-NLS-1$
        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}
            throw new IOException(Messages.getString("rmi.0A", t.getMessage()));//$NON-NLS-1$
View Full Code Here

        }

        try {
            Class regClass = Class.forName(
                    "org.apache.harmony.rmi.registry.RegistryImpl_Stub"); //$NON-NLS-1$
            RemoteRef ref;

            if (csf == null) {
                ref = new UnicastRef(host, port, new ObjID(ObjID.REGISTRY_ID));
            } else {
                ref = new UnicastRef2(host, port, csf,
View Full Code Here

     * ActivationID.activate() method. 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 caught 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

        FakeActivationGroup fag;
        ActivationGroupID aid;
        aid = new ActivationGroupID(null);
        fag = new FakeActivationGroup(null);
        fag = new FakeActivationGroup(aid);
        RemoteRef ref = fag.getRef();
        logger.log(Level.FINEST, "ActivationGroup.ref = " + ref);
        assertion(ref instanceof UnicastServerRef,
                "ActivationGroup should be exported as"
                + " UnicastRemoteObject");
    }
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.