01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.ws.scout.registry.infomodel;
18:
19: import java.util.ArrayList;
20: import java.util.Collection;
21: import java.util.Iterator;
22:
23: import javax.xml.registry.JAXRException;
24: import javax.xml.registry.LifeCycleManager;
25: import javax.xml.registry.UnexpectedObjectException;
26: import javax.xml.registry.infomodel.Organization;
27: import javax.xml.registry.infomodel.Service;
28: import javax.xml.registry.infomodel.ServiceBinding;
29:
30: /**
31: * Implements JAXR Interface.
32: * For futher details, look into the JAXR API Javadoc.
33: *
34: * @author Anil Saldhana <anil@apache.org>
35: */
36: public class ServiceImpl extends RegistryEntryImpl implements Service {
37:
38: private Organization org = null;
39: private Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
40:
41: /**
42: * Creates a new instance of ServiceImpl
43: */
44: public ServiceImpl(LifeCycleManager lifeCycleManager) {
45: super (lifeCycleManager);
46: }
47:
48: public void addServiceBinding(ServiceBinding sb)
49: throws JAXRException {
50: serviceBindings.add(sb);
51: ((ServiceBindingImpl) sb).setService(this );
52: }
53:
54: public void addServiceBindings(Collection col) throws JAXRException {
55: try {
56: Iterator iter = col.iterator();
57: while (iter.hasNext()) {
58: addServiceBinding((ServiceBinding) iter.next());
59: }
60: } catch (ClassCastException ce) {
61: throw new UnexpectedObjectException(ce
62: .getLocalizedMessage());
63: }
64: }
65:
66: public Organization getProvidingOrganization() throws JAXRException {
67: if (org == null)
68: return super .getSubmittingOrganization();
69: return org;
70: }
71:
72: public Collection getServiceBindings() throws JAXRException {
73: return serviceBindings;
74: }
75:
76: public void removeServiceBinding(ServiceBinding serviceBinding)
77: throws JAXRException {
78: serviceBindings.remove(serviceBinding);
79: }
80:
81: public void removeServiceBindings(Collection collection)
82: throws JAXRException {
83: serviceBindings.removeAll(collection);
84: }
85:
86: public void setProvidingOrganization(Organization organization)
87: throws JAXRException {
88: this.org = organization;
89: }
90: }
|