All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ops4j.pax.configmanager.internal.ConfigurationFileHandlerServiceTracker Maven / Gradle / Ivy

Go to download

Pax Configuration Manger Service provides a framework to read files (default property files handling is supplied) from a directory and use ConfigurationAdmin to update the service with the properties loaded.

The newest version!
/*
 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 * you may not use  this file  except in  compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed  under the  License is distributed on an "AS IS" BASIS,
 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 * implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ops4j.pax.configmanager.internal;

import org.ops4j.lang.NullArgumentException;
import org.ops4j.pax.configmanager.IConfigurationFileHandler;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;

/**
 * {@code ConfigurationFileHandlerServiceTracker} tracks {@code IConfigurationFileHandler} services.
 *
 * @author Edward Yakop
 * @author Makas Tzavellas
 */
final class ConfigurationFileHandlerServiceTracker extends ServiceTracker
{

    private static final String SERVICE_NAME = IConfigurationFileHandler.class.getName();

    private final ConfigurationAdminFacade m_configurationFacade;

    ConfigurationFileHandlerServiceTracker( BundleContext context, ConfigurationAdminFacade facade )
        throws IllegalArgumentException
    {
        super( context, SERVICE_NAME, null );

        NullArgumentException.validateNotNull( facade, "facade" );
        m_configurationFacade = facade;
    }

    @Override
    public final Object addingService( ServiceReference reference )
    {
        IConfigurationFileHandler fileHandler = (IConfigurationFileHandler) super.addingService( reference );

        m_configurationFacade.addFileHandler( fileHandler );

        return fileHandler;
    }

    @Override
    public final void removedService( ServiceReference serviceReference, Object objService )
    {
        IConfigurationFileHandler fileHandler = (IConfigurationFileHandler) objService;

        m_configurationFacade.removeFileHandler( fileHandler );

        super.removedService( serviceReference, objService );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy