001/*
002 * (C) Copyright 2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 */
017
018package org.nuxeo.ecm.core.opencmis.bindings;
019
020import org.osgi.framework.BundleActivator;
021import org.osgi.framework.BundleContext;
022import org.osgi.framework.FrameworkEvent;
023import org.osgi.framework.FrameworkListener;
024
025/**
026 * This bundle activator ensures that the init sequence happens in the right order.
027 */
028public class Activator implements BundleActivator, FrameworkListener {
029
030    /*
031     * Called when our bundle is started. All we do is ask for an event when the entire Framework is ready.
032     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext )
033     */
034    @Override
035    public void start(BundleContext context) {
036        context.addFrameworkListener(this);
037    }
038
039    @Override
040    public void stop(BundleContext context) {
041
042    }
043
044    /*
045     * This is the point where the initialization actually occurs. This is called by the framework when it's finished
046     * initializing and we echo that message to the object that we have delayed.
047     */
048    @Override
049    public void frameworkEvent(FrameworkEvent event) {
050        if (event.getType() == FrameworkEvent.STARTED) {
051            ContextListenerDelayer.activate(event);
052        }
053    }
054
055}