KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > wsn > AbstractEndpoint


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.wsn;
18
19 import org.w3._2005._08.addressing.AttributedURIType;
20 import org.w3._2005._08.addressing.EndpointReferenceType;
21
22 public abstract class AbstractEndpoint {
23
24     protected String JavaDoc name;
25     protected String JavaDoc address;
26     protected EndpointManager manager;
27     protected Object JavaDoc endpoint;
28     
29     public AbstractEndpoint(String JavaDoc name) {
30         setName(name);
31     }
32     
33     public String JavaDoc getName() {
34         return name;
35     }
36
37     public void setName(String JavaDoc name) {
38         this.name = name;
39         this.address = createAddress();
40     }
41
42     public String JavaDoc getAddress() {
43         return address;
44     }
45     
46     public void setAddress(String JavaDoc address) {
47         this.address = address;
48     }
49     
50     public void register() throws EndpointRegistrationException {
51         endpoint = manager.register(getAddress(), this);
52     }
53     
54     public void unregister() throws EndpointRegistrationException {
55         if (endpoint != null) {
56             manager.unregister(endpoint);
57         }
58     }
59
60     public EndpointManager getManager() {
61         return manager;
62     }
63
64     public void setManager(EndpointManager manager) {
65         this.manager = manager;
66     }
67     
68     protected abstract String JavaDoc createAddress();
69
70     public static EndpointReferenceType createEndpointReference(String JavaDoc address) {
71         EndpointReferenceType epr = new EndpointReferenceType();
72         AttributedURIType addressUri = new AttributedURIType();
73         addressUri.setValue(address);
74         epr.setAddress(addressUri);
75         return epr;
76     }
77
78 }
79
Popular Tags