Archived

This forum has been archived. Please start a new discussion on GitHub.

Can deactivated object adapter really be reactivated ?

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

  • 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.
  • dwayne
    dwayne St. John's, Newfoundland
    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
  • Thank you, I see.
  • 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!
  • marc
    marc Florida
    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.