当前位置: 首页>>代码示例>>Java>>正文


Java Util.createProxy方法代码示例

本文整理汇总了Java中sun.rmi.server.Util.createProxy方法的典型用法代码示例。如果您正苦于以下问题:Java Util.createProxy方法的具体用法?Java Util.createProxy怎么用?Java Util.createProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.rmi.server.Util的用法示例。


在下文中一共展示了Util.createProxy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import sun.rmi.server.Util; //导入方法依赖的package包/类
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:DGCImpl.java

示例2: EndpointEntry

import sun.rmi.server.Util; //导入方法依赖的package包/类
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DGCClient.java

示例3: getRegistry

import sun.rmi.server.Util; //导入方法依赖的package包/类
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:LocateRegistry.java

示例4: run

import sun.rmi.server.Util; //导入方法依赖的package包/类
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref,
                    DGCImpl::checkInput);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);

            Permissions perms = new Permissions();
            perms.add(new SocketPermission("*", "accept,resolve"));
            ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
            AccessControlContext acceptAcc = new AccessControlContext(pd);

            Target target = AccessController.doPrivileged(
                new PrivilegedAction<Target>() {
                    public Target run() {
                        return new Target(dgc, disp, stub, dgcID, true);
                    }
                }, acceptAcc);

            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:46,代码来源:DGCImpl.java

示例5: run

import sun.rmi.server.Util; //导入方法依赖的package包/类
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);

            Permissions perms = new Permissions();
            perms.add(new SocketPermission("*", "accept,resolve"));
            ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
            AccessControlContext acceptAcc = new AccessControlContext(pd);

            Target target = AccessController.doPrivileged(
                new PrivilegedAction<Target>() {
                    public Target run() {
                        return new Target(dgc, disp, stub, dgcID, true);
                    }
                }, acceptAcc);

            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:45,代码来源:DGCImpl.java

示例6: getRegistry

import sun.rmi.server.Util; //导入方法依赖的package包/类
/**
    * Returns a locally created remote reference to the remote object
    * <code>Registry</code> on the specified <code>host</code> and
    * <code>port</code>.  Communication with this remote registry will
    * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
    * to create <code>Socket</code> connections to the registry on the
    * remote <code>host</code> and <code>port</code>.
    *
    * @param host host for the remote registry
    * @param port port on which the registry accepts requests
    * @param csf  client-side <code>Socket</code> factory used to
    *      make connections to the registry.  If <code>csf</code>
    *      is null, then the default client-side <code>Socket</code>
    *      factory will be used in the registry stub.
    * @return reference (a stub) to the remote registry
    * @exception RemoteException if the reference could not be created
    * @since 1.2
    */
   public static Registry getRegistry(String host, int port,
			       RMIClientSocketFactory csf)
throws RemoteException
   {
Registry registry = null;

if (port <= 0)
    port = Registry.REGISTRY_PORT;

if (host == null || host.length() == 0) {
    // If host is blank (as returned by "file:" URL in 1.0.2 used in
    // java.rmi.Naming), try to convert to real local host name so
    // that the RegistryImpl's checkAccess will not fail.
    try {
	host = java.net.InetAddress.getLocalHost().getHostAddress();
    } catch (Exception e) {
	// If that failed, at least try "" (localhost) anyway...
	host = "";
    }
}

/*
 * Create a proxy for the registry with the given host, port, and
 * client socket factory.  If the supplied client socket factory is
 * null, then the ref type is a UnicastRef, otherwise the ref type
 * is a UnicastRef2.  If the property
 * java.rmi.server.ignoreStubClasses is true, then the proxy
 * returned is an instance of a dynamic proxy class that implements
 * the Registry interface; otherwise the proxy returned is an
 * instance of the pregenerated stub class for RegistryImpl.
 **/
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);
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:59,代码来源:LocateRegistry.java


注:本文中的sun.rmi.server.Util.createProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。