1 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 name; 25 protected String address; 26 protected EndpointManager manager; 27 protected Object endpoint; 28 29 public AbstractEndpoint(String name) { 30 setName(name); 31 } 32 33 public String getName() { 34 return name; 35 } 36 37 public void setName(String name) { 38 this.name = name; 39 this.address = createAddress(); 40 } 41 42 public String getAddress() { 43 return address; 44 } 45 46 public void setAddress(String 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 createAddress(); 69 70 public static EndpointReferenceType createEndpointReference(String 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 |