001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.servicemix.jbi.container;
018:
019: import java.io.Serializable;
020:
021: import javax.xml.namespace.QName;
022:
023: import org.apache.servicemix.jbi.messaging.PojoMarshaler;
024: import org.apache.servicemix.jbi.resolver.EndpointChooser;
025: import org.apache.servicemix.jbi.resolver.EndpointResolver;
026: import org.apache.servicemix.jbi.resolver.InterfaceNameEndpointResolver;
027: import org.apache.servicemix.jbi.resolver.ServiceAndEndpointNameResolver;
028: import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
029: import org.apache.servicemix.jbi.resolver.URIResolver;
030:
031: /**
032: * Represents the registration of a component with the {@link JBIContainer}
033: *
034: * @org.apache.xbean.XBean element="activationSpec" description="The Component
035: * configuration consisting of its container related
036: * properties such as its routing information"
037: *
038: * @version $Revision: 564374 $
039: */
040: public class ActivationSpec implements Serializable {
041:
042: static final long serialVersionUID = 8458586342841647313L;
043:
044: private String id;
045: private String componentName;
046: private Object component;
047: private QName service;
048: private QName interfaceName;
049: private QName operation;
050: private String endpoint;
051: private transient EndpointResolver destinationResolver;
052: private transient EndpointChooser interfaceChooser;
053: private transient EndpointChooser serviceChooser;
054: private QName destinationService;
055: private QName destinationInterface;
056: private QName destinationOperation;
057: private String destinationEndpoint;
058: private transient PojoMarshaler marshaler;
059: private SubscriptionSpec[] subscriptions = {};
060: private boolean failIfNoDestinationEndpoint = true;
061: private Boolean persistent;
062: private String destinationUri;
063:
064: public ActivationSpec() {
065: }
066:
067: public ActivationSpec(Object component) {
068: this .component = component;
069: }
070:
071: public ActivationSpec(String id, Object component) {
072: this .id = id;
073: this .component = component;
074: }
075:
076: /**
077: * The unique component ID
078: *
079: * @return the unique ID
080: */
081: public String getId() {
082: return id;
083: }
084:
085: /**
086: * Sets the unique component ID
087: *
088: * @param id
089: */
090: public void setId(String id) {
091: this .id = id;
092: }
093:
094: public String getComponentName() {
095: return componentName;
096: }
097:
098: public void setComponentName(String componentName) {
099: this .componentName = componentName;
100: }
101:
102: /**
103: * @org.apache.xbean.Property
104: * @return
105: */
106: public Object getComponent() {
107: return component;
108: }
109:
110: public void setComponent(Object component) {
111: this .component = component;
112: }
113:
114: /**
115: * Returns the service of the component to register
116: */
117: public QName getService() {
118: return service;
119: }
120:
121: public void setService(QName service) {
122: this .service = service;
123: }
124:
125: /**
126: * Returns the endpoint name of this component
127: */
128: public String getEndpoint() {
129: return endpoint;
130: }
131:
132: public void setEndpoint(String endpoint) {
133: this .endpoint = endpoint;
134: }
135:
136: public QName getInterfaceName() {
137: return interfaceName;
138: }
139:
140: public void setInterfaceName(QName interfaceName) {
141: this .interfaceName = interfaceName;
142: }
143:
144: public QName getOperation() {
145: return operation;
146: }
147:
148: public void setOperation(QName operation) {
149: this .operation = operation;
150: }
151:
152: /**
153: * Returns the destination resolver used to decide which destination the
154: * container should route this component to.
155: *
156: * @return the destination resolver, lazily creating one if possible
157: */
158: public EndpointResolver getDestinationResolver() {
159: if (destinationResolver == null) {
160: destinationResolver = createEndpointResolver();
161: }
162: return destinationResolver;
163: }
164:
165: /**
166: * Sets the destination resolver used by the container to route requests
167: * send on the default endpoint.
168: *
169: * @param destinationResolver
170: */
171: public void setDestinationResolver(
172: EndpointResolver destinationResolver) {
173: this .destinationResolver = destinationResolver;
174: }
175:
176: public EndpointChooser getInterfaceChooser() {
177: return interfaceChooser;
178: }
179:
180: public void setInterfaceChooser(EndpointChooser interfaceChooser) {
181: this .interfaceChooser = interfaceChooser;
182: }
183:
184: public EndpointChooser getServiceChooser() {
185: return serviceChooser;
186: }
187:
188: public void setServiceChooser(EndpointChooser serviceChooser) {
189: this .serviceChooser = serviceChooser;
190: }
191:
192: /**
193: * The destination service name
194: */
195: public QName getDestinationService() {
196: return destinationService;
197: }
198:
199: public void setDestinationService(QName destinationService) {
200: this .destinationService = destinationService;
201: }
202:
203: /**
204: * The destination interface
205: */
206: public QName getDestinationInterface() {
207: return destinationInterface;
208: }
209:
210: public void setDestinationInterface(QName destinationInterface) {
211: this .destinationInterface = destinationInterface;
212: }
213:
214: /**
215: * The destination operation name
216: */
217: public QName getDestinationOperation() {
218: return destinationOperation;
219: }
220:
221: public void setDestinationOperation(QName destinationOperation) {
222: this .destinationOperation = destinationOperation;
223: }
224:
225: /**
226: * The destination endpoint
227: */
228: public String getDestinationEndpoint() {
229: return destinationEndpoint;
230: }
231:
232: public void setDestinationEndpoint(String destinationEndpoint) {
233: this .destinationEndpoint = destinationEndpoint;
234: }
235:
236: public PojoMarshaler getMarshaler() {
237: return marshaler;
238: }
239:
240: public void setMarshaler(PojoMarshaler marshaler) {
241: this .marshaler = marshaler;
242: }
243:
244: public SubscriptionSpec[] getSubscriptions() {
245: return subscriptions;
246: }
247:
248: public void setSubscriptions(SubscriptionSpec[] subscriptions) {
249: this .subscriptions = subscriptions;
250: }
251:
252: public boolean isFailIfNoDestinationEndpoint() {
253: return failIfNoDestinationEndpoint;
254: }
255:
256: /**
257: * Sets whether or not there should be a failure if there is no matching
258: * endpoint for the service dispatch. It may be in a pure publish/subscribe
259: * model you want all available subscribes to receive the message but do not
260: * mind if there is not a single destination endpoint that can be found.
261: *
262: * @param failIfNoDestinationEndpoint
263: */
264: public void setFailIfNoDestinationEndpoint(
265: boolean failIfNoDestinationEndpoint) {
266: this .failIfNoDestinationEndpoint = failIfNoDestinationEndpoint;
267: }
268:
269: /**
270: * Lazily create a resolver from the available information
271: */
272: protected EndpointResolver createEndpointResolver() {
273: // lets construct a resolver if any of the output
274: if (destinationService != null) {
275: if (destinationEndpoint != null) {
276: return new ServiceAndEndpointNameResolver(
277: destinationService, destinationEndpoint);
278: } else {
279: return new ServiceNameEndpointResolver(
280: destinationService);
281: }
282: } else if (destinationInterface != null) {
283: return new InterfaceNameEndpointResolver(
284: destinationInterface);
285: } else if (destinationUri != null) {
286: return new URIResolver(destinationUri);
287: }
288: return null;
289: }
290:
291: public Boolean getPersistent() {
292: return persistent;
293: }
294:
295: /**
296: * Set if message exchanges issued by the component should be persistent or
297: * not. This value will override the default one given on the
298: * {@link org.apache.servicemix.jbi.container.JBIContainer#persistent}
299: * attribute.
300: *
301: * @param persistent
302: * the new value to set
303: */
304: public void setPersistent(Boolean persistent) {
305: this .persistent = persistent;
306: }
307:
308: /**
309: * @return the destinationUri
310: */
311: public String getDestinationUri() {
312: return destinationUri;
313: }
314:
315: /**
316: * @param destinationUri
317: * the destinationUri to set
318: */
319: public void setDestinationUri(String destinationUri) {
320: this.destinationUri = destinationUri;
321: }
322:
323: }
|