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<Object>() {
-                                               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<Object>() {
+                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<Listener> listeners = (List<Listener>) 
listenersRecipe.create();
-                for (Listener listener : listeners) {
-                    List<Class> classList = new ArrayList<Class>();
-                    Class clz = getInterfaceClass();
-                    if (clz != null) { 
-                        classList.add(clz);
-                    } else {
-                        classList.add(Object.class);
-                    }
-                    listener.init(classList);
+        if (listenersRecipe != null) {
+            List<Listener> listeners = 
(List<Listener>)listenersRecipe.create();
+            for (Listener listener : listeners) {
+                List<Class> classList = new ArrayList<Class>();
+                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<Class<?>> loadAllClasses(Iterable<String> 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) {


Reply via email to