1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.universAAL.ri.gateway.eimanager.impl.exporting;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.universAAL.middleware.bus.model.AbstractBus;
28 import org.universAAL.middleware.container.ModuleContext;
29 import org.universAAL.middleware.service.DefaultServiceCaller;
30 import org.universAAL.middleware.service.ServiceBus;
31 import org.universAAL.middleware.service.ServiceBusFacade;
32 import org.universAAL.middleware.service.ServiceCall;
33 import org.universAAL.middleware.service.ServiceCallee;
34 import org.universAAL.middleware.service.ServiceResponse;
35 import org.universAAL.middleware.service.owls.profile.ServiceProfile;
36 import org.universAAL.ri.gateway.communicator.Activator;
37 import org.universAAL.ri.gateway.eimanager.impl.ProxyBusMember;
38
39 public class ProxyServiceCaller extends ProxyBusMember {
40
41 private DefaultServiceCaller caller;
42 private String serverNamespace;
43 private String serviceType;
44 private Map<String, List<ServiceProfile>> profiles;
45 private ServiceBus bus;
46
47 public ProxyServiceCaller(final ExportedProxyManager manager,
48 final String targetId, final ModuleContext mc,
49 final String serverNamespace, final String serviceType,
50 final Map<String, List<ServiceProfile>> profiles) {
51 super(manager, targetId, "", mc);
52 caller = new DefaultServiceCaller(mc);
53 this.serverNamespace = serverNamespace;
54 this.serviceType = serviceType;
55 this.profiles = profiles;
56 bus = ServiceBusFacade.fetchBus(Activator.mc);
57 }
58
59 public ServiceResponse invoke(final ServiceCall call, final String memberId) {
60 return ((ServiceCallee) ((AbstractBus) bus).getBusMember(memberId))
61 .handleCall(call);
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 @Override
83 public void removeProxy() {
84 caller.close();
85 }
86
87 @Override
88 public String getId() {
89 return caller.getMyID();
90 }
91
92 public String getServiceType() {
93 return serviceType;
94 }
95
96 public ServiceProfile[] getProfiles() {
97 List<ServiceProfile> profilesList = new ArrayList<ServiceProfile>();
98 for (List<ServiceProfile> value : profiles.values()) {
99 profilesList.addAll(value);
100 }
101 return profilesList.toArray(new ServiceProfile[0]);
102 }
103
104 public void setProfiles(final Map<String, List<ServiceProfile>> profiles) {
105 this.profiles = profiles;
106 }
107
108 }