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.importing;
22  
23  import org.universAAL.middleware.container.ModuleContext;
24  import org.universAAL.middleware.context.ContextEvent;
25  import org.universAAL.middleware.context.ContextSubscriber;
26  import org.universAAL.middleware.context.DefaultContextPublisher;
27  import org.universAAL.middleware.context.owl.ContextProvider;
28  import org.universAAL.ri.gateway.eimanager.impl.ProxyBusMember;
29  
30  public class ProxyContextPublisher extends ProxyBusMember {
31      
32      private DefaultContextPublisher publisher;
33      
34      private ContextSubscriber subscriber;
35      
36      public ProxyContextPublisher(ContextSubscriber subscriber, ContextProvider info, ImportedProxyManager manager, String targetId,
37  	    ModuleContext mc) {
38  	super(manager, targetId,"", mc);
39  	//TODO modify
40  	//this.publisher = new DefaultContextPublisher(mc, info);
41  	this.subscriber = subscriber;
42      }
43      
44      public void publishContextEvent(ContextEvent event){
45  	subscriber.handleContextEvent(event);
46  	//publisher.publish(event);
47      }
48      
49      public void removeProxy() {
50  	publisher.close();
51      }
52      
53      public String getId() {
54  	return (publisher != null)? publisher.getMyID() : "SHOULD NOT BE SEEN";
55      }
56  }