diff --git a/core/pom.xml b/core/pom.xml index ca514b88..1f2a1f39 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -36,43 +36,38 @@ test - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-aop + org.springframework + spring-aop - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-beans + org.springframework + spring-beans - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-context + org.springframework + spring-context - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-core + org.springframework + spring-core - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-expression + org.springframework + spring-expression - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-test + org.springframework + spring-test test - - org.apache.servicemix.bundles - org.apache.servicemix.bundles.aopalliance - provided - org.osgi - org.osgi.core + osgi.core provided org.osgi - org.osgi.compendium + osgi.cmpn provided diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java index abd031ec..637340b6 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintConverterService.java @@ -14,15 +14,11 @@ package org.eclipse.gemini.blueprint.blueprint.container; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.eclipse.gemini.blueprint.blueprint.container.support.BlueprintEditorRegistrar; -import org.eclipse.gemini.blueprint.context.support.internal.security.SecurityUtils; import org.osgi.service.blueprint.container.Converter; import org.osgi.service.blueprint.container.ReifiedType; import org.springframework.beans.SimpleTypeConverter; @@ -93,19 +89,7 @@ public Object convert(final Object source, TypeDescriptor sourceType, TypeDescri return source; final ReifiedType type = TypeFactory.getType(targetType); - boolean hasSecurity = (System.getSecurityManager() != null); - AccessControlContext acc = (hasSecurity ? SecurityUtils.getAccFrom(cbf) : null); - Object result; - - if (hasSecurity) { - result = AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return doConvert(source, type); - } - }, acc); - } else { - result = doConvert(source, type); - } + Object result = doConvert(source, type); if (result != null) { return result; diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintContainerServicePublisher.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintContainerServicePublisher.java index 825bb3cc..78311ee4 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintContainerServicePublisher.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/BlueprintContainerServicePublisher.java @@ -14,15 +14,11 @@ package org.eclipse.gemini.blueprint.blueprint.container.support; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Dictionary; import java.util.Hashtable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.gemini.blueprint.context.support.internal.security.SecurityUtils; import org.eclipse.gemini.blueprint.util.OsgiBundleUtils; import org.eclipse.gemini.blueprint.util.OsgiServiceUtils; import org.osgi.framework.Bundle; @@ -100,18 +96,7 @@ private void registerService(ApplicationContext applicationContext) { if (log.isDebugEnabled()) log.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames)); - AccessControlContext acc = SecurityUtils.getAccFrom(applicationContext); - - // publish service - if (System.getSecurityManager() != null) { - registration = AccessController.doPrivileged(new PrivilegedAction() { - public ServiceRegistration run() { - return bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties); - } - }, acc); - } else { - registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties); - } + registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties); } private void unregisterService() { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/compendium/internal/cm/UpdateMethodAdapter.java b/core/src/main/java/org/eclipse/gemini/blueprint/compendium/internal/cm/UpdateMethodAdapter.java index 70b0d31e..083a0c74 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/compendium/internal/cm/UpdateMethodAdapter.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/compendium/internal/cm/UpdateMethodAdapter.java @@ -49,8 +49,8 @@ class UpdateMethodAdapter { * @return */ static Map determineUpdateMethod(final Class target, final String methodName) { - Assert.notNull(target); - Assert.notNull(methodName); + Assert.notNull(target, "required field"); + Assert.notNull(methodName, "required field"); final Map methods = new LinkedHashMap(2); final boolean trace = log.isTraceEnabled(); diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/AbstractReferenceDefinitionParser.java b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/AbstractReferenceDefinitionParser.java index 24d5fc61..fd789377 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/AbstractReferenceDefinitionParser.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/AbstractReferenceDefinitionParser.java @@ -166,7 +166,7 @@ protected AbstractBeanDefinition parseInternal(Element element, ParserContext pa BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); Class beanClass = getBeanClass(element); - Assert.notNull(beanClass); + Assert.notNull(beanClass, "required field"); if (beanClass != null) { builder.getRawBeanDefinition().setBeanClass(beanClass); diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/OsgiDefaultsDefinition.java b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/OsgiDefaultsDefinition.java index 0714ea55..1c99e6b2 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/OsgiDefaultsDefinition.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/OsgiDefaultsDefinition.java @@ -44,7 +44,7 @@ public class OsgiDefaultsDefinition { private Availability availability = Availability.MANDATORY; public OsgiDefaultsDefinition(Document document, ParserContext parserContext) { - Assert.notNull(document); + Assert.notNull(document, "required field"); Element root = document.getDocumentElement(); ReferenceParsingUtil.checkAvailabilityAndCardinalityDuplication(root, DEFAULT_AVAILABILITY, diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/CustomListenerAdapterUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/CustomListenerAdapterUtils.java index 2eeb50bd..f0726798 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/CustomListenerAdapterUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/CustomListenerAdapterUtils.java @@ -71,7 +71,7 @@ static Map, List> determineCustomMethods(final Class target, return Collections.emptyMap(); } - Assert.notEmpty(possibleArgumentTypes); + Assert.notEmpty(possibleArgumentTypes, "required field"); if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction, List>>() { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceLifecycleListenerAdapter.java b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceLifecycleListenerAdapter.java index afa19111..f4ac397c 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceLifecycleListenerAdapter.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceLifecycleListenerAdapter.java @@ -15,17 +15,12 @@ package org.eclipse.gemini.blueprint.config.internal.adapter; import java.lang.reflect.Method; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.gemini.blueprint.context.support.internal.security.SecurityUtils; import org.eclipse.gemini.blueprint.service.importer.ImportedOsgiServiceProxy; import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener; import org.eclipse.gemini.blueprint.util.internal.ReflectionUtils; @@ -80,7 +75,7 @@ public class OsgiServiceLifecycleListenerAdapter implements OsgiServiceLifecycle private boolean initialized; public void afterPropertiesSet() { - Assert.notNull(beanFactory); + Assert.notNull(beanFactory, "required field"); Assert.isTrue(target != null || StringUtils.hasText(targetBeanName), "one of 'target' or 'targetBeanName' properties has to be set"); @@ -113,20 +108,11 @@ private void initialize() { bindMethods = CustomListenerAdapterUtils.determineCustomMethods(clazz, bindMethod, isBlueprintCompliant); - boolean isSecurityEnabled = System.getSecurityManager() != null; final Class clz = clazz; // determine methods using ServiceReference signature if (StringUtils.hasText(bindMethod)) { - if (isSecurityEnabled) { - bindReference = AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - return findServiceReferenceMethod(clz, bindMethod); - } - }); - } else { - bindReference = findServiceReferenceMethod(clz, bindMethod); - } + bindReference = findServiceReferenceMethod(clz, bindMethod); if (bindMethods.isEmpty()) { String beanName = (target == null ? "" : " bean [" + targetBeanName + "] ;"); @@ -138,15 +124,7 @@ public Method run() { unbindMethods = CustomListenerAdapterUtils.determineCustomMethods(clazz, unbindMethod, isBlueprintCompliant); if (StringUtils.hasText(unbindMethod)) { - if (isSecurityEnabled) { - unbindReference = AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - return findServiceReferenceMethod(clz, unbindMethod); - } - }); - } else { - unbindReference = findServiceReferenceMethod(clz, unbindMethod); - } + unbindReference = findServiceReferenceMethod(clz, unbindMethod); if (unbindMethods.isEmpty()) { String beanName = (target == null ? "" : " bean [" + targetBeanName + "] ;"); @@ -227,29 +205,13 @@ public void bind(final Object service, final Map properties) throws Exception { if (!initialized) retrieveTarget(); - boolean isSecurityEnabled = (System.getSecurityManager() != null); - AccessControlContext acc = null; - - if (isSecurityEnabled) { - acc = SecurityUtils.getAccFrom(beanFactory); - } - // first call interface method (if it exists) if (isLifecycleListener) { if (trace) log.trace("Invoking listener interface methods"); try { - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - ((OsgiServiceLifecycleListener) target).bind(service, properties); - return null; - } - }, acc); - } else { - ((OsgiServiceLifecycleListener) target).bind(service, properties); - } + ((OsgiServiceLifecycleListener) target).bind(service, properties); } catch (Exception ex) { if (ex instanceof PrivilegedActionException) { ex = ((PrivilegedActionException) ex).getException(); @@ -258,18 +220,8 @@ public Object run() throws Exception { } } - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - CustomListenerAdapterUtils.invokeCustomMethods(target, bindMethods, service, properties); - invokeCustomServiceReferenceMethod(target, bindReference, service); - return null; - } - }, acc); - } else { - CustomListenerAdapterUtils.invokeCustomMethods(target, bindMethods, service, properties); - invokeCustomServiceReferenceMethod(target, bindReference, service); - } + CustomListenerAdapterUtils.invokeCustomMethods(target, bindMethods, service, properties); + invokeCustomServiceReferenceMethod(target, bindReference, service); } public void unbind(final Object service, final Map properties) throws Exception { @@ -281,45 +233,19 @@ public void unbind(final Object service, final Map properties) throws Exception log.trace("Invoking unbind method for service " + ObjectUtils.identityToString(service) + " with props=" + properties); - boolean isSecurityEnabled = (System.getSecurityManager() != null); - AccessControlContext acc = null; - - if (isSecurityEnabled) { - acc = SecurityUtils.getAccFrom(beanFactory); - } - // first call interface method (if it exists) if (isLifecycleListener) { if (trace) log.trace("Invoking listener interface methods"); try { - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - ((OsgiServiceLifecycleListener) target).unbind(service, properties); - return null; - } - }, acc); - } else { - ((OsgiServiceLifecycleListener) target).unbind(service, properties); - } + ((OsgiServiceLifecycleListener) target).unbind(service, properties); } catch (Exception ex) { log.warn("Standard unbind method on [" + target.getClass().getName() + "] threw exception", ex); } } - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - CustomListenerAdapterUtils.invokeCustomMethods(target, unbindMethods, service, properties); - invokeCustomServiceReferenceMethod(target, unbindReference, service); - return null; - } - }, acc); - } else { - CustomListenerAdapterUtils.invokeCustomMethods(target, unbindMethods, service, properties); - invokeCustomServiceReferenceMethod(target, unbindReference, service); - } + CustomListenerAdapterUtils.invokeCustomMethods(target, unbindMethods, service, properties); + invokeCustomServiceReferenceMethod(target, unbindReference, service); } /** diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceRegistrationListenerAdapter.java b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceRegistrationListenerAdapter.java index 2aecba46..7454aad0 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceRegistrationListenerAdapter.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/config/internal/adapter/OsgiServiceRegistrationListenerAdapter.java @@ -15,17 +15,12 @@ package org.eclipse.gemini.blueprint.config.internal.adapter; import java.lang.reflect.Method; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.gemini.blueprint.context.support.internal.security.SecurityUtils; import org.eclipse.gemini.blueprint.service.exporter.OsgiServiceRegistrationListener; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -70,7 +65,7 @@ public class OsgiServiceRegistrationListenerAdapter implements OsgiServiceRegist private boolean isBlueprintCompliant = false; public void afterPropertiesSet() { - Assert.notNull(beanFactory); + Assert.notNull(beanFactory, "required field"); Assert.isTrue(target != null || StringUtils.hasText(targetBeanName), "one of 'target' or 'targetBeanName' properties has to be set"); @@ -127,28 +122,13 @@ public void registered(final Object service, final Map serviceProperties) { if (!initialized) retrieveTarget(); - boolean isSecurityEnabled = System.getSecurityManager() != null; - AccessControlContext acc = null; - if (isSecurityEnabled) { - acc = SecurityUtils.getAccFrom(beanFactory); - } - // first call interface method (if it exists) if (isListener) { if (trace) log.trace("Invoking listener interface methods"); try { - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - ((OsgiServiceRegistrationListener) target).registered(service, serviceProperties); - return null; - } - }, acc); - } else { - ((OsgiServiceRegistrationListener) target).registered(service, serviceProperties); - } + ((OsgiServiceRegistrationListener) target).registered(service, serviceProperties); } catch (Exception ex) { if (ex instanceof PrivilegedActionException) { ex = ((PrivilegedActionException) ex).getException(); @@ -157,17 +137,7 @@ public Object run() throws Exception { } } - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - CustomListenerAdapterUtils.invokeCustomMethods(target, registrationMethods, service, - serviceProperties); - return null; - } - }, acc); - } else { - CustomListenerAdapterUtils.invokeCustomMethods(target, registrationMethods, service, serviceProperties); - } + CustomListenerAdapterUtils.invokeCustomMethods(target, registrationMethods, service, serviceProperties); } public void unregistered(final Object service, final Map serviceProperties) { @@ -180,45 +150,19 @@ public void unregistered(final Object service, final Map serviceProperties) { if (!initialized) retrieveTarget(); - boolean isSecurityEnabled = System.getSecurityManager() != null; - AccessControlContext acc = null; - - if (isSecurityEnabled) { - acc = SecurityUtils.getAccFrom(beanFactory); - } - // first call interface method (if it exists) if (isListener) { if (trace) log.trace("Invoking listener interface methods"); try { - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - ((OsgiServiceRegistrationListener) target).unregistered(service, serviceProperties); - return null; - } - }, acc); - } else { - ((OsgiServiceRegistrationListener) target).unregistered(service, serviceProperties); - } + ((OsgiServiceRegistrationListener) target).unregistered(service, serviceProperties); } catch (Exception ex) { log.warn("Standard unregistered method on [" + target.getClass().getName() + "] threw exception", ex); } } - if (isSecurityEnabled) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - CustomListenerAdapterUtils.invokeCustomMethods(target, unregistrationMethods, service, - serviceProperties); - return null; - } - }, acc); - } else { - CustomListenerAdapterUtils.invokeCustomMethods(target, unregistrationMethods, service, serviceProperties); - } + CustomListenerAdapterUtils.invokeCustomMethods(target, unregistrationMethods, service, serviceProperties); } /** diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEvent.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEvent.java index 35f06d78..c70b7cb5 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEvent.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEvent.java @@ -46,7 +46,7 @@ public abstract class OsgiBundleApplicationContextEvent extends ApplicationConte */ public OsgiBundleApplicationContextEvent(ApplicationContext source, Bundle bundle) { super(source); - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); this.bundle = bundle; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEventMulticasterAdapter.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEventMulticasterAdapter.java index 3128480a..4ab0bb7a 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEventMulticasterAdapter.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/event/OsgiBundleApplicationContextEventMulticasterAdapter.java @@ -36,7 +36,7 @@ public class OsgiBundleApplicationContextEventMulticasterAdapter implements * @param delegatedMulticaster */ public OsgiBundleApplicationContextEventMulticasterAdapter(ApplicationEventMulticaster delegatedMulticaster) { - Assert.notNull(delegatedMulticaster); + Assert.notNull(delegatedMulticaster, "required field"); this.delegatedMulticaster = delegatedMulticaster; } @@ -47,7 +47,7 @@ public OsgiBundleApplicationContextEventMulticasterAdapter(ApplicationEventMulti * listener instance. However, depending on the equals implementation, this might affect the object identity. */ public void addApplicationListener(OsgiBundleApplicationContextListener osgiListener) { - Assert.notNull(osgiListener); + Assert.notNull(osgiListener, "required field"); delegatedMulticaster.addApplicationListener(ApplicationListenerAdapter.createAdapter(osgiListener)); } @@ -66,7 +66,7 @@ public void removeAllListeners() { * listener instance. However, depending on the equals implementation, this might affect the object identity. */ public void removeApplicationListener(OsgiBundleApplicationContextListener osgiListener) { - Assert.notNull(null); + Assert.notNull(null, "required field"); delegatedMulticaster.removeApplicationListener(ApplicationListenerAdapter.createAdapter(osgiListener)); } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java index 9581949f..d943fff9 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java @@ -17,10 +17,6 @@ import java.beans.PropertyEditor; import java.io.IOException; -import java.security.AccessControlContext; -import java.security.AccessControlException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Dictionary; import java.util.Map; @@ -44,8 +40,6 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.Scope; -import org.springframework.beans.factory.support.AbstractBeanFactory; -import org.springframework.beans.factory.support.SecurityContextProvider; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.support.AbstractRefreshableApplicationContext; @@ -115,8 +109,6 @@ public abstract class AbstractOsgiBundleApplicationContext extends AbstractRefre */ private ResourcePatternResolver osgiPatternResolver; - private volatile AccessControlContext acc; - /** * Creates a new AbstractOsgiBundleApplicationContext with no parent. */ @@ -151,8 +143,6 @@ public void setBundleContext(BundleContext bundleContext) { this.setDisplayName(ClassUtils.getShortName(getClass()) + "(bundle=" + getBundleSymbolicName() + ", config=" + StringUtils.arrayToCommaDelimitedString(getConfigLocations()) + ")"); - - this.acc = AccessControlFactory.createContext(bundle); } public BundleContext getBundleContext() { @@ -229,16 +219,6 @@ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactor beanFactory.addBeanPostProcessor(new BundleContextAwareProcessor(this.bundleContext)); beanFactory.ignoreDependencyInterface(BundleContextAware.class); - if (beanFactory instanceof AbstractBeanFactory) { - AbstractBeanFactory bf = (AbstractBeanFactory) beanFactory; - bf.setSecurityContextProvider(new SecurityContextProvider() { - - public AccessControlContext getAccessControlContext() { - return acc; - } - }); - } - enforceExporterImporterDependency(beanFactory); // add predefined beans @@ -269,22 +249,17 @@ private void addPredefinedBean(ConfigurableListableBeanFactory beanFactory, Stri * @param beanFactory */ private void enforceExporterImporterDependency(ConfigurableListableBeanFactory beanFactory) { - Object instance = null; - - instance = AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() { - // create the service manager - ClassLoader loader = AbstractOsgiBundleApplicationContext.class.getClassLoader(); - try { - Class managerClass = loader.loadClass(EXPORTER_IMPORTER_DEPENDENCY_MANAGER); - return BeanUtils.instantiateClass(managerClass); - } catch (ClassNotFoundException cnfe) { - throw new ApplicationContextException("Cannot load class " + EXPORTER_IMPORTER_DEPENDENCY_MANAGER, - cnfe); - } - } - }); + Object instance; + + // create the service manager + ClassLoader loader = AbstractOsgiBundleApplicationContext.class.getClassLoader(); + try { + Class managerClass = loader.loadClass(EXPORTER_IMPORTER_DEPENDENCY_MANAGER); + instance = BeanUtils.instantiateClass(managerClass); + } catch (ClassNotFoundException cnfe) { + throw new ApplicationContextException("Cannot load class " + EXPORTER_IMPORTER_DEPENDENCY_MANAGER, + cnfe); + } // sanity check Assert.isInstanceOf(BeanFactoryAware.class, instance); @@ -343,23 +318,7 @@ private void publishContextAsOsgiServiceIfNecessary() { if (logger.isDebugEnabled()) logger.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames)); - // Publish under all the significant interfaces we see - boolean hasSecurity = (System.getSecurityManager() != null); - - if (hasSecurity) { - try { - serviceRegistration = AccessController.doPrivileged(new PrivilegedAction() { - public ServiceRegistration run() { - return getBundleContext().registerService(serviceNames, AbstractOsgiBundleApplicationContext.this, serviceProperties); - } - }, acc); - } catch (AccessControlException ex) { - logger.error("Application context service publication aborted due to security issues " - + "- does the bundle has the rights to publish the service ? ", ex); - } - } else { - serviceRegistration = getBundleContext().registerService(serviceNames, this, serviceProperties); - } + serviceRegistration = getBundleContext().registerService(serviceNames, this, serviceProperties); } else { if (logger.isInfoEnabled()) { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/ChainedEntityResolver.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/ChainedEntityResolver.java index 90cbd574..f6aa39cc 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/ChainedEntityResolver.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/ChainedEntityResolver.java @@ -40,7 +40,7 @@ class ChainedEntityResolver implements EntityResolver { public void addEntityResolver(EntityResolver resolver, String resolverToString) { - Assert.notNull(resolver); + Assert.notNull(resolver, "required field"); resolvers.put(resolver, resolverToString); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/DelegatedNamespaceHandlerResolver.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/DelegatedNamespaceHandlerResolver.java index 96407687..29c67629 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/DelegatedNamespaceHandlerResolver.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/DelegatedNamespaceHandlerResolver.java @@ -40,7 +40,7 @@ class DelegatedNamespaceHandlerResolver implements NamespaceHandlerResolver { public void addNamespaceHandler(NamespaceHandlerResolver resolver, String resolverToString) { - Assert.notNull(resolver); + Assert.notNull(resolver, "required field"); resolvers.put(resolver, resolverToString); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java index 25b961d9..3ec4a1f0 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java @@ -16,8 +16,6 @@ package org.eclipse.gemini.blueprint.context.support; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import org.eclipse.gemini.blueprint.io.OsgiBundleResource; import org.eclipse.gemini.blueprint.util.OsgiStringUtils; @@ -117,20 +115,9 @@ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throw final BundleContext ctx = getBundleContext(); - if (System.getSecurityManager() != null) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String filter = BundleUtils.createNamespaceFilter(ctx); - resolvers[0] = createNamespaceHandlerResolver(ctx, filter, getClassLoader()); - resolvers[1] = createEntityResolver(ctx, filter, getClassLoader()); - return null; - } - }); - } else { - String filter = BundleUtils.createNamespaceFilter(ctx); - resolvers[0] = createNamespaceHandlerResolver(ctx, filter, getClassLoader()); - resolvers[1] = createEntityResolver(ctx, filter, getClassLoader()); - } + String filter = BundleUtils.createNamespaceFilter(ctx); + resolvers[0] = createNamespaceHandlerResolver(ctx, filter, getClassLoader()); + resolvers[1] = createEntityResolver(ctx, filter, getClassLoader()); beanDefinitionReader.setNamespaceHandlerResolver((NamespaceHandlerResolver) resolvers[0]); beanDefinitionReader.setEntityResolver((EntityResolver) resolvers[1]); @@ -280,4 +267,9 @@ private EntityResolver lookupEntityResolver(final BundleContext bundleContext, S public String[] getConfigLocations() { return super.getConfigLocations(); } + + @Override + public void destroy() throws Exception { + this.close(); + } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ChainedClassLoader.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ChainedClassLoader.java index c8a4ff61..b61e90f2 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ChainedClassLoader.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ChainedClassLoader.java @@ -79,7 +79,7 @@ public ChainedClassLoader(ClassLoader[] loaders, ClassLoader parent) { this.parent = parent; - Assert.notEmpty(loaders); + Assert.notEmpty(loaders, "required field"); synchronized (this.loaders) { for (int i = 0; i < loaders.length; i++) { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ClassLoaderFactory.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ClassLoaderFactory.java index 731ab985..bcd3a25d 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ClassLoaderFactory.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/classloader/ClassLoaderFactory.java @@ -46,7 +46,7 @@ public abstract class ClassLoaderFactory { * @return AOP class loader created using the given argument */ public static ChainedClassLoader getAopClassLoaderFor(ClassLoader classLoader) { - Assert.notNull(classLoader); + Assert.notNull(classLoader, "required field"); return aopClassLoaderFactory.createClassLoader(classLoader); } @@ -65,7 +65,7 @@ public static ChainedClassLoader getAopClassLoaderFor(ClassLoader classLoader) { * @return associated wrapping class loader */ public static ClassLoader getBundleClassLoaderFor(Bundle bundle) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); return bundleClassLoaderFactory.createClassLoader(bundle); } } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/scope/OsgiBundleScope.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/scope/OsgiBundleScope.java index 92860baa..240e9542 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/scope/OsgiBundleScope.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/scope/OsgiBundleScope.java @@ -73,7 +73,7 @@ public static class BundleScopeServiceFactory implements ServiceFactory { public BundleScopeServiceFactory(ServiceFactory serviceFactory) { - Assert.notNull(serviceFactory); + Assert.notNull(serviceFactory, "required field"); this.decoratedServiceFactory = serviceFactory; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/security/SecurityUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/security/SecurityUtils.java deleted file mode 100644 index 31685fa8..00000000 --- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/internal/security/SecurityUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.context.support.internal.security; - -import java.security.AccessControlContext; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.ApplicationContext; - -/** - * @author Costin Leau - */ -public abstract class SecurityUtils { - - public static AccessControlContext getAccFrom(BeanFactory beanFactory) { - AccessControlContext acc = null; - if (beanFactory != null) { - if (beanFactory instanceof ConfigurableBeanFactory) { - return ((ConfigurableBeanFactory) beanFactory).getAccessControlContext(); - } - } - return acc; - } - - public static AccessControlContext getAccFrom(ApplicationContext ac) { - return (ac != null ? getAccFrom(ac.getAutowireCapableBeanFactory()) : null); - } -} diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/dependency/internal/DefaultMandatoryDependencyManager.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/dependency/internal/DefaultMandatoryDependencyManager.java index b7bafe12..c8d7d05f 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/dependency/internal/DefaultMandatoryDependencyManager.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/dependency/internal/DefaultMandatoryDependencyManager.java @@ -160,7 +160,7 @@ public void importerUnsatisfied(Object importer, OsgiServiceDependency dependenc private ConfigurableListableBeanFactory beanFactory; public void addServiceExporter(Object exporter, String exporterBeanName) { - Assert.hasText(exporterBeanName); + Assert.hasText(exporterBeanName, "required field"); if (exportersSeen.putIfAbsent(exporterBeanName, VALUE) == null) { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBean.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBean.java index 2e49daef..17b00b5b 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBean.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBean.java @@ -20,7 +20,6 @@ import org.eclipse.gemini.blueprint.context.BundleContextAware; import org.eclipse.gemini.blueprint.context.support.internal.classloader.ClassLoaderFactory; import org.eclipse.gemini.blueprint.context.support.internal.scope.OsgiBundleScope; -import org.eclipse.gemini.blueprint.context.support.internal.security.SecurityUtils; import org.eclipse.gemini.blueprint.service.exporter.OsgiServicePropertiesResolver; import org.eclipse.gemini.blueprint.service.exporter.support.internal.controller.ExporterController; import org.eclipse.gemini.blueprint.service.exporter.support.internal.controller.ExporterInternalActions; @@ -43,9 +42,6 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -360,17 +356,7 @@ ServiceRegistration registerService(Class[] classes, final Dictionary service if (isBeanBundleScoped()) serviceFactory = new OsgiBundleScope.BundleScopeServiceFactory(serviceFactory); - if (System.getSecurityManager() != null) { - AccessControlContext acc = SecurityUtils.getAccFrom(beanFactory); - final ServiceFactory serviceFactoryFinal = serviceFactory; - return AccessController.doPrivileged(new PrivilegedAction() { - public ServiceRegistration run() { - return bundleContext.registerService(names, serviceFactoryFinal, serviceProperties); - } - }, acc); - } else { - return bundleContext.registerService(names, serviceFactory, serviceProperties); - } + return bundleContext.registerService(names, serviceFactory, serviceProperties); } private boolean isBeanBundleScoped() { @@ -452,7 +438,7 @@ void unregisterService(ServiceRegistration registration) { * @see ExportContextClassLoaderEnum */ public void setExportContextClassLoader(ExportContextClassLoaderEnum ccl) { - Assert.notNull(ccl); + Assert.notNull(ccl, "required field"); this.contextClassLoader = ccl; } @@ -503,7 +489,7 @@ public void setTargetBeanName(String name) { * @param detector */ public void setInterfaceDetector(InterfaceDetector detector) { - Assert.notNull(detector); + Assert.notNull(detector, "required field"); this.interfaceDetector = detector; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/controller/ExporterController.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/controller/ExporterController.java index eea1e1b1..a70333b4 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/controller/ExporterController.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/controller/ExporterController.java @@ -30,7 +30,7 @@ public class ExporterController implements ExporterInternalActions { public ExporterController(ExporterInternalActions executor) { - Assert.notNull(executor); + Assert.notNull(executor, "required field"); this.executor = executor; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationDecorator.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationDecorator.java index ab5503c4..8bd18006 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationDecorator.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationDecorator.java @@ -35,7 +35,7 @@ public class ServiceRegistrationDecorator implements ServiceRegistration { private volatile UnregistrationNotifier notifier; public ServiceRegistrationDecorator(ServiceRegistration registration) { - Assert.notNull(registration); + Assert.notNull(registration, "required field"); this.delegate = registration; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/event/OsgiServiceDependencyEvent.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/event/OsgiServiceDependencyEvent.java index e7d1e6d4..580b4381 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/event/OsgiServiceDependencyEvent.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/event/OsgiServiceDependencyEvent.java @@ -38,7 +38,7 @@ public abstract class OsgiServiceDependencyEvent extends ApplicationEvent { */ public OsgiServiceDependencyEvent(Object source, OsgiServiceDependency dependency) { super(source); - Assert.notNull(dependency); + Assert.notNull(dependency, "required field"); this.dependency = dependency; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractOsgiServiceImportFactoryBean.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractOsgiServiceImportFactoryBean.java index a9adf7eb..74196d0b 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractOsgiServiceImportFactoryBean.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractOsgiServiceImportFactoryBean.java @@ -169,7 +169,7 @@ public void setInterfaces(Class[] interfaces) { * @see ImportContextClassLoaderEnum */ public void setImportContextClassLoader(ImportContextClassLoaderEnum contextClassLoader) { - Assert.notNull(contextClassLoader); + Assert.notNull(contextClassLoader, "required field"); this.contextClassLoader = contextClassLoader; } @@ -279,7 +279,7 @@ public Availability getAvailability() { * @param availability */ public void setAvailability(Availability availability) { - Assert.notNull(availability); + Assert.notNull(availability, "required field"); this.availability = availability; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractServiceProxyCreator.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractServiceProxyCreator.java index 3adc21fa..5558c9ab 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractServiceProxyCreator.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/AbstractServiceProxyCreator.java @@ -15,6 +15,7 @@ package org.eclipse.gemini.blueprint.service.importer.support; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.aopalliance.aop.Advice; @@ -63,8 +64,8 @@ abstract class AbstractServiceProxyCreator implements ServiceProxyCreator { AbstractServiceProxyCreator(Class[] classes, ClassLoader aopClassLoader, ClassLoader bundleClassLoader, BundleContext bundleContext, ImportContextClassLoaderEnum iccl) { - Assert.notNull(bundleContext); - Assert.notNull(aopClassLoader); + Assert.notNull(bundleContext, "required field"); + Assert.notNull(aopClassLoader, "required field"); this.classes = classes; this.bundleContext = bundleContext; @@ -102,10 +103,23 @@ public ProxyPlusCallback createServiceProxy(ServiceReference reference) { advices.add(infrastructureMixin); advices.add(dispatcherInterceptor); - return new ProxyPlusCallback(ProxyUtils.createProxy(getInterfaces(reference), null, classLoader, bundleContext, + return new ProxyPlusCallback(ProxyUtils.createProxy(getInterfacesWithNoOpInterface(reference), null, classLoader, bundleContext, advices), dispatcherInterceptor); } + /** + * We need to define additional interface if we are not passing any `target` for a proxy. + * @see ServiceProxyNoOpInterface + */ + private Class[] getInterfacesWithNoOpInterface(ServiceReference reference) { + Class[] interfaces = getInterfaces(reference); + + Class[] allInterfaces = Arrays.copyOf(interfaces, interfaces.length + 1); + allInterfaces[interfaces.length] = ServiceProxyNoOpInterface.class; + + return allInterfaces; + } + private Advice determineTCCLAdvice(ServiceReference reference) { try { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/OsgiServiceCollectionProxyFactoryBean.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/OsgiServiceCollectionProxyFactoryBean.java index caec271b..e9b3da86 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/OsgiServiceCollectionProxyFactoryBean.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/OsgiServiceCollectionProxyFactoryBean.java @@ -257,7 +257,7 @@ public void setComparator(Comparator comparator) { * @param collectionType the collection type as string using one of the values above. */ public void setCollectionType(CollectionType collectionType) { - Assert.notNull(collectionType); + Assert.notNull(collectionType, "required field"); this.collectionType = collectionType; } @@ -296,7 +296,7 @@ public MemberType getMemberType() { * @param type the collection member type */ public void setMemberType(MemberType type) { - Assert.notNull(type); + Assert.notNull(type, "required field"); this.memberType = type; } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/ServiceProxyNoOpInterface.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/ServiceProxyNoOpInterface.java new file mode 100644 index 00000000..a2867030 --- /dev/null +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/ServiceProxyNoOpInterface.java @@ -0,0 +1,15 @@ +package org.eclipse.gemini.blueprint.service.importer.support; + +import org.springframework.aop.IntroductionAdvisor; +import org.springframework.aop.framework.ProxyFactory; + +/** + * It is a no-op interface simply to pass the issues described in https://github.com/spring-projects/spring-framework/issues/33985 + * + * In short {@link ProxyFactory} will throw an exception if requesting proxy doesn't define `target` + * and all defined interfaces are defined by registered through {@link IntroductionAdvisor}. + * + * By adding this interface directly we can be sure it will pass validation. + */ +public interface ServiceProxyNoOpInterface { +} diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ImportedOsgiServiceProxyAdvice.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ImportedOsgiServiceProxyAdvice.java index 0710238d..6083ebb0 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ImportedOsgiServiceProxyAdvice.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ImportedOsgiServiceProxyAdvice.java @@ -37,7 +37,7 @@ public class ImportedOsgiServiceProxyAdvice extends DelegatingIntroductionInterc public ImportedOsgiServiceProxyAdvice(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); this.reference = (reference instanceof ServiceReferenceProxy ? (ServiceReferenceProxy) reference : new StaticServiceReferenceProxy(reference)); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/InfrastructureOsgiProxyAdvice.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/InfrastructureOsgiProxyAdvice.java index 0fcadf4d..a0d34ecf 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/InfrastructureOsgiProxyAdvice.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/InfrastructureOsgiProxyAdvice.java @@ -34,7 +34,7 @@ public class InfrastructureOsgiProxyAdvice extends DelegatingIntroductionInterce public InfrastructureOsgiProxyAdvice(ServiceInvoker serviceInvoker) { - Assert.notNull(serviceInvoker); + Assert.notNull(serviceInvoker, "required field"); this.invoker = serviceInvoker; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceDynamicInterceptor.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceDynamicInterceptor.java index 36852f27..25efa13c 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceDynamicInterceptor.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceDynamicInterceptor.java @@ -455,8 +455,8 @@ private void publishEvent(ApplicationEvent event) { } public void afterPropertiesSet() { - Assert.notNull(proxy); - Assert.notNull(eventSource); + Assert.notNull(proxy, "required field"); + Assert.notNull(eventSource, "required field"); boolean debug = log.isDebugEnabled(); diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceStaticInterceptor.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceStaticInterceptor.java index f568e1a1..87276fbb 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceStaticInterceptor.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/ServiceStaticInterceptor.java @@ -45,7 +45,7 @@ public class ServiceStaticInterceptor extends ServiceInvoker { private volatile Object target = null; public ServiceStaticInterceptor(BundleContext context, ServiceReference reference) { - Assert.notNull(context); + Assert.notNull(context, "required field"); Assert.notNull(reference, "a not null service reference is required"); this.bundleContext = context; this.reference = reference; diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/StaticServiceReferenceProxy.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/StaticServiceReferenceProxy.java index 21f5ecb1..c684beb0 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/StaticServiceReferenceProxy.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/StaticServiceReferenceProxy.java @@ -20,6 +20,8 @@ import org.osgi.framework.ServiceReference; import org.springframework.util.Assert; +import java.util.Dictionary; + /** * Simple {@link ServiceReference} proxy which simply does delegation, without any extra features. It's main purpose is * to allow the consistent behaviour between dynamic and static proxies. @@ -39,7 +41,7 @@ public class StaticServiceReferenceProxy implements ServiceReferenceProxy { * @param target service reference */ public StaticServiceReferenceProxy(ServiceReference target) { - Assert.notNull(target); + Assert.notNull(target, "required field"); this.target = target; } @@ -82,4 +84,9 @@ public int hashCode() { public int compareTo(Object other) { return ServiceComparatorUtil.compare(target, other); } + + @Override + public Dictionary getProperties() { + return target.getProperties(); + } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/SwappingServiceReferenceProxy.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/SwappingServiceReferenceProxy.java index c5a38184..924ed719 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/SwappingServiceReferenceProxy.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/aop/SwappingServiceReferenceProxy.java @@ -16,10 +16,13 @@ import org.eclipse.gemini.blueprint.service.importer.ServiceReferenceProxy; import org.eclipse.gemini.blueprint.service.importer.support.internal.util.ServiceComparatorUtil; +import org.eclipse.gemini.blueprint.util.internal.MapBasedDictionary; import org.osgi.framework.Bundle; import org.osgi.framework.ServiceReference; import org.springframework.util.Assert; +import java.util.Dictionary; + /** * Synchronized, swapping {@link ServiceReference} implementation that delegates to an underlying implementation which * can be swapped at runtime. @@ -38,7 +41,7 @@ class SwappingServiceReferenceProxy implements ServiceReferenceProxy { private ServiceReference delegate; synchronized ServiceReference swapDelegates(ServiceReference newDelegate) { - Assert.notNull(newDelegate); + Assert.notNull(newDelegate, "required field"); ServiceReference old = this.delegate; this.delegate = newDelegate; @@ -124,4 +127,9 @@ public synchronized int compareTo(Object other) { } return ServiceComparatorUtil.compare(delegate, other); } + + @Override + public Dictionary getProperties() { + return (delegate == null ? new MapBasedDictionary<>() : delegate.getProperties()); + } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedList.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedList.java index bf9b1d4b..73e84261 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedList.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedList.java @@ -56,7 +56,7 @@ public DynamicSortedList(int size) { // the main difference is that duplicates are accepted @SuppressWarnings("unchecked") public boolean add(E o) { - Assert.notNull(o); + Assert.notNull(o, "required field"); if (comparator == null && !(o instanceof Comparable)) throw new ClassCastException("given object does not implement " + Comparable.class.getName() diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedSet.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedSet.java index 018ca341..31161584 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedSet.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/DynamicSortedSet.java @@ -63,7 +63,7 @@ public Comparator comparator() { } public boolean add(E o) { - Assert.notNull(o); + Assert.notNull(o, "required field"); if (comparator == null && !(o instanceof Comparable)) throw new ClassCastException("given object does not implement " + Comparable.class.getName() @@ -87,7 +87,7 @@ public boolean add(E o) { } public boolean remove(Object o) { - Assert.notNull(o); + Assert.notNull(o, "required field"); return super.remove(o); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/OsgiServiceCollection.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/OsgiServiceCollection.java index 79d5f5e9..a62cc4fc 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/OsgiServiceCollection.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/collection/OsgiServiceCollection.java @@ -463,7 +463,7 @@ public Object[] toArray(Object[] array) { * @param listeners The listeners to set. */ public void setListeners(OsgiServiceLifecycleListener[] listeners) { - Assert.notNull(listeners); + Assert.notNull(listeners, "required field"); this.listeners = listeners; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/controller/ImporterController.java b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/controller/ImporterController.java index 520a31d1..2ebea55a 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/controller/ImporterController.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/service/importer/support/internal/controller/ImporterController.java @@ -27,7 +27,7 @@ public class ImporterController implements ImporterInternalActions { public ImporterController(ImporterInternalActions executor) { - Assert.notNull(executor); + Assert.notNull(executor, "required field"); this.executor = executor; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiBundleUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiBundleUtils.java index 4dcbbacc..44e8afdc 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiBundleUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiBundleUtils.java @@ -227,7 +227,7 @@ public static boolean isFragment(Bundle bundle) { * @return true if the given bundle is a fragment, false otherwise */ public static boolean isSystemBundle(Bundle bundle) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); return (bundle.getBundleId() == 0); } @@ -271,7 +271,7 @@ public static Bundle findBundleBySymbolicName(BundleContext bundleContext, Strin * @return the header value */ public static Version getHeaderAsVersion(Bundle bundle, String header) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); return Version.parseVersion((String) bundle.getHeaders().get(header)); } } \ No newline at end of file diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiListenerUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiListenerUtils.java index 8786744a..10d7733a 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiListenerUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiListenerUtils.java @@ -16,6 +16,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.osgi.framework.AllServiceListener; import org.osgi.framework.BundleContext; import org.osgi.framework.Filter; import org.osgi.framework.InvalidSyntaxException; @@ -85,12 +86,17 @@ public static void addServiceListener(BundleContext context, ServiceListener lis // now get the already registered services and call the listener // (the listener should be able to handle duplicates) - dispatchServiceRegistrationEvents(OsgiServiceReferenceUtils.getServiceReferences(context, filter), listener); + // + // If we have `AllServiceListener` we also should find "all" already registered services + ServiceReference[] serviceReferences = listener instanceof AllServiceListener ? + OsgiServiceReferenceUtils.getAllServiceReferences(context, filter) : + OsgiServiceReferenceUtils.getServiceReferences(context, filter); + dispatchServiceRegistrationEvents(serviceReferences, listener); } private static void registerListener(BundleContext context, ServiceListener listener, String filter) { - Assert.notNull(context); - Assert.notNull(listener); + Assert.notNull(context, "required field"); + Assert.notNull(listener, "required field"); try { // add listener diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiPlatformDetector.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiPlatformDetector.java index 7333ca3f..47b2db60 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiPlatformDetector.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiPlatformDetector.java @@ -1,24 +1,24 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - +/****************************************************************************** + * Copyright (c) 2006, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 + * is available at http://www.opensource.org/licenses/apache2.0.php. + * You may elect to redistribute this code under either of these licenses. + * + * Contributors: + * VMware Inc. + *****************************************************************************/ + package org.eclipse.gemini.blueprint.util; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; /** * Utility class that detects the running platform. Useful when certain quirks or tweaks have to made for a specific @@ -82,8 +82,8 @@ public static boolean isFelix(BundleContext bundleContext) { } private static boolean determinePlatform(BundleContext context, String[] labels) { - Assert.notNull(context); - Assert.notNull(labels); + Assert.notNull(context, "required field"); + Assert.notNull(labels, "required field"); String vendorProperty = context.getProperty(Constants.FRAMEWORK_VENDOR); if (vendorProperty == null) { diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiServiceReferenceUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiServiceReferenceUtils.java index ac34fbca..faf3d464 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiServiceReferenceUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/OsgiServiceReferenceUtils.java @@ -159,6 +159,28 @@ public static ServiceReference[] getServiceReferences(BundleContext bundleContex } } + /** + * ATLASSIAN added + * Returns references to all services matching the given class name and OSGi filter. + * + * @param bundleContext OSGi bundle context + * @param clazz fully qualified class name (can be null) + * @param filter valid OSGi filter (can be null) + * @return non-null array of references to matching services + * + * @since ATLASSIAN + */ + public static ServiceReference[] getAllServiceReferences(BundleContext bundleContext, String clazz, String filter) { + Assert.notNull(bundleContext, "bundleContext should be not null"); + + try { + ServiceReference[] refs = bundleContext.getAllServiceReferences(clazz, filter); + return (refs == null ? new ServiceReference[0] : refs); + } catch (InvalidSyntaxException ise) { + throw (RuntimeException) new IllegalArgumentException("invalid filter: " + ise.getFilter()).initCause(ise); + } + } + /** * Returns references to all services matching the given class names and OSGi filter. * @@ -188,6 +210,20 @@ public static ServiceReference[] getServiceReferences(BundleContext bundleContex return getServiceReferences(bundleContext, (String) null, filter); } + /** + * ATLASSIAN added + * Returns references to all services matching the OSGi filter. + * + * @param bundleContext OSGi bundle context + * @param filter valid OSGi filter (can be null) + * @return non-null array of references to matching services + * + * @since ATLASSIAN + */ + public static ServiceReference[] getAllServiceReferences(BundleContext bundleContext, String filter) { + return getAllServiceReferences(bundleContext, null, filter); + } + /** * Returns the service id ({@link Constants#SERVICE_ID}) of the given service reference. * @@ -195,7 +231,7 @@ public static ServiceReference[] getServiceReferences(BundleContext bundleContex * @return service id */ public static long getServiceId(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); return ((Long) reference.getProperty(Constants.SERVICE_ID)).longValue(); } @@ -206,7 +242,7 @@ public static long getServiceId(ServiceReference reference) { * @return service ranking */ public static int getServiceRanking(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); Object ranking = reference.getProperty(Constants.SERVICE_RANKING); // if the property is not supplied or of incorrect type, use a @@ -221,7 +257,7 @@ public static int getServiceRanking(ServiceReference reference) { * @return service advertised class names */ public static String[] getServiceObjectClasses(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); return (String[]) reference.getProperty(Constants.OBJECTCLASS); } @@ -248,7 +284,7 @@ public static Dictionary getServicePropertiesSnapshot(ServiceReference reference * @return a Map containing the service reference properties taken as a snapshot */ public static Map getServicePropertiesSnapshotAsMap(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); String[] keys = reference.getPropertyKeys(); Map map = new LinkedHashMap(keys.length); @@ -288,7 +324,7 @@ public static Dictionary getServiceProperties(ServiceReference reference) { * @see #getServiceProperties(ServiceReference) */ public static Map getServicePropertiesAsMap(ServiceReference reference) { - Assert.notNull(reference); + Assert.notNull(reference, "required field"); return new ServiceReferenceBasedMap(reference); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/BeanFactoryUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/BeanFactoryUtils.java index bac70bc2..47a0ccf7 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/BeanFactoryUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/BeanFactoryUtils.java @@ -46,8 +46,8 @@ public abstract class BeanFactoryUtils { */ public static String[] getTransitiveDependenciesForBean(ConfigurableListableBeanFactory beanFactory, String beanName, boolean rawFactoryBeans, Class type) { - Assert.notNull(beanFactory); - Assert.hasText(beanName); + Assert.notNull(beanFactory, "required field"); + Assert.hasText(beanName, "required field"); Assert.isTrue(beanFactory.containsBean(beanName), "no bean by name [" + beanName + "] can be found"); diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ClassUtils.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ClassUtils.java index d065ebc0..39d39200 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ClassUtils.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ClassUtils.java @@ -211,13 +211,13 @@ private static class ClassLoaderBridge { private final ClassLoader classLoader; public ClassLoaderBridge(Bundle bundle) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); this.bundle = bundle; this.classLoader = null; } public ClassLoaderBridge(ClassLoader classLoader) { - Assert.notNull(classLoader); + Assert.notNull(classLoader, "required field"); this.classLoader = classLoader; this.bundle = null; } @@ -353,7 +353,7 @@ private static Class[] getVisibleClasses(Class[] classes, ClassLoaderBridg * @return all interfaces implemented by the given class. */ public static Class[] getAllInterfaces(Class clazz) { - Assert.notNull(clazz); + Assert.notNull(clazz, "required field"); return getAllInterfaces(clazz, new LinkedHashSet>(8)); } @@ -384,8 +384,8 @@ private static Class[] getAllInterfaces(Class clazz, Set> interfa * @return */ public static boolean isPresent(String className, Bundle bundle) { - Assert.hasText(className); - Assert.notNull(bundle); + Assert.hasText(className, "required field"); + Assert.notNull(bundle, "required field"); try { bundle.loadClass(className); @@ -403,7 +403,7 @@ public static boolean isPresent(String className, Bundle bundle) { * @return */ public static ClassLoader getClassLoader(Class clazz) { - Assert.notNull(clazz); + Assert.notNull(clazz, "required field"); ClassLoader loader = clazz.getClassLoader(); return (loader == null ? ClassLoader.getSystemClassLoader() : loader); } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/MapBasedDictionary.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/MapBasedDictionary.java index d4655e20..f4bbedd4 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/MapBasedDictionary.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/MapBasedDictionary.java @@ -60,7 +60,7 @@ private static class IteratorBasedEnumeration implements Enumeration { public IteratorBasedEnumeration(Iterator it) { - Assert.notNull(it); + Assert.notNull(it, "required field"); this.it = it; } diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMap.java b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMap.java index f62a5b15..2037d821 100644 --- a/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMap.java +++ b/core/src/main/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMap.java @@ -88,7 +88,7 @@ private boolean eq(Object o1, Object o2) { public ServiceReferenceBasedMap(ServiceReference ref) { - Assert.notNull(ref); + Assert.notNull(ref, "required field"); this.reference = ref; } @@ -101,7 +101,7 @@ public boolean containsKey(Object key) { } public boolean containsValue(Object value) { - Assert.notNull(value); + Assert.notNull(value, "required field"); String[] keys = reference.getPropertyKeys(); for (int i = 0; i < keys.length; i++) { if (value.equals(reference.getProperty(keys[i]))) diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/DictionaryEditorTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/DictionaryEditorTest.java index 1db37a33..5add6485 100644 --- a/core/src/test/java/org/eclipse/gemini/blueprint/DictionaryEditorTest.java +++ b/core/src/test/java/org/eclipse/gemini/blueprint/DictionaryEditorTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.propertyeditors.PropertiesEditor; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; @@ -32,6 +33,16 @@ public class DictionaryEditorTest extends AbstractJUnit4SpringContextTests imple private Dictionary dictionary; @Autowired + // Spring detects 2 matching beans: + // - dictionary (defined in `dict-editor.xml`) + // - systemProperties - one of the default beans + // + // Spring 6.1 stopped using previous "name discoverer" + // Use of `Qualifier` annotation explicitly defines the bean we want to inject + // Another option would be to compile code with `-parameters` flag + // + // see https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x/b05067858f10a9b3a42a09556c07fbaa1dfdf8d3#parameter-name-retention + @Qualifier("dictionary") public void setDictionary(Dictionary dictionary) { this.dictionary = dictionary; } diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/MockConfigurationAdmin.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/MockConfigurationAdmin.java index 14188e2d..db20bc98 100644 --- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/MockConfigurationAdmin.java +++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/MockConfigurationAdmin.java @@ -43,6 +43,16 @@ public Configuration getConfiguration(String pid) throws IOException { return null; } + @Override + public Configuration getFactoryConfiguration(String s, String s1, String s2) throws IOException { + return null; + } + + @Override + public Configuration getFactoryConfiguration(String s, String s1) throws IOException { + return null; + } + public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException { return null; } diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/internal/ScopeTests.java b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/internal/ScopeTests.java index 604f14aa..6124c6a2 100644 --- a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/internal/ScopeTests.java +++ b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/internal/ScopeTests.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.config.Scope; import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.factory.xml.XmlBeanFactory; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.ClassUtils; @@ -79,14 +79,17 @@ public Object get(String name, ObjectFactory objectFactory) { private DefaultListableBeanFactory bf; - private class ScopedXmlFactory extends XmlBeanFactory { + private class ScopedXmlFactory extends DefaultListableBeanFactory { + + private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this); public ScopedXmlFactory(Resource resource, BeanFactory parentBeanFactory) throws BeansException { - super(resource, parentBeanFactory); + super(parentBeanFactory); + reader.loadBeanDefinitions(resource); } public ScopedXmlFactory(Resource resource) throws BeansException { - super(resource); + this(resource, null); registerScope("foo", new FooScope()); registerScope("bar", new FooScope()); } diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java index cf45afd6..1cb3a849 100644 --- a/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java +++ b/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java @@ -57,7 +57,9 @@ public class ClassUtilsTest extends TestCase { public void testAutoDetectClassesForPublishingDisabled() { Class[] resolved = getClassHierarchy(Integer.class, INTERFACES); - assertThat(resolved).hasSize(2); + // In Java 8 `Integer` used to implement `Comparable` and `Serializable` + // In Java 17 it has additional interfaces `Constable` and `ConstantDesc` + assertThat(resolved).hasSize(4); } public void testAutoDetectClassesForPublishingInterfaces() { diff --git a/extender/pom.xml b/extender/pom.xml index b6fdb514..a96ff041 100644 --- a/extender/pom.xml +++ b/extender/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -42,31 +42,26 @@ - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-beans + org.springframework + spring-beans - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-core + org.springframework + spring-core - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-context + org.springframework + spring-context - - org.apache.servicemix.bundles - org.apache.servicemix.bundles.aopalliance - test - org.osgi - org.osgi.core + osgi.core provided org.osgi - org.osgi.compendium + osgi.cmpn provided diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependenciesEvent.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependenciesEvent.java index 2a4e041b..a4a2bf4e 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependenciesEvent.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependenciesEvent.java @@ -53,7 +53,7 @@ public class BootstrappingDependenciesEvent extends OsgiBundleApplicationContext public BootstrappingDependenciesEvent(ApplicationContext source, Bundle bundle, Collection nestedEvents, Filter filter, long timeLeft) { super(source, bundle); - Assert.notNull(nestedEvents); + Assert.notNull(nestedEvents, "required field"); this.dependencyEvents = nestedEvents; this.dependenciesFilter = filter; this.timeLeft = timeLeft; diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependencyEvent.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependencyEvent.java index f14b2219..ad67c892 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependencyEvent.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/event/BootstrappingDependencyEvent.java @@ -43,7 +43,7 @@ public class BootstrappingDependencyEvent extends OsgiBundleApplicationContextEv */ public BootstrappingDependencyEvent(ApplicationContext source, Bundle bundle, OsgiServiceDependencyEvent nestedEvent) { super(source, bundle); - Assert.notNull(nestedEvent); + Assert.notNull(nestedEvent, "required field"); this.dependencyEvent = nestedEvent; } diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java index 406c298f..9dda37ad 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java @@ -26,7 +26,6 @@ import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration; import org.eclipse.gemini.blueprint.extender.internal.support.OsgiBeanFactoryPostProcessorAdapter; import org.eclipse.gemini.blueprint.extender.internal.util.concurrent.Counter; -import org.eclipse.gemini.blueprint.extender.internal.util.concurrent.RunnableTimedExecution; import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration; import org.eclipse.gemini.blueprint.util.OsgiBundleUtils; import org.eclipse.gemini.blueprint.util.OsgiStringUtils; @@ -135,7 +134,7 @@ protected void maybeCreateApplicationContextFor(Bundle bundle) { boolean debug = log.isDebugEnabled(); String bundleString = "[" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]"; - final Long bundleId = new Long(bundle.getBundleId()); + final Long bundleId = bundle.getBundleId(); if (managedContexts.containsKey(bundleId)) { if (debug) { @@ -418,9 +417,9 @@ public String toString() { public ConfigurableOsgiBundleApplicationContext getManagedContext(Bundle bundle) { ConfigurableOsgiBundleApplicationContext context = null; try { - Long id = new Long(bundle.getBundleId()); - context = (ConfigurableOsgiBundleApplicationContext) managedContexts.get(id); - } catch (IllegalStateException _) { + Long id = bundle.getBundleId(); + context = managedContexts.get(id); + } catch (IllegalStateException ignored) { // ignore } return context; diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/dependencies/startup/DependencyServiceManager.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/dependencies/startup/DependencyServiceManager.java index 676ecda5..5b3ce16b 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/dependencies/startup/DependencyServiceManager.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/dependencies/startup/DependencyServiceManager.java @@ -1,29 +1,25 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc., Oracle Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - * Oracle Inc. - *****************************************************************************/ - +/****************************************************************************** + * Copyright (c) 2006, 2010 VMware Inc., Oracle Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 + * is available at http://www.opensource.org/licenses/apache2.0.php. + * You may elect to redistribute this code under either of these licenses. + * + * Contributors: + * VMware Inc. + * Oracle Inc. + *****************************************************************************/ + package org.eclipse.gemini.blueprint.extender.internal.dependencies.startup; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -38,15 +34,12 @@ import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; import org.springframework.beans.factory.BeanFactoryUtils; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.eclipse.gemini.blueprint.context.DelegatedExecutionOsgiBundleApplicationContext; import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEvent; -import org.eclipse.gemini.blueprint.extender.OsgiServiceDependencyFactory; -import org.eclipse.gemini.blueprint.extender.event.BootstrappingDependenciesEvent; -import org.eclipse.gemini.blueprint.extender.event.BootstrappingDependencyEvent; -import org.eclipse.gemini.blueprint.extender.internal.util.PrivilegedUtils; +import org.eclipse.gemini.blueprint.extender.OsgiServiceDependencyFactory; +import org.eclipse.gemini.blueprint.extender.event.BootstrappingDependenciesEvent; +import org.eclipse.gemini.blueprint.extender.event.BootstrappingDependencyEvent; import org.eclipse.gemini.blueprint.service.importer.OsgiServiceDependency; import org.eclipse.gemini.blueprint.service.importer.event.OsgiServiceDependencyEvent; import org.eclipse.gemini.blueprint.service.importer.event.OsgiServiceDependencyWaitEndedEvent; @@ -65,10 +58,10 @@ */ public class DependencyServiceManager { - private static final Map UNMODIFIABLE_DEPENDENCY_MAP = Collections.unmodifiableMap(new HashMap(0)); - - private static final Log log = LogFactory.getLog(DependencyServiceManager.class); - + private static final Map UNMODIFIABLE_DEPENDENCY_MAP = Collections.unmodifiableMap(new HashMap(0)); + + private static final Log log = LogFactory.getLog(DependencyServiceManager.class); + private final Object monitor = new Object(); protected final Map dependencies = new LinkedHashMap(); @@ -157,8 +150,8 @@ public void serviceChanged(ServiceEvent serviceEvent) { log.error("Exception during dependency processing for " + context.getDisplayName(), th); contextStateAccessor.fail(th); } - } - + } + private void updateDependencies(ServiceEvent serviceEvent) { boolean trace = log.isTraceEnabled(); boolean debug = log.isDebugEnabled(); @@ -171,11 +164,11 @@ private void updateDependencies(ServiceEvent serviceEvent) { contextToString = context.getDisplayName(); } - Set mandatoryServiceDependencies; - synchronized (monitor) { - mandatoryServiceDependencies = new HashSet(dependencies.keySet()); - } - + Set mandatoryServiceDependencies; + synchronized (monitor) { + mandatoryServiceDependencies = new HashSet(dependencies.keySet()); + } + for (MandatoryServiceDependency dependency : mandatoryServiceDependencies) { // check all dependencies (there might be multiple imports for the same service) if (dependency.matches(serviceEvent)) { @@ -188,13 +181,13 @@ private void updateDependencies(ServiceEvent serviceEvent) { case ServiceEvent.REGISTERED: case ServiceEvent.MODIFIED: dependency.increment(); - String removedDependency; - synchronized (monitor) { - removedDependency = unsatisfiedDependencies.remove(dependency); - } + String removedDependency; + synchronized (monitor) { + removedDependency = unsatisfiedDependencies.remove(dependency); + } if (removedDependency != null) { Map unsatisfiedDependenciesSnapshot = getUnsatisfiedDependencies(); - if (debug) { + if (debug) { log.debug("Registered dependency for " + contextToString + "; eliminating " + dependency + ", remaining [" + unsatisfiedDependenciesSnapshot + "]"); } @@ -202,7 +195,7 @@ private void updateDependencies(ServiceEvent serviceEvent) { sendDependencySatisfiedEvent(dependency); sendBootstrappingDependenciesEvent(unsatisfiedDependenciesSnapshot.keySet()); } else { - if (debug) { + if (debug) { Map unsatisfiedDependenciesSnapshot = getUnsatisfiedDependencies(); log.debug("Increasing the number of matching services for " + contextToString + "; " + dependency + ", remaining [" + unsatisfiedDependenciesSnapshot + "]"); @@ -214,11 +207,11 @@ private void updateDependencies(ServiceEvent serviceEvent) { case ServiceEvent.UNREGISTERING: int count = dependency.decrement(); if (count == 0) { - synchronized (monitor) { - unsatisfiedDependencies.put(dependency, dependency.getBeanName()); - } - Map unsatisfiedDependenciesSnapshot = getUnsatisfiedDependencies(); - if (debug) { + synchronized (monitor) { + unsatisfiedDependencies.put(dependency, dependency.getBeanName()); + } + Map unsatisfiedDependenciesSnapshot = getUnsatisfiedDependencies(); + if (debug) { log.debug("Unregistered dependency for " + contextToString + " adding " + dependency + "; total unsatisfied [" + unsatisfiedDependenciesSnapshot + "]"); } @@ -244,8 +237,8 @@ private void updateDependencies(ServiceEvent serviceEvent) { } } } - } - + } + } /** @@ -275,39 +268,22 @@ public DependencyServiceManager(ContextExecutorAccessor executor, protected void findServiceDependencies() throws Exception { try { - if (System.getSecurityManager() != null) { - final AccessControlContext acc = getAcc(); - - PrivilegedUtils.executeWithCustomTCCL(context.getClassLoader(), - new PrivilegedUtils.UnprivilegedThrowableExecution() { - public Object run() throws Throwable { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - doFindDependencies(); - return null; - } - }, acc); - return null; - } - }); - } else { - doFindDependencies(); - } + doFindDependencies(); } catch (Throwable th) { if (th instanceof Exception) throw ((Exception) th); throw (Error) th; } - Collection unsatisfiedDependencyValues = getUnsatisfiedDependencies().values(); - + Collection unsatisfiedDependencyValues = getUnsatisfiedDependencies().values(); + if (log.isDebugEnabled()) { - int numDependencies; - int numUnsatisfiedDependencies; - synchronized (monitor) { - numDependencies = dependencies.size(); - numUnsatisfiedDependencies = unsatisfiedDependencies.size(); - } + int numDependencies; + int numUnsatisfiedDependencies; + synchronized (monitor) { + numDependencies = dependencies.size(); + numUnsatisfiedDependencies = unsatisfiedDependencies.size(); + } log.debug(numDependencies + " OSGi service dependencies, " + numUnsatisfiedDependencies + " unsatisfied (for beans " + unsatisfiedDependencyValues + ") in " + context.getDisplayName()); @@ -318,10 +294,10 @@ public Object run() throws Exception { + unsatisfiedDependencyValues + "]"); } if (log.isTraceEnabled()) { - Collection dependencyValues; - synchronized (monitor) { - dependencyValues = new ArrayList(dependencies.values()); - } + Collection dependencyValues; + synchronized (monitor) { + dependencyValues = new ArrayList(dependencies.values()); + } log.trace("Total OSGi service dependencies beans " + dependencyValues); log.trace("Unsatified OSGi service dependencies beans " + unsatisfiedDependencyValues); } @@ -363,16 +339,16 @@ private void doFindDependencies() throws Exception { if (discoveredDependencies != null) for (OsgiServiceDependency dependency : discoveredDependencies) { if (dependency.isMandatory()) { - MandatoryServiceDependency msd = new MandatoryServiceDependency(bundleContext, dependency); + MandatoryServiceDependency msd = new MandatoryServiceDependency(bundleContext, dependency); synchronized (monitor) { - dependencies.put(msd, dependency.getBeanName()); + dependencies.put(msd, dependency.getBeanName()); } if (!msd.isServicePresent()) { log.info("Adding OSGi service dependency for importer [" + msd.getBeanName() + "] matching OSGi filter [" + msd.filterAsString + "]"); - synchronized (monitor) { - unsatisfiedDependencies.put(msd, dependency.getBeanName()); + synchronized (monitor) { + unsatisfiedDependencies.put(msd, dependency.getBeanName()); } } else { if (debug) @@ -385,18 +361,18 @@ private void doFindDependencies() throws Exception { } public boolean isSatisfied() { - synchronized (monitor) { - return unsatisfiedDependencies.isEmpty(); + synchronized (monitor) { + return unsatisfiedDependencies.isEmpty(); } } - public Map getUnsatisfiedDependencies() { - if (isSatisfied()) { - return UNMODIFIABLE_DEPENDENCY_MAP; + public Map getUnsatisfiedDependencies() { + if (isSatisfied()) { + return UNMODIFIABLE_DEPENDENCY_MAP; } else { - synchronized (monitor) { - return Collections.unmodifiableMap(new HashMap(unsatisfiedDependencies)); - } + synchronized (monitor) { + return Collections.unmodifiableMap(new HashMap(unsatisfiedDependencies)); + } } } @@ -410,17 +386,7 @@ protected void register() { // send dependency event before registering the filter sendInitialBootstrappingEvents(getUnsatisfiedDependencies().keySet()); - if (System.getSecurityManager() != null) { - AccessControlContext acc = getAcc(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - OsgiListenerUtils.addServiceListener(bundleContext, listener, filter); - return null; - } - }, acc); - } else { - OsgiListenerUtils.addServiceListener(bundleContext, listener, filter); - } + OsgiListenerUtils.addServiceListener(bundleContext, listener, filter); } /** @@ -429,15 +395,15 @@ public Object run() { * * @return */ - private String createDependencyFilter() { - synchronized (monitor) { + private String createDependencyFilter() { + synchronized (monitor) { return createDependencyFilter(dependencies.keySet()); } } String createUnsatisfiedDependencyFilter() { - synchronized (monitor) { - return createDependencyFilter(unsatisfiedDependencies.keySet()); + synchronized (monitor) { + return createDependencyFilter(unsatisfiedDependencies.keySet()); } } @@ -472,8 +438,8 @@ protected void deregister() { } List getUnsatisfiedDependenciesAsEvents() { - synchronized (monitor) { - return getUnsatisfiedDependenciesAsEvents(unsatisfiedDependencies.keySet()); + synchronized (monitor) { + return getUnsatisfiedDependenciesAsEvents(unsatisfiedDependencies.keySet()); } } @@ -539,19 +505,11 @@ private void sendBootstrappingDependenciesEvent(Set private void publishEvent(OsgiBundleApplicationContextEvent dependencyEvent) { this.contextStateAccessor.getEventMulticaster().multicastEvent(dependencyEvent); } - - private AccessControlContext getAcc() { - AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory(); - if (beanFactory instanceof ConfigurableBeanFactory) { - return ((ConfigurableBeanFactory) beanFactory).getAccessControlContext(); - } - return null; - } - - public boolean allDependenciesSatisfied() { - synchronized (monitor) { - return unsatisfiedDependencies.isEmpty(); - } - } + + public boolean allDependenciesSatisfied() { + synchronized (monitor) { + return unsatisfiedDependencies.isEmpty(); + } + } } \ No newline at end of file diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/NamespaceManager.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/NamespaceManager.java index 72604fbb..b69b08bc 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/NamespaceManager.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/NamespaceManager.java @@ -172,7 +172,7 @@ private boolean hasCompatibleNamespaceType(Bundle bundle) { * @param bundle handler bundle */ public void maybeRemoveNameSpaceHandlerFor(Bundle bundle) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); boolean removed = this.namespacePlugins.removePlugin(bundle); if (removed && log.isDebugEnabled()) { log.debug("Removed namespace handler resolver for " + OsgiStringUtils.nullSafeNameAndSymName(bundle)); diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/PrivilegedUtils.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/PrivilegedUtils.java deleted file mode 100644 index 5a14b46d..00000000 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/PrivilegedUtils.java +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.extender.internal.util; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; - -/** - * Utility class for commons actions used within PrivilegedBlocks. - * - * @author Costin Leau - * - */ -public abstract class PrivilegedUtils { - - private static class GetTCCLAction implements PrivilegedAction { - - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - - public ClassLoader getTCCL() { - return AccessController.doPrivileged(this); - } - } - - public interface UnprivilegedThrowableExecution { - - public T run() throws Throwable; - } - - public interface UnprivilegedExecution { - - public T run(); - } - - - private static final GetTCCLAction getTCCLAction = new GetTCCLAction(); - - - public static ClassLoader getTCCL() { - return getTCCLAction.getTCCL(); - } - - /** - * Temporarily changes the TCCL to the given one for the duration of the - * given execution. All actions except the execution are executed with - * privileged access. - * - * Consider checking if there is a security manager in place before calling - * this method. - * - * @param customClassLoader - * @param execution - * @return - */ - public static T executeWithCustomTCCL(final ClassLoader customClassLoader, - final UnprivilegedExecution execution) { - final Thread currentThread = Thread.currentThread(); - final ClassLoader oldTCCL = getTCCLAction.getTCCL(); - - try { - AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() { - currentThread.setContextClassLoader(customClassLoader); - return null; - } - }); - return execution.run(); - } - finally { - AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() { - currentThread.setContextClassLoader(oldTCCL); - return null; - } - }); - } - } - - /** - * Temporarily changes the TCCL to the given one for the duration of the - * given execution. All actions except the execution are executed with - * privileged access. - * - * Consider checking if there is a security manager in place before calling - * this method. - * - * @param customClassLoader - * @param execution - * @return - * @throws Throwable - */ - public static T executeWithCustomTCCL(final ClassLoader customClassLoader, - final UnprivilegedThrowableExecution execution) throws Throwable { - final Thread currentThread = Thread.currentThread(); - final ClassLoader oldTCCL = getTCCLAction.getTCCL(); - - try { - AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() { - currentThread.setContextClassLoader(customClassLoader); - return null; - } - }); - return execution.run(); - } - catch (PrivilegedActionException pae) { - throw pae.getCause(); - } - finally { - AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() { - currentThread.setContextClassLoader(oldTCCL); - return null; - } - }); - } - } -} \ No newline at end of file diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/concurrent/RunnableTimedExecution.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/concurrent/RunnableTimedExecution.java index cab08796..f406c549 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/concurrent/RunnableTimedExecution.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/util/concurrent/RunnableTimedExecution.java @@ -81,7 +81,7 @@ public static boolean execute(Runnable task, long waitTime) { } public static boolean execute(Runnable task, long waitTime, TaskExecutor taskExecutor) { - Assert.notNull(task); + Assert.notNull(task, "required field"); Counter counter = new Counter("counter for task: " + task); Runnable wrapper = new MonitoredRunnable(task, counter); diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java index 0f0a9cf9..ccd06f7b 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java @@ -62,8 +62,8 @@ public ApplicationContextConfiguration(Bundle bundle) { } public ApplicationContextConfiguration(Bundle bundle, ConfigurationScanner configurationScanner) { - Assert.notNull(bundle); - Assert.notNull(configurationScanner); + Assert.notNull(bundle, "required field"); + Assert.notNull(configurationScanner, "required field"); this.bundle = bundle; this.configurationScanner = configurationScanner; diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java index 5234349d..b2528640 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java @@ -79,7 +79,7 @@ public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(B * @param configurationScanner The configurationScanner to set. */ public void setConfigurationScanner(ConfigurationScanner configurationScanner) { - Assert.notNull(configurationScanner); + Assert.notNull(configurationScanner, "required field"); this.configurationScanner = configurationScanner; } } \ No newline at end of file diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/internal/ConfigUtils.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/internal/ConfigUtils.java index 8214cc8c..fbf7bc25 100644 --- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/internal/ConfigUtils.java +++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/internal/ConfigUtils.java @@ -105,7 +105,7 @@ public abstract class ConfigUtils { public static boolean matchExtenderVersionRange(Bundle bundle, String header, Version versionToMatch) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); // get version range String range = (String) bundle.getHeaders().get(header); diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManagerTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManagerTest.java index 9ee88a65..0b45fe92 100644 --- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManagerTest.java +++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManagerTest.java @@ -28,7 +28,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.Version; -import static java.lang.Thread.yield; import static java.util.concurrent.TimeUnit.SECONDS; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; @@ -96,7 +95,7 @@ public void testFailingAsynchronousShutdown() throws Exception { withFailingApplicationContextClose(); shutdownContext(); - yield(); + Thread.yield(); verifyContextIsClosed(); verifyOsgiContextProcessorInteractions(); @@ -130,7 +129,7 @@ public void testSuccessfulAsynchronousDestruction() throws Exception { addContextToLifecycleManager(); destroy(); - yield(); + Thread.yield(); verifyContextIsClosed(); verifyOsgiContextProcessorInteractions(); diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/DummyApplicationEventMulticaster.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/DummyApplicationEventMulticaster.java index bede3dc1..3ffaa38d 100644 --- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/DummyApplicationEventMulticaster.java +++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/DummyApplicationEventMulticaster.java @@ -19,6 +19,8 @@ import org.springframework.context.event.ApplicationEventMulticaster; import org.springframework.core.ResolvableType; +import java.util.function.Predicate; + /** * @author Costin Leau */ @@ -44,6 +46,14 @@ public void removeApplicationListener(ApplicationListener arg0) { public void removeApplicationListenerBean(String arg0) { } + @Override + public void removeApplicationListeners(Predicate> predicate) { + } + + @Override + public void removeApplicationListenerBeans(Predicate predicate) { + } + public void addApplicationListenerBean(String listenerBeanName) { } diff --git a/extensions/pom.xml b/extensions/pom.xml index 9a5c3c6e..dcc4c6a3 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -25,18 +25,18 @@ - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-core + org.springframework + spring-core provided org.osgi - org.osgi.compendium + osgi.cmpn provided org.osgi - org.osgi.core + osgi.core provided diff --git a/extensions/src/main/java/org/eclipse/gemini/blueprint/extensions/annotation/ServiceReferenceInjectionBeanPostProcessor.java b/extensions/src/main/java/org/eclipse/gemini/blueprint/extensions/annotation/ServiceReferenceInjectionBeanPostProcessor.java index 8f742333..360421ba 100644 --- a/extensions/src/main/java/org/eclipse/gemini/blueprint/extensions/annotation/ServiceReferenceInjectionBeanPostProcessor.java +++ b/extensions/src/main/java/org/eclipse/gemini/blueprint/extensions/annotation/ServiceReferenceInjectionBeanPostProcessor.java @@ -26,7 +26,7 @@ import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.*; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; +import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.ReflectionUtils; @@ -45,8 +45,8 @@ * * @author Andy Piper */ -public class ServiceReferenceInjectionBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements - BundleContextAware, BeanFactoryAware, BeanClassLoaderAware { +public class ServiceReferenceInjectionBeanPostProcessor implements + BundleContextAware, BeanFactoryAware, BeanClassLoaderAware, SmartInstantiationAwareBeanPostProcessor { private BundleContext bundleContext; diff --git a/integration-tests/bundles/blueprint/config.bundle/pom.xml b/integration-tests/bundles/blueprint/config.bundle/pom.xml index d76d593e..251df74f 100644 --- a/integration-tests/bundles/blueprint/config.bundle/pom.xml +++ b/integration-tests/bundles/blueprint/config.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt.blueprint bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/blueprint/error.bundle/pom.xml b/integration-tests/bundles/blueprint/error.bundle/pom.xml index 6b4fd131..0eb1aa3c 100644 --- a/integration-tests/bundles/blueprint/error.bundle/pom.xml +++ b/integration-tests/bundles/blueprint/error.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt.blueprint bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/blueprint/pom.xml b/integration-tests/bundles/blueprint/pom.xml index 49313737..8cbcb2e2 100644 --- a/integration-tests/bundles/blueprint/pom.xml +++ b/integration-tests/bundles/blueprint/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint-integration-test-bundles org.eclipse.gemini.blueprint.iandt - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/blueprint/simple.bundle/pom.xml b/integration-tests/bundles/blueprint/simple.bundle/pom.xml index 1b2a52d5..f2f511c0 100644 --- a/integration-tests/bundles/blueprint/simple.bundle/pom.xml +++ b/integration-tests/bundles/blueprint/simple.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt.blueprint bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/blueprint/waiting.bundle/pom.xml b/integration-tests/bundles/blueprint/waiting.bundle/pom.xml index c626f906..1eb61aae 100644 --- a/integration-tests/bundles/blueprint/waiting.bundle/pom.xml +++ b/integration-tests/bundles/blueprint/waiting.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt.blueprint bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/cardinality.0to1.bundle/pom.xml b/integration-tests/bundles/cardinality.0to1.bundle/pom.xml index 0504f2d7..154a2eb4 100644 --- a/integration-tests/bundles/cardinality.0to1.bundle/pom.xml +++ b/integration-tests/bundles/cardinality.0to1.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/async.nowait.bundle/pom.xml b/integration-tests/bundles/config.bundle/async.nowait.bundle/pom.xml index 0ae861b7..9614e232 100644 --- a/integration-tests/bundles/config.bundle/async.nowait.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/async.nowait.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/async.wait.bundle/pom.xml b/integration-tests/bundles/config.bundle/async.wait.bundle/pom.xml index eb3efa6f..9541bee8 100644 --- a/integration-tests/bundles/config.bundle/async.wait.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/async.wait.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/no.publish.bundle/pom.xml b/integration-tests/bundles/config.bundle/no.publish.bundle/pom.xml index 5b3cb852..7bcfe27b 100644 --- a/integration-tests/bundles/config.bundle/no.publish.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/no.publish.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/pom.xml b/integration-tests/bundles/config.bundle/pom.xml index c064dbc6..b468f173 100644 --- a/integration-tests/bundles/config.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/sync.nowait.bundle/pom.xml b/integration-tests/bundles/config.bundle/sync.nowait.bundle/pom.xml index b30f8f8b..2e118c39 100644 --- a/integration-tests/bundles/config.bundle/sync.nowait.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/sync.nowait.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/sync.tail.bundle/pom.xml b/integration-tests/bundles/config.bundle/sync.tail.bundle/pom.xml index d746c309..06029567 100644 --- a/integration-tests/bundles/config.bundle/sync.tail.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/sync.tail.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.bundle/sync.wait.bundle/pom.xml b/integration-tests/bundles/config.bundle/sync.wait.bundle/pom.xml index c1394440..ac495ffe 100644 --- a/integration-tests/bundles/config.bundle/sync.wait.bundle/pom.xml +++ b/integration-tests/bundles/config.bundle/sync.wait.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt config.bundle - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/config.file.with.dots.bundle/pom.xml b/integration-tests/bundles/config.file.with.dots.bundle/pom.xml index 97ab3b39..e34489f8 100644 --- a/integration-tests/bundles/config.file.with.dots.bundle/pom.xml +++ b/integration-tests/bundles/config.file.with.dots.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/configuration.test.bundle/pom.xml b/integration-tests/bundles/configuration.test.bundle/pom.xml index b8baab57..6c7b32ca 100644 --- a/integration-tests/bundles/configuration.test.bundle/pom.xml +++ b/integration-tests/bundles/configuration.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/deadlock.bundle/pom.xml b/integration-tests/bundles/deadlock.bundle/pom.xml index 5b9e3252..c9516cec 100644 --- a/integration-tests/bundles/deadlock.bundle/pom.xml +++ b/integration-tests/bundles/deadlock.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/dependency.factory.bundle/pom.xml b/integration-tests/bundles/dependency.factory.bundle/pom.xml index ea0abe89..f61cad0d 100644 --- a/integration-tests/bundles/dependency.factory.bundle/pom.xml +++ b/integration-tests/bundles/dependency.factory.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/dependency.test.bundle/pom.xml b/integration-tests/bundles/dependency.test.bundle/pom.xml index 5d68e08f..4b427195 100644 --- a/integration-tests/bundles/dependency.test.bundle/pom.xml +++ b/integration-tests/bundles/dependency.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/error.bundle/pom.xml b/integration-tests/bundles/error.bundle/pom.xml index 6ee1b583..a56e6c07 100644 --- a/integration-tests/bundles/error.bundle/pom.xml +++ b/integration-tests/bundles/error.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/export.import.dependency.bundle/pom.xml b/integration-tests/bundles/export.import.dependency.bundle/pom.xml index c7d0319f..619c5b44 100644 --- a/integration-tests/bundles/export.import.dependency.bundle/pom.xml +++ b/integration-tests/bundles/export.import.dependency.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/extender.fragment.bundle/pom.xml b/integration-tests/bundles/extender.fragment.bundle/pom.xml index 34612237..d538791b 100644 --- a/integration-tests/bundles/extender.fragment.bundle/pom.xml +++ b/integration-tests/bundles/extender.fragment.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/extender.listener.bundle/pom.xml b/integration-tests/bundles/extender.listener.bundle/pom.xml index 7f9b7b7f..a126e7e4 100644 --- a/integration-tests/bundles/extender.listener.bundle/pom.xml +++ b/integration-tests/bundles/extender.listener.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/extender.version.bundle/pom.xml b/integration-tests/bundles/extender.version.bundle/pom.xml index ddddc4d2..77d65118 100644 --- a/integration-tests/bundles/extender.version.bundle/pom.xml +++ b/integration-tests/bundles/extender.version.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/io.fragment.1.bundle/pom.xml b/integration-tests/bundles/io.fragment.1.bundle/pom.xml index e477a253..d7fb23b7 100644 --- a/integration-tests/bundles/io.fragment.1.bundle/pom.xml +++ b/integration-tests/bundles/io.fragment.1.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/io.fragment.2.bundle/pom.xml b/integration-tests/bundles/io.fragment.2.bundle/pom.xml index a2fbaf43..dda0aebf 100644 --- a/integration-tests/bundles/io.fragment.2.bundle/pom.xml +++ b/integration-tests/bundles/io.fragment.2.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/jdk.proxy.bundle/pom.xml b/integration-tests/bundles/jdk.proxy.bundle/pom.xml index b5503da6..4f286bf7 100644 --- a/integration-tests/bundles/jdk.proxy.bundle/pom.xml +++ b/integration-tests/bundles/jdk.proxy.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/jdk5/component.scan.bundle/pom.xml b/integration-tests/bundles/jdk5/component.scan.bundle/pom.xml index f7658c8c..e5c0a3d7 100644 --- a/integration-tests/bundles/jdk5/component.scan.bundle/pom.xml +++ b/integration-tests/bundles/jdk5/component.scan.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt spring-osgi-jdk5-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/jdk5/pom.xml b/integration-tests/bundles/jdk5/pom.xml index 49cf26da..fa5ed6ae 100644 --- a/integration-tests/bundles/jdk5/pom.xml +++ b/integration-tests/bundles/jdk5/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/lifecycle.test.bundle/pom.xml b/integration-tests/bundles/lifecycle.test.bundle/pom.xml index ab76ee5c..7a316863 100644 --- a/integration-tests/bundles/lifecycle.test.bundle/pom.xml +++ b/integration-tests/bundles/lifecycle.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/namespace.own.consumer.bundle/pom.xml b/integration-tests/bundles/namespace.own.consumer.bundle/pom.xml index dee677f9..e276e20a 100644 --- a/integration-tests/bundles/namespace.own.consumer.bundle/pom.xml +++ b/integration-tests/bundles/namespace.own.consumer.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/pom.xml b/integration-tests/bundles/pom.xml index fddad055..66217798 100644 --- a/integration-tests/bundles/pom.xml +++ b/integration-tests/bundles/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-tests-parent - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -31,7 +31,7 @@ org.osgi - org.osgi.core + osgi.core provided diff --git a/integration-tests/bundles/proxy.creator.bundle/pom.xml b/integration-tests/bundles/proxy.creator.bundle/pom.xml index 7aa28099..7bff01ff 100644 --- a/integration-tests/bundles/proxy.creator.bundle/pom.xml +++ b/integration-tests/bundles/proxy.creator.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/proxy.destruction.test.bundle/pom.xml b/integration-tests/bundles/proxy.destruction.test.bundle/pom.xml index 47cb8341..6b99e485 100644 --- a/integration-tests/bundles/proxy.destruction.test.bundle/pom.xml +++ b/integration-tests/bundles/proxy.destruction.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/proxy.listener/pom.xml b/integration-tests/bundles/proxy.listener/pom.xml index 60fed384..4335f951 100644 --- a/integration-tests/bundles/proxy.listener/pom.xml +++ b/integration-tests/bundles/proxy.listener/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/recursive.type.bundle/pom.xml b/integration-tests/bundles/recursive.type.bundle/pom.xml index 535fee91..bfeb8431 100644 --- a/integration-tests/bundles/recursive.type.bundle/pom.xml +++ b/integration-tests/bundles/recursive.type.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/reference.test.bundle/pom.xml b/integration-tests/bundles/reference.test.bundle/pom.xml index 7610f8c0..68175e34 100644 --- a/integration-tests/bundles/reference.test.bundle/pom.xml +++ b/integration-tests/bundles/reference.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/scoped.a.bundle/pom.xml b/integration-tests/bundles/scoped.a.bundle/pom.xml index 36896ca0..b37d944e 100644 --- a/integration-tests/bundles/scoped.a.bundle/pom.xml +++ b/integration-tests/bundles/scoped.a.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/scoped.b.bundle/pom.xml b/integration-tests/bundles/scoped.b.bundle/pom.xml index b77ed20d..e6a9f57c 100644 --- a/integration-tests/bundles/scoped.b.bundle/pom.xml +++ b/integration-tests/bundles/scoped.b.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/scoped.common.bundle/pom.xml b/integration-tests/bundles/scoped.common.bundle/pom.xml index 7b04887f..7f82cdae 100644 --- a/integration-tests/bundles/scoped.common.bundle/pom.xml +++ b/integration-tests/bundles/scoped.common.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/service.listener.bundle/pom.xml b/integration-tests/bundles/service.listener.bundle/pom.xml index 6437914c..8408bf24 100644 --- a/integration-tests/bundles/service.listener.bundle/pom.xml +++ b/integration-tests/bundles/service.listener.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/simple.service.2.bundle/pom.xml b/integration-tests/bundles/simple.service.2.bundle/pom.xml index e494d4d9..d89d702a 100644 --- a/integration-tests/bundles/simple.service.2.bundle/pom.xml +++ b/integration-tests/bundles/simple.service.2.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/simple.service.3.bundle/pom.xml b/integration-tests/bundles/simple.service.3.bundle/pom.xml index 06b1e8e6..d6851e8e 100644 --- a/integration-tests/bundles/simple.service.3.bundle/pom.xml +++ b/integration-tests/bundles/simple.service.3.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/simple.service.bundle.2.identical/pom.xml b/integration-tests/bundles/simple.service.bundle.2.identical/pom.xml index 6335767a..746d40cc 100644 --- a/integration-tests/bundles/simple.service.bundle.2.identical/pom.xml +++ b/integration-tests/bundles/simple.service.bundle.2.identical/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/simple.service.bundle.identical/pom.xml b/integration-tests/bundles/simple.service.bundle.identical/pom.xml index 20407473..ea9afdb0 100644 --- a/integration-tests/bundles/simple.service.bundle.identical/pom.xml +++ b/integration-tests/bundles/simple.service.bundle.identical/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/simple.service.bundle/pom.xml b/integration-tests/bundles/simple.service.bundle/pom.xml index 5cb595cb..4e6805bb 100644 --- a/integration-tests/bundles/simple.service.bundle/pom.xml +++ b/integration-tests/bundles/simple.service.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/tccl.bundle/pom.xml b/integration-tests/bundles/tccl.bundle/pom.xml index 4c75f731..69b83183 100644 --- a/integration-tests/bundles/tccl.bundle/pom.xml +++ b/integration-tests/bundles/tccl.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/tccl.intf.bundle/pom.xml b/integration-tests/bundles/tccl.intf.bundle/pom.xml index 20f20c3d..92937203 100644 --- a/integration-tests/bundles/tccl.intf.bundle/pom.xml +++ b/integration-tests/bundles/tccl.intf.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/trivial.bundle/pom.xml b/integration-tests/bundles/trivial.bundle/pom.xml index 0766dd7c..da7cd0c8 100644 --- a/integration-tests/bundles/trivial.bundle/pom.xml +++ b/integration-tests/bundles/trivial.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/bundles/trivial.test.bundle/pom.xml b/integration-tests/bundles/trivial.test.bundle/pom.xml index be47e091..fea442bc 100644 --- a/integration-tests/bundles/trivial.test.bundle/pom.xml +++ b/integration-tests/bundles/trivial.test.bundle/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-test-bundles - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index f351bc27..ac2bfe40 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint gemini-blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -24,24 +24,6 @@ tests - - - release - - - - - maven-surefire-plugin - - true - - - - - - - - diff --git a/integration-tests/tests/pom.xml b/integration-tests/tests/pom.xml index bae666f3..df6c65cf 100644 --- a/integration-tests/tests/pom.xml +++ b/integration-tests/tests/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint.iandt gemini-blueprint-integration-tests-parent - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -197,7 +197,7 @@ ${project.build.testOutputDirectory}/logback-test.xml - ${clover.argLine} ${security.argLine} -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass + ${clover.argLine} ${security.argLine} -XX:+UnlockDiagnosticVMOptions --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/compliance/io/CallingResourceOnDifferentBundlesTest.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/compliance/io/CallingResourceOnDifferentBundlesTest.java index 131a2380..3c96ea05 100644 --- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/compliance/io/CallingResourceOnDifferentBundlesTest.java +++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/compliance/io/CallingResourceOnDifferentBundlesTest.java @@ -70,7 +70,8 @@ public void testCallGetResourcesOnADifferentBundle() throws Exception { } public void testCallGetResourceOnADifferentBundleRetrievedThroughBundleEvent() throws Exception { - String EXTRA_BUNDLE = "org.apache.servicemix.bundles.spring-core"; + // those tests are using Atlassian Spring bundle now instead of servicemix repackages + String EXTRA_BUNDLE = "platform-spring-bundle"; Bundle[] bundles = bundleContext.getBundles(); Bundle bundle = null; diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/configopt/BehaviorBaseTest.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/configopt/BehaviorBaseTest.java index 458915ae..b1346f16 100644 --- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/configopt/BehaviorBaseTest.java +++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/configopt/BehaviorBaseTest.java @@ -38,7 +38,7 @@ public abstract class BehaviorBaseTest extends BaseIntegrationTest { * @param alive */ protected void assertContextServiceIs(Bundle bundle, boolean alive, long maxWait) { - Assert.notNull(bundle); + Assert.notNull(bundle, "required field"); try { waitOnContextCreation(bundle.getSymbolicName(), maxWait / 1000 + 1); diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/ClassSpaceWildcardTest.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/ClassSpaceWildcardTest.java index fc77f318..7f5aaa6b 100644 --- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/ClassSpaceWildcardTest.java +++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/ClassSpaceWildcardTest.java @@ -45,7 +45,10 @@ public void testWildcardAtRootFileLevel() throws Exception { // similar as the root test but inside META-INF public void testWildcardAtFolderLevel() throws Exception { Resource res[] = patternLoader.getResources("classpath:/META-INF/*"); - assertEquals("not enough packages found", 1, res.length); + // after updating configuration to include license file `META-INF/*` contains 2 resources: + // - `MANIFEST.MF` + // - `license-apache.txt` + assertEquals("not enough packages found", 2, res.length); printPathWithinContext(res); } diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/OSGI799Test.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/OSGI799Test.java index ef8ac0cc..dd08a806 100644 --- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/OSGI799Test.java +++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/io/OSGI799Test.java @@ -34,7 +34,14 @@ * * The test will install two bundle, one with a custom classpath exporting a package and the other importing that * particular package. - * + * + * ATLASSIAN notes: + * Apparently Gemini implementation treats every "Bundle-ClassPath" entry as a separate root. + * `osgi-799-exp.jar` defines 3 entries there: + * - `.` - typical simple root of the jar + * - `cp` - a directory inside the jar + * - `nested.jar` - a nested jar that is loaded by the bundle classloader (we are using similar pattern to register embedded libraries in plugins) + * * @author Costin Leau */ public class OSGI799Test extends BaseIoTest { @@ -94,6 +101,10 @@ protected ResourcePatternResolver getImporterPatternLoader() { public void testExportedCustomCP() throws Exception { ResourcePatternResolver resolver = getExporterPatternLoader(); + // It detects: + // - `/some/path/root/root.res` from the default classpath root (`.`) + // - `some/path/cp/cp.res` from the `cp` directory (defined as classpath root) + // - `some/path/nested/nested.res` from the `nested.jar` (defined as classpath root) Resource[] resources = resolver.getResources("classpath:/some/**/*.res"); System.out.println(Arrays.toString(resources)); assertEquals(3, resources.length); @@ -101,6 +112,8 @@ public void testExportedCustomCP() throws Exception { public void testImportedCustomCP() throws Exception { ResourcePatternResolver resolver = getImporterPatternLoader(); + // Importer bundle imports all the paths (they are not only packages!) + // so it has access to exactly the same resources as the exporter defined in test above Resource[] resources = resolver.getResources("classpath:some/**/*.res"); System.out.println(Arrays.toString(resources)); assertEquals(3, resources.length); @@ -108,29 +121,58 @@ public void testImportedCustomCP() throws Exception { public void testExportedCustomFoldersCP() throws Exception { ResourcePatternResolver resolver = getExporterPatternLoader(); + // It detects: + // - `/cp/some/path/cp/cp.res` from the default classpath root (`.`) + // - `/some/path/root/root.res` from the default classpath root (`.`) + // - `some/path/cp/cp.res` from the `cp` directory (defined as classpath root) + // - `some/path/nested/nested.res` from the `nested.jar` (defined as classpath root) Resource[] resources = resolver.getResources("classpath:/**/path/**/*"); System.out.println(Arrays.toString(resources)); - assertEquals(8, resources.length); + // Original value - 8 + // Actual expected value should be 4, as shown above + // The tests used to execute on Spring 5 that contains a bug: + // https://github.com/spring-projects/spring-framework/issues/27506 + // in this specific scenario, it returned not only files, but also directories - hence the result was 8. + assertEquals(4, resources.length); } public void testImporterCustomFoldersCP() throws Exception { ResourcePatternResolver resolver = getImporterPatternLoader(); + // The pattern is exactly the same as in case above + // Importer imports: + // - `some.path.root` + // - `some.path.cp` + // - `some.path.nested` + // There is no import for `cp.some.path.cp`, so that resource won't be available for importer Resource[] resources = resolver.getResources("classpath:/**/path/**/*"); System.out.println(Arrays.toString(resources)); - assertEquals(5, resources.length); + // Original value - 5 + // See explanation in above test case + assertEquals(3, resources.length); } public void testExportedCustomPatternFoldersCP() throws Exception { ResourcePatternResolver resolver = getExporterPatternLoader(); + // The pattern is almost the same as in previous case. + // The difference is in `p?th` instead of `path`. + // However, bundle doesn't contain any other directories that could match that pattern. + // Result resources are exactly the same as in the exporter case above. Resource[] resources = resolver.getResources("classpath:/**/p?th/**/*"); System.out.println(Arrays.toString(resources)); - assertEquals(8, resources.length); + // Original value - 8 + // For explanation check exporter case above + assertEquals(4, resources.length); } public void testImporterCustomPatternFoldersCP() throws Exception { ResourcePatternResolver resolver = getImporterPatternLoader(); + // Pattern is exactly the same as in case above. + // Here we have exactly the same case as in previous importer case. + // Importer doesn't import all the packages/directories, so instead of 4 it has access to only 3 resources. Resource[] resources = resolver.getResources("classpath:/**/p?th/**/*"); System.out.println(Arrays.toString(resources)); - assertEquals(5, resources.length); + // Original value - 5 + // For explanation check cases above + assertEquals(3, resources.length); } } \ No newline at end of file diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/jdk5/io/ComponentScanTest.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/jdk5/io/ComponentScanTest.java index 329fab8c..d566718d 100644 --- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/jdk5/io/ComponentScanTest.java +++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/jdk5/io/ComponentScanTest.java @@ -16,6 +16,7 @@ import org.eclipse.gemini.blueprint.iandt.BaseIntegrationTest; import org.eclipse.gemini.blueprint.iandt.io.component.ComponentBean; +import org.springframework.stereotype.Component; /** * Integration test for Spring 2.5 component scan. @@ -25,6 +26,21 @@ */ public class ComponentScanTest extends BaseIntegrationTest { + static { + // Modern Spring versions are trying to load and compare annotation by its runtime type. + // Older versions were simply comparing names of the class. + // That is an important change in OSGi world, + // where some bundles may not have access to specific classes or have different versions of them. + // + // Those tests create OSGi bundles on the fly. Code below ensures that created bundle will import Spring package. + // With that configuration Spring used by Gemini will be able to properly load an XML configuration. + // + // For Spring change see: + // https://github.com/spring-projects/spring-framework/issues/22884 + // https://github.com/spring-projects/spring-framework/commit/7fbf3f97cdeffd7e60a7dc9b19ca59ce73cd1cea#diff-8edf0405eb9b93018d302aaa928ec58c231a58e34d92bcd7c3241b42c99be99cR99 + Class componentClass = Component.class; + } + protected String[] getConfigLocations() { return new String[] { "/org/eclipse/gemini/blueprint/iandt/jdk5/io/component-scan.xml" }; } diff --git a/integration-tests/tests/src/test/resources/logback-test.xml b/integration-tests/tests/src/test/resources/logback-test.xml index c27d7e38..27888067 100644 --- a/integration-tests/tests/src/test/resources/logback-test.xml +++ b/integration-tests/tests/src/test/resources/logback-test.xml @@ -5,6 +5,9 @@ %-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{32}:%line - %msg %ex%n + + WARN + diff --git a/io/pom.xml b/io/pom.xml index 371cc2cb..0fe520dd 100644 --- a/io/pom.xml +++ b/io/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -32,13 +32,13 @@ test - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-core + org.springframework + spring-core provided org.osgi - org.osgi.core + osgi.core provided diff --git a/io/src/main/java/org/eclipse/gemini/blueprint/io/OsgiBundleResource.java b/io/src/main/java/org/eclipse/gemini/blueprint/io/OsgiBundleResource.java index 3d7d11e6..2d155955 100644 --- a/io/src/main/java/org/eclipse/gemini/blueprint/io/OsgiBundleResource.java +++ b/io/src/main/java/org/eclipse/gemini/blueprint/io/OsgiBundleResource.java @@ -425,7 +425,7 @@ ContextResource[] getAllUrlsFromBundleSpace(String location) throws IOException throw new IllegalArgumentException( "cannot locate items in bundle-space w/o a bundle; specify one when creating this resolver"); - Assert.notNull(location); + Assert.notNull(location, "required field"); Set resources = new LinkedHashSet(5); location = StringUtils.cleanPath(location); diff --git a/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/OsgiResourceUtils.java b/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/OsgiResourceUtils.java index 2f79d9b7..bb92f1b7 100644 --- a/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/OsgiResourceUtils.java +++ b/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/OsgiResourceUtils.java @@ -84,7 +84,7 @@ public static String getPrefix(String path) { * @return */ public static int getSearchType(String path) { - Assert.notNull(path); + Assert.notNull(path, "required field"); int type = PREFIX_TYPE_NOT_SPECIFIED; String prefix = getPrefix(path); diff --git a/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/resolver/PackageAdminResolver.java b/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/resolver/PackageAdminResolver.java index 267c9ad1..7aa0dc20 100644 --- a/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/resolver/PackageAdminResolver.java +++ b/io/src/main/java/org/eclipse/gemini/blueprint/io/internal/resolver/PackageAdminResolver.java @@ -57,7 +57,7 @@ public class PackageAdminResolver implements DependencyResolver { public PackageAdminResolver(BundleContext bundleContext) { - Assert.notNull(bundleContext); + Assert.notNull(bundleContext, "required field"); this.bundleContext = bundleContext; } diff --git a/mock/pom.xml b/mock/pom.xml index 54be2e3c..f4467418 100644 --- a/mock/pom.xml +++ b/mock/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -24,7 +24,7 @@ org.osgi - org.osgi.core + osgi.core provided diff --git a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockBundleContext.java b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockBundleContext.java index 427c626c..7427004e 100644 --- a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockBundleContext.java +++ b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockBundleContext.java @@ -38,7 +38,9 @@ import org.osgi.framework.Filter; import org.osgi.framework.FrameworkListener; import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceFactory; import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceObjects; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; @@ -166,7 +168,12 @@ public S getService(ServiceReference reference) { } } - private static Class getClass(Type type) { + @Override + public ServiceObjects getServiceObjects(ServiceReference reference) { + return null; + } + + private static Class getClass(Type type) { if (type instanceof Class) { return (Class) type; } @@ -280,7 +287,12 @@ public ServiceRegistration registerService(Class clazz, S service, Dic return registration; } - public void removeServiceListener(ServiceListener listener) { + @Override + public ServiceRegistration registerService(Class clazz, ServiceFactory factory, Dictionary properties) { + return new MockServiceRegistration(properties); + } + + public void removeServiceListener(ServiceListener listener) { serviceListeners.remove(listener); } diff --git a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java index 33bacdf7..3eb9ef3e 100644 --- a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java +++ b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java @@ -244,4 +244,9 @@ public int compareTo(Object reference) { return result; } + + @Override + public Dictionary getProperties() { + return properties; + } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index e4cc8ad8..7c6c4e55 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.eclipse.gemini.blueprint gemini-blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT pom Gemini Blueprint http://www.eclipse.org/gemini/blueprint/ @@ -23,8 +23,8 @@ UTF-8 - 5.0.4.RELEASE_1 - 5.0.0 + 6.2.0 + 6.0.0 org.eclipse.gemini.blueprint ${project.groupId}.${project.artifactId} @@ -38,14 +38,10 @@ - 5.0.0 + 7.0.0 - - 3.9.1.v20130814-1242 - - 7.1.2 - - 4.4.0 + + 7.0.5 ${basedir}/docs/src/javadoc @@ -54,18 +50,18 @@ false - false - ..${file.separator}policy.all - [${spring.base.version},6) + [${spring.base.version},7) "${spring.version.range.nq}" [${project.version},${project.version}] "${gemini.blueprint.version.range.nq}" "[1.0,2.0)" + + org.eclipse.gemini.blueprint.test.platform.FelixPlatform @@ -97,10 +93,9 @@ - http://git.eclipse.org/c/gemini.blueprint/org.eclipse.gemini.blueprint.git/ - scm:git:git//git.eclipse.org/gitroot/gemini.blueprint/org.eclipse.gemini.blueprint.git - - scm:git:file:///gitroot/gemini.blueprint/org.eclipse.gemini.blueprint.git + https://github.com/atlassian-forks/gemini.blueprint + scm:git:git@github.com:atlassian-forks/gemini.blueprint.git + scm:git:git@github.com:atlassian-forks/gemini.blueprint.git HEAD @@ -188,6 +183,7 @@ extender extensions test-support + integration-tests @@ -221,38 +217,38 @@ - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-aop + org.springframework + spring-aop ${spring.maven.artifact.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-beans + org.springframework + spring-beans ${spring.maven.artifact.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-core + org.springframework + spring-core ${spring.maven.artifact.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-context + org.springframework + spring-context ${spring.maven.artifact.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-expression + org.springframework + spring-expression ${spring.maven.artifact.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-test + org.springframework + spring-test ${spring.maven.artifact.version} @@ -264,13 +260,13 @@ org.osgi - org.osgi.core + osgi.core ${osgi.ver} org.osgi - org.osgi.compendium + osgi.cmpn ${osgi.ver} @@ -280,18 +276,6 @@ 4.12_1 - - org.eclipse.birt.runtime - org.eclipse.osgi - ${equinox.ver} - - - - org.knopflerfish - framework - ${kf.ver} - - org.apache.felix org.apache.felix.main @@ -306,6 +290,12 @@ + + com.atlassian.platform.dependencies + platform-spring-bundle + 8.0.0-jakarta-001 + + @@ -313,9 +303,9 @@ - javax.inject - javax.inject - 1 + jakarta.servlet + jakarta.servlet-api + 4.0.4 @@ -373,6 +363,24 @@ ${logback.version} provided + + + org.apache.felix + org.apache.felix.main + ${felix.ver} + provided + + + org.apache.felix + org.apache.felix.framework + + + + + org.osgi + osgi.core + compile + @@ -388,18 +396,6 @@ - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - true - - org.apache.maven.plugins maven-release-plugin @@ -414,7 +410,7 @@ biz.aQute.bnd bnd-maven-plugin - 3.3.0 + 7.0.0 @@ -436,7 +432,7 @@ org.apache.maven.plugins maven-site-plugin - 3.6 + 3.21.0 org.apache.maven.plugins @@ -467,6 +463,9 @@ org.apache.maven.plugins maven-surefire-plugin 2.19.1 + + --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED + @@ -491,9 +490,10 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.4.0 true + false -Xdoclint:none @@ -510,16 +510,6 @@ maven-jxr-plugin 2.5 - - org.codehaus.mojo - jdepend-maven-plugin - 2.0 - - - org.codehaus.mojo - findbugs-maven-plugin - 3.0.4 - org.apache.maven.plugins maven-antrun-plugin @@ -543,7 +533,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 2.9 + 3.8.0 @@ -554,8 +544,8 @@ maven-compiler-plugin 3.6.1 - 1.8 - 1.8 + 17 + 17 @@ -631,68 +621,6 @@ maven-site-plugin true - - - org.apache.maven.plugins - maven-jxr-plugin - - true - - - - org.apache.maven.plugins - maven-surefire-report-plugin - - true - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - - - - - - - org.codehaus.mojo - findbugs-maven-plugin - - - Normal - Default - - ${findbugs.skip} - - - - - - - - - org.apache.maven.plugins - maven-pmd-plugin - - 1.7 - - - - - - - - org.codehaus.mojo - jdepend-maven-plugin - - @@ -778,83 +706,43 @@ + + org.apache.maven.plugins + maven-resources-plugin + + + copy-license + process-sources + + copy-resources + + + ${project.build.outputDirectory}/META-INF + true + + + ${user.dir} + + license-apache.txt + + true + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + - - + - - equinox - - - org.eclipse.birt.runtime - org.eclipse.osgi - ${equinox.ver} - provided - - - - org.eclipse.gemini.blueprint.test.platform.EquinoxPlatform - - - - - knopflerfish - - - org.knopflerfish - framework - ${kf.ver} - provided - - - - org.eclipse.gemini.blueprint.test.platform.KnopflerfishPlatform - true - - - - - felix - - - org.apache.felix - org.apache.felix.main - ${felix.ver} - provided - - - org.apache.felix - org.apache.felix.framework - - - - - org.osgi - org.osgi.core - compile - - - - org.eclipse.gemini.blueprint.test.platform.FelixPlatform - - - - - - it - - - env-test - - - - integration-tests - - @@ -897,30 +785,6 @@ --> release - - core - extender - extensions - integration-tests - io - mock - test-support - - - - - - org.osgi - org.osgi.core - compile - - - @@ -956,45 +820,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - - default-deploy - deploy - - deploy - - - - - ossrh - https://oss.sonatype.org/ - false - - true - - @@ -1006,14 +831,13 @@ - http://www.eclipse.org/gemini/blueprint/download/ - ossrh - https://oss.sonatype.org/content/repositories/snapshots + atlassian-3rdparty-snapshot + https://packages.atlassian.com/maven/3rdparty-snapshot - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + atlassian-3rdparty + https://packages.atlassian.com/maven/3rdparty @@ -1044,4 +868,40 @@ + + + + org.apache.maven.plugins + maven-jxr-plugin + + true + + + + org.apache.maven.plugins + maven-surefire-report-plugin + + true + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + + 1.7 + + + + + diff --git a/test-support/pom.xml b/test-support/pom.xml index 7353ced2..c08394ea 100644 --- a/test-support/pom.xml +++ b/test-support/pom.xml @@ -5,7 +5,7 @@ gemini-blueprint org.eclipse.gemini.blueprint - 3.0.0.M01-SNAPSHOT + 4.0.0-atlassian-5-SNAPSHOT ../pom.xml @@ -39,14 +39,14 @@ - org.apache.servicemix.bundles - org.apache.servicemix.bundles.spring-test + org.springframework + spring-test org.ow2.asm - asm-all - 5.2 + asm + 9.6 @@ -64,27 +64,15 @@ - org.osgi - org.osgi.core + org.apache.felix + org.apache.felix.main provided true - org.eclipse.birt.runtime - org.eclipse.osgi - provided - true - - - org.knopflerfish - framework - provided - true - - - org.apache.felix - org.apache.felix.main + org.osgi + osgi.core provided true @@ -95,6 +83,12 @@ gemini-blueprint-mock test + + + com.atlassian.platform.dependencies + platform-spring-bundle + runtime + diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractConfigurableOsgiTests.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractConfigurableOsgiTests.java index 9cea66c1..205c02ad 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractConfigurableOsgiTests.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractConfigurableOsgiTests.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Properties; -import org.eclipse.gemini.blueprint.test.platform.EquinoxPlatform; +import org.eclipse.gemini.blueprint.test.platform.FelixPlatform; import org.eclipse.gemini.blueprint.test.platform.OsgiPlatform; import org.eclipse.gemini.blueprint.test.platform.Platforms; import org.osgi.framework.Constants; @@ -103,7 +103,7 @@ protected OsgiPlatform createPlatform() { // fall back if (platform == null) - platform = new EquinoxPlatform(); + platform = new FelixPlatform(); Properties config = platform.getConfigurationProperties(); // add boot delegation @@ -128,7 +128,7 @@ protected String getPlatformName() { logger.trace("System property [" + OSGI_FRAMEWORK_SELECTOR + "] has value=" + systemProperty); } - return (!StringUtils.hasText(systemProperty) ? Platforms.EQUINOX : systemProperty); + return (!StringUtils.hasText(systemProperty) ? Platforms.FELIX : systemProperty); } /** diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractDependencyManagerTests.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractDependencyManagerTests.java index 03eabe83..5bcf355c 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractDependencyManagerTests.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractDependencyManagerTests.java @@ -77,7 +77,6 @@ public AbstractDependencyManagerTests(String name) { } private static final String GEMINI_BLUEPRINT_VERSION_PROP_KEY = "ignore.gemini.blueprint.version"; - private static final String SPRING_VERSION_PROP_KEY = "ignore.spring.version"; /** uninitialised - read from the properties file */ private String springOsgiVersion = null; @@ -100,19 +99,6 @@ protected String getSpringDMVersion() { return springOsgiVersion; } - /** - * Returns the version of the Spring bundles installed by the testing - * framework. - * - * @return Spring framework dependency version - */ - protected String getSpringVersion() { - if (springBundledVersion == null) { - springBundledVersion = readProperty(SPRING_VERSION_PROP_KEY); - } - return springBundledVersion; - } - private String readProperty(final String name) { if (System.getSecurityManager() != null) { return (String) AccessController.doPrivileged(new PrivilegedAction() { @@ -180,7 +166,6 @@ protected String[] getTestFrameworkBundlesNames() { // pass properties to test instance running inside OSGi space System.getProperties().put(GEMINI_BLUEPRINT_VERSION_PROP_KEY, props.get(GEMINI_BLUEPRINT_VERSION_PROP_KEY)); - System.getProperties().put(SPRING_VERSION_PROP_KEY, props.get(SPRING_VERSION_PROP_KEY)); Properties excluded = PropertiesUtil.filterKeysStartingWith(props, IGNORE); diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOptionalDependencyInjectionTests.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOptionalDependencyInjectionTests.java index 46ffda4a..64f98d8e 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOptionalDependencyInjectionTests.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOptionalDependencyInjectionTests.java @@ -54,6 +54,11 @@ public abstract class AbstractOptionalDependencyInjectionTests extends AbstractD // the disposable interface is added just so that byte code detect the org.springframework.beans.factory package private static class EmptyOsgiApplicationContext extends AbstractDelegatedExecutionApplicationContext implements DisposableBean { protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException, BeansException {} + + @Override + public void destroy() throws Exception { + this.close(); + } } diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOsgiTests.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOsgiTests.java index 0c5614fa..3083e5e3 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOsgiTests.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractOsgiTests.java @@ -398,8 +398,15 @@ private void initializeServiceRunnerInvocationMethods() throws Exception { BundleContext ctx = getRuntimeBundleContext(); - ServiceReference reference = ctx.getServiceReference(ACTIVATOR_REFERENCE); - Assert.notNull(reference, "no OSGi service reference found at " + ACTIVATOR_REFERENCE); + // analysing the code of Felix 7 it returns only those services that can be assigned by the requester + // here we are in the context of "System Bundle" and we are trying to get service from different bundle + // "System Bundle" doesn't have access to that class, so Felix returns `null` + // By calling all services we are omitting that check + ServiceReference[] allServiceReferences = ctx.getAllServiceReferences(ACTIVATOR_REFERENCE, null); + if (allServiceReferences.length == 0) { + throw new IllegalArgumentException("no OSGi service reference found at " + ACTIVATOR_REFERENCE); + } + ServiceReference reference = allServiceReferences[0]; service = ctx.getService(reference); Assert.notNull(service, "no service found for reference: " + reference); diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractSynchronizedOsgiTests.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractSynchronizedOsgiTests.java index 8b6236d7..d73c1845 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractSynchronizedOsgiTests.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/AbstractSynchronizedOsgiTests.java @@ -22,6 +22,7 @@ import org.eclipse.gemini.blueprint.util.OsgiBundleUtils; import org.eclipse.gemini.blueprint.util.OsgiListenerUtils; import org.eclipse.gemini.blueprint.util.OsgiStringUtils; +import org.osgi.framework.AllServiceListener; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceEvent; @@ -117,13 +118,10 @@ protected void waitOnContextCreation(BundleContext context, String forBundleWith String filter = "(org.springframework.context.service.name=" + forBundleWithSymbolicName + ")"; - ServiceListener listener = new ServiceListener() { - - public void serviceChanged(ServiceEvent event) { - if (event.getType() == ServiceEvent.REGISTERED) - counter.decrement(); - } - }; + AllServiceListener listener = event -> { + if (event.getType() == ServiceEvent.REGISTERED) + counter.decrement(); + }; OsgiListenerUtils.addServiceListener(context, listener, filter); diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/holder/ReflectionOsgiHolder.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/holder/ReflectionOsgiHolder.java index f1f2a86d..eb298cc8 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/holder/ReflectionOsgiHolder.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/holder/ReflectionOsgiHolder.java @@ -42,7 +42,7 @@ class ReflectionOsgiHolder extends OsgiTestInfoHolder { * @param twinInstance instance to wrap */ ReflectionOsgiHolder(Object twinInstance) { - Assert.notNull(twinInstance); + Assert.notNull(twinInstance, "required field"); this.instance = twinInstance; Class clazz = instance.getClass(); GET_TEST_BUNDLE_ID = ReflectionUtils.findMethod(clazz, "getTestBundleId"); diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/DependencyVisitor.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/DependencyVisitor.java index 06866044..9184564e 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/DependencyVisitor.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/DependencyVisitor.java @@ -65,7 +65,7 @@ */ public class DependencyVisitor extends ClassVisitor { - private final AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM5) { + private final AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM7) { @Override public void visit(String name, Object value) { DependencyVisitor.this.visit(name, value); @@ -92,7 +92,7 @@ public void visitEnd() { } }; - private final SignatureVisitor sv = new SignatureVisitor(Opcodes.ASM5) { + private final SignatureVisitor sv = new SignatureVisitor(Opcodes.ASM7) { @Override public void visitFormalTypeParameter(String name) { DependencyVisitor.this.visitFormalTypeParameter(name); @@ -174,7 +174,7 @@ public void visitEnd() { } }; - private final FieldVisitor fv = new FieldVisitor(Opcodes.ASM5) { + private final FieldVisitor fv = new FieldVisitor(Opcodes.ASM7) { @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { return DependencyVisitor.this.visitAnnotation(desc, visible); @@ -196,7 +196,7 @@ public void visitEnd() { } }; - private final MethodVisitor mv = new MethodVisitor(Opcodes.ASM5) { + private final MethodVisitor mv = new MethodVisitor(Opcodes.ASM7) { @Override public void visitParameter(String name, int access) { DependencyVisitor.this.visitParameter(name, access); @@ -354,7 +354,7 @@ public void visitEnd() { }; public DependencyVisitor() { - super(Opcodes.ASM5); + super(Opcodes.ASM7); } private AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) { diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/PropertiesUtil.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/PropertiesUtil.java index a991c951..39ed4eb2 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/PropertiesUtil.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/internal/util/PropertiesUtil.java @@ -248,7 +248,7 @@ public static Properties filterKeysStartingWith(Properties properties, String pr return EMPTY_PROPERTIES; } - Assert.notNull(properties); + Assert.notNull(properties, "required field"); Properties excluded = (properties instanceof OrderedProperties ? new OrderedProperties() : new Properties()); @@ -278,7 +278,7 @@ public static Properties filterValuesStartingWith(Properties properties, String return EMPTY_PROPERTIES; } - Assert.notNull(properties); + Assert.notNull(properties, "required field"); Properties excluded = (properties instanceof OrderedProperties ? new OrderedProperties() : new Properties()); for (Enumeration enm = properties.keys(); enm.hasMoreElements();) { @@ -305,7 +305,7 @@ public static Properties filterValuesStartingWith(Properties properties, String * @return */ public static Properties expandProperties(Properties props) { - Assert.notNull(props); + Assert.notNull(props, "required field"); Set entrySet = props.entrySet(); diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatform.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatform.java deleted file mode 100644 index c3dd650e..00000000 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatform.java +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.test.platform; - -import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Properties; - -import org.eclipse.core.runtime.adaptor.EclipseStarter; -import org.osgi.framework.BundleContext; - -/** - * Equinox (3.2.x) OSGi platform. - * - * @author Costin Leau - * - */ -public class EquinoxPlatform extends AbstractOsgiPlatform { - - private BundleContext context; - - - public EquinoxPlatform() { - toString = "Equinox OSGi Platform"; - } - - Properties getPlatformProperties() { - // default properties - Properties props = new Properties(); - props.setProperty("eclipse.ignoreApp", "true"); - props.setProperty("osgi.clean", "true"); - props.setProperty("osgi.noShutdown", "true"); - - // local temporary folder for running tests - // prevents accidental rewrites - props.setProperty("osgi.configuration.area", "./target/eclipse_config"); - props.setProperty("osgi.instance.area", "./target/eclipse_config"); - props.setProperty("osgi.user.area", "./target/eclipse_config"); - - // props.setProperty("eclipse.consoleLog", "true"); - // props.setProperty("osgi.debug", ""); - - return props; - } - - public BundleContext getBundleContext() { - return context; - } - - public void start() throws Exception { - - if (context == null) { - // copy configuration properties to sys properties - System.getProperties().putAll(getConfigurationProperties()); - - // Equinox 3.1.x returns void - use of reflection is required - // use main since in 3.1.x it sets up some system properties -// EclipseStarter.main(new String[0]); - -// final Field field = EclipseStarter.class.getDeclaredField("context"); - -// AccessController.doPrivileged(new PrivilegedAction() { -// public Object run() { -// field.setAccessible(true); -// return null; -// } -// }); -// context = (BundleContext) field.get(null); - context = EclipseStarter.startup(new String[0], null); - } - } - - public void stop() throws Exception { - if (context != null) { - context = null; - EclipseStarter.shutdown(); - } - } -} \ No newline at end of file diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatform.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatform.java deleted file mode 100644 index f7327670..00000000 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatform.java +++ /dev/null @@ -1,185 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.test.platform; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.eclipse.gemini.blueprint.test.internal.util.IOUtils; -import org.knopflerfish.framework.FrameworkFactoryImpl; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.springframework.beans.BeanUtils; -import org.springframework.util.ClassUtils; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ReflectionUtils; - -/** - * Knopflerfish 2.0.4+/3.x Platform. Automatically detects the available version on the class path and uses the - * appropriate means to configure and instantiate it. - * - * @author Costin Leau - */ -public class KnopflerfishPlatform extends AbstractOsgiPlatform { - - private static class KF2Platform implements Platform { - private static final Class BOOT_CLASS; - private static final Constructor CONSTRUCTOR; - private static final Method LAUNCH; - private static final Method GET_BUNDLE_CONTEXT; - private static final Method SHUTDOWN; - - static { - BOOT_CLASS = ClassUtils.resolveClassName(KF_2X_BOOT_CLASS, KF2Platform.class.getClassLoader()); - - try { - CONSTRUCTOR = BOOT_CLASS.getDeclaredConstructor(Object.class); - } catch (NoSuchMethodException nsme) { - throw new IllegalArgumentException("Invalid framework class", nsme); - } - - LAUNCH = BeanUtils.findDeclaredMethod(BOOT_CLASS, "launch", new Class[] { long.class }); - GET_BUNDLE_CONTEXT = - org.springframework.util.ReflectionUtils.findMethod(BOOT_CLASS, "getSystemBundleContext"); - SHUTDOWN = org.springframework.util.ReflectionUtils.findMethod(BOOT_CLASS, "shutdown"); - } - - private final Object monitor; - private Object framework; - - KF2Platform(Object monitor) { - this.monitor = monitor; - - } - - public BundleContext start() { - framework = BeanUtils.instantiateClass(CONSTRUCTOR, monitor); - ReflectionUtils.invokeMethod(LAUNCH, framework, 0); - return (BundleContext) ReflectionUtils.invokeMethod(GET_BUNDLE_CONTEXT, framework); - } - - public void stop() { - if (framework != null) { - ReflectionUtils.invokeMethod(SHUTDOWN, framework); - framework = null; - } - } - } - - private static class KF3Platform implements Platform { - private Bundle framework; - private final Map properties; - private final Log log; - private FrameworkTemplate fwkTemplate; - - KF3Platform(Map properties, Log log) { - this.properties = properties; - this.log = log; - } - - public BundleContext start() { - framework = new FrameworkFactoryImpl().newFramework(properties); - fwkTemplate = new DefaultFrameworkTemplate(framework, log); - fwkTemplate.init(); - fwkTemplate.start(); - - return framework.getBundleContext(); - } - - public void stop() { - if (fwkTemplate != null) { - fwkTemplate.stopAndWait(1000); - fwkTemplate = null; - } - } - } - - private static final String KF_2X_BOOT_CLASS = "org.knopflerfish.framework.Framework"; - private static final boolean KF_2X = - ClassUtils.isPresent(KF_2X_BOOT_CLASS, KnopflerfishPlatform.class.getClassLoader()); - - private BundleContext context; - private Platform framework; - private File kfStorageDir; - - public KnopflerfishPlatform() { - toString = "Knopflerfish OSGi Platform"; - } - - Properties getPlatformProperties() { - if (kfStorageDir == null) { - kfStorageDir = createTempDir("kf"); - kfStorageDir.deleteOnExit(); - if (log.isDebugEnabled()) - log.debug("KF temporary storage dir is " + kfStorageDir.getAbsolutePath()); - - } - - // default properties - Properties props = new Properties(); - props.setProperty("org.osgi.framework.dir", kfStorageDir.getAbsolutePath()); - props.setProperty("org.knopflerfish.framework.bundlestorage", "file"); - props.setProperty("org.knopflerfish.framework.bundlestorage.file.reference", "true"); - props.setProperty("org.knopflerfish.framework.bundlestorage.file.unpack", "true"); - props.setProperty("org.knopflerfish.startlevel.use", "true"); - props.setProperty("org.knopflerfish.osgi.setcontextclassloader", "true"); - // embedded mode - props.setProperty("org.knopflerfish.framework.exitonshutdown", "false"); - // disable patch CL - props.setProperty("org.knopflerfish.framework.patch", "false"); - // new in KF 2.0.4 - automatically exports system packages based on the JRE version - props.setProperty("org.knopflerfish.framework.system.export.all", "true"); - // props.setProperty("org.knopflerfish.framework.system.export.all_15", "true"); - // add strict bootpath delegation (introduced in KF 2.3.0) - // since otherwise classes will be loaded from the booth classpath - // when generating JDK proxies instead of the OSGi space - // since KF thinks that a non-OSGi class is making the call. - props.setProperty("org.knopflerfish.framework.strictbootclassloading", "true"); - - return props; - } - - public BundleContext getBundleContext() { - return context; - } - - public void start() throws Exception { - if (framework == null) { - // copy configuration properties to sys properties - System.getProperties().putAll(getConfigurationProperties()); - Map props = new HashMap(); - CollectionUtils.mergePropertiesIntoMap(getPlatformProperties(), props); - framework = (KF_2X ? new KF2Platform(this) : new KF3Platform(props, log)); - context = framework.start(); - } - } - - public void stop() throws Exception { - if (framework != null) { - context = null; - try { - framework.stop(); - } finally { - framework = null; - IOUtils.delete(kfStorageDir); - } - } - } -} \ No newline at end of file diff --git a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/Platforms.java b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/Platforms.java index 24c0e3bf..bad27013 100644 --- a/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/Platforms.java +++ b/test-support/src/main/java/org/eclipse/gemini/blueprint/test/platform/Platforms.java @@ -21,18 +21,6 @@ */ public abstract class Platforms { - /** - * Equinox OSGi platform - * constant. - */ - public static final String EQUINOX = EquinoxPlatform.class.getName(); - - /** - * Knopflerfish OSGi platform - * constant. - */ - public static final String KNOPFLERFISH = KnopflerfishPlatform.class.getName(); - /** * Felix OSGi platform constant. */ diff --git a/test-support/src/main/resources/org/eclipse/gemini/blueprint/test/internal/boot-bundles.properties b/test-support/src/main/resources/org/eclipse/gemini/blueprint/test/internal/boot-bundles.properties index 713548b6..64cd176b 100644 --- a/test-support/src/main/resources/org/eclipse/gemini/blueprint/test/internal/boot-bundles.properties +++ b/test-support/src/main/resources/org/eclipse/gemini/blueprint/test/internal/boot-bundles.properties @@ -19,13 +19,13 @@ ignore.junit.version=4.12_1 ignore.logback.version=1.0.13 -ignore.spring.version=5.0.4.RELEASE_1 +ignore.atlassian.spring.bundle.version=8.0.0-jakarta-001 ignore.gemini.blueprint.version=${project.version} ignore.slf4j.version=1.7.5 ignore.assertj.version=3.6.2 # groupIds -ignore.servicemix.bundles.groupId=org.apache.servicemix.bundles +ignore.atlassian.spring.bundle.groupId=com.atlassian.platform.dependencies ignore.gemini.blueprint.groupId=org.eclipse.gemini.blueprint ignore.slf4j.groupId=org.slf4j ignore.logback.groupId=ch.qos.logback @@ -44,19 +44,11 @@ ${ignore.slf4j.groupId},jcl-over-slf4j,${ignore.slf4j.version}= ${ignore.logback.groupId},logback-core,${ignore.logback.version}= ${ignore.logback.groupId},logback-classic,${ignore.logback.version}= -# aop alliance -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.aopalliance,1.0_6= - # AssertJ for using AssertJ-assertions in OSGi test bundles at runtime org.assertj,assertj-core,${ignore.assertj.version}= # spring libs -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-beans,${ignore.spring.version}= -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-core,${ignore.spring.version}= -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-context,${ignore.spring.version}= -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-expression,${ignore.spring.version}= -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-aop,${ignore.spring.version}= -${ignore.servicemix.bundles.groupId},${ignore.servicemix.bundles.groupId}.spring-test,${ignore.spring.version}= +${ignore.atlassian.spring.bundle.groupId},platform-spring-bundle,${ignore.atlassian.spring.bundle.version}= # gemini blueprint libs ${ignore.gemini.blueprint.groupId},gemini-blueprint-io,${ignore.gemini.blueprint.version}= diff --git a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatformTest.java b/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatformTest.java deleted file mode 100644 index 12d21a02..00000000 --- a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/EquinoxPlatformTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.test.platform; - - -/** - * @author Costin Leau - * - */ -public class EquinoxPlatformTest extends CommonPlatformTest { - - AbstractOsgiPlatform createPlatform() { - return new EquinoxPlatform(); - } -} diff --git a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatformTest.java b/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatformTest.java deleted file mode 100644 index aa4953d7..00000000 --- a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/platform/KnopflerfishPlatformTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006, 2010 VMware Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0 - * is available at http://www.opensource.org/licenses/apache2.0.php. - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * VMware Inc. - *****************************************************************************/ - -package org.eclipse.gemini.blueprint.test.platform; - - -/** - * @author Costin Leau - * - */ -public class KnopflerfishPlatformTest extends CommonPlatformTest { - - protected void setUp() throws Exception { - System.setProperty("org.knopflerfish.osgi.registerserviceurlhandler", "false"); - super.setUp(); - } - - protected void tearDown() throws Exception { - System.getProperties().remove("org.knopflerfish.osgi.registerserviceurlhandler"); - super.tearDown(); - } - - AbstractOsgiPlatform createPlatform() { - return new KnopflerfishPlatform(); - } -}