@@ -0,0 +1,1343 @@
+package be.iminds.iot.firefly.application.actions;%0A%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.UUID;%0A%0Aimport org.osgi.service.component.annotations.Component;%0Aimport org.osgi.service.component.annotations.Reference;%0Aimport org.osgi.service.component.annotations.ReferenceCardinality;%0Aimport org.osgi.service.component.annotations.ReferencePolicy;%0A%0Aimport be.iminds.iot.firefly.application.Actions;%0Aimport be.iminds.iot.things.api.Thing;%0Aimport be.iminds.iot.things.api.lamp.Lamp;%0A%0A@Component(property=%7B%22aiolos.proxy=false%22%7D)%0Apublic class LampActions implements Actions %7B%0A%0A%09private Map%3CUUID, Lamp%3E lamps = Collections.synchronizedMap(new HashMap%3CUUID, Lamp%3E());%0A%09%0A%09@Override%0A%09public String getType() %7B%0A%09%09return %22lamp%22;%0A%09%7D%0A%0A%09@Override%0A%09public void action(UUID id, String... params) %7B%0A%09%09Lamp lamp = lamps.get(id);%0A%09%09if(lamp!=null)%7B%0A%09%09%09if(params.length==0)%7B%0A%09%09%09%09// default action - switch camera on/off%0A%09%09%09%09lamp.toggle();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09@Reference(cardinality=ReferenceCardinality.MULTIPLE,%0A%09%09%09policy=ReferencePolicy.DYNAMIC)%0A%09public void addLamp(Lamp l, Map%3CString, Object%3E properties)%7B%0A%09%09UUID id = (UUID) properties.get(Thing.ID);%0A%09%09lamps.put(id, l);%0A%09%7D%0A%09%0A%09public void removeLamp(Lamp l, Map%3CString, Object%3E properties)%7B%0A%09%09UUID id = (UUID) properties.get(Thing.ID);%0A%09%09lamps.remove(id);%0A%09%7D%0A%0A%09%0A%7D%0A

add default toggle action for Lamps