Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008, 2010 VMware Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: VMware Inc. - initial contribution /
package org.eclipse.virgo.kernel.model.internal.configurationadmin;
import  org.eclipse.equinox.region.Region;
import  org.osgi.service.cm.Configuration;
import  org.osgi.service.cm.ConfigurationAdmin;
import  org.osgi.service.cm.ConfigurationListener;
An initializer responsible for registering a ModelConfigurationListener and enumerating any existing Configuration objects from ConfigurationAdmin

Concurrent Semantics
Threadsafe

    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private final BundleContext bundleContext;
    private final ConfigurationAdmin configurationAdmin;
    private final Region globalRegion;
    public ModelConfigurationListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull BundleContext bundleContext, @NonNull ConfigurationAdmin configurationAdmin, @NonNull Region globalRegion) {
        this. = artifactRepository;
        this. = bundleContext;
        this. = configurationAdmin;
        this. = globalRegion;
    }

    
Registers a ModelConfigurationListener with the service registry. Enumerates any existing Configuration objects that exist from ConfigurationAdmin.

    public void initialize() throws IOExceptionInvalidSyntaxException {
        this..track(this..registerService(ConfigurationListener.class.getCanonicalName(), configurationListenernull));
        Configuration[] configurations = this..listConfigurations(null);
        if (configurations != null) {
            for (Configuration configuration : configurations) {
                try {
                    this..add(new ConfigurationArtifact(configuration.getPid(), ));
                } catch (Exception e) {
                    .error(String.format("Exception adding configuration '%s' to the repository"configuration.getPid()), e);
                }
            }
        }
    }

    
Unregisters the listener from the service registry
    @PreDestroy
    public void destroy() {
        this..unregisterAll();
    }
New to GrepCode? Check out our FAQ X