aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1713916 [1/2] - in /aries/trunk/jpa: examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/ examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/ examples/tasklist-model/...
Date Wed, 11 Nov 2015 19:15:00 GMT
Author: cschneider
Date: Wed Nov 11 19:14:59 2015
New Revision: 1713916

URL: http://svn.apache.org/viewvc?rev=1713916&view=rev
Log:
[ARIES-1448] Fix Issues reported by Sonar

Added:
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkPersistenceProvider.java
Removed:
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkProviderService.java
Modified:
    aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java
    aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java
    aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
    aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java
    aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java
    aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceImpl.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithEmfImpl.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMethodImpl.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMultiAnnotationImpl.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithSupplierImpl.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaComponentProcessor.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/ResourceLocalTransactionParticipant.java
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java
    aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnitParser.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/TempBundleDelegatingClassLoader.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/DummyDataSource.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistrySingleton.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/AbstractJpaTemplate.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/EMSupplierImpl.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/ResourceLocalJpaTemplate.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/XAJpaTemplate.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/EMFTracker.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/EmProxy.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/TMTracker.java
    aries/trunk/jpa/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionAttribute.java

Modified: aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java (original)
+++ aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java Wed Nov 11 19:14:59 2015
@@ -36,26 +36,31 @@ public class TaskServiceImpl implements
     EntityManager em;
 
     @Transactional(TxType.SUPPORTS)
+    @Override
     public Task getTask(Integer id) {
         return em.find(Task.class, id);
     }
 
     
+    @Override
     public void addTask(Task task) {
         em.persist(task);
         em.flush();
     }
 
     @Transactional(TxType.SUPPORTS)
+    @Override
     public Collection<Task> getTasks() {
         CriteriaQuery<Task> query = em.getCriteriaBuilder().createQuery(Task.class);
         return em.createQuery(query.select(query.from(Task.class))).getResultList();
     }
 
+    @Override
     public void updateTask(Task task) {
         em.persist(task);
     }
 
+    @Override
     public void deleteTask(Integer id) {
         em.remove(getTask(id));
     }

Modified: aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java (original)
+++ aries/trunk/jpa/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java Wed Nov 11 19:14:59 2015
@@ -33,9 +33,7 @@ import org.apache.aries.jpa.example.task
 import org.osgi.service.component.annotations.Reference;
 
 public class TasklistServlet extends HttpServlet {
-    
-    TaskService taskService;
-
+    private transient TaskService taskService; // NOSONAR
     private static final long serialVersionUID = 34992072289535683L;
 
     @Override
@@ -44,7 +42,7 @@ public class TasklistServlet extends Htt
         String add = req.getParameter("add");
         String taskId = req.getParameter("taskId");
         String title = req.getParameter("title");
-        PrintWriter writer = resp.getWriter();
+        PrintWriter writer = resp.getWriter(); // NOSONAR
         if (add != null) {
             addTask(taskId, title);
         } else if (taskId != null && taskId.length() > 0) {

Modified: aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java (original)
+++ aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java Wed Nov 11 19:14:59 2015
@@ -36,16 +36,20 @@ public class TaskServiceImpl implements
 
     private JpaTemplate jpa;
 
+    @Override
     public Task getTask(final Integer id) {
         return jpa.txExpr(TransactionType.Required, new EmFunction<Task>() {
+            @Override
             public Task apply(EntityManager em) {
                 return em.find(Task.class, id);
             }
         });
     }
 
+    @Override
     public void addTask(final Task task) {
         jpa.tx(new EmConsumer() {
+            @Override
             public void accept(EntityManager em) {
                     em.persist(task);
                     em.flush();
@@ -53,24 +57,30 @@ public class TaskServiceImpl implements
         });
     }
 
+    @Override
     public Collection<Task> getTasks() {
         return jpa.txExpr(new EmFunction<Collection<Task>>() {
+            @Override
             public Collection<Task> apply(EntityManager em) {
                 return em.createQuery("select t from Task t", Task.class).getResultList();
             }
         });
     }
 
+    @Override
     public void updateTask(final Task task) {
         jpa.tx(new EmConsumer() {
+            @Override
             public void accept(EntityManager em) {
                 em.persist(task);
             }
         });
     }
 
+    @Override
     public void deleteTask(final Integer id) {
         jpa.tx(new EmConsumer() {
+            @Override
             public void accept(EntityManager em) {
                 em.remove(getTask(id));
             }

Modified: aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java (original)
+++ aries/trunk/jpa/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java Wed Nov 11 19:14:59 2015
@@ -39,10 +39,8 @@ import org.osgi.service.component.annota
     property = { "alias:String=/tasklist" }
 ) 
 public class TasklistServlet extends HttpServlet {
-    
-    TaskService taskService;
-
     private static final long serialVersionUID = 34992072289535683L;
+    private transient TaskService taskService; // NOSONAR
 
     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
@@ -50,7 +48,7 @@ public class TasklistServlet extends Htt
         String add = req.getParameter("add");
         String taskId = req.getParameter("taskId");
         String title = req.getParameter("title");
-        PrintWriter writer = resp.getWriter();
+        PrintWriter writer = resp.getWriter(); // NOSONAR
         if (add != null) {
             addTask(taskId, title);
         } else if (taskId != null && taskId.length() > 0) {

Modified: aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java (original)
+++ aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java Wed Nov 11 19:14:59 2015
@@ -34,10 +34,9 @@ public class Task {
     Date dueDate;
     boolean finished;
     
-    
     public Task() {
+        // Allow JPA to create the instance
     }
-    
 
     public Task(Integer id, String title, String description) {
         super();

Modified: aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java (original)
+++ aries/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java Wed Nov 11 19:14:59 2015
@@ -21,9 +21,9 @@ package org.apache.aries.jpa.example.tas
 import java.util.Collection;
 
 public interface TaskService {
-	Task getTask(Integer id);
-	void addTask(Task task);
-	void updateTask(Task task);
-	void deleteTask(Integer id);
-	Collection<Task> getTasks();
+    Task getTask(Integer id);
+    void addTask(Task task);
+    void updateTask(Task task);
+    void deleteTask(Integer id);
+    Collection<Task> getTasks();
 }

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java Wed Nov 11 19:14:59 2015
@@ -55,7 +55,7 @@ public class CarLifeCycle implements Run
         carService.deleteCar(id);
         Car car2 = carService.getCar(id);
         if (car2 != null) {
-            throw new RuntimeException("Car with id " + id + " should be deleted");
+            throw new RuntimeException("Car with id " + id + " should be deleted"); // NOSONAR
         }
     }
 

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java Wed Nov 11 19:14:59 2015
@@ -44,6 +44,7 @@ public class CarServiceEmJtaAnn implemen
     }
 
     @Transactional(Transactional.TxType.SUPPORTS)
+    @Override
     public Collection<Car> getCars() {
         return em.createQuery("select c from Car c", Car.class).getResultList();
     }

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceImpl.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceImpl.java Wed Nov 11 19:14:59 2015
@@ -36,6 +36,7 @@ public class CarServiceImpl extends Abst
         em.persist(car);
     }
 
+    @Override
     public Collection<Car> getCars() {
         return em.createQuery("select c from Car c", Car.class).getResultList();
     }

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithEmfImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithEmfImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithEmfImpl.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithEmfImpl.java Wed Nov 11 19:14:59 2015
@@ -50,10 +50,10 @@ public class CarServiceWithEmfImpl imple
         em.close();
     }
 
+    @Override
     public Collection<Car> getCars() {
-        EntityManager em = null;
+        EntityManager em = emf.createEntityManager();
         try {
-            em = emf.createEntityManager();
             return em.createQuery("select c from Car c", Car.class).getResultList();
         } finally {
             em.close();

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMethodImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMethodImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMethodImpl.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMethodImpl.java Wed Nov 11 19:14:59 2015
@@ -41,6 +41,7 @@ public class CarServiceWithMethodImpl im
         em.flush();
     }
 
+    @Override
     public Collection<Car> getCars() {
         return em.createQuery("select c from Car c", Car.class).getResultList();
     }

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMultiAnnotationImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMultiAnnotationImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMultiAnnotationImpl.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithMultiAnnotationImpl.java Wed Nov 11 19:14:59 2015
@@ -53,6 +53,7 @@ public class CarServiceWithMultiAnnotati
         localEm.close();
     }
 
+    @Override
     public Collection<Car> getCars() {
         return em.createQuery("select c from Car c", Car.class).getResultList();
     }

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithSupplierImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithSupplierImpl.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithSupplierImpl.java (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceWithSupplierImpl.java Wed Nov 11 19:14:59 2015
@@ -44,6 +44,7 @@ public class CarServiceWithSupplierImpl
         em.get().flush();
     }
 
+    @Override
     public Collection<Car> getCars() {
         return em.get().createQuery("select c from Car c", Car.class).getResultList();
     }

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java Wed Nov 11 19:14:59 2015
@@ -21,5 +21,5 @@ package org.apache.aries.jpa.template;
 import javax.persistence.EntityManager;
 
 public interface EmConsumer {
-	void accept(EntityManager em);
+    void accept(EntityManager em);
 }

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java Wed Nov 11 19:14:59 2015
@@ -21,5 +21,5 @@ package org.apache.aries.jpa.template;
 import javax.persistence.EntityManager;
 
 public interface EmFunction<R> {
-	R apply(EntityManager em);
+    R apply(EntityManager em);
 }

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java Wed Nov 11 19:14:59 2015
@@ -20,9 +20,9 @@ package org.apache.aries.jpa.template;
 
 
 public interface JpaTemplate {
-	<R> R txExpr(TransactionType type, EmFunction<R> code);
-	void tx(TransactionType type, EmConsumer code);
-	
-	<R> R txExpr(EmFunction<R> code);
-	void tx(EmConsumer code);
+    <R> R txExpr(TransactionType type, EmFunction<R> code);
+    void tx(TransactionType type, EmConsumer code);
+
+    <R> R txExpr(EmFunction<R> code);
+    void tx(EmConsumer code);
 }

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java Wed Nov 11 19:14:59 2015
@@ -19,5 +19,5 @@
 package org.apache.aries.jpa.template;
 
 public enum TransactionType {
-	Mandatory, Never, NotSupported, Required, RequiresNew, Supports
+    Mandatory, Never, NotSupported, Required, RequiresNew, Supports // NOSONAR
 }

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java Wed Nov 11 19:14:59 2015
@@ -34,14 +34,15 @@ public class Activator implements Bundle
         context.registerService(NamespaceHandler.class, handler, createProps(JpaNsHandler.NAMESPACE_JPA_20));
     }
 
-    private Dictionary<String, String> createProps(String namespace) {
-        Dictionary<String, String> props = new Hashtable<String, String>();
+    private static Dictionary<String, String> createProps(String namespace) {
+        Dictionary<String, String> props = new Hashtable<String, String>(); // NOSONAR
         props.put("osgi.service.blueprint.namespace", namespace);
         return props;
     }
 
     @Override
     public void stop(BundleContext context) throws Exception {
+        // Unregistering happens automatically
     }
 
 }

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java Wed Nov 11 19:14:59 2015
@@ -29,31 +29,28 @@ public class AnnotationScanner {
 
     public List<AccessibleObject> getJpaAnnotatedMembers(Class<?> c, Class<? extends Annotation> annotation) {
         final List<AccessibleObject> jpaAnnotated = new ArrayList<AccessibleObject>();
+        for (Class<?> cl = c; cl != Object.class; cl = cl.getSuperclass()) {  
+            parseClass(annotation, jpaAnnotated, cl);
+        }
+        return jpaAnnotated;
+    }
 
-        Class<?> cl = c;
-        if (c != Object.class) {
-            while (cl != Object.class) {
-                for (Field field : cl.getDeclaredFields()) {
-                    if (field.isAnnotationPresent(annotation)) {
-                        field.setAccessible(true);
-                        jpaAnnotated.add(field);
-                    }
-                }
-
-                for (Method method : cl.getDeclaredMethods()) {
-                    if ((method.isAnnotationPresent(annotation)) && method.getName().startsWith("set") && method.getParameterTypes().length == 1) {
-                        jpaAnnotated.add(method);
-                    }
-                }
-
-                cl = cl.getSuperclass();
+    private static void parseClass(Class<? extends Annotation> annotation, final List<AccessibleObject> jpaAnnotated, Class<?> cl) {
+        for (Field field : cl.getDeclaredFields()) {
+            if (field.isAnnotationPresent(annotation)) {
+                field.setAccessible(true);
+                jpaAnnotated.add(field);
             }
         }
 
-        return jpaAnnotated;
+        for (Method method : cl.getDeclaredMethods()) {
+            if ((method.isAnnotationPresent(annotation)) && method.getName().startsWith("set") && method.getParameterTypes().length == 1) {
+                jpaAnnotated.add(method);
+            }
+        }
     }
 
-    public String getName(AccessibleObject member) {
+    public static String getName(AccessibleObject member) {
         if (member instanceof Field) {
             return ((Field)member).getName();
         } else if (member instanceof Method) {
@@ -67,7 +64,7 @@ public class AnnotationScanner {
         throw new IllegalArgumentException();
     }
     
-    public Class<?> getType(AccessibleObject member) {
+    public static Class<?> getType(AccessibleObject member) {
         if (member instanceof Field) {
             return ((Field)member).getType();
         } else if (member instanceof Method) {

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaComponentProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaComponentProcessor.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaComponentProcessor.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaComponentProcessor.java Wed Nov 11 19:14:59 2015
@@ -85,15 +85,15 @@ public class JpaComponentProcessor imple
         try {
             compClass = bundle.loadClass(compDef.getClassName());
         } catch (final ClassNotFoundException e) {
-            throw new IllegalArgumentException("Bean class not found " + compDef.getClassName());
+            throw new IllegalArgumentException("Bean class not found " + compDef.getClassName(), e);
         }
         compDef.setFieldInjection(true);
         List<AccessibleObject> pcMembers = annotationScanner.getJpaAnnotatedMembers(compClass, PersistenceContext.class);
         for (AccessibleObject member : pcMembers) {
             PersistenceContext pcAnn = member.getAnnotation(PersistenceContext.class);
             
-            String propName = annotationScanner.getName(member);
-            Class<?> iface = annotationScanner.getType(member);
+            String propName = AnnotationScanner.getName(member);
+            Class<?> iface = AnnotationScanner.getType(member);
             LOGGER.debug("Injecting {} into prop {} of bean {} with class {}", iface.getSimpleName(), propName, compName, compClass);
             MutableRefMetadata ref = getServiceRef(cdr, pcAnn.unitName(), iface);
             compDef.addProperty(propName, ref);
@@ -106,8 +106,8 @@ public class JpaComponentProcessor imple
         List<AccessibleObject> puMembers = annotationScanner.getJpaAnnotatedMembers(compClass, PersistenceUnit.class);
         for (AccessibleObject member : puMembers) {
             PersistenceUnit puAnn = member.getAnnotation(PersistenceUnit.class);
-            String propName = annotationScanner.getName(member);
-            Class<?> iface = annotationScanner.getType(member);
+            String propName = AnnotationScanner.getName(member);
+            Class<?> iface = AnnotationScanner.getType(member);
             LOGGER.debug("Injecting {} into prop {} of bean {} with class {}", iface.getSimpleName(), propName, compName, compClass);
             MutableRefMetadata ref = getServiceRef(cdr, puAnn.unitName(), iface);
             compDef.addProperty(propName, ref);
@@ -125,27 +125,27 @@ public class JpaComponentProcessor imple
         return ref;
     }
     
-    @SuppressWarnings("unchecked")
-    ComponentMetadata createServiceRef(String id, Class<?> iface) {
+    private ComponentMetadata createServiceRef(String id, Class<?> iface) {
         final MutableReferenceMetadata refMeta = pc.createMetadata(MutableReferenceMetadata.class);
         refMeta.setActivation(getDefaultActivation(pc));
         refMeta.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
         refMeta.setRuntimeInterface(iface);
         refMeta.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
-        refMeta.setDependsOn((List<String>)Collections.EMPTY_LIST);
+        List<String> emptyList = Collections.emptyList();
+        refMeta.setDependsOn(emptyList);
         refMeta.setId(id);
         return refMeta;
     }
 
-    @SuppressWarnings("unchecked")
-    ComponentMetadata createJPAServiceRef(String unitName, Class<?> iface) {
+    private ComponentMetadata createJPAServiceRef(String unitName, Class<?> iface) {
         final MutableReferenceMetadata refMeta = pc.createMetadata(MutableReferenceMetadata.class);
         refMeta.setActivation(getDefaultActivation(pc));
         refMeta.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
         refMeta.setRuntimeInterface(iface);
         refMeta.setFilter(String.format("(%s=%s)", JPA_UNIT_NAME, unitName));
         refMeta.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
-        refMeta.setDependsOn((List<String>)Collections.EMPTY_LIST);
+        List<String> emptyList = Collections.emptyList();
+        refMeta.setDependsOn(emptyList);
         refMeta.setId(getId(unitName, iface));
         return refMeta;
     }
@@ -154,13 +154,13 @@ public class JpaComponentProcessor imple
         return unitName + "-" + iface.getSimpleName();
     }
     
-    private int getDefaultActivation(ParserContext ctx) {
+    private static int getDefaultActivation(ParserContext ctx) {
         return "ACTIVATION_EAGER".equalsIgnoreCase(ctx.getDefaultActivation())
             ? ReferenceMetadata.ACTIVATION_EAGER : ReferenceMetadata.ACTIVATION_LAZY;
     }
     
     @SuppressWarnings("unchecked")
-    private <T>T getComponent(ComponentDefinitionRegistry cdr, String id) {
+    private static <T>T getComponent(ComponentDefinitionRegistry cdr, String id) {
         return (T)((PassThroughMetadata) cdr.getComponentDefinition(id)).getObject();
     }
 

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java Wed Nov 11 19:14:59 2015
@@ -32,7 +32,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class JpaInterceptor implements Interceptor {
-    private static Logger LOG = LoggerFactory.getLogger(JpaInterceptor.class);
+    private static final Logger LOG = LoggerFactory.getLogger(JpaInterceptor.class);
     EntityManager em;
     private Boolean cachedIsResourceLocal;
     private Coordinator coordinator;
@@ -46,10 +46,12 @@ public class JpaInterceptor implements I
         this.emId = emId;
     }
 
+    @Override
     public int getRank() {
         return 0;
     }
 
+    @Override
     public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable {
         if (coordinator == null) {
             initServices();
@@ -64,7 +66,7 @@ public class JpaInterceptor implements I
             return coordination;
         } catch (Exception e) {
             LOG.warn("Exception from EmSupplier.preCall", e);
-            throw new RuntimeException(e);
+            throw new RuntimeException(e); // NOSONAR
         }
     }
 
@@ -73,6 +75,7 @@ public class JpaInterceptor implements I
         em = (EntityManager)container.getComponentInstance(emId);
     }
 
+    @Override
     public void postCallWithException(ComponentMetadata cm, Method m, Throwable ex, Object preCallToken) {
         LOG.debug("PostCallWithException for bean {}, method {}", cm.getId(), m.getName(), ex);
         if (preCallToken != null) {
@@ -80,6 +83,7 @@ public class JpaInterceptor implements I
         }
     }
 
+    @Override
     public void postCallWithReturn(ComponentMetadata cm, Method m, Object returnType, Object preCallToken)
         throws Exception {
         LOG.debug("PostCallWithReturn for bean {}, method {}", cm.getId(), m.getName());
@@ -88,8 +92,6 @@ public class JpaInterceptor implements I
         }
     }
 
-
-
     private boolean isResourceLocal(EntityManager em) {
         if (cachedIsResourceLocal == null) {
             cachedIsResourceLocal = isResourceLocalInternal(em);
@@ -104,10 +106,6 @@ public class JpaInterceptor implements I
     private boolean isResourceLocalInternal(EntityManager em) {
         PersistenceUnitTransactionType transactionType = (PersistenceUnitTransactionType)em.getProperties()
             .get(PersistenceUnitTransactionType.class.getName());
-        if (transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
-            return true;
-        } else {
-            return false;
-        }
+        return transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL;
     }
 }

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java Wed Nov 11 19:14:59 2015
@@ -19,6 +19,7 @@
 package org.apache.aries.jpa.blueprint.impl;
 
 import java.net.URL;
+import java.util.Collections;
 import java.util.Set;
 
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
@@ -36,18 +37,17 @@ public class JpaNsHandler implements Nam
     public static final String NAMESPACE_JPA_20 = "http://aries.apache.org/xmlns/jpa/v2.0.0";
     public static final String NAMESPACE_JPAN_10 = "http://aries.apache.org/xmlns/jpan/v1.0.0";
 
-    private void parseElement(Element elt, ComponentMetadata cm, ParserContext pc) {
+    private void parseElement(Element elt, ParserContext pc) {
         ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
 
-        if ("enable".equals(elt.getLocalName())) {
-            if (!cdr.containsComponentDefinition(JpaComponentProcessor.class.getSimpleName())) {
-                MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
-                meta.setId(JpaComponentProcessor.class.getSimpleName());
-                meta.setRuntimeClass(JpaComponentProcessor.class);
-                meta.setProcessor(true);
-                meta.addProperty("pc", passThrough(pc, pc));
-                cdr.registerComponentDefinition(meta);
-            }
+        if ("enable".equals(elt.getLocalName()) &&
+            !cdr.containsComponentDefinition(JpaComponentProcessor.class.getSimpleName())) {
+            MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
+            meta.setId(JpaComponentProcessor.class.getSimpleName());
+            meta.setRuntimeClass(JpaComponentProcessor.class);
+            meta.setProcessor(true);
+            meta.addProperty("pc", passThrough(pc, pc));
+            cdr.registerComponentDefinition(meta);
         }
     }
 
@@ -57,19 +57,21 @@ public class JpaNsHandler implements Nam
         return meta;
     }
 
+    @Override
     public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc) {
         if (node instanceof Element) {
-            Element elt = (Element)node;
-            parseElement(elt, cm, pc);
+            parseElement((Element)node, pc);
         }
         return cm;
     }
 
+    @Override
     public Metadata parse(Element elt, ParserContext pc) {
-        parseElement(elt, pc.getEnclosingComponent(), pc);
+        parseElement(elt, pc);
         return null;
     }
 
+    @Override
     public URL getSchemaLocation(String namespace) {
         if (NAMESPACE_JPAN_10.equals(namespace)) {
             // deprecated (remove in jpa 3)
@@ -81,9 +83,10 @@ public class JpaNsHandler implements Nam
         }
     }
 
+    @Override
     @SuppressWarnings("rawtypes")
     public Set<Class> getManagedClasses() {
-        return null;
+        return Collections.emptySet();
     }
 
 }

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/ResourceLocalTransactionParticipant.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/ResourceLocalTransactionParticipant.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/ResourceLocalTransactionParticipant.java (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/ResourceLocalTransactionParticipant.java Wed Nov 11 19:14:59 2015
@@ -22,8 +22,11 @@ import javax.persistence.EntityManager;
 
 import org.osgi.service.coordinator.Coordination;
 import org.osgi.service.coordinator.Participant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 final class ResourceLocalTransactionParticipant implements Participant {
+    private static final Logger LOG = LoggerFactory.getLogger(ResourceLocalTransactionParticipant.class);
     private final EntityManager em;
 
     ResourceLocalTransactionParticipant(EntityManager em) {
@@ -41,8 +44,8 @@ final class ResourceLocalTransactionPart
         if (em.getTransaction().getRollbackOnly()) {
             try {
                 em.getTransaction().rollback();
-             } catch (Exception e1) {
-                 // Ignore
+             } catch (Exception e) {
+                LOG.debug("Exception on transaction rollback", e);
              }
         } else {
             em.getTransaction().commit();

Modified: aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java (original)
+++ aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java Wed Nov 11 19:14:59 2015
@@ -18,13 +18,24 @@
  */
 package org.apache.aries.jpa.eclipselink.adapter;
 
+import java.lang.reflect.Constructor;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
@@ -32,17 +43,6 @@ import org.osgi.framework.wiring.BundleW
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.spi.PersistenceProvider;
-
 /**
  * Eclipselink adapter main class.
  * 
@@ -56,17 +56,15 @@ import javax.persistence.spi.Persistence
 public class Activator implements BundleActivator, BundleListener {
     public static final String ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME = "org.eclipse.persistence.jpa";
     public static final String ECLIPSELINK_JPA_PROVIDER_CLASS_NAME = "org.eclipse.persistence.jpa.PersistenceProvider";
+    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
     private final ConcurrentMap<Bundle, ServiceRegistration<?>> registeredProviders = new ConcurrentHashMap<Bundle, ServiceRegistration<?>>();
     
-    private static final Logger logger = LoggerFactory.getLogger(Activator.class);
-    
     private BundleContext context;
     
+    @Override
     public void start(BundleContext ctx) {
-        logger.debug("Starting EclipseLink adapter");
-        
+        LOG.debug("Starting EclipseLink adapter");
         context = ctx;
-        
         ctx.addBundleListener(this);
         
         for (Bundle b : ctx.getBundles()) {
@@ -75,18 +73,20 @@ public class Activator implements Bundle
         }
     }
     
+    @Override
     public void stop(BundleContext ctx) {
-        logger.debug("Stopping EclipseLink adapter");
+        LOG.debug("Stopping EclipseLink adapter");
 
         for (ServiceRegistration<?> reg : registeredProviders.values()) {
           reg.unregister();
         }
       }
     
+    @Override
     public void bundleChanged(BundleEvent event) {
         if ((event.getType() & (BundleEvent.RESOLVED)) != 0) {
             handlePotentialEclipseLink(event.getBundle());
-        } else if (event.getType() == BundleEvent.UNRESOLVED | event.getType() == BundleEvent.UNINSTALLED) {
+        } else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
             ServiceRegistration<?> reg = registeredProviders.remove(event.getBundle());
             if (reg != null) {
                 reg.unregister();
@@ -95,35 +95,41 @@ public class Activator implements Bundle
     }
     
     private void handlePotentialEclipseLink(Bundle b) {
-        if (b.getSymbolicName().equals(ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME)) {
-            logger.debug("Found EclipseLink bundle {}", b);
-            
-            // make sure we can actually find the JPA provider we expect to find
-            try {
-                b.loadClass(ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
-            } catch (ClassNotFoundException cnfe) {
-                logger.debug("Did not find provider class, exiting");
-                // not one we can handle
-                return;
-            }
-            
-            if (!!!registeredProviders.containsKey(b)) {
-                logger.debug("Adding new EclipseLink provider for bundle {}", b);
-                
-                ServiceFactory<PersistenceProvider> factory = new EclipseLinkProviderService(b);
-                
-                Dictionary<String, Object> props = new Hashtable<String, Object>();
-                props.put("org.apache.aries.jpa.container.weaving.packages", getJPAPackages(b));
-                props.put("javax.persistence.provider", ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
-                            
-                ServiceRegistration<?> reg = context.registerService(
-                        PersistenceProvider.class.getName(), factory, props);
-                
-                ServiceRegistration<?> old = registeredProviders.putIfAbsent(b, reg);
-                if (old != null) {
-                    reg.unregister();
-                }
-            }
+        if (!ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName())) {
+            return;
+        }
+        if (registeredProviders.containsKey(b)) {
+            return;
+        }
+        
+        PersistenceProvider provider = createEclipselinkProvider(b);
+        if (provider == null) {
+            return;
+        }
+
+        LOG.debug("Adding new EclipseLink provider for bundle {}", b);
+        PersistenceProvider proxiedProvider = new EclipseLinkPersistenceProvider(provider, b);
+        
+        Dictionary<String, Object> props = new Hashtable<String, Object>(); // NOSONAR
+        props.put("org.apache.aries.jpa.container.weaving.packages", getJPAPackages(b));
+        props.put("javax.persistence.provider", ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
+        ServiceRegistration<?> reg = context.registerService(PersistenceProvider.class, proxiedProvider, props);
+        
+        ServiceRegistration<?> old = registeredProviders.putIfAbsent(b, reg);
+        if (old != null) {
+            reg.unregister();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static PersistenceProvider createEclipselinkProvider(Bundle b) {
+        try {
+            Class<? extends PersistenceProvider> providerClass = (Class<? extends PersistenceProvider>)b.loadClass(Activator.ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
+            Constructor<? extends PersistenceProvider> con = providerClass.getConstructor();
+            return con.newInstance();
+        } catch (Exception e) {
+            LOG.debug("Unable to load EclipseLink provider class. Ignoring bundle " + b.getSymbolicName(), e);
+            return null;
         }
     }
     
@@ -139,36 +145,29 @@ public class Activator implements Bundle
      */
     private String[] getJPAPackages(Bundle jpaBundle) {
         Set<String> result = new HashSet<String>();
-        
+
         for (Bundle b : context.getBundles()) {
             BundleWiring bw = b.adapt(BundleWiring.class);
-            if(bw != null) {
-	            List<BundleWire> wires = bw.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
-	
-	            for (BundleWire w : wires) {
-	                String pkgName = (String) w.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
-	
-	                boolean add = false;
-	                if (b.equals(jpaBundle)) {
-	                    add = true;
-	                } else if (pkgName.startsWith("org.eclipse.persistence")) {
-	                    add = true;
-	                }
-	                
-	                if (add) {
-	                    String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + b.getSymbolicName() + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE  + "=" + b.getVersion();                    
-	                    result.add(pkgName + suffix);
-	                }
-	            }
+            if (bw == null) {
+                continue;
+            }
+            boolean isJpaBundle = b.equals(jpaBundle);
+            List<BundleWire> wires = bw.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
+            for (BundleWire w : wires) {
+                String pkgName = (String)w.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
+                boolean add = isJpaBundle || pkgName.startsWith("org.eclipse.persistence");
+                if (add) {
+                    result.add(getPkg(b, pkgName));
+                }
             }
         }
         
-        result.add("org.apache.aries.jpa.eclipselink.adapter.platform;" + 
-                Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + context.getBundle().getSymbolicName() + ";" + 
-                Constants.BUNDLE_VERSION_ATTRIBUTE  + "=" + context.getBundle().getVersion());        
-        
-        logger.debug("Found JPA packages {}", result);
-        
+        result.add(getPkg(context.getBundle(), "org.apache.aries.jpa.eclipselink.adapter.platform"));
+        LOG.debug("Found JPA packages {}", result);
         return result.toArray(new String[0]);
     }
+
+    private static String getPkg(Bundle b, String pkgName) {
+        return String.format("%s;%s=%s; %s=%s", pkgName, Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, b.getSymbolicName(), Constants.BUNDLE_VERSION_ATTRIBUTE, b.getVersion());
+    }
 }

Added: aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkPersistenceProvider.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkPersistenceProvider.java?rev=1713916&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkPersistenceProvider.java (added)
+++ aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkPersistenceProvider.java Wed Nov 11 19:14:59 2015
@@ -0,0 +1,64 @@
+/*
+ * 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 WARRANTIESOR 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.jpa.eclipselink.adapter;
+
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.ProviderUtil;
+
+import org.osgi.framework.Bundle;
+
+@SuppressWarnings("rawtypes")
+final class EclipseLinkPersistenceProvider implements PersistenceProvider {
+    private final PersistenceProvider delegate;
+    private final Bundle eclipeLinkBundle;
+
+    EclipseLinkPersistenceProvider(PersistenceProvider delegate, Bundle eclipeLinkBundle) {
+        this.delegate = delegate;
+        this.eclipeLinkBundle = eclipeLinkBundle;
+    }
+
+    @Override
+    public ProviderUtil getProviderUtil() {
+        return delegate.getProviderUtil();
+    }
+    
+    @Override
+    public EntityManagerFactory createEntityManagerFactory(String arg0, Map arg1) {
+        return delegate.createEntityManagerFactory(arg0, arg1);
+    }
+
+    @Override
+    public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo punit, Map props) {
+        return delegate.createContainerEntityManagerFactory(new PersistenceUnitProxyWithTargetServer(punit, eclipeLinkBundle), props);
+    }
+
+    @Override
+    public void generateSchema(PersistenceUnitInfo punit, Map arg1) {
+        delegate.generateSchema(new PersistenceUnitProxyWithTargetServer(punit, eclipeLinkBundle), arg1);
+    }
+
+    @Override
+    public boolean generateSchema(String arg0, Map arg1) {
+        return delegate.generateSchema(arg0, arg1);
+    }
+}

Modified: aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java (original)
+++ aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java Wed Nov 11 19:14:59 2015
@@ -1,5 +1,5 @@
 /*
-// * Licensed to the Apache Software Foundation (ASF) under one
+ * 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
@@ -47,58 +47,72 @@ public class PersistenceUnitProxyWithTar
             FrameworkUtil.getBundle(getClass()));
     }
 
+    @Override
     public void addTransformer(ClassTransformer arg0) {
         delegate.addTransformer(arg0);
     }
 
+    @Override
     public boolean excludeUnlistedClasses() {
         return delegate.excludeUnlistedClasses();
     }
 
+    @Override
     public ClassLoader getClassLoader() {
         return unionClassLoader;
     }
 
+    @Override
     public List<URL> getJarFileUrls() {
         return delegate.getJarFileUrls();
     }
 
+    @Override
     public DataSource getJtaDataSource() {
         return delegate.getJtaDataSource();
     }
 
+    @Override
     public List<String> getManagedClassNames() {
         return delegate.getManagedClassNames();
     }
 
+    @Override
     public List<String> getMappingFileNames() {
         return delegate.getMappingFileNames();
     }
 
+    @Override
     public ClassLoader getNewTempClassLoader() {
         return delegate.getNewTempClassLoader();
     }
 
+    @Override
     public DataSource getNonJtaDataSource() {
         return delegate.getNonJtaDataSource();
     }
 
+    @Override
     public String getPersistenceProviderClassName() {
         return delegate.getPersistenceProviderClassName();
     }
 
+    @Override
     public String getPersistenceUnitName() {
         return delegate.getPersistenceUnitName();
     }
 
+    @Override
     public URL getPersistenceUnitRootUrl() {
         return delegate.getPersistenceUnitRootUrl();
     }
 
+    @Override
     public String getPersistenceXMLSchemaVersion() {
         return delegate.getPersistenceXMLSchemaVersion();
     }
 
+    @Override
     public Properties getProperties() {
         Properties props = delegate.getProperties();
         
@@ -106,7 +120,7 @@ public class PersistenceUnitProxyWithTar
             props = new Properties();
         }
         
-        if (!!!props.containsKey("eclipselink.target-server")) {
+        if (!props.containsKey("eclipselink.target-server")) {
             props.put("eclipselink.target-server", 
                 "org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer");
         }
@@ -114,14 +128,17 @@ public class PersistenceUnitProxyWithTar
         return props;
     }
 
+    @Override
     public SharedCacheMode getSharedCacheMode() {
         return delegate.getSharedCacheMode();
     }
 
+    @Override
     public PersistenceUnitTransactionType getTransactionType() {
         return delegate.getTransactionType();
     }
 
+    @Override
     public ValidationMode getValidationMode() {
         return delegate.getValidationMode();
     }

Modified: aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java (original)
+++ aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java Wed Nov 11 19:14:59 2015
@@ -26,68 +26,71 @@ import java.io.OutputStream;
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public final class UnionClassLoader extends ClassLoader implements BundleReference{
-  
-  private static final String ORG_OSGI_FRAMEWORK = "org.osgi.framework.";
-  private static final int DOT_INDEX = ORG_OSGI_FRAMEWORK.lastIndexOf('.');
-  private final Bundle eclipseLinkBundle;
-  private final Bundle adaptorBundle;
-  
-  public UnionClassLoader(ClassLoader parentLoader, Bundle b, Bundle adaptor) {
-    super(parentLoader);
-    this.eclipseLinkBundle = b;
-    this.adaptorBundle = adaptor;
-  }
-
-  protected Class<?> findClass(String name) throws ClassNotFoundException {
-    
-    if("org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer".equals(name) ||
-        "org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSWrapper".equals(name)) {
-      
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      InputStream is = getClass().getClassLoader().getResourceAsStream(
-          name.replace('.', '/') + ".class");
-      
-      if(is == null)
-        throw new ClassNotFoundException(name);
-      
-      
-      try {
-        copy(is, baos);
-      } catch (IOException ioe) {
-        throw new ClassNotFoundException(name, ioe);
-      }
-      return defineClass(name, baos.toByteArray(), 0, baos.size());
-    } else if (name.startsWith(ORG_OSGI_FRAMEWORK) &&
-        name.lastIndexOf('.') == DOT_INDEX) {
-      return adaptorBundle.loadClass(name);
-    }
-    return eclipseLinkBundle.loadClass(name);
-  }
-
-  public Bundle getBundle() {
-    return adaptorBundle;
-  }
-  
-	private static void copy(InputStream in, OutputStream out)
-			throws IOException {
-		try {
-			int len;
-			byte[] b = new byte[1024];
-			while ((len = in.read(b)) != -1)
-				out.write(b, 0, len);
-		} finally {
-			close(in);
-		}
-	}
-
-	private static void close(Closeable c) {
-		try {
-			if (c != null)
-				c.close();
-		} catch (IOException e) {
-			c = null;
-		}
-	}
-}
\ No newline at end of file
+public final class UnionClassLoader extends ClassLoader implements BundleReference {
+    private static final String ORG_OSGI_FRAMEWORK = "org.osgi.framework.";
+    private static final int DOT_INDEX = ORG_OSGI_FRAMEWORK.lastIndexOf('.');
+    private static final Logger LOG = LoggerFactory.getLogger(UnionClassLoader.class);
+    private final Bundle eclipseLinkBundle;
+    private final Bundle adaptorBundle;
+
+    public UnionClassLoader(ClassLoader parentLoader, Bundle b, Bundle adaptor) {
+        super(parentLoader);
+        this.eclipseLinkBundle = b;
+        this.adaptorBundle = adaptor;
+    }
+
+    @Override
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
+        if ("org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer".equals(name) 
+            || "org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSWrapper".equals(name)) {
+            return loadTempClass(name);
+        } else if (name.startsWith(ORG_OSGI_FRAMEWORK) && name.lastIndexOf('.') == DOT_INDEX) {
+            return adaptorBundle.loadClass(name);
+        }
+        return eclipseLinkBundle.loadClass(name);
+    }
+
+    private Class<?> loadTempClass(String name) throws ClassNotFoundException, ClassFormatError {
+        InputStream is = getClass().getClassLoader().getResourceAsStream(name.replace('.', '/') + ".class");
+        if (is == null) {
+            throw new ClassNotFoundException(name);
+        }
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            copy(is, baos);
+        } catch (IOException ioe) {
+            throw new ClassNotFoundException(name, ioe);
+        }
+        return defineClass(name, baos.toByteArray(), 0, baos.size());
+    }
+
+    @Override
+    public Bundle getBundle() {
+        return adaptorBundle;
+    }
+
+    private static void copy(InputStream in, OutputStream out) throws IOException {
+        try {
+            int len;
+            byte[] b = new byte[1024];
+            while ((len = in.read(b)) != -1) {
+                out.write(b, 0, len);
+            }
+        } finally {
+            close(in);
+        }
+    }
+
+    private static void close(Closeable c) {
+        try {
+            if (c != null) {
+                c.close();
+            }
+        } catch (IOException e) {
+            LOG.debug("Exception closing", e);
+        }
+    }
+}

Modified: aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java (original)
+++ aries/trunk/jpa/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java Wed Nov 11 19:14:59 2015
@@ -36,8 +36,7 @@ public class OSGiTSWrapper extends JTATr
             ServiceReference ref = ctx.getServiceReference(TransactionManager.class.getName());
             
             if (ref != null) {
-                TransactionManager manager = (TransactionManager) ctx.getService(ref);
-                return manager;
+                return (TransactionManager) ctx.getService(ref);
             }            
         }
         

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java Wed Nov 11 19:14:59 2015
@@ -49,7 +49,7 @@ public class Activator implements Bundle
      * weaving hooks that are not yet visible to the bundle class loader.
      */
     private void registerWeavingHook(BundleContext context, TransformerRegistry tr) {
-        Dictionary<String, Object> props = new Hashtable<String, Object>(1);
+        Dictionary<String, Object> props = new Hashtable<String, Object>(1); // NOSONAR
         props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
         context.registerService(WeavingHook.class.getName(), tr, props);
     }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java Wed Nov 11 19:14:59 2015
@@ -40,7 +40,7 @@ public class DSFTracker extends ServiceT
     private static final String JDBC_DRIVER = "javax.persistence.jdbc.driver";
     private static final String JDBC_URL = "javax.persistence.jdbc.url";
     private static final String JDBC_USER = "javax.persistence.jdbc.user";
-    private static final String JDBC_PASSWORD = "javax.persistence.jdbc.password";
+    private static final String JDBC_PASSWORD = "javax.persistence.jdbc.password"; // NOSONAR
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DSFTracker.class);
 
@@ -101,11 +101,10 @@ public class DSFTracker extends ServiceT
             put(props, DataSourceFactory.JDBC_URL, punit, JDBC_URL);
             put(props, DataSourceFactory.JDBC_USER, punit, JDBC_USER);
             put(props, DataSourceFactory.JDBC_PASSWORD, punit, JDBC_PASSWORD);
-            DataSource ds = dsf.createDataSource(props);
-            return ds;
+            return dsf.createDataSource(props);
         } catch (SQLException e) {
-            throw new RuntimeException("Error creating DataSource for persistence unit " + punit + "."
-                                       + e.getMessage(), e);
+            String msg = "Error creating DataSource for persistence unit " + punit + "." + e.getMessage();
+            throw new RuntimeException(msg, e); // NOSONAR
         }
     }
 

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java Wed Nov 11 19:14:59 2015
@@ -49,9 +49,8 @@ import org.slf4j.LoggerFactory;
  * the JPA_CONFIGURATION_PREFIX.<persistence unit name>.
  */
 public class ManagedEMF implements Closeable, ManagedService {
-	private static final Logger LOGGER = LoggerFactory.getLogger(ManagedEMF.class);
-
-    private static String JPA_CONFIGURATION_PREFIX = "org.apache.aries.jpa.";
+    private static final Logger LOGGER = LoggerFactory.getLogger(ManagedEMF.class);
+    private static final String JPA_CONFIGURATION_PREFIX = "org.apache.aries.jpa.";
 
     private EntityManagerFactory emf;
     private ServiceRegistration<EntityManagerFactory> reg;
@@ -67,12 +66,11 @@ public class ManagedEMF implements Close
         this.persistenceUnit = persistenceUnit;
         this.bundle = bundle;
         registerManagedService(containerContext, persistenceUnit);
-        //createAndPublishEMF(null);
         closed = false;
     }
 
     private void registerManagedService(BundleContext containerContext, PersistenceUnitInfo persistenceUnit) {
-        Dictionary<String, Object> configuration = new Hashtable<String, Object>();
+        Dictionary<String, Object> configuration = new Hashtable<String, Object>(); // NOSONAR
         configuration.put(Constants.SERVICE_PID,
                           JPA_CONFIGURATION_PREFIX + persistenceUnit.getPersistenceUnitName());
         configReg = containerContext.registerService(ManagedService.class.getName(), this, configuration);
@@ -81,10 +79,9 @@ public class ManagedEMF implements Close
     public void closeEMF() {
         if (reg != null) {
             try {
-
                 reg.unregister();
             } catch (Exception e) {
-                // Ignore. May happen if persistence unit bundle is unloaded/updated
+                LOGGER.debug("Exception on unregister", e);
             }
         }
         if (emf != null && emf.isOpen()) {
@@ -98,6 +95,7 @@ public class ManagedEMF implements Close
         emf = null;
     }
     
+    @Override
     public void close() {
         closed = true;
         closeEMF();
@@ -135,7 +133,7 @@ public class ManagedEMF implements Close
     }
 
     public static Dictionary<String, String> createProperties(PersistenceUnitInfo persistenceUnit, Bundle puBundle) {
-        Dictionary<String, String> props = new Hashtable<String, String>();
+        Dictionary<String, String> props = new Hashtable<String, String>(); // NOSONAR
         props.put(JPA_UNIT_NAME, persistenceUnit.getPersistenceUnitName());
         if (persistenceUnit.getPersistenceProviderClassName() != null) {
             props.put(JPA_UNIT_PROVIDER, persistenceUnit.getPersistenceProviderClassName());
@@ -145,7 +143,7 @@ public class ManagedEMF implements Close
     }
 
     private Map<String, Object> asMap(Dictionary<String, ?> dict) {
-        Map<String, Object> map = new HashMap<String, Object>();
+        Map<String, Object> map = new HashMap<String, Object>(); // NOSONAR
         map.put(PersistenceUnitTransactionType.class.getName(), persistenceUnit.getTransactionType());
         for (Enumeration<String> e = dict.keys(); e.hasMoreElements();) {
             String key = e.nextElement();

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java Wed Nov 11 19:14:59 2015
@@ -39,29 +39,42 @@ import org.slf4j.LoggerFactory;
  */
 public class PersistenceBundleTracker implements BundleTrackerCustomizer<Bundle> {
     private static final Logger LOGGER = LoggerFactory.getLogger(PersistenceBundleTracker.class);
-    Map<Bundle, Collection<PersistenceProviderTracker>> trackers;
-    private BundleContext context;
+    private final Map<Bundle, Collection<PersistenceProviderTracker>> trackers;
+    private final BundleContext context;
+    private Map<Integer, String> typeMap;
 
     public PersistenceBundleTracker(BundleContext context) {
         this.context = context;
         trackers = new HashMap<Bundle, Collection<PersistenceProviderTracker>>();
+        this.typeMap = new HashMap<Integer, String>();
+        this.typeMap.put(BundleEvent.INSTALLED, "INSTALLED");
+        this.typeMap.put(BundleEvent.LAZY_ACTIVATION, "LAZY_ACTIVATION");
+        this.typeMap.put(BundleEvent.RESOLVED, "RESOLVED");
+        this.typeMap.put(BundleEvent.STARTED, "STARTED");
+        this.typeMap.put(BundleEvent.STARTING, "Starting");
+        this.typeMap.put(BundleEvent.STOPPED, "STOPPED");
+        this.typeMap.put(BundleEvent.UNINSTALLED, "UNINSTALLED");
+        this.typeMap.put(256, "UNRESOLVED");
+        this.typeMap.put(BundleEvent.UPDATED, "UPDATED");
     }
 
+    @Override
     public synchronized Bundle addingBundle(Bundle bundle, BundleEvent event) {
         if (event != null && event.getType() == BundleEvent.STOPPED) {
             // Avoid starting persistence units in state STOPPED.
             // TODO No idea why we are called at all in this state
             return bundle;
         }
-        if (getTrackers(bundle).size() == 0) {
+        if (getTrackers(bundle).isEmpty()) {
             findPersistenceUnits(bundle, event);
         }
         return bundle;
     }
 
+    @Override
     public synchronized void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
         Collection<PersistenceProviderTracker> providerTrackers = trackers.remove(bundle);
-        if (providerTrackers == null || providerTrackers.size() == 0) {
+        if (providerTrackers == null || providerTrackers.isEmpty()) {
             return;
         }
         LOGGER.info("removing persistence units for " + bundle.getSymbolicName() + " " + getType(event));
@@ -76,12 +89,12 @@ public class PersistenceBundleTracker im
             punit.addAnnotated();
             trackProvider(bundle, punit);
         }
-        if (getTrackers(bundle).size() > 0) {
+        if (!getTrackers(bundle).isEmpty()) {
             LOGGER.info("Persistence units added for bundle " + bundle.getSymbolicName() + " event " + getEventType(event));
         }
     }
 
-    private Integer getEventType(BundleEvent event) {
+    private static Integer getEventType(BundleEvent event) {
         return (event != null) ? event.getType() : null;
     }
 
@@ -96,36 +109,16 @@ public class PersistenceBundleTracker im
 
     @Override
     public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {
+        // Only interested in added or removed
     }
 
-    private static String getType(BundleEvent event) {
+    private String getType(BundleEvent event) {
         if (event == null) {
             return "null";
         }
         int type = event.getType();
-        switch (type) {
-        case BundleEvent.INSTALLED:
-            return "INSTALLED";
-        case BundleEvent.LAZY_ACTIVATION:
-            return "LAZY_ACTIVATION";
-        case BundleEvent.RESOLVED:
-            return "RESOLVED";
-        case BundleEvent.STARTED:
-            return "STARTED";
-        case BundleEvent.STARTING:
-            return "Starting";
-        case BundleEvent.STOPPED:
-            return "STOPPED";
-        case BundleEvent.UNINSTALLED:
-        case 256: // Not sure why but this event is sent when a bundle is uninstalled
-            return "UNINSTALLED";
-        case BundleEvent.UNRESOLVED:
-            return "UNRESOLVED";
-        case BundleEvent.UPDATED:
-            return "UPDATED";
-        default:
-            return "unknown event type: " + type;
-        }
+        String typeSt = typeMap.get(type);
+        return (typeSt != null) ? typeSt : "unknown event type: " + type;
     }
     
     private Collection<PersistenceProviderTracker> getTrackers(Bundle bundle) {

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java Wed Nov 11 19:14:59 2015
@@ -54,7 +54,7 @@ public class PersistenceProviderTracker
     }
 
     private static Filter createFilter(BundleContext context, PersistenceUnit punit) {
-        String filter = null;
+        String filter;
         if (punit.getPersistenceProviderClassName() != null) {
             filter = String.format("(&(objectClass=%s)(%s=%s))",
                                    PersistenceProvider.class.getName(),
@@ -84,7 +84,7 @@ public class PersistenceProviderTracker
 
         createAndCloseDummyEMF(provider);
 
-        stored.dsTracker = createDataSourceTracker(stored, provider, providerName);
+        stored.dsTracker = createDataSourceTracker(provider);
         EntityManagerFactoryBuilder emfBuilder = new AriesEntityManagerFactoryBuilder(provider, punit);
         Dictionary<String, ?> props = ManagedEMF.createProperties(punit, punit.getBundle());
         stored.reg = context.registerService(EntityManagerFactoryBuilder.class, emfBuilder , props);
@@ -111,7 +111,7 @@ public class PersistenceProviderTracker
         punit.setNonJtaDataSource(null);
     }
 
-    private ServiceTracker<?, ?> createDataSourceTracker(StoredPerProvider stored, PersistenceProvider provider, String providerName) {
+    private ServiceTracker<?, ?> createDataSourceTracker(PersistenceProvider provider) {
         if (usesDataSource()) {
             if (!usesDataSourceService()) {
                 LOGGER.warn("Persistence unit " + punit.getPersistenceUnitName() + " refers to a non OSGi service DataSource");

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java Wed Nov 11 19:14:59 2015
@@ -27,8 +27,15 @@ import javax.persistence.MappedSuperclas
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.wiring.BundleWiring;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 class JPAAnnotationScanner {
+    private static final Logger LOG = LoggerFactory.getLogger(JPAAnnotationScanner.class);
+    
+    private JPAAnnotationScanner() {
+    }
+    
     public static Collection<String> findJPAAnnotatedClasses(Bundle b) {
         BundleWiring bw = b.adapt(BundleWiring.class);
         Collection<String> resources = bw.listResources("/", "*.class", 
@@ -47,12 +54,16 @@ class JPAAnnotationScanner {
               classes.add(s);
             }
             
-          } catch (ClassNotFoundException cnfe) {
-            
-          } catch (NoClassDefFoundError ncdfe) {
-            
+          } catch (ClassNotFoundException e) {
+              logEx(e);
+          } catch (NoClassDefFoundError e) {
+              logEx(e);
           }
         }
         return classes;
       }
+
+    private static void logEx(Throwable e) {
+        LOG.debug("Exception while scanning for JPA annotations", e);
+    }
 }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java Wed Nov 11 19:14:59 2015
@@ -18,8 +18,9 @@
  */
 package org.apache.aries.jpa.container.parser.impl;
 
+import java.util.ArrayDeque;
 import java.util.Collection;
-import java.util.Stack;
+import java.util.Deque;
 
 import javax.persistence.SharedCacheMode;
 import javax.persistence.ValidationMode;
@@ -36,7 +37,7 @@ import org.xml.sax.helpers.DefaultHandle
  */
 public class JPAHandler extends DefaultHandler {
     /** The Persistence Units that we have parsed */
-    private final Stack<PersistenceUnit> persistenceUnits = new Stack<PersistenceUnit>();
+    private final Deque<PersistenceUnit> persistenceUnits = new ArrayDeque<PersistenceUnit>();
     /** The name of the current element */
     private String elementName;
     /** The version of the persistence.xml file */
@@ -106,7 +107,7 @@ public class JPAHandler extends DefaultH
             pu.setExcludeUnlisted(Boolean.parseBoolean(s));
         else if ("shared-cache-mode".equals(elementName))
             pu.setSharedCacheMode(SharedCacheMode.valueOf(s));
-          else if ("validation-mode".equals(elementName))
+        else if ("validation-mode".equals(elementName))
             pu.setValidationMode(ValidationMode.valueOf(s));
     }
 

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java?rev=1713916&r1=1713915&r2=1713916&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java Wed Nov 11 19:14:59 2015
@@ -95,10 +95,9 @@ public class PersistenceUnit implements
         return this.classLoader;
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public List<URL> getJarFileUrls() {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     @Override
@@ -112,15 +111,12 @@ public class PersistenceUnit implements
 
     @Override
     public List<String> getManagedClassNames() {
-        ArrayList<String> names = new ArrayList<String>();
-        names.addAll(classNames);
-        return names;
+        return new ArrayList<String>(classNames);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public List<String> getMappingFileNames() {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     public String getName() {



Mime
View raw message