1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class ServiceImpl extends RegistryEntryImpl implements Service |
39 | |
{ |
40 | |
|
41 | 0 | private Organization org = null; |
42 | 0 | private Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>(); |
43 | 0 | private String orgKey = null; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public ServiceImpl(LifeCycleManager lifeCycleManager) |
49 | |
{ |
50 | 0 | super(lifeCycleManager); |
51 | 0 | } |
52 | |
|
53 | |
public void addServiceBinding(ServiceBinding sb) |
54 | |
throws JAXRException |
55 | |
{ |
56 | 0 | serviceBindings.add(sb); |
57 | 0 | ((ServiceBindingImpl)sb).setService(this); |
58 | 0 | } |
59 | |
|
60 | |
public void addServiceBindings(Collection col) |
61 | |
throws JAXRException |
62 | |
{ |
63 | |
try{ |
64 | 0 | Iterator iter = col.iterator(); |
65 | 0 | while(iter.hasNext()) |
66 | |
{ |
67 | 0 | addServiceBinding((ServiceBinding)iter.next()); |
68 | |
} |
69 | 0 | }catch(ClassCastException ce) |
70 | |
{ |
71 | 0 | throw new UnexpectedObjectException(ce.getLocalizedMessage()); |
72 | 0 | } |
73 | 0 | } |
74 | |
|
75 | |
public Organization getProvidingOrganization() |
76 | |
throws JAXRException |
77 | |
{ |
78 | 0 | 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 | 0 | return org; |
92 | |
} |
93 | |
|
94 | |
public Collection getServiceBindings() throws JAXRException |
95 | |
{ |
96 | 0 | 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 | 0 | this.org = organization; |
115 | 0 | } |
116 | |
|
117 | |
public void setSubmittingOrganizationKey(String key) { |
118 | 0 | orgKey = key; |
119 | 0 | } |
120 | |
|
121 | |
public String getSubmittingOrganizationKey() { |
122 | 0 | return orgKey; |
123 | |
} |
124 | |
} |