com.cognifide.slice.commons.SliceModulesFactory Maven / Gradle / Ivy
package com.cognifide.slice.commons;
import java.util.ArrayList;
import java.util.List;
import org.ops4j.peaberry.Peaberry;
import org.osgi.framework.BundleContext;
import com.cognifide.slice.api.context.ContextScope;
import com.cognifide.slice.core.internal.context.SliceContextScope;
import com.cognifide.slice.core.internal.module.ContextModule;
import com.cognifide.slice.core.internal.module.JcrModule;
import com.cognifide.slice.core.internal.module.LinkModule;
import com.cognifide.slice.core.internal.module.SliceModule;
import com.cognifide.slice.core.internal.module.SliceResourceModule;
import com.cognifide.slice.core.internal.module.SlingModule;
import com.google.inject.Module;
/**
* Factory for all Slice-related modules. It should be used in application's activator to register
* Slice-related modules
*
* @author maciej.majchrzak
*
*/
public class SliceModulesFactory {
private SliceModulesFactory() {
}
/**
* Creates and returns a list of all Slice-related modules, including framework's internal modules as well
* as Sling's and JCR's ones. The list includes:
*
* - Peaberry module
* - {@link SliceModule}
* - {@link SlingModule}
* - {@link JcrModule}
* - {@link LinkModule}
* - {@link ContextModule}
* - {@link SliceResourceModule}
*
*
* @return list of Slice-related modules
*/
public static List createModules(final BundleContext bundleContext, final String injectorName,
final String bundleNameFilter, final String basePackage) {
final ContextScope contextScope = new SliceContextScope();
List modules = new ArrayList();
modules.add(Peaberry.osgiModule(bundleContext));
modules.add(new SliceModule(injectorName, contextScope));
modules.add(new SlingModule(contextScope));
modules.add(new JcrModule());
modules.add(new LinkModule());
modules.add(new ContextModule());
modules.add(new SliceResourceModule(bundleContext, bundleNameFilter, basePackage));
return modules;
}
}