You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2017/07/11 09:05:47 UTC
cxf-dosgi git commit: [DOSGI-254] Make proxyfactory generic. Small
fix in test
Repository: cxf-dosgi
Updated Branches:
refs/heads/master 7a5315cbd -> 5b953b2dd
[DOSGI-254] Make proxyfactory generic. Small fix in test
Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/5b953b2d
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/5b953b2d
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/5b953b2d
Branch: refs/heads/master
Commit: 5b953b2dd983788e61e42673139e3d5d5822671e
Parents: 7a5315c
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Jul 11 11:04:37 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Jul 11 11:04:37 2017 +0200
----------------------------------------------------------------------
.../org/apache/cxf/dosgi/common/proxy/ProxyFactory.java | 11 ++++++-----
.../dosgi/common/proxy/ServiceInvocationHandlerTest.java | 4 ++--
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5b953b2d/common/src/main/java/org/apache/cxf/dosgi/common/proxy/ProxyFactory.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/proxy/ProxyFactory.java b/common/src/main/java/org/apache/cxf/dosgi/common/proxy/ProxyFactory.java
index ec10f6e..03c2a14 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/proxy/ProxyFactory.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/proxy/ProxyFactory.java
@@ -23,10 +23,11 @@ import java.lang.reflect.Proxy;
public final class ProxyFactory {
private ProxyFactory() {
}
-
- public static Object create(Object serviceProxy, Class<?> iType) {
- return Proxy.newProxyInstance(iType.getClassLoader(), new Class[] {
- iType
- }, new ServiceInvocationHandler(serviceProxy, iType));
+
+ @SuppressWarnings("unchecked")
+ public static <T> T create(Object serviceProxy, Class<T> iType) {
+ Class<?>[] ifaces = new Class<?>[] {iType};
+ return (T)Proxy.newProxyInstance(iType.getClassLoader(), ifaces,
+ new ServiceInvocationHandler(serviceProxy, iType));
}
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5b953b2d/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
index 30cf5a8..43a90a7 100644
--- a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
@@ -80,7 +80,7 @@ public class ServiceInvocationHandlerTest {
@Test(expected = IOException.class)
public void testException() throws IOException {
- MySubService proxy = (MySubService)ProxyFactory.create(new MyServiceImpl(), MySubService.class);
+ MySubService proxy = ProxyFactory.create(new MyServiceImpl(), MySubService.class);
proxy.throwException2();
}
@@ -90,7 +90,7 @@ public class ServiceInvocationHandlerTest {
*/
@Test(expected = ServiceException.class)
public void testInheritedException() throws IOException {
- MyBaseService proxy = (MyBaseService)ProxyFactory.create(new MyServiceImpl(), MySubService.class);
+ MySubService proxy = ProxyFactory.create(new MyServiceImpl(), MySubService.class);
proxy.throwException1();
}