...
Code Block | ||||
---|---|---|---|---|
| ||||
package com.cognifide.app.core; import java.util.ArrayList; import java.util.List; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import com.cognifide.slice.api.context.ContextScope; import com.cognifide.slice.api.injector.InjectorRunner; import com.cognifide.slice.commons.SliceModulesFactory; import com.cognifide.slice.core.internal.context.SliceContextScope; import com.cognifide.slice.cq.module.CQModulesFactory; import com.cognifide.slice.validation.ValidationModulesFactory; import com.google.inject.Module; public class Activator implements BundleActivator { private static final String BUNDLE_NAME_FILTER = "com\\.cognifide\\.app\\..*"; private static final String BASE_PACKAGE = "com.cognifide.app"; private static final String INJECTOR_NAME = "myapp"; @Override @Override public void start(final BundleContext bundleContext) throws Exception { final ContextScope scope = new SliceContextScope(); final final InjectorRunner injectorRunner = new InjectorRunner(bundleContext, INJECTOR_NAME, scope); List<Module> sliceModules = SliceModulesFactory.createModules(bundleContext, INJECTOR_NAME, BUNDLE_NAME_FILTER, BASE_PACKAGE); final List<Module> cqModulessliceModules = CQModulesFactorySliceModulesFactory.createModules(bundleContext); final List<Module> validationModulescqModules = ValidationModulesFactoryCQModulesFactory.createModules(); final List<Module> customModules = createCustomModules(); injectorRunner.installModules(sliceModules); injectorRunner.installModules(cqModules); injectorRunner.installModules(validationModules); injectorRunner.installModules(customModules); injectorRunner.start(); } private List<Module> createCustomModules() { List<Module> applicationModules = new ArrayList<Module>(); //populate the list with your modules return applicationModules; } } |
...