com.cognifide.slice.commons.SliceModulesFactory Maven / Gradle / Ivy
/*-
* #%L
* Slice - Core
* %%
* Copyright (C) 2012 Cognifide Limited
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
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.JcrModule;
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.cognifide.slice.persistence.impl.module.PersistenceModule;
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 SliceResourceModule}
*
* @param bundleContext bundle Context
* @return list of Slice-related modules
*/
public static List createModules(final BundleContext bundleContext) {
final ContextScope contextScope = new SliceContextScope();
List modules = new ArrayList();
modules.add(Peaberry.osgiModule(bundleContext));
modules.add(new SliceModule(contextScope, bundleContext.getBundle()));
modules.add(new SlingModule(contextScope));
modules.add(new JcrModule());
modules.add(new SliceResourceModule());
modules.add(new PersistenceModule());
return modules;
}
}