Home Comments

Can deactivated object adapter really be reactivated ?

rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
In page 733 of Ice 3.1.0 manul:
...
Once an adapter has been deactivated, you can reactivate it again. Any attempt to use a deactivated object adapter results in an ObjectAdapterDeactivatedException.
...

However, the following code throws an exception:
public class Server {
	public static void main(String[] args) {
		int status = 0;
		Ice.Communicator ic = null;
		try {
			ic = Ice.Util.initialize(args);
			Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints(
					"SimplePrinterAdapter", "default -p 10000");
			Ice.Object object = new PrinterI();
			adapter.add(object, ic.stringToIdentity("SimplePrinter"));
			System.out.println("1....");
			adapter.activate();
			System.out.println("2....");
			adapter.deactivate();
			System.out.println("3....");
			adapter.activate();
			//adapter.hold();			//error
			System.out.println("4....");
			ic.waitForShutdown();
		} catch (Ice.LocalException e) {
			e.printStackTrace();
			status = 1;
		} catch (Exception e) {
			System.err.println(e.getMessage());
			status = 1;
		}
		if (ic != null) {
			// Clean up
			//
			try {
				ic.destroy();
			} catch (Exception e) {
				System.err.println(e.getMessage());
				status = 1;
			}
		}
		System.exit(status);
	}
}

The exception is as follows:
D:\>java Server
1....
2....
3....
Ice.ObjectAdapterDeactivatedException
    name = "SimplePrinterAdapter"
        at Ice.ObjectAdapterI.checkForDeactivation(ObjectAdapterI.java:946)
        at Ice.ObjectAdapterI.activate(ObjectAdapterI.java:40)
        at Server.main(Server.java:25)

Comments

  • rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
    In my option, since ObjectAdapter has three states: hold, active, inactive, it is better that we don't allow an deactivated ObjectAdapter to be reactivated.
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi,

    That is a typo in the manual. It should read
    Once an adapter has been deactivated, you cannot reactivate it again.
    

    However, as of Ice 3.1.0 it is possible to recreate an adapter with the same name as a deactivated adapter as soon as waitForDeactivate() returns on the first adapter.

    Regards,
    Dwayne
  • rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
    Thank you, I see.
  • rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
    Another:

    Page 733, Line 22 ~ 24:
      You can reactivate an inactive adapter by calling activate on it, but only once waitForDeactivate has returned.
    


    Page 734, Line 6 ~ 7:
      Once an adapter is in the inactive state, it can be reactivated again, but only once waitForDeactivate has returned. Calling hold, waitForHold, or deactivate on an adapter that is in the inactive state has no effect.
    

    Maybe, it is not a typo. I am confused!
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Object adapters cannot be reactivated. You can recreate an object adapter with the same name (after waitForDeactivate() returns), but you cannot reactivate an existing object adapter. Sorry for the confusion, and we will fix the manual.
Sign In or Register to comment.