Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05D4B11661 for ; Thu, 11 Sep 2014 13:48:33 +0000 (UTC) Received: (qmail 76757 invoked by uid 500); 11 Sep 2014 13:48:32 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 76688 invoked by uid 500); 11 Sep 2014 13:48:32 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 76677 invoked by uid 99); 11 Sep 2014 13:48:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 13:48:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 13:48:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1945B23888A6; Thu, 11 Sep 2014 13:48:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1624286 - in /aries/trunk/jndi: jndi-api/ jndi-api/src/main/java/org/apache/aries/jndi/spi/ jndi-core/ jndi-core/src/main/java/org/apache/aries/jndi/ jndi-core/src/main/java/org/apache/aries/jndi/startup/ jndi-url/ jndi-url/src/main/java/o... Date: Thu, 11 Sep 2014 13:48:09 -0000 To: commits@aries.apache.org From: hughesj@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140911134810.1945B23888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hughesj Date: Thu Sep 11 13:48:08 2014 New Revision: 1624286 URL: http://svn.apache.org/r1624286 Log: ARIES-1117: Cleanup Aries JNDI from JNDI Map of provider URLs via 'unaugmentation'. Added: aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/AugmenterInvoker.java aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentUnaugmentation.java aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/AugmenterInvokerImpl.java Modified: aries/trunk/jndi/jndi-api/pom.xml aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/packageinfo aries/trunk/jndi/jndi-core/pom.xml aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiObjectFactoryBuilder.java aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java aries/trunk/jndi/jndi-url/pom.xml aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java Modified: aries/trunk/jndi/jndi-api/pom.xml URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-api/pom.xml?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-api/pom.xml (original) +++ aries/trunk/jndi/jndi-api/pom.xml Thu Sep 11 13:48:08 2014 @@ -32,9 +32,9 @@ org.apache.aries.jndi.api bundle Apache Aries JNDI API - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT - This bundle contains the JNDI 1.0.0 API + This bundle contains the JNDI API Added: aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/AugmenterInvoker.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/AugmenterInvoker.java?rev=1624286&view=auto ============================================================================== --- aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/AugmenterInvoker.java (added) +++ aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/AugmenterInvoker.java Thu Sep 11 13:48:08 2014 @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.aries.jndi.spi; + +import java.util.Hashtable; + +public interface AugmenterInvoker +{ + public void augmentEnvironment(Hashtable environment); + public void unaugmentEnvironment(Hashtable environment); +} Added: aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentUnaugmentation.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentUnaugmentation.java?rev=1624286&view=auto ============================================================================== --- aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentUnaugmentation.java (added) +++ aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentUnaugmentation.java Thu Sep 11 13:48:08 2014 @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.aries.jndi.spi; + +import java.util.Hashtable; + +public interface EnvironmentUnaugmentation +{ + public void unaugmentEnvironment(Hashtable env); +} Modified: aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/packageinfo URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/packageinfo?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/packageinfo (original) +++ aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/packageinfo Thu Sep 11 13:48:08 2014 @@ -16,4 +16,4 @@ # specific language governing permissions and limitations # under the License. # -version 1.0.0 +version 1.1.0 Modified: aries/trunk/jndi/jndi-core/pom.xml URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/pom.xml?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/pom.xml (original) +++ aries/trunk/jndi/jndi-core/pom.xml Thu Sep 11 13:48:08 2014 @@ -61,7 +61,7 @@ org.apache.aries.jndi org.apache.aries.jndi.api provided - 1.0.0 + 1.1.0-SNAPSHOT org.osgi Added: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/AugmenterInvokerImpl.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/AugmenterInvokerImpl.java?rev=1624286&view=auto ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/AugmenterInvokerImpl.java (added) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/AugmenterInvokerImpl.java Thu Sep 11 13:48:08 2014 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.aries.jndi; + +import java.util.Hashtable; + +import org.apache.aries.jndi.spi.EnvironmentAugmentation; +import org.apache.aries.jndi.spi.EnvironmentUnaugmentation; +import org.apache.aries.jndi.spi.AugmenterInvoker; +import org.apache.aries.jndi.startup.Activator; + + +public class AugmenterInvokerImpl implements AugmenterInvoker { + + private static AugmenterInvokerImpl instance = null; + + public static AugmenterInvokerImpl getInstance() { + if (instance == null) { + instance = new AugmenterInvokerImpl(); + } + return instance; + } + + + public void augmentEnvironment(Hashtable environment) + { + Object[] objects = Activator.getEnvironmentAugmentors(); + + if (objects != null) { + for (Object obj : objects) { + if (obj instanceof EnvironmentAugmentation) { + ((EnvironmentAugmentation)obj).augmentEnvironment(environment); + } + } + } + } + + public void unaugmentEnvironment(Hashtable environment) + { + Object[] objects = Activator.getEnvironmentUnaugmentors(); + + if (objects != null) { + for (Object obj : objects) { + if (obj instanceof EnvironmentUnaugmentation) { + ((EnvironmentUnaugmentation)obj).unaugmentEnvironment(environment); + } + } + } + } +} Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java (original) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java Thu Sep 11 13:48:08 2014 @@ -71,7 +71,6 @@ public class ContextManagerService imple private Context getInitialContext(Map environment) throws NamingException { Hashtable env = Utils.toHashtable(environment); - Utils.augmentEnvironment(env); Context context = ContextHelper.getInitialContext(callerContext, env); contexts.add(context); return context; Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java (original) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java Thu Sep 11 13:48:08 2014 @@ -39,13 +39,15 @@ public class OSGiInitialContextFactoryBu public Context getInitialContext(Hashtable environment) throws NamingException { - Utils.augmentEnvironment(environment); + AugmenterInvokerImpl.getInstance().augmentEnvironment(environment); BundleContext context = Utils.getBundleContext(environment, InitialContext.class); if (context == null) { throw new NoInitialContextException(Utils.MESSAGES.getMessage("cannot.find.callers.bundlecontext")); } + AugmenterInvokerImpl.getInstance().unaugmentEnvironment(environment); + return ContextHelper.getInitialContext(context, environment); } -} \ No newline at end of file +} Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiObjectFactoryBuilder.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiObjectFactoryBuilder.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiObjectFactoryBuilder.java (original) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiObjectFactoryBuilder.java Thu Sep 11 13:48:08 2014 @@ -71,10 +71,12 @@ public class OSGiObjectFactoryBuilder im } private BundleContext getCallerBundleContext(Hashtable environment) throws NamingException { + AugmenterInvokerImpl.getInstance().augmentEnvironment(environment); BundleContext context = Utils.getBundleContext(environment, NamingManager.class); if (context == null) { context = Utils.getBundleContext(environment, DirectoryManager.class); } + AugmenterInvokerImpl.getInstance().unaugmentEnvironment(environment); return context; } } Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java (original) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java Thu Sep 11 13:48:08 2014 @@ -28,8 +28,6 @@ import java.util.Map; import javax.naming.NamingException; -import org.apache.aries.jndi.spi.EnvironmentAugmentation; -import org.apache.aries.jndi.startup.Activator; import org.apache.aries.util.nls.MessageUtil; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -199,16 +197,4 @@ public final class Utils { }); } - public static void augmentEnvironment(Hashtable environment) - { - Object[] objects = Activator.getEnvironmentAugmentors(); - - if (objects != null) { - for (Object obj : objects) { - if (obj instanceof EnvironmentAugmentation) { - ((EnvironmentAugmentation)obj).augmentEnvironment(environment); - } - } - } - } -} \ No newline at end of file +} Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java (original) +++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java Thu Sep 11 13:48:08 2014 @@ -34,7 +34,10 @@ import org.apache.aries.jndi.OSGiInitial import org.apache.aries.jndi.OSGiObjectFactoryBuilder; import org.apache.aries.jndi.ProviderAdminServiceFactory; import org.apache.aries.jndi.Utils; +import org.apache.aries.jndi.AugmenterInvokerImpl; import org.apache.aries.jndi.spi.EnvironmentAugmentation; +import org.apache.aries.jndi.spi.EnvironmentUnaugmentation; +import org.apache.aries.jndi.spi.AugmenterInvoker; import org.apache.aries.jndi.tracker.ServiceTrackerCustomizers; import org.apache.aries.jndi.urls.URLObjectFactoryFinder; import org.osgi.framework.Bundle; @@ -64,6 +67,7 @@ public class Activator implements Bundle private static ServiceTracker initialContextFactories; private static ServiceTracker objectFactories; private static ServiceTracker environmentAugmentors; + private static ServiceTracker environmentUnaugmentors; private BundleTracker bt = null; public void start(BundleContext context) { @@ -73,6 +77,7 @@ public class Activator implements Bundle icfBuilders = initServiceTracker(context, InitialContextFactoryBuilder.class, ServiceTrackerCustomizers.ICFB_CACHE); urlObjectFactoryFinders = initServiceTracker(context, URLObjectFactoryFinder.class, ServiceTrackerCustomizers.URLOBJFACTORYFINDER_CACHE); environmentAugmentors = initServiceTracker(context, EnvironmentAugmentation.class, null); + environmentUnaugmentors = initServiceTracker(context, EnvironmentUnaugmentation.class, null); try { OSGiInitialContextFactoryBuilder builder = new OSGiInitialContextFactoryBuilder(); @@ -111,6 +116,11 @@ public class Activator implements Bundle context.registerService(JNDIContextManager.class.getName(), new ContextManagerServiceFactory(), null); + + context.registerService(AugmenterInvoker.class.getName(), + AugmenterInvokerImpl.getInstance(), + null); + //Start the bundletracker that clears out the cache. (only interested in stopping events) bt = new BundleTracker(context,Bundle.STOPPING,new ServiceTrackerCustomizers.CacheBundleTrackerCustomizer()); bt.open(); @@ -157,6 +167,7 @@ public class Activator implements Bundle objectFactories.close(); initialContextFactories.close(); environmentAugmentors.close(); + environmentUnaugmentors.close(); if (bt != null) { bt.close(); @@ -213,4 +224,10 @@ public class Activator implements Bundle { return environmentAugmentors.getServices(); } + + public static Object[] getEnvironmentUnaugmentors() + { + return environmentUnaugmentors.getServices(); + } + } Modified: aries/trunk/jndi/jndi-url/pom.xml URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/pom.xml?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-url/pom.xml (original) +++ aries/trunk/jndi/jndi-url/pom.xml Thu Sep 11 13:48:08 2014 @@ -70,7 +70,7 @@ org.apache.aries.jndi org.apache.aries.jndi.api provided - 1.0.0 + 1.1.0-SNAPSHOT org.apache.aries Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java (original) +++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java Thu Sep 11 13:48:08 2014 @@ -29,8 +29,11 @@ import javax.naming.NamingException; import javax.naming.OperationNotSupportedException; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; import org.osgi.service.jndi.JNDIConstants; +import org.apache.aries.jndi.spi.AugmenterInvoker; + public abstract class AbstractServiceRegistryContext implements Context { @@ -41,6 +44,8 @@ public abstract class AbstractServiceReg protected NameParser parser = new OsgiNameParser(); private static final String ARIES_SERVICES = "aries:services/"; + private static AugmenterInvoker augmenterInvoker = null; + @SuppressWarnings("unchecked") public AbstractServiceRegistryContext(BundleContext callerContext, Hashtable environment) { @@ -48,7 +53,13 @@ public abstract class AbstractServiceReg env.putAll((Map) environment); // ARIES-397:, If the caller has provided a BundleContext // in the hashtable, use this in preference to callerContext + if (augmenterInvoker == null && callerContext != null) { + ServiceReference augmenterSR = callerContext.getServiceReference(AugmenterInvoker.class.getName()); + if (augmenterSR != null) augmenterInvoker = (AugmenterInvoker) callerContext.getService(augmenterSR); + } + if (augmenterInvoker != null) augmenterInvoker.augmentEnvironment(environment); BundleContext bc = (BundleContext) env.get(JNDIConstants.BUNDLE_CONTEXT); + if (augmenterInvoker != null) augmenterInvoker.unaugmentEnvironment(environment); if (bc != null) { this.callerContext = bc; } else { @@ -61,9 +72,17 @@ public abstract class AbstractServiceReg { env = new HashMap(); env.putAll((Map) environment); + Hashtable environmentHT = new Hashtable(); + environmentHT.putAll(env); // ARIES-397: If the caller has provided a BundleContext // in the hashtable, use this in preference to callerContext + if (augmenterInvoker == null && callerContext != null) { + ServiceReference augmenterSR = callerContext.getServiceReference(AugmenterInvoker.class.getName()); + if (augmenterSR != null) augmenterInvoker = (AugmenterInvoker) callerContext.getService(augmenterSR); + } + if (augmenterInvoker != null) augmenterInvoker.augmentEnvironment(environmentHT); BundleContext bc = (BundleContext) env.get(JNDIConstants.BUNDLE_CONTEXT); + if (augmenterInvoker != null) augmenterInvoker.unaugmentEnvironment(environmentHT); if (bc != null) { this.callerContext = bc; } else { Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java?rev=1624286&r1=1624285&r2=1624286&view=diff ============================================================================== --- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java (original) +++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java Thu Sep 11 13:48:08 2014 @@ -26,20 +26,35 @@ import javax.naming.Name; import javax.naming.spi.ObjectFactory; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.service.jndi.JNDIConstants; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.jndi.JNDIConstants; + +import org.apache.aries.jndi.spi.AugmenterInvoker; public class BlueprintURLContextFactory implements ObjectFactory { - final private Bundle _callersBundle; + final private Bundle _callersBundle; + + private static AugmenterInvoker augmenterInvoker = null; public BlueprintURLContextFactory(Bundle callersBundle) { _callersBundle = callersBundle; } @Override - public Object getObjectInstance(Object obj, Name name, Context callersCtx, Hashtable envmt) throws Exception { - BundleContext bc = (BundleContext) envmt.get(JNDIConstants.BUNDLE_CONTEXT); + public Object getObjectInstance(Object obj, Name name, Context callersCtx, Hashtable envmt) throws Exception { + + if (augmenterInvoker == null && _callersBundle != null) { + BundleContext callerBundleContext = _callersBundle.getBundleContext(); + ServiceReference augmenterSR = callerBundleContext.getServiceReference(AugmenterInvoker.class.getName()); + if (augmenterSR != null) augmenterInvoker = (AugmenterInvoker) callerBundleContext.getService(augmenterSR); + } + if (augmenterInvoker != null) augmenterInvoker.augmentEnvironment(envmt); + + BundleContext bc = (BundleContext) envmt.get(JNDIConstants.BUNDLE_CONTEXT); + if (augmenterInvoker != null) augmenterInvoker.unaugmentEnvironment(envmt); + Bundle b = (bc != null)? bc.getBundle() : null; Object result = null; if (obj == null) {