001: /*
002: * Copyright 2001-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.ws.scout.registry.infomodel;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
020: import java.util.Iterator;
021:
022: import javax.xml.registry.InvalidRequestException;
023: import javax.xml.registry.JAXRException;
024: import javax.xml.registry.LifeCycleManager;
025: import javax.xml.registry.UnexpectedObjectException;
026: import javax.xml.registry.infomodel.InternationalString;
027: import javax.xml.registry.infomodel.Service;
028: import javax.xml.registry.infomodel.ServiceBinding;
029: import javax.xml.registry.infomodel.SpecificationLink;
030:
031: /**
032: * Implements JAXR Interface.
033: * For futher details, look into the JAXR API Javadoc.
034: *
035: * @author Anil Saldhana <anil@apache.org>
036: */
037: public class ServiceBindingImpl extends RegistryObjectImpl implements
038: ServiceBinding {
039: private Collection<SpecificationLink> links = new ArrayList<SpecificationLink>();
040: private String accessuri = null;
041: private Service service = null;
042: private ServiceBinding targetbinding = null;
043: private boolean validateuri = false;
044:
045: public ServiceBindingImpl(LifeCycleManager lifeCycleManager) {
046: super (lifeCycleManager);
047: }
048:
049: public ServiceBindingImpl(LifeCycleManager lifeCycleManager,
050: InternationalString n) {
051: super (lifeCycleManager, n);
052: }
053:
054: public void addSpecificationLink(SpecificationLink sl)
055: throws JAXRException {
056: links.add(sl);
057: ((SpecificationLinkImpl) sl).setServiceBinding(this );
058: }
059:
060: public void addSpecificationLinks(Collection col)
061: throws JAXRException {
062: try {
063: Iterator iter = col.iterator();
064: while (iter.hasNext()) {
065: addSpecificationLink((SpecificationLink) iter.next());
066: }
067: } catch (ClassCastException e) {
068: throw new UnexpectedObjectException();
069: }
070: }
071:
072: public String getAccessURI() throws JAXRException {
073: return accessuri;
074: }
075:
076: public Service getService() throws JAXRException {
077: return service;
078: }
079:
080: public Collection getSpecificationLinks() throws JAXRException {
081: return links;
082: }
083:
084: public ServiceBinding getTargetBinding() throws JAXRException {
085: return targetbinding;
086: }
087:
088: public void removeSpecificationLink(SpecificationLink link)
089: throws JAXRException {
090: links.remove(link);
091: }
092:
093: public void removeSpecificationLinks(
094: Collection<SpecificationLink> col) throws JAXRException {
095: links.removeAll(col);
096: }
097:
098: public void setAccessURI(String s) throws JAXRException {
099: if (targetbinding != null)
100: throw new InvalidRequestException(
101: "There is already a Target Binding defined");
102: accessuri = s;
103: }
104:
105: public void setTargetBinding(ServiceBinding sb)
106: throws JAXRException {
107: if (accessuri != null)
108: throw new InvalidRequestException(
109: "There is already an Access URI defined");
110:
111: targetbinding = sb;
112: }
113:
114: public boolean getValidateURI() throws JAXRException {
115: return validateuri;
116: }
117:
118: public void setValidateURI(boolean b) throws JAXRException {
119: validateuri = b;
120: }
121:
122: //Specific API
123: public void setService(Service s) {
124: service = s;
125: }
126: }
|