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 9231E17AF8 for ; Wed, 29 Apr 2015 10:21:47 +0000 (UTC) Received: (qmail 67876 invoked by uid 500); 29 Apr 2015 10:00:11 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 40452 invoked by uid 500); 29 Apr 2015 09:59:52 -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 93714 invoked by uid 99); 29 Apr 2015 07:16:33 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 07:16:33 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id A2091AC05AB for ; Wed, 29 Apr 2015 07:16:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1676682 - in /aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container: AbstractServiceReferenceRecipe.java ReferenceRecipe.java Date: Wed, 29 Apr 2015 07:16:33 -0000 To: commits@aries.apache.org From: cschneider@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150429071633.A2091AC05AB@hades.apache.org> Author: cschneider Date: Wed Apr 29 07:16:31 2015 New Revision: 1676682 URL: http://svn.apache.org/r1676682 Log: [ARIES-1314] Fixing some warnings Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1676682&r1=1676681&r2=1676682&view=diff ============================================================================== --- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java (original) +++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java Wed Apr 29 07:16:31 2015 @@ -71,6 +71,7 @@ import org.slf4j.LoggerFactory; * * @version $Rev$, $Date$ */ +@SuppressWarnings("rawtypes") public abstract class AbstractServiceReferenceRecipe extends AbstractRecipe implements ServiceListener, SatisfiableRecipe { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractServiceReferenceRecipe.class); @@ -112,12 +113,7 @@ public abstract class AbstractServiceRef this.optional = (metadata.getAvailability() == ReferenceMetadata.AVAILABILITY_OPTIONAL); this.filter = createOsgiFilter(metadata, null); - if (System.getSecurityManager() != null) { - accessControlContext = createAccessControlContext(); - } else - { - accessControlContext = null; - } + accessControlContext = (System.getSecurityManager() != null) ? createAccessControlContext() : null; } @@ -233,63 +229,61 @@ public abstract class AbstractServiceRef return null; } - protected Object getServiceSecurely(final ServiceReference serviceReference) { - if (accessControlContext == null) { - return getBundleContextForServiceLookup().getService( - serviceReference); - - } else { - // If we're operating with security, use the privileges of the bundle - // we're managing to do the lookup - return AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return getBundleContextForServiceLookup() - .getService(serviceReference); - } - }, accessControlContext); - } - } - + @SuppressWarnings("unchecked") + protected Object getServiceSecurely(final ServiceReference serviceReference) { + if (accessControlContext == null) { + return getBundleContextForServiceLookup().getService(serviceReference); + } else { + // If we're operating with security, use the privileges of the bundle + // we're managing to do the lookup + return AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return getBundleContextForServiceLookup().getService(serviceReference); + } + }, accessControlContext); + } + } - /** - * We may need to execute code within a doPrivileged block, and if so, it should be the - * privileges of the bundle with the blueprint file that get used, not the privileges - * of blueprint-core. To achieve this we use an access context. - * @return - */ + /** + * We may need to execute code within a doPrivileged block, and if so, it should be the privileges of the + * bundle with the blueprint file that get used, not the privileges of blueprint-core. To achieve this we + * use an access context. + * + * @return + */ private AccessControlContext createAccessControlContext() { - return new AccessControlContext(AccessController.getContext(), - new DomainCombiner() { - public ProtectionDomain[] combine(ProtectionDomain[] arg0, - ProtectionDomain[] arg1) { - return new ProtectionDomain[] { new ProtectionDomain(null, null) { - public boolean implies(Permission permission) { - return getBundleContextForServiceLookup().getBundle().hasPermission(permission); - } - } - }; - } + return new AccessControlContext(AccessController.getContext(), new DomainCombiner() { + public ProtectionDomain[] combine(ProtectionDomain[] arg0, ProtectionDomain[] arg1) { + ProtectionDomain protectionDomain = new ProtectionDomain(null, null) { + public boolean implies(Permission permission) { + return getBundleContextForServiceLookup().getBundle().hasPermission(permission); + } + }; + return new ProtectionDomain[] { + protectionDomain + }; + } }); } + @SuppressWarnings("unchecked") protected void createListeners() { - if (listenersRecipe != null) { - List listeners = (List) listenersRecipe.create(); - for (Listener listener : listeners) { - List classList = new ArrayList(); - Class clz = getInterfaceClass(); - if (clz != null) { - classList.add(clz); - } else { - classList.add(Object.class); - } - listener.init(classList); + if (listenersRecipe != null) { + List listeners = (List)listenersRecipe.create(); + for (Listener listener : listeners) { + List classList = new ArrayList(); + Class clz = getInterfaceClass(); + if (clz != null) { + classList.add(clz); + } else { + classList.add(Object.class); } - this.listeners = listeners; - } else { - this.listeners = Collections.emptyList(); + listener.init(classList); } + this.listeners = listeners; + } else { + this.listeners = Collections.emptyList(); + } } protected List> loadAllClasses(Iterable interfaceNames) { Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java?rev=1676682&r1=1676681&r2=1676682&view=diff ============================================================================== --- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java (original) +++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java Wed Apr 29 07:16:31 2015 @@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory; * * @version $Rev$, $Date$ */ +@SuppressWarnings("rawtypes") public class ReferenceRecipe extends AbstractServiceReferenceRecipe { private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceRecipe.class); @@ -206,7 +207,7 @@ public class ReferenceRecipe extends Abs if (isStarted() && trackedServiceReference == null && metadata.getTimeout() > 0 && metadata.getAvailability() == ServiceReferenceMetadata.AVAILABILITY_MANDATORY) { //Here we want to get the blueprint bundle itself, so don't use #getBundleContextForServiceLookup() - blueprintContainer.getEventDispatcher().blueprintEvent(new BlueprintEvent(BlueprintEvent.WAITING, blueprintContainer.getBundleContext().getBundle(), blueprintContainer.getExtenderBundle(), new String[] { getOsgiFilter() })); + blueprintContainer.getEventDispatcher().blueprintEvent(createWaitingevent()); monitor.wait(metadata.getTimeout()); } Object result = null; @@ -255,6 +256,13 @@ public class ReferenceRecipe extends Abs } } + private BlueprintEvent createWaitingevent() { + return new BlueprintEvent(BlueprintEvent.WAITING, + blueprintContainer.getBundleContext().getBundle(), + blueprintContainer.getExtenderBundle(), + new String[] { getOsgiFilter() }); + } + private ServiceReference getServiceReference() throws InterruptedException { synchronized (monitor) { if (!optional) {