com.github.dynamicextensionsalfresco.controlpanel.Container Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of control-panel Show documentation
Show all versions of control-panel Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.controlpanel;
import com.github.dynamicextensionsalfresco.controlpanel.template.TemplateBundle;
import com.github.dynamicextensionsalfresco.controlpanel.template.TemplateServiceReference;
import com.github.dynamicextensionsalfresco.controlpanel.template.Variables;
import com.github.dynamicextensionsalfresco.osgi.RepositoryStoreService;
import com.github.dynamicextensionsalfresco.webscripts.annotations.Attribute;
import com.github.dynamicextensionsalfresco.webscripts.annotations.Authentication;
import com.github.dynamicextensionsalfresco.webscripts.annotations.AuthenticationType;
import com.github.dynamicextensionsalfresco.webscripts.annotations.Cache;
import com.github.dynamicextensionsalfresco.webscripts.annotations.HttpMethod;
import com.github.dynamicextensionsalfresco.webscripts.annotations.Uri;
import com.github.dynamicextensionsalfresco.webscripts.annotations.UriVariable;
import com.github.dynamicextensionsalfresco.webscripts.annotations.WebScript;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanIsAbstractException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* Handles requests for the configuration page.
*
* @author Laurens Fridael
*
*/
@Component
@WebScript(baseUri = "/dynamic-extensions/container", defaultFormat = "html", families = "control panel")
@Authentication(AuthenticationType.ADMIN)
@Cache(neverCache = true)
public class Container extends AbstractControlPanelHandler {
/* Dependencies */
@Autowired
private BundleHelper bundleHelper;
@Autowired
private FileFolderService fileFolderService;
@Autowired
private NodeService nodeService;
@Autowired
private RepositoryStoreService repositoryStoreService;
/* Main operations */
@Uri(method = HttpMethod.GET)
public Map index() {
return Collections.emptyMap();
}
@Uri(method = HttpMethod.GET, value = "/system-packages")
public Map systemPackages() {
return model(Variables.SYSTEM_PACKAGES, getSystemPackages());
}
@Uri(method = HttpMethod.GET, value = "/services")
public Map services() {
return model(Variables.SERVICES_BY_BUNDLE, getTemplateServicesByBundle());
}
@Uri(method = HttpMethod.GET, value = "/services/bundle/{bundleid}/{serviceIndex}")
public Map service(@UriVariable final long bundleid, @UriVariable int serviceIndex) {
final List servicesByBundle = getTemplateServicesByBundle();
TemplateServiceReference serviceReferences = null;
for (TemplateBundle templateBundle : servicesByBundle) {
if (templateBundle.getBundleId() == bundleid) {
serviceReferences = templateBundle.getServices().get(serviceIndex);
break;
}
}
final Object context;
if (serviceReferences != null) {
@SuppressWarnings("unchecked")
final ServiceReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy