01: /*
02: * <copyright>
03: *
04: * Copyright 2000-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26: package org.cougaar.core.component;
27:
28: /**
29: * An <code>Object</code> that contains internal state.
30: * <p>
31: * Component mobility and persistence requires the saving and
32: * restoration of internal Component state. The typical lifecycle
33: * for both scenarios is:<ol>
34: * <li>The Component is asked for it's state</li>
35: * <li>The Component is destroyed</li>
36: * <li>A new instance of the Component is created from a
37: * <code>ComponentDescription</code>. The new location
38: * might be on a different host.</li>
39: * <li>The state is passed to the StateComponent<li>
40: * </ol><br>
41: * <p>
42: * All <code>Container</code>s are StateComponents because (minimally)
43: * they contain a tree of child Components.
44: * <p>
45: * <code>Binder</code>s act as proxies for the child state-saving.
46: * <p>
47: * This interface might be removed in the future and replaced
48: * with reflective method-lookup, similar to <code>BindingUtility</code>.
49: */
50: public interface StateObject {
51:
52: /**
53: * Get the current state of the Component that is sufficient to
54: * reload the Component from a ComponentDescription.
55: *
56: * @return null if this Component currently has no state
57: */
58: Object getState();
59:
60: /**
61: * Set-state is called by the parent Container if the state
62: * is non-null.
63: * <p>
64: * The state Object is whatever this StateComponent provided
65: * in it's <tt>getState()</tt> implementation.
66: */
67: void setState(Object o);
68:
69: }
|