This project has retired. For details please refer to its Attic page.
Coverage Report
Coverage Report - org.apache.ws.scout.registry.infomodel.ServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceImpl
57%
20/35
37%
3/8
1.9
 
 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  
 
 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.BusinessQueryManager;
 24  
 import javax.xml.registry.JAXRException;
 25  
 import javax.xml.registry.LifeCycleManager;
 26  
 import javax.xml.registry.RegistryService;
 27  
 import javax.xml.registry.UnexpectedObjectException;
 28  
 import javax.xml.registry.infomodel.Organization;
 29  
 import javax.xml.registry.infomodel.Service;
 30  
 import javax.xml.registry.infomodel.ServiceBinding;
 31  
 
 32  
 /**
 33  
  * Implements JAXR Interface.
 34  
  * For futher details, look into the JAXR API Javadoc.
 35  
  *
 36  
  * @author Anil Saldhana  <anil@apache.org>
 37  
  */
 38  
 public class ServiceImpl extends RegistryEntryImpl implements Service
 39  
 {
 40  
 
 41  116
     private Organization org = null;
 42  116
     private Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
 43  116
     private String orgKey = null;
 44  
     
 45  
     /**
 46  
      * Creates a new instance of ServiceImpl
 47  
      */
 48  
     public ServiceImpl(LifeCycleManager lifeCycleManager)
 49  
     {
 50  116
         super(lifeCycleManager);
 51  116
     }
 52  
 
 53  
     public void addServiceBinding(ServiceBinding sb)
 54  
             throws JAXRException
 55  
     {
 56  56
         serviceBindings.add(sb);
 57  56
         ((ServiceBindingImpl)sb).setService(this);
 58  56
     }
 59  
 
 60  
     public void addServiceBindings(Collection col)
 61  
             throws JAXRException
 62  
     {
 63  
        try{
 64  2
         Iterator iter = col.iterator();
 65  4
         while(iter.hasNext())
 66  
         {
 67  2
             addServiceBinding((ServiceBinding)iter.next());
 68  
         }
 69  0
        }catch(ClassCastException ce)
 70  
        {
 71  0
            throw new UnexpectedObjectException(ce.getLocalizedMessage());
 72  2
        }
 73  2
     }
 74  
 
 75  
     public Organization getProvidingOrganization()
 76  
             throws JAXRException
 77  
     {
 78  20
         if (org == null) {
 79  0
                 if (super.getSubmittingOrganization() != null) {
 80  0
                         return super.getSubmittingOrganization();
 81  
                 } else {
 82  0
                         RegistryService rs = super.getLifeCycleManager().getRegistryService();
 83  0
                         BusinessQueryManager bqm = rs.getBusinessQueryManager();
 84  0
                         if (orgKey==null) return null;
 85  0
                 Organization o = (Organization) bqm.getRegistryObject(orgKey,
 86  
                         LifeCycleManager.ORGANIZATION);
 87  0
                 setProvidingOrganization(o);        
 88  0
                 return o;
 89  
                 }
 90  
         }
 91  20
         return org;
 92  
     }
 93  
 
 94  
     public Collection getServiceBindings() throws JAXRException
 95  
     {
 96  30
         return serviceBindings;
 97  
     }
 98  
 
 99  
     public void removeServiceBinding(ServiceBinding serviceBinding)
 100  
             throws JAXRException
 101  
     {
 102  0
         serviceBindings.remove(serviceBinding);
 103  0
     }
 104  
 
 105  
     public void removeServiceBindings(Collection collection)
 106  
             throws JAXRException
 107  
     {
 108  0
         serviceBindings.removeAll(collection);
 109  0
     }
 110  
 
 111  
     public void setProvidingOrganization(Organization organization)
 112  
             throws JAXRException
 113  
     {
 114  46
         this.org = organization;
 115  46
     }
 116  
     
 117  
     public void setSubmittingOrganizationKey(String key) {
 118  20
             orgKey = key;
 119  20
     }
 120  
     
 121  
     public String getSubmittingOrganizationKey() {
 122  0
             return orgKey;
 123  
     }   
 124  
 }