001/*
002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of 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,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 */
019
020package org.nuxeo.ecm.core.opencmis.bindings;
021
022import org.osgi.framework.BundleActivator;
023import org.osgi.framework.BundleContext;
024import org.osgi.framework.FrameworkEvent;
025import org.osgi.framework.FrameworkListener;
026
027/**
028 * This bundle activator ensures that the init sequence happens in the right order.
029 */
030public class Activator implements BundleActivator, FrameworkListener {
031
032    /*
033     * Called when our bundle is started. All we do is ask for an event when the entire Framework is ready.
034     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext )
035     */
036    @Override
037    public void start(BundleContext context) {
038        context.addFrameworkListener(this);
039    }
040
041    @Override
042    public void stop(BundleContext context) {
043
044    }
045
046    /*
047     * This is the point where the initialization actually occurs. This is called by the framework when it's finished
048     * initializing and we echo that message to the object that we have delayed.
049     */
050    @Override
051    public void frameworkEvent(FrameworkEvent event) {
052        if (event.getType() == FrameworkEvent.STARTED) {
053            ContextListenerDelayer.activate(event);
054        }
055    }
056
057}