This project has retired. For details please refer to its Attic page.
ServiceBindingImpl xref
View Javadoc
1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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  package org.apache.ws.scout.registry.infomodel;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.Iterator;
21  
22  import javax.xml.registry.InvalidRequestException;
23  import javax.xml.registry.JAXRException;
24  import javax.xml.registry.LifeCycleManager;
25  import javax.xml.registry.UnexpectedObjectException;
26  import javax.xml.registry.infomodel.InternationalString;
27  import javax.xml.registry.infomodel.Service;
28  import javax.xml.registry.infomodel.ServiceBinding;
29  import javax.xml.registry.infomodel.SpecificationLink;
30  
31  /**
32   * Implements JAXR Interface.
33   * For futher details, look into the JAXR API Javadoc.
34   *
35   * @author Anil Saldhana  <anil@apache.org>
36   */
37  public class ServiceBindingImpl extends RegistryObjectImpl implements ServiceBinding
38  {
39      private Collection<SpecificationLink> links = new ArrayList<SpecificationLink>();
40      private String accessuri = null;
41      private Service service = null;
42      private ServiceBinding targetbinding = null;
43      private boolean validateuri = false;
44  
45      public ServiceBindingImpl(LifeCycleManager lifeCycleManager)
46      {
47          super(lifeCycleManager);
48      }
49  
50      public ServiceBindingImpl(LifeCycleManager lifeCycleManager, InternationalString n)
51      {
52          super(lifeCycleManager, n);
53      }
54  
55      public void addSpecificationLink(SpecificationLink sl) throws JAXRException
56      {
57          links.add(sl);
58          ((SpecificationLinkImpl)sl).setServiceBinding(this);
59      }
60  
61      public void addSpecificationLinks(Collection col) throws JAXRException
62      {
63          try
64          {
65              Iterator iter = col.iterator();
66              while(iter.hasNext())
67              {
68                 addSpecificationLink((SpecificationLink)iter.next());
69              }
70          } catch (ClassCastException e)
71          {
72              throw new UnexpectedObjectException();
73          }
74      }
75  
76      public String getAccessURI() throws JAXRException
77      {
78          return accessuri;
79      }
80  
81      public Service getService() throws JAXRException
82      {
83          return service;
84      }
85  
86      public Collection getSpecificationLinks() throws JAXRException
87      {
88          return links;
89      }
90  
91      public ServiceBinding getTargetBinding() throws JAXRException
92      {
93          return targetbinding;
94      }
95  
96      public void removeSpecificationLink(SpecificationLink link) throws JAXRException
97      {
98          links.remove(link);
99      }
100 
101     public void removeSpecificationLinks(Collection col) throws JAXRException
102     {
103         links.removeAll(col);
104     }
105 
106     public void setAccessURI(String s) throws JAXRException
107     {
108         if(targetbinding != null)
109         throw new InvalidRequestException("There is already a Target Binding defined");
110         accessuri = s;
111     }
112 
113     public void setTargetBinding(ServiceBinding sb) throws JAXRException
114     {
115         if(accessuri != null)
116                 throw new InvalidRequestException("There is already an Access URI defined");
117 
118         targetbinding = sb;
119     }
120 
121     public boolean getValidateURI() throws JAXRException
122     {
123         return validateuri;
124     }
125 
126     public void setValidateURI(boolean b) throws JAXRException
127     {
128         validateuri = b;
129     }
130 
131     //Specific API
132     public void setService(Service s)
133     {
134         service =s;
135     }
136 }