// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/Thing.java
// public interface Thing {
// 
//     public final static String ID = "thing.id";
//     public final static String DEVICE = "thing.device";
//     public final static String SERVICE = "thing.service";
//     public final static String GATEWAY = "thing.gateway";
//     public final static String TYPE = "thing.type";
//     
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/ChangeEvent.java
// public class ChangeEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public String stateVariable; /* state variable that changed */
// 	public Object stateValue; /* new value of the state variable */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/OfflineEvent.java
// public class OfflineEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/OnlineEvent.java
// public class OnlineEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public String service; /* service of the thing */
// 	public String device; /* device name of the thing */
// 	public String type; /* thing type */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.dyamand.event.Event;
import org.dyamand.event.EventListener;
import org.dyamand.event.ServicePOJOOfflineEvent;
import org.dyamand.event.ServicePOJOOnlineEvent;
import org.dyamand.event.StateChangedEvent;
import org.dyamand.service.ServicePOJO;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventProperties;
import osgi.enroute.dto.api.DTOs;
import be.iminds.iot.things.api.Thing;
import be.iminds.iot.things.api.event.ChangeEvent;
import be.iminds.iot.things.api.event.OfflineEvent;
import be.iminds.iot.things.api.event.OnlineEvent;
			e.type = type;
			e.timestamp = System.currentTimeMillis();
	
			final String topic = "be/iminds/iot/thing/online/"+thingId;
			ea.sendEvent(new org.osgi.service.event.Event(topic, dtos.asMap(e)));
		} catch(Exception e){
			System.err.println("Error sending online event "+e);
		}
	}
	
	private void notifyOffline(
			final UUID thingId){	    
		try {
			OfflineEvent e = new OfflineEvent();
			e.thingId = thingId;
			e.gatewayId = gatewayId;
			e.timestamp = System.currentTimeMillis();
	
		    final String topic = "be/iminds/iot/thing/offline/"+thingId;
			ea.sendEvent(new org.osgi.service.event.Event(topic, dtos.asMap(e)));
		} catch(Exception e){
			System.err.println("Error sending offline event "+e);
		}
	}
	
	private void notifiyStateChange(
			final UUID thingId, 
			final String stateVariable, 
			final Object stateValue){
		try {
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/Thing.java
// public interface Thing {
// 
//     public final static String ID = "thing.id";
//     public final static String DEVICE = "thing.device";
//     public final static String SERVICE = "thing.service";
//     public final static String GATEWAY = "thing.gateway";
//     public final static String TYPE = "thing.type";
//     
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/ChangeEvent.java
// public class ChangeEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public String stateVariable; /* state variable that changed */
// 	public Object stateValue; /* new value of the state variable */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/OfflineEvent.java
// public class OfflineEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }
// 
// Path: be.iminds.iot.things.api/src/be/iminds/iot/things/api/event/OnlineEvent.java
// public class OnlineEvent {
// 	
// 	public UUID thingId; /* id of the thing */
// 	public UUID gatewayId; /* gateway that published the event */
// 	public String service; /* service of the thing */
// 	public String device; /* device name of the thing */
// 	public String type; /* thing type */
// 	public long timestamp; /* timestamp the event was generated */
// 	
// }


// Path: be.iminds.iot.things.dyamand.adapter/src/be/iminds/iot/things/dyamand/adapter/DyamandAdapter.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.dyamand.event.Event;
import org.dyamand.event.EventListener;
import org.dyamand.event.ServicePOJOOfflineEvent;
import org.dyamand.event.ServicePOJOOnlineEvent;
import org.dyamand.event.StateChangedEvent;
import org.dyamand.service.ServicePOJO;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventProperties;
import osgi.enroute.dto.api.DTOs;
import be.iminds.iot.things.api.Thing;
import be.iminds.iot.things.api.event.ChangeEvent;
import be.iminds.iot.things.api.event.OfflineEvent;
import be.iminds.iot.things.api.event.OnlineEvent;

			e.type = type;
			e.timestamp = System.currentTimeMillis();
	
			final String topic = "be/iminds/iot/thing/online/"+thingId;
			ea.sendEvent(new org.osgi.service.event.Event(topic, dtos.asMap(e)));
		} catch(Exception e){
			System.err.println("Error sending online event "+e);
		}
	}
	
	private void notifyOffline(
			final UUID thingId){	    
		try {
			OfflineEvent e = new OfflineEvent();
			e.thingId = thingId;
			e.gatewayId = gatewayId;
			e.timestamp = System.currentTimeMillis();
	
		    final String topic = "be/iminds/iot/thing/offline/"+thingId;
			ea.sendEvent(new org.osgi.service.event.Event(topic, dtos.asMap(e)));
		} catch(Exception e){
			System.err.println("Error sending offline event "+e);
		}
	}
	
	private void notifiyStateChange(
			final UUID thingId, 
			final String stateVariable, 
			final Object stateValue){
		try {
			ChangeEvent e = new ChangeEvent();