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