本文整理汇总了Java中java.rmi.activation.Activatable类的典型用法代码示例。如果您正苦于以下问题:Java Activatable类的具体用法?Java Activatable怎么用?Java Activatable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Activatable类属于java.rmi.activation包,在下文中一共展示了Activatable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inactiveObject
import java.rmi.activation.Activatable; //导入依赖的package包/类
/**
* The group's <code>inactiveObject</code> method is called
* indirectly via a call to the <code>Activatable.inactive</code>
* method. A remote object implementation must call
* <code>Activatable</code>'s <code>inactive</code> method when
* that object deactivates (the object deems that it is no longer
* active). If the object does not call
* <code>Activatable.inactive</code> when it deactivates, the
* object will never be garbage collected since the group keeps
* strong references to the objects it creates. <p>
*
* The group's <code>inactiveObject</code> method
* unexports the remote object from the RMI runtime so that the
* object can no longer receive incoming RMI calls. This call will
* only succeed if the object has no pending/executing calls. If
* the object does have pending/executing RMI calls, then false
* will be returned.
*
* If the object has no pending/executing calls, the object is
* removed from the RMI runtime and the group informs its
* <code>ActivationMonitor</code> (via the monitor's
* <code>inactiveObject</code> method) that the remote object is
* not currently active so that the remote object will be
* re-activated by the activator upon a subsequent activation
* request.
*
* @param id the object's activation identifier
* @returns true if the operation succeeds (the operation will
* succeed if the object in currently known to be active and is
* either already unexported or is currently exported and has no
* pending/executing calls); false is returned if the object has
* pending/executing calls in which case it cannot be deactivated
* @exception UnknownObjectException if object is unknown (may already
* be inactive)
* @exception RemoteException if call informing monitor fails
*/
public boolean inactiveObject(ActivationID id)
throws ActivationException, UnknownObjectException, RemoteException
{
try {
acquireLock(id);
synchronized (this) {
if (groupInactive == true)
throw new ActivationException("group is inactive");
}
ActiveEntry entry = active.get(id);
if (entry == null) {
// REMIND: should this be silent?
throw new UnknownObjectException("object not active");
}
try {
if (Activatable.unexportObject(entry.impl, false) == false)
return false;
} catch (NoSuchObjectException allowUnexportedObjects) {
}
try {
super.inactiveObject(id);
} catch (UnknownObjectException allowUnregisteredObjects) {
}
active.remove(id);
} finally {
releaseLock(id);
checkInactiveGroup();
}
return true;
}
示例2: inactiveObject
import java.rmi.activation.Activatable; //导入依赖的package包/类
/**
* The group's <code>inactiveObject</code> method is called
* indirectly via a call to the <code>Activatable.inactive</code>
* method. A remote object implementation must call
* <code>Activatable</code>'s <code>inactive</code> method when
* that object deactivates (the object deems that it is no longer
* active). If the object does not call
* <code>Activatable.inactive</code> when it deactivates, the
* object will never be garbage collected since the group keeps
* strong references to the objects it creates. <p>
*
* The group's <code>inactiveObject</code> method
* unexports the remote object from the RMI runtime so that the
* object can no longer receive incoming RMI calls. This call will
* only succeed if the object has no pending/executing calls. If
* the object does have pending/executing RMI calls, then false
* will be returned.
*
* If the object has no pending/executing calls, the object is
* removed from the RMI runtime and the group informs its
* <code>ActivationMonitor</code> (via the monitor's
* <code>inactiveObject</code> method) that the remote object is
* not currently active so that the remote object will be
* re-activated by the activator upon a subsequent activation
* request.
*
* @param id the object's activation identifier
* @return true if the operation succeeds (the operation will
* succeed if the object in currently known to be active and is
* either already unexported or is currently exported and has no
* pending/executing calls); false is returned if the object has
* pending/executing calls in which case it cannot be deactivated
* @exception UnknownObjectException if object is unknown (may already
* be inactive)
* @exception RemoteException if call informing monitor fails
*/
public boolean inactiveObject(ActivationID id)
throws ActivationException, UnknownObjectException, RemoteException
{
try {
acquireLock(id);
synchronized (this) {
if (groupInactive == true)
throw new ActivationException("group is inactive");
}
ActiveEntry entry = active.get(id);
if (entry == null) {
// REMIND: should this be silent?
throw new UnknownObjectException("object not active");
}
try {
if (Activatable.unexportObject(entry.impl, false) == false)
return false;
} catch (NoSuchObjectException allowUnexportedObjects) {
}
try {
super.inactiveObject(id);
} catch (UnknownObjectException allowUnregisteredObjects) {
}
active.remove(id);
} finally {
releaseLock(id);
checkInactiveGroup();
}
return true;
}
示例3: DownloadActivationGroup
import java.rmi.activation.Activatable; //导入依赖的package包/类
public DownloadActivationGroup(ActivationID id, MarshalledObject mobj)
throws ActivationException, RemoteException
{
this.id = id;
Activatable.exportObject(this, id, 0);
System.err.println("object activated in group");
}
示例4: inactiveObject
import java.rmi.activation.Activatable; //导入依赖的package包/类
public boolean inactiveObject(ActivationID id) throws ActivationException,
UnknownObjectException, RemoteException {
ActiveObject ao = (ActiveObject) active_objects.get(id);
if (ao == null) {
// rmi.93=Object was not registered or already deactivated.
throw new UnknownObjectException(Messages.getString("rmi.93")); //$NON-NLS-1$
}
Activatable.unexportObject(ao.getImpl(), false);
super.inactiveObject(id);
active_objects.remove(id);
return true;
}
示例5: testSimpleInstall
import java.rmi.activation.Activatable; //导入依赖的package包/类
public void testSimpleInstall() throws Exception {
try {
Properties props = new Properties();
ActivationGroupDesc groupDesc = new ActivationGroupDesc(props, null);
System.out.println("groupDesc = " + groupDesc);
System.out.flush();
ActivationSystem as = ActivationGroup.getSystem();
System.out.println("ActivationSystem = " + as);
ActivationGroupID groupID = as.registerGroup(groupDesc);
System.out.println("groupID = " + groupID);
System.out.println("Activation group descriptor registered.");
MarshalledObject data = new MarshalledObject("HelloImpl");
System.out.println("MarshalledObject data = " + data);
ActivationDesc desc = new ActivationDesc(groupID, "org.apache.harmony.rmi.tests.java.rmi.activation.HelloImpl", "", null);
System.out.println("Registering ActivationDesc:");
Remote stub = Activatable.register(desc);
System.out.println("Activation descriptor registered: " + stub);
Registry reg = LocateRegistry.getRegistry();
System.out.println("Registry = " + reg);
reg.rebind("HelloImpl_Stub", stub);
System.out.println("Stub bound in registry.");
} catch (Throwable t) {
System.out.println("Exception in HelloInstaller: " + t);
t.printStackTrace();
fail("Exception in HelloInstaller: " + t);
}
}
示例6: testInactive001
import java.rmi.activation.Activatable; //导入依赖的package包/类
public void testInactive001() {
try {
Activatable.inactive(null);
fail(msgRaise + "ActivationException");
} catch (ActivationException ae) {
} catch (Throwable e) {
fail("Failed with:" + e);
}
}
示例7: testInactive002
import java.rmi.activation.Activatable; //导入依赖的package包/类
public void testInactive002() {
try {
Activatable.inactive(new ActivationID(null));
fail(msgRaise + "ActivationException");
} catch (ActivationException ae) {
} catch (Throwable e) {
fail("Failed with:" + e);
}
}
示例8: testInactive003
import java.rmi.activation.Activatable; //导入依赖的package包/类
public void testInactive003() {
try {
ActivationID aid = new ActivationID(ac);
aid.activate(false);
Activatable.inactive(aid);
} catch (Throwable e) {
fail("Failed with:" + e);
}
}
示例9: main
import java.rmi.activation.Activatable; //导入依赖的package包/类
public static void main(String[] args) {
RMID rmid = null;
System.out.println("\nRegression test for bug 4510355\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMIDOnEphemeralPort();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(
null,
new String[] {
"--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED",
"--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED",
"--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED",
"--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, cmd);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
rmid.cleanup();
}
}
示例10: main
import java.rmi.activation.Activatable; //导入依赖的package包/类
public static void main(String[] args) {
RMID rmid = null;
System.out.println("\nRegression test for bug 4510355\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMID();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(
null,
new String[] {
"-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED",
"-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED",
"-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED",
"-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, cmd);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
rmid.cleanup();
}
}