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.qos.ca;
28:
29: import org.cougaar.core.component.ServiceBroker;
30:
31: /**
32: * This class is implements a Coordination Artifact for creating facts
33: * from beans. The only role so far is Consumer, which "consumes"
34: * new-beans and bean-modification Blackboard objects and asserts
35: * corresponding facts into the Role Player's rule engine.
36: *
37: * @see BeanToFactFacetImpl
38: */
39: abstract public class BeanCoordinationArtifactProvider extends
40: CoordinationArtifactProviderImpl {
41:
42: private static final String BeanCA = "BeanCA";
43: private static final String ConsumerRole = "Consumer";
44:
45: public BeanCoordinationArtifactProvider(ServiceBroker sb) {
46: super (BeanCA, sb);
47: }
48:
49: abstract protected class BeanCA extends CoordinationArtifactImpl
50: implements CoordArtConstants {
51: private String artifactId;
52:
53: protected BeanCA(CoordinationArtifactProvider owner,
54: ConnectionSpec spec) {
55: super (owner, spec);
56: this .artifactId = spec.ca_parameters
57: .getProperty(ArtifactIdAttr);
58: }
59:
60: abstract protected BeanToFactFacetImpl makeBeanToFactFacet(
61: ServiceBroker sb, ConnectionSpec spec, RolePlayer player);
62:
63: public String getArtifactId() {
64: return artifactId;
65: }
66:
67: protected Facet makeFacet(ConnectionSpec spec, RolePlayer player) {
68: ServiceBroker sb = getServiceBroker();
69: if (spec.role.equals(ConsumerRole)) {
70: return makeBeanToFactFacet(sb, spec, player);
71: } else {
72: throw new RuntimeException("Bogus role in spec: "
73: + spec);
74: }
75: }
76: }
77:
78: }
|