KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > common > Endpoint


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.common;
18
19 import org.apache.commons.logging.Log;
20 import org.w3c.dom.Document JavaDoc;
21
22 import javax.jbi.messaging.MessageExchange;
23 import javax.jbi.messaging.MessageExchange.Role;
24 import javax.wsdl.Definition;
25 import javax.xml.namespace.QName JavaDoc;
26
27 public abstract class Endpoint {
28
29     protected QName JavaDoc service;
30     protected String JavaDoc endpoint;
31     protected QName JavaDoc interfaceName;
32     protected Document JavaDoc description;
33     protected Definition definition;
34     protected ServiceUnit serviceUnit;
35     protected Log logger;
36     
37     public Endpoint() {
38     }
39     
40     public Endpoint(ServiceUnit serviceUnit, QName JavaDoc service, String JavaDoc endpoint) {
41         this.serviceUnit = serviceUnit;
42         this.service = service;
43         this.endpoint = endpoint;
44     }
45     
46     /**
47      * @return Returns the endpoint.
48      */

49     public String JavaDoc getEndpoint() {
50         return endpoint;
51     }
52     /**
53      * @param endpoint The endpoint to set.
54      */

55     public void setEndpoint(String JavaDoc endpoint) {
56         this.endpoint = endpoint;
57     }
58     /**
59      * @return Returns the service.
60      */

61     public QName JavaDoc getService() {
62         return service;
63     }
64     /**
65      * @param service The service to set.
66      */

67     public void setService(QName JavaDoc service) {
68         this.service = service;
69     }
70     /**
71      * @return Returns the role.
72      */

73     public abstract Role getRole();
74     /**
75      * @return Returns the description.
76      */

77     public Document JavaDoc getDescription() {
78         return description;
79     }
80     /**
81      * @param description The description to set.
82      */

83     public void setDescription(Document JavaDoc description) {
84         this.description = description;
85     }
86     /**
87      * @return Returns the interfaceName.
88      */

89     public QName JavaDoc getInterfaceName() {
90         return interfaceName;
91     }
92     /**
93      * @param interfaceName The interfaceName to set.
94      */

95     public void setInterfaceName(QName JavaDoc interfaceName) {
96         this.interfaceName = interfaceName;
97     }
98     /**
99      * @return Returns the serviceUnit.
100      */

101     public ServiceUnit getServiceUnit() {
102         return serviceUnit;
103     }
104
105     /**
106      * @param serviceUnit The serviceUnit to set.
107      */

108     public void setServiceUnit(ServiceUnit serviceUnit) {
109         this.serviceUnit = serviceUnit;
110         this.logger = serviceUnit.component.logger;
111     }
112
113     public boolean isExchangeOkay(MessageExchange exchange) {
114         // TODO: We could check the MEP here
115
return true;
116     }
117
118     public abstract void activate() throws Exception JavaDoc;
119     
120     public abstract void deactivate() throws Exception JavaDoc;
121
122     public abstract ExchangeProcessor getProcessor();
123     
124     public String JavaDoc toString() {
125         return "Endpoint[service: " + service + ", " +
126                         "endpoint: " + endpoint + ", " +
127                         "role: " + (getRole() == Role.PROVIDER ? "provider" : "consumer") + "]";
128     }
129
130     public Definition getDefinition() {
131         return definition;
132     }
133
134     public void setDefinition(Definition definition) {
135         this.definition = definition;
136     }
137
138 }
139
Popular Tags