public void start()

in testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java [107:156]


    public void start() throws Exception {
        Set<String> jars = getJars(Felix.class);
        ClassLoader classLoader = new GuardClassLoader(toURLs(jars.toArray(new String[jars.size()])), null);

        BundleActivator activator = new BundleActivator() {
            private ServiceRegistration registration;

            public void start(BundleContext context) {
                registration = context.registerService(MainService.class.getName(), new MainService() {
                    public String[] getArgs() {
                        return new String[0];
                    }
                    public int getExitCode() {
                        return 0;
                    }
                    public void setExitCode(int exitCode) {
                    }
                }, null);
            }

            public void stop(BundleContext context) {
                registration.unregister();
            }
        };
        List<BundleActivator> activations = new ArrayList<BundleActivator>();
        activations.add(activator);

        Properties props = getConfigurationProperties();
        props.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activations);

        Thread.currentThread().setContextClassLoader(classLoader);
        Class cl = classLoader.loadClass(Felix.class.getName());
        Constructor cns = cl.getConstructor(Map.class);
        platform = cns.newInstance(props);
        platform.getClass().getMethod("start").invoke(platform);

        Bundle systemBundle = (Bundle) platform;

        // call getBundleContext
        final Method getContext = systemBundle.getClass().getMethod("getBundleContext", null);

        AccessController.doPrivileged(new PrivilegedAction() {

            public Object run() {
                getContext.setAccessible(true);
                return null;
            }
        });
        context = (BundleContext) getContext.invoke(systemBundle, null);
    }