All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.osgi.ApplicationContextBundleContextRegistrar Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.osgi;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.launch.Framework;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Registers the {@link ApplicationContext} as a service in the OSGi {@link Framework}.
 * 

* This enables OSGi {@link Bundle}s to directly reference named dependencies. * * @author Laurens Fridael * */ public class ApplicationContextBundleContextRegistrar implements BundleContextRegistrar, ApplicationContextAware { private static final String COMPONENT_NAME = "HostApplicationContext"; private static final String OSGI_SERVICE_BLUEPRINT_COMPNAME = "osgi.service.blueprint.compname"; /* Dependencies */ private ApplicationContext applicationContext; /* Main operations */ @Override public List> registerInBundleContext(final BundleContext bundleContext) { final Hashtable serviceProperties = new Hashtable(); serviceProperties.put(OSGI_SERVICE_BLUEPRINT_COMPNAME, COMPONENT_NAME); serviceProperties.put("hostApplication", "alfresco"); final List> registrations = new ArrayList>(); registrations.add(bundleContext .registerService(ApplicationContext.class, applicationContext, serviceProperties)); return registrations; } /* Dependencies */ @Override public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy