本文整理汇总了Java中java.rmi.server.ObjID.REGISTRY_ID属性的典型用法代码示例。如果您正苦于以下问题:Java ObjID.REGISTRY_ID属性的具体用法?Java ObjID.REGISTRY_ID怎么用?Java ObjID.REGISTRY_ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.rmi.server.ObjID
的用法示例。
在下文中一共展示了ObjID.REGISTRY_ID属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegistry
/**
* @com.intel.drl.spec_ref
*/
public static Registry getRegistry(String host,
int port,
RMIClientSocketFactory csf)
throws RemoteException {
if (host == null) {
try {
host = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException uhe) {
host = "localhost"; //$NON-NLS-1$
}
}
if (port <= 0) {
port = Registry.REGISTRY_PORT;
}
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,
new ObjID(ObjID.REGISTRY_ID));
}
return (Registry) regClass.getConstructor(
new Class[] { RemoteRef.class }).newInstance(
new Object[] { ref });
} catch (Exception ex) {
// rmi.16=Unable to get registry.
throw new RemoteException(Messages.getString("rmi.16"), ex); //$NON-NLS-1$
}
}
示例2: getRegistry
/**
* 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);
}
示例3: getRegistry
public static Registry getRegistry(String host, int port, RMIClientSocketFactory csf) throws RemoteException {
RemoteRef ref = new UnicastRef(new ObjID(ObjID.REGISTRY_ID), host, port, csf);
return (new RegistryImpl_Stub(ref));
}
示例4: RegistryImpl
public RegistryImpl(int port, RMIClientSocketFactory cf, RMIServerSocketFactory sf) throws RemoteException {
super(new UnicastServerRef(new ObjID(ObjID.REGISTRY_ID), port, sf));
// The following is unnecessary, because UnicastRemoteObject export itself automatically.
//((UnicastServerRef)getRef()).exportObject(this);
}
示例5: getRegistry
public static Registry getRegistry(String host, int port, RMIClientSocketFactory csf) throws RemoteException {
RemoteRef ref = new UnicastRef(new ObjID(ObjID.REGISTRY_ID), host, port, csf);
return (new RegistryImpl_Stub(ref));
}
示例6: RegistryImpl
public RegistryImpl(int port, RMIClientSocketFactory cf, RMIServerSocketFactory sf) throws RemoteException {
super(new UnicastServerRef(new ObjID(ObjID.REGISTRY_ID), port, sf));
// The following is unnecessary, because UnicastRemoteObject export itself automatically.
//((UnicastServerRef)getRef()).exportObject(this);
}
示例7: getRegistry
/**
* 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);
}