KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > container > ActivationSpec


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.jbi.container;
18
19 import org.apache.servicemix.jbi.messaging.PojoMarshaler;
20 import org.apache.servicemix.jbi.resolver.EndpointChooser;
21 import org.apache.servicemix.jbi.resolver.EndpointResolver;
22 import org.apache.servicemix.jbi.resolver.InterfaceNameEndpointResolver;
23 import org.apache.servicemix.jbi.resolver.ServiceAndEndpointNameResolver;
24 import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
25 import org.apache.servicemix.jbi.resolver.URIResolver;
26
27 import javax.xml.namespace.QName JavaDoc;
28
29 import java.io.Serializable JavaDoc;
30
31 /**
32  * Represents the registration of a component with the {@link JBIContainer}
33  *
34  * @org.apache.xbean.XBean element="activationSpec"
35  * description="The Component configuration consisting of its container related properties such as its routing information"
36  *
37  * @version $Revision: 426415 $
38  */

39 public class ActivationSpec implements Serializable JavaDoc {
40     
41     static final long serialVersionUID = 8458586342841647313L;
42     private String JavaDoc id;
43     private String JavaDoc componentName;
44     private Object JavaDoc component;
45     private QName JavaDoc service;
46     private QName JavaDoc interfaceName;
47     private QName JavaDoc operation;
48     private String JavaDoc endpoint;
49     private transient EndpointResolver destinationResolver;
50     private transient EndpointChooser interfaceChooser;
51     private transient EndpointChooser serviceChooser;
52     private QName JavaDoc destinationService;
53     private QName JavaDoc destinationInterface;
54     private QName JavaDoc destinationOperation;
55     private String JavaDoc destinationEndpoint;
56     private transient PojoMarshaler marshaler;
57     private SubscriptionSpec[] subscriptions = {};
58     private boolean failIfNoDestinationEndpoint = true;
59     private Boolean JavaDoc persistent;
60     private String JavaDoc destinationUri;
61
62
63     public ActivationSpec() {
64     }
65
66     public ActivationSpec(Object JavaDoc component) {
67         this.component = component;
68     }
69
70     public ActivationSpec(String JavaDoc id, Object JavaDoc component) {
71         this.id = id;
72         this.component = component;
73     }
74
75     /**
76      * The unique component ID
77      *
78      * @return the unique ID
79      */

80     public String JavaDoc getId() {
81         return id;
82     }
83
84     /**
85      * Sets the unique component ID
86      *
87      * @param id
88      */

89     public void setId(String JavaDoc id) {
90         this.id = id;
91     }
92
93     public String JavaDoc getComponentName() {
94         return componentName;
95     }
96
97     public void setComponentName(String JavaDoc componentName) {
98         this.componentName = componentName;
99     }
100
101     /**
102      * @org.apache.xbean.Property
103      * @return
104      */

105     public Object JavaDoc getComponent() {
106         return component;
107     }
108
109     public void setComponent(Object JavaDoc component) {
110         this.component = component;
111     }
112
113     /**
114      * Returns the service of the component to register
115      */

116     public QName JavaDoc getService() {
117         return service;
118     }
119
120     public void setService(QName JavaDoc service) {
121         this.service = service;
122     }
123
124     /**
125      * Returns the endpoint name of this component
126      */

127     public String JavaDoc getEndpoint() {
128         return endpoint;
129     }
130
131     public void setEndpoint(String JavaDoc endpoint) {
132         this.endpoint = endpoint;
133     }
134
135     public QName JavaDoc getInterfaceName() {
136         return interfaceName;
137     }
138
139     public void setInterfaceName(QName JavaDoc interfaceName) {
140         this.interfaceName = interfaceName;
141     }
142
143     public QName JavaDoc getOperation() {
144         return operation;
145     }
146
147     public void setOperation(QName JavaDoc operation) {
148         this.operation = operation;
149     }
150
151     /**
152      * Returns the destination resolver used to decide which
153      * destination the container should route this component to.
154      *
155      * @return the destination resolver, lazily creating one if possible
156      */

157     public EndpointResolver getDestinationResolver() {
158         if (destinationResolver == null) {
159             destinationResolver = createEndpointResolver();
160         }
161         return destinationResolver;
162     }
163
164     /**
165      * Sets the destination resolver used by the container to route
166      * requests send on the default endpoint.
167      *
168      * @param destinationResolver
169      */

170     public void setDestinationResolver(EndpointResolver destinationResolver) {
171         this.destinationResolver = destinationResolver;
172     }
173
174
175     public EndpointChooser getInterfaceChooser() {
176         return interfaceChooser;
177     }
178
179     public void setInterfaceChooser(EndpointChooser interfaceChooser) {
180         this.interfaceChooser = interfaceChooser;
181     }
182
183     public EndpointChooser getServiceChooser() {
184         return serviceChooser;
185     }
186
187     public void setServiceChooser(EndpointChooser serviceChooser) {
188         this.serviceChooser = serviceChooser;
189     }
190
191     /**
192      * The destination service name
193      */

194     public QName JavaDoc getDestinationService() {
195         return destinationService;
196     }
197
198     public void setDestinationService(QName JavaDoc destinationService) {
199         this.destinationService = destinationService;
200     }
201
202     /**
203      * The destination interface
204      */

205     public QName JavaDoc getDestinationInterface() {
206         return destinationInterface;
207     }
208
209     public void setDestinationInterface(QName JavaDoc destinationInterface) {
210         this.destinationInterface = destinationInterface;
211     }
212
213     /**
214      * The destination operation name
215      */

216     public QName JavaDoc getDestinationOperation() {
217         return destinationOperation;
218     }
219
220     public void setDestinationOperation(QName JavaDoc destinationOperation) {
221         this.destinationOperation = destinationOperation;
222     }
223
224     /**
225      * The destination endpoint
226      */

227     public String JavaDoc getDestinationEndpoint() {
228         return destinationEndpoint;
229     }
230
231     public void setDestinationEndpoint(String JavaDoc destinationEndpoint) {
232         this.destinationEndpoint = destinationEndpoint;
233     }
234
235     public PojoMarshaler getMarshaler() {
236         return marshaler;
237     }
238
239     public void setMarshaler(PojoMarshaler marshaler) {
240         this.marshaler = marshaler;
241     }
242
243     public SubscriptionSpec[] getSubscriptions() {
244         return subscriptions;
245     }
246
247     public void setSubscriptions(SubscriptionSpec[] subscriptions) {
248         this.subscriptions = subscriptions;
249     }
250     
251     public boolean isFailIfNoDestinationEndpoint() {
252         return failIfNoDestinationEndpoint;
253     }
254
255     /**
256      * Sets whether or not there should be a failure if there is no matching endpoint for the service dispatch.
257      * It may be in a pure publish/subscribe model you want all available subscribes to receive the message but do not mind
258      * if there is not a single destination endpoint that can be found.
259      *
260      * @param failIfNoDestinationEndpoint
261      */

262     public void setFailIfNoDestinationEndpoint(boolean failIfNoDestinationEndpoint) {
263         this.failIfNoDestinationEndpoint = failIfNoDestinationEndpoint;
264     }
265
266     /**
267      * Lazily create a resolver from the available information
268      */

269     protected EndpointResolver createEndpointResolver() {
270         // lets construct a resolver if any of the output
271
if (destinationService != null) {
272             if (destinationEndpoint != null) {
273                 return new ServiceAndEndpointNameResolver(destinationService, destinationEndpoint);
274             }
275             else {
276                 return new ServiceNameEndpointResolver(destinationService);
277             }
278         }
279         else if (destinationInterface != null) {
280             return new InterfaceNameEndpointResolver(destinationInterface);
281         } else if (destinationUri != null) {
282             return new URIResolver(destinationUri);
283         }
284         return null;
285     }
286
287     public Boolean JavaDoc getPersistent() {
288         return persistent;
289     }
290
291     /**
292      * Set if message exchanges issued by the component should be persistent
293      * or not. This value will override the default one given on the
294      * {@link org.apache.servicemix.jbi.container.JBIContainer#persistent} attribute.
295      *
296      * @param persistent the new value to set
297      */

298     public void setPersistent(Boolean JavaDoc persistent) {
299         this.persistent = persistent;
300     }
301
302     /**
303      * @return the destinationUri
304      */

305     public String JavaDoc getDestinationUri() {
306         return destinationUri;
307     }
308
309     /**
310      * @param destinationUri the destinationUri to set
311      */

312     public void setDestinationUri(String JavaDoc destinationUri) {
313         this.destinationUri = destinationUri;
314     }
315
316
317 }
318
Popular Tags