deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rafab...@apache.org
Subject deltaspike git commit: DELTASPIKE-905 - move the code from ProxyClassGeneratorLookup to DeltaSpikeProxyFactory (1:1)
Date Thu, 04 Jun 2015 18:06:42 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master cd0bf79d3 -> 1aa0d1be8


DELTASPIKE-905 - move the code from ProxyClassGeneratorLookup to DeltaSpikeProxyFactory (1:1)


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/1aa0d1be
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/1aa0d1be
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/1aa0d1be

Branch: refs/heads/master
Commit: 1aa0d1be8adae22e723e89b2b94fb438e3ac2b1f
Parents: cd0bf79
Author: Rafael Benevides <rafabene@gmail.com>
Authored: Tue Jun 2 15:15:06 2015 -0400
Committer: Rafael Benevides <rafabene@gmail.com>
Committed: Thu Jun 4 14:06:06 2015 -0400

----------------------------------------------------------------------
 .../proxy/api/DeltaSpikeProxyFactory.java       | 41 +++++++++++-
 .../proxy/api/ProxyClassGeneratorLookup.java    | 68 --------------------
 .../OSGI-INF/ProxyClassGeneratorLookup.xml      |  8 +--
 3 files changed, 44 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1aa0d1be/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java
b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java
index 6232d9b..d66947e 100644
--- a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java
+++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java
@@ -26,14 +26,53 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.interceptor.InterceptorBinding;
+
 import org.apache.deltaspike.core.util.ClassUtils;
+import org.apache.deltaspike.core.util.ServiceUtils;
 import org.apache.deltaspike.proxy.spi.ProxyClassGenerator;
 
 public abstract class DeltaSpikeProxyFactory
 {
     private static final String SUPER_ACCESSOR_METHOD_SUFFIX = "$super";
     
+    private static ProxyClassGenerator generator;
+
+    /**
+     * Looks up a unique service implementation.
+     *
+     * @return ProxyClassGenerator service
+     */
+    private static ProxyClassGenerator lookupService()
+    {
+        if (generator == null)
+        {
+            List<ProxyClassGenerator> proxyClassGeneratorList = ServiceUtils
+                .loadServiceImplementations(ProxyClassGenerator.class);
+
+            if (proxyClassGeneratorList.size() != 1)
+            {
+                throw new IllegalStateException(proxyClassGeneratorList.size()
+                    + " implementations of " + ProxyClassGenerator.class.getName()
+                    + " found. Expected exactly one implementation.");
+            }
+            generator = proxyClassGeneratorList.get(0);
+        }
+        return generator;
+    }
+
+    /**
+     * Setter invoked by OSGi Service Component Runtime
+     *
+     * @param generator
+     *            generator service
+     */
+    public void setGenerator(ProxyClassGenerator generator)
+    {
+        DeltaSpikeProxyFactory.generator = generator;
+    }
+
     public <T> Class<T> getProxyClass(Class<T> targetClass,
             Class<? extends InvocationHandler> delegateInvocationHandlerClass)
     {
@@ -75,7 +114,7 @@ public abstract class DeltaSpikeProxyFactory
                 }
             }
 
-            ProxyClassGenerator proxyClassGenerator = ProxyClassGeneratorLookup.lookupService();
+            ProxyClassGenerator proxyClassGenerator = lookupService();
 
             proxyClass = proxyClassGenerator.generateProxyClass(classLoader,
                     targetClass,

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1aa0d1be/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/ProxyClassGeneratorLookup.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/ProxyClassGeneratorLookup.java
b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/ProxyClassGeneratorLookup.java
deleted file mode 100644
index 38d44de..0000000
--- a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/ProxyClassGeneratorLookup.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.deltaspike.proxy.api;
-
-import java.util.List;
-
-import org.apache.deltaspike.core.util.ServiceUtils;
-import org.apache.deltaspike.proxy.spi.ProxyClassGenerator;
-
-/**
- * Looks up a {@link ProxyClassGenerator} via Java SE ServiceLoader or via Declarative Services
- * injection when running under OSGi.
- */
-public class ProxyClassGeneratorLookup
-{
-
-    private static ProxyClassGenerator generator;
-
-    /**
-     * Looks up a unique service implementation.
-     * 
-     * @return ProxyClassGenerator service
-     */
-    public static ProxyClassGenerator lookupService()
-    {
-        if (generator == null)
-        {
-            List<ProxyClassGenerator> proxyClassGeneratorList = ServiceUtils
-                .loadServiceImplementations(ProxyClassGenerator.class);
-
-            if (proxyClassGeneratorList.size() != 1)
-            {
-                throw new IllegalStateException(proxyClassGeneratorList.size()
-                    + " implementations of " + ProxyClassGenerator.class.getName()
-                    + " found. Expected exactly one implementation.");
-            }
-            generator = proxyClassGeneratorList.get(0);
-        }
-        return generator;
-    }
-
-    /**
-     * Setter invoked by OSGi Service Component Runtime
-     * 
-     * @param generator
-     *            generator service
-     */
-    public void setGenerator(ProxyClassGenerator generator)
-    {
-        ProxyClassGeneratorLookup.generator = generator;
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1aa0d1be/deltaspike/modules/proxy/api/src/main/resources/OSGI-INF/ProxyClassGeneratorLookup.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy/api/src/main/resources/OSGI-INF/ProxyClassGeneratorLookup.xml
b/deltaspike/modules/proxy/api/src/main/resources/OSGI-INF/ProxyClassGeneratorLookup.xml
index 8437882..ff1e6fe 100644
--- a/deltaspike/modules/proxy/api/src/main/resources/OSGI-INF/ProxyClassGeneratorLookup.xml
+++ b/deltaspike/modules/proxy/api/src/main/resources/OSGI-INF/ProxyClassGeneratorLookup.xml
@@ -17,8 +17,8 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="ProxyClassGeneratorLookup">
-   <implementation class="org.apache.deltaspike.proxy.api.ProxyClassGeneratorLookup"/>
-   <reference bind="setGenerator" cardinality="1..1" interface="org.apache.deltaspike.proxy.spi.ProxyClassGenerator"

-       name="ProxyClassGenerator" policy="static" unbind="setGenerator"/>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DeltaSpikeProxyFactory">
+   <implementation class="org.apache.deltaspike.proxy.api.DeltaSpikeProxyFactory"/>
+   <reference bind="setGenerator" cardinality="1..1" interface="org.apache.deltaspike.proxy.spi.DeltaSpikeProxyFactory"

+       name="DeltaSpikeProxyFactory" policy="static" unbind="setGenerator"/>
 </scr:component>


Mime
View raw message