@@ -0,0 +1,2926 @@
+/*%0A * #%25L%0A * OW2 Chameleon - Fuchsia Framework%0A * %25%25%0A * Copyright (C) 2009 - 2014 OW2 Chameleon%0A * %25%25%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * #L%25%0A */%0Apackage org.ow2.chameleon.fuchsia.importer.philipshue;%0A%0Aimport com.philips.lighting.model.PHBridge;%0Aimport com.philips.lighting.model.PHLight;%0Aimport org.osgi.framework.BundleContext;%0Aimport org.osgi.framework.ServiceRegistration;%0Aimport org.ow2.chameleon.fuchsia.core.declaration.ImportDeclaration;%0Aimport org.ow2.chameleon.fuchsia.core.declaration.ImportDeclarationBuilder;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.*;%0A%0Apublic class FetchBridgeLampsTask extends TimerTask %7B%0A%0A    private final Logger LOG = LoggerFactory.getLogger(FetchBridgeLampsTask.class);%0A%0A    private final PHBridge bridge;%0A%0A    private final BundleContext context;%0A%0A    private final Map%3CString,ServiceRegistration%3E lamps;%0A%0A    public FetchBridgeLampsTask(PHBridge bridge,final Map%3CString,ServiceRegistration%3E lamps,BundleContext context)%7B%0A        this.bridge=bridge;%0A        this.lamps=lamps;%0A        this.context=context;%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A%0A        for(PHLight light:bridge.getResourceCache().getAllLights())%7B%0A%0A            if(!light.isReachable())%7B%0A%0A                ServiceRegistration sr=lamps.remove(light.getIdentifier());%0A                if(sr!=null)%0A                    sr.unregister();%0A%0A            %7Delse if(!lamps.keySet().contains(light.getIdentifier()))%7B%0A%0A                Map%3CString, Object%3E metadata = new HashMap%3CString, Object%3E();%0A%0A                metadata.put(%22id%22, %22light-%22+light.getIdentifier());%0A                metadata.put(%22discovery.philips.device.name%22, light.getModelNumber());%0A                metadata.put(%22discovery.philips.device.type%22, light.getClass().getName());%0A                metadata.put(%22discovery.philips.device.object%22, light);%0A%0A                Dictionary metatableService=new Hashtable(metadata);%0A%0A                ImportDeclaration declaration = ImportDeclarationBuilder.fromMetadata(metadata).build();%0A%0A                ServiceRegistration sr=context.registerService(ImportDeclaration.class,declaration,metatableService);%0A%0A                if(lamps.containsKey(light.getIdentifier()))%7B%0A                    LOG.warn(%22Lamp with identifier %7B%7D alreadu exists%22,light.getIdentifier());%0A                %7D%0A%0A                lamps.put(light.getIdentifier(),sr);%0A%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

add missing extracted thread