001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and contributors.
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 *     gracinet
018 *
019 * $Id$
020 */
021
022package org.nuxeo.runtime.test;
023
024import java.net.URL;
025
026import org.apache.commons.logging.Log;
027import org.apache.commons.logging.LogFactory;
028import org.nuxeo.runtime.api.Framework;
029import org.nuxeo.runtime.osgi.OSGiComponentLoader;
030import org.nuxeo.runtime.osgi.OSGiRuntimeActivator;
031import org.nuxeo.runtime.osgi.OSGiRuntimeService;
032import org.osgi.framework.BundleContext;
033
034/**
035 * @author gracinet
036 */
037public class OSGIRuntimeTestActivator extends OSGiRuntimeActivator {
038
039    private static final Log log = LogFactory.getLog(OSGIRuntimeTestActivator.class);
040
041    @Override
042    public void start(BundleContext context) {
043        log.info("Starting Runtime Activator");
044        // create the runtime
045        runtime = new OSGiRuntimeService(context);
046
047        // load main config file if any
048        URL config = context.getBundle().getResource("/OSGI-INF/nuxeo.properties");
049        if (config != null) {
050            System.setProperty(OSGiRuntimeService.PROP_CONFIG_DIR, config.toExternalForm());
051        }
052
053        initialize(runtime);
054        // start it
055        Framework.initialize(runtime);
056        // register bundle component loader
057        componentLoader = new OSGiComponentLoader(runtime);
058        // TODO register osgi services
059    }
060
061}