001/* 002 Copyright (c) 2012, 2019, Anatole Tresch, Werner Keil and others by the @author tag. 003 004 Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 use this file except in compliance with the License. You may obtain a copy of 006 the License at 007 008 http://www.apache.org/licenses/LICENSE-2.0 009 010 Unless required by applicable law or agreed to in writing, software 011 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 License for the specific language governing permissions and limitations under 014 the License. 015 */ 016package org.javamoney.moneta.convert.imf; 017 018import org.javamoney.moneta.OSGIServiceHelper; 019import org.osgi.framework.BundleActivator; 020import org.osgi.framework.BundleContext; 021 022import javax.money.convert.ExchangeRateProvider; 023import java.util.logging.Logger; 024 025/** 026 * A bundle activator that registers the OSGI services. 027 */ 028public class OSGIActivator implements BundleActivator { 029 030 private static final Logger LOG = Logger.getLogger(OSGIActivator.class.getName()); 031 032 @Override 033 public void start(BundleContext context) { 034 LOG.info("Registering JavaMoney services..."); 035 OSGIServiceHelper.registerService(context.getBundle(), ExchangeRateProvider.class, IMFRateProvider.class); 036 LOG.info("Registered JavaMoney services..."); 037 } 038 039 @Override 040 public void stop(BundleContext context) { 041 LOG.info("Unregistering JavaMoney services..."); 042 OSGIServiceHelper.unregisterService(context.getBundle(), ExchangeRateProvider.class, IMFRateProvider.class); 043 } 044}