001/* 002 * (C) Copyright 2006-2011 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 * 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; 028 029import org.nuxeo.common.Environment; 030import org.nuxeo.runtime.api.Framework; 031import org.nuxeo.runtime.osgi.OSGiComponentLoader; 032import org.nuxeo.runtime.osgi.OSGiRuntimeActivator; 033import org.nuxeo.runtime.osgi.OSGiRuntimeService; 034 035import org.osgi.framework.BundleContext; 036 037/** 038 * @author gracinet 039 */ 040public class OSGIRuntimeTestActivator extends OSGiRuntimeActivator { 041 042 private static final Log log = LogFactory.getLog(OSGIRuntimeTestActivator.class); 043 044 @Override 045 public void start(BundleContext context) { 046 log.info("Starting Runtime Activator"); 047 // create the runtime 048 runtime = new OSGiRuntimeService(context); 049 System.setProperty("java.io.tmpdir", Environment.getDefault().getTemp().getAbsolutePath()); 050 051 // load main config file if any 052 URL config = context.getBundle().getResource("/OSGI-INF/nuxeo.properties"); 053 if (config != null) { 054 System.setProperty(OSGiRuntimeService.PROP_CONFIG_DIR, config.toExternalForm()); 055 } 056 057 initialize(runtime); 058 // start it 059 Framework.initialize(runtime); 060 // register bundle component loader 061 componentLoader = new OSGiComponentLoader(runtime); 062 // TODO register osgi services 063 } 064 065}