View Javadoc

1   /*
2   Copyright 2011-2014 AGH-UST, http://www.agh.edu.pl
3   Faculty of Computer Science, Electronics and Telecommunications
4   Department of Computer Science 
5   
6   See the NOTICE file distributed with this work for additional
7   information regarding copyright ownership
8   
9   Licensed under the Apache License, Version 2.0 (the "License");
10  you may not use this file except in compliance with the License.
11  You may obtain a copy of the License at
12  
13    http://www.apache.org/licenses/LICENSE-2.0
14  
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20  */
21  package org.universAAL.ri.gateway.eimanager.impl.exporting;
22  
23  import java.io.IOException;
24  
25  import org.universAAL.middleware.container.ModuleContext;
26  import org.universAAL.middleware.rdf.Resource;
27  import org.universAAL.middleware.ui.UICaller;
28  import org.universAAL.middleware.ui.UIHandlerProfile;
29  import org.universAAL.middleware.ui.UIRequest;
30  import org.universAAL.middleware.ui.UIResponse;
31  import org.universAAL.ri.gateway.eimanager.impl.ProxyBusMember;
32  
33  public class ProxyUICaller extends ProxyBusMember {
34  
35  	private ProxiedUICaller caller;
36  	private String modalityRegex;
37  	private UIHandlerProfile[] handlerProfiles;
38  
39  	public ProxyUICaller(ExportedProxyManager manager, String targetId,
40  			ModuleContext mc, String modalityRegex,
41  			UIHandlerProfile[] handlerProfiles) {
42  		super(manager, targetId,"", mc);
43  		this.modalityRegex = modalityRegex;
44  		this.handlerProfiles = handlerProfiles;
45  		caller = new ProxiedUICaller(mc);
46  	}
47  
48  	public void invoke(UIRequest req) {
49  		caller.sendUIRequest(req);
50  	}
51  
52  	public void removeProxy() {
53  		caller.close();
54  	}
55  
56  	class ProxiedUICaller extends UICaller {
57  
58  		protected ProxiedUICaller(ModuleContext context) {
59  			super(context);
60  		}
61  
62  		public void communicationChannelBroken() {
63  		}
64  
65  		public void dialogAborted(String dialogID, Resource data) {
66  		}
67  
68  		public void handleUIResponse(UIResponse input) {
69  			try {
70  				((ExportedProxyManager) getManager()).handleUIResponse(
71  						targetId, input);
72  			} catch (IOException e) {
73  				// TODO Auto-generated catch block
74  				e.printStackTrace();
75  			}
76  		}
77  	}
78  
79  	public String getId() {
80  		return caller.getMyID();
81  	}
82  
83  	public String getModalityRegex() {
84  		return modalityRegex;
85  	}
86  
87  	public void setModalityRegex(String modalityRegex) {
88  		this.modalityRegex = modalityRegex;
89  	}
90  
91  	public UIHandlerProfile[] getHandlerProfiles() {
92  		return handlerProfiles;
93  	}
94  
95  	public void setHandlerProfiles(UIHandlerProfile[] handlerProfiles) {
96  		this.handlerProfiles = handlerProfiles;
97  	}
98  }