1 19 package org.sample.registry.model.impl; 20 21 import java.util.Collections ; 22 import java.util.List ; 23 import org.sample.registry.model.RegistryComponent; 24 import org.sample.registry.model.RegistryVisitor; 25 import org.sample.registry.model.Service; 26 import org.sample.registry.model.ServiceProvider; 27 import org.sample.registry.model.ServiceType; 28 import org.w3c.dom.Element ; 29 30 public class ServiceImpl extends RegistryComponentImpl.Named implements Service { 31 32 public ServiceImpl(RegistryModelImpl model, Element e) { 33 super(model, e); 34 } 35 36 public ServiceImpl(RegistryModelImpl model) { 37 this(model, createElementNS(model, RegistryQNames.SERVICE)); 38 } 39 40 public Reference<ServiceType> getServiceType() { 41 String type = getAttribute(RegistryAttributes.TYPE); 42 if (type != null) { 43 return new Reference<ServiceType>(type, ServiceType.class, this); 44 } else { 45 return null; 46 } 47 } 48 49 public void setServiceType(Reference<ServiceType> type) { 50 String v = type == null ? null : type.getRefString(); 51 setAttribute(SERVICE_TYPE_PROPERTY, RegistryAttributes.TYPE, v); 52 } 53 54 public Integer getCapacity() { 55 String v = getAttribute(RegistryAttributes.CAPACITY); 56 if (v != null) { 57 return Integer.valueOf(v); 58 } else { 59 return null; 60 } 61 } 62 63 public void setCapacity(Integer capacity) { 64 super.setAttribute(CAPACITY_PROPERTY, RegistryAttributes.CAPACITY, capacity); 65 } 66 67 public ServiceProvider getProvider() { 68 return getChild(ServiceProvider.class); 69 } 70 71 public void setProvider(ServiceProvider provider) { 72 List <Class <? extends RegistryComponent>> empty = Collections.emptyList(); 73 setChild(ServiceProvider.class, SERVICE_PROVIDER_PROPERTY, provider, empty); 74 } 75 76 public void accept(RegistryVisitor visitor) { 77 visitor.visit(this); 78 } 79 } 80 | Popular Tags |