01: /*
02: * <copyright>
03: *
04: * Copyright 1997-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:
27: package org.cougaar.core.blackboard;
28:
29: import org.cougaar.bootstrap.SystemProperties;
30:
31: /**
32: * Marker interface for blackboard objects that react to
33: * a {@link org.cougaar.core.service.BlackboardService}
34: * {@link org.cougaar.core.service.BlackboardService#publishAdd},
35: * {@link org.cougaar.core.service.BlackboardService#publishChange},
36: * or
37: * {@link org.cougaar.core.service.BlackboardService#publishRemove}
38: * calls.
39: * <p>
40: * Typically, these methods are used to maintain
41: * some object state, attach {@link ChangeReport}s, check for
42: * well-formedness and/or emit warnings about various problems.
43: */
44: public interface ActiveSubscriptionObject {
45:
46: /** Default value for {@link #deferCommit} */
47: boolean DEFAULT_DEFER_COMMIT = false;
48:
49: /** Property for controlling {@link #deferCommit} */
50: String DEFER_COMMIT_PROPERTY = ActiveSubscriptionObject.class
51: .getName()
52: + ".deferCommit";
53:
54: /**
55: * Whether or not to invoke ActiveSubscriptionObject methods when
56: * the publisher invokes add/change/remove, or delay these method
57: * calls until the distributor sees the closed transaction.
58: * <p>
59: * When deferCommit is true, ActiveSubscriptionObject methods will
60: * be invoked with commit=false at publish time, and commit=true
61: * at LP time. When deferCommit is false, both invocations
62: * will happen at publishTime and certain checks will be disabled
63: * (as uninteresting).
64: * <p>
65: * The default value is defined by {@link #DEFAULT_DEFER_COMMIT}
66: *
67: * @property org.cougaar.core.blackboard.ActiveSubscriptionObject.deferCommit
68: * When set to true, causes ActiveSubscriptionObject side effects to occur
69: * at LP invocation time rather than immediately during publishAdd
70: * @note deferCommit implies that the ActiveSubscriptionObject cannot veto publishes!
71: */
72: boolean deferCommit = SystemProperties.getBoolean(
73: DEFER_COMMIT_PROPERTY, DEFAULT_DEFER_COMMIT);
74:
75: /**
76: * Called by {@link Subscriber#publishAdd}.
77: * @throws BlackboardException if the object cannot be committed.
78: */
79: void addingToBlackboard(Subscriber subscriber, boolean commit);
80:
81: /**
82: * Called by {@link Subscriber#publishChange}.
83: * @throws BlackboardException if the object cannot be committed.
84: * @see Transaction#noteChangeReport(Object,ChangeReport)
85: */
86: void changingInBlackboard(Subscriber subscriber, boolean commit);
87:
88: /**
89: * Called by {@link Subscriber#publishRemove}.
90: * @throws BlackboardException if the object cannot be committed.
91: */
92: void removingFromBlackboard(Subscriber subscriber, boolean commit);
93: }
|