View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/infomodel/ServiceImpl.java,v 1.14 2003/07/23 01:14:51 farrukh_najmi Exp $ 3 * 4 * 5 */ 6 7 package com.sun.xml.registry.ebxml.infomodel; 8 9 import javax.xml.registry.*; 10 import javax.xml.registry.infomodel.*; 11 import java.util.*; 12 import java.io.*; 13 14 import org.oasis.ebxml.registry.bindings.rim.ServiceType; 15 import org.oasis.ebxml.registry.bindings.rim.ServiceBindingType; 16 import org.oasis.ebxml.registry.bindings.rim.ObjectRef; 17 18 19 import com.sun.xml.registry.ebxml.LifeCycleManagerImpl; 20 21 /*** 22 * Class Declaration for Class1 23 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 24 */ 25 public class ServiceImpl extends RegistryEntryImpl implements Service { 26 27 private HashSet bindings = new HashSet(); 28 private Organization providingOrg = null; 29 30 public ServiceImpl(LifeCycleManagerImpl lcm) throws JAXRException { 31 super(lcm); 32 } 33 34 public ServiceImpl(LifeCycleManagerImpl lcm, ServiceType ebService) 35 throws JAXRException { 36 super(lcm, ebService); 37 38 ServiceBindingType[] ebBindings = ebService.getServiceBinding(); 39 for (int i = 0; i < ebBindings.length; i++) { 40 addServiceBinding(new ServiceBindingImpl(lcm, ebBindings[i])); 41 } 42 } 43 44 public String toXML() throws JAXRException { 45 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType ebObj = toBindingObject(); 46 StringWriter sw = new StringWriter(); 47 try { 48 ebObj.marshal(sw); 49 } catch (org.exolab.castor.xml.MarshalException x) { 50 throw new JAXRException(x); 51 } catch (org.exolab.castor.xml.ValidationException x) { 52 throw new JAXRException(x); 53 } 54 return sw.toString(); 55 } 56 57 public void setProvidingOrganization(Organization org) throws JAXRException { 58 providingOrg = org; 59 if (org != providingOrg) { 60 if (!(org instanceof OrganizationImpl)) { 61 throw new InvalidRequestException("Expected OrganizationImpl, got " + org); 62 } 63 providingOrg = (OrganizationImpl)org; 64 setModified(true); 65 } 66 } 67 68 public void addServiceBinding(ServiceBinding binding) throws JAXRException { 69 bindings.add(binding); 70 ((ServiceBindingImpl)binding).setService(this); 71 } 72 73 public void addServiceBindings(Collection _bindings) throws JAXRException { 74 Iterator iter = _bindings.iterator(); 75 while (iter.hasNext()) { 76 Object obj = (ServiceBindingImpl)iter.next(); 77 if (!(obj instanceof ServiceBindingImpl)) { 78 throw new InvalidRequestException("Expected ServiceBindingImpl, got " + obj); 79 } 80 ServiceBindingImpl binding = (ServiceBindingImpl)obj; 81 addServiceBinding(binding); 82 } 83 } 84 85 public void removeServiceBinding(ServiceBinding binding) throws JAXRException { 86 bindings.remove(binding); 87 ((ServiceBindingImpl)binding).setService(null); 88 } 89 90 public void removeServiceBindings(Collection _bindings) throws JAXRException { 91 Iterator iter = _bindings.iterator(); 92 while (iter.hasNext()) { 93 Object obj = (ServiceBindingImpl)iter.next(); 94 if (!(obj instanceof ServiceBindingImpl)) { 95 throw new InvalidRequestException("Expected ServiceBindingImpl, got " + obj); 96 } 97 ServiceBindingImpl binding = (ServiceBindingImpl)obj; 98 removeServiceBinding(binding); 99 } 100 } 101 102 public Collection getServiceBindings() throws JAXRException { 103 return bindings; 104 } 105 106 public Organization getProvidingOrganization() throws javax.xml.registry.JAXRException { 107 return providingOrg; 108 } 109 110 /*** 111 * This method takes this JAXR infomodel object and returns an 112 * equivalent binding object for it. Note it does the reverse of one 113 * of the constructors above. 114 */ 115 public org.oasis.ebxml.registry.bindings.rim.Service toBindingObject() throws JAXRException { 116 org.oasis.ebxml.registry.bindings.rim.Service ebService = 117 new org.oasis.ebxml.registry.bindings.rim.Service(); 118 119 setBindingObject(ebService); 120 121 return ebService; 122 } 123 124 protected void setBindingObject(org.oasis.ebxml.registry.bindings.rim.ServiceType ebService) throws JAXRException { 125 super.setBindingObject(ebService); 126 127 Iterator iter = getServiceBindings().iterator(); 128 while (iter.hasNext()) { 129 ServiceBindingImpl binding = (ServiceBindingImpl)iter.next(); 130 ebService.addServiceBinding(binding.toBindingObject()); 131 } 132 } 133 134 public void getComposedObjects(HashSet composedObjects) throws JAXRException { 135 super.getComposedObjects(composedObjects); 136 137 Collection bindings = getServiceBindings(); 138 composedObjects.addAll(bindings); 139 Iterator iter = bindings.iterator(); 140 while (iter.hasNext()) { 141 ServiceBindingImpl binding = (ServiceBindingImpl)iter.next(); 142 binding.getComposedObjects(composedObjects); 143 } 144 } 145 146 }

This page was automatically generated by Maven