You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/05/19 14:26:56 UTC
[isis] 01/03: ISIS-1949: move objenesis dependencies
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 4e85abbde3d5aa19207325d8ba217ebbee345b5b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat May 19 15:54:29 2018 +0200
ISIS-1949: move objenesis dependencies
Task-Url: https://issues.apache.org/jira/browse/ISIS-1949
---
core/plugins/codegen-javassist/pom.xml | 5 +
core/unittestsupport/pom.xml | 126 +++++++++------------
.../jmocking/JavassistImposteriser.java | 8 +-
core/wrapper/pom.xml | 5 -
.../isis/core/wrapper/internal/util/Util.java | 53 ---------
.../isis/core/wrapper/proxy/ProxyCreator.java | 21 +++-
6 files changed, 77 insertions(+), 141 deletions(-)
diff --git a/core/plugins/codegen-javassist/pom.xml b/core/plugins/codegen-javassist/pom.xml
index 190059b..a0f7382 100644
--- a/core/plugins/codegen-javassist/pom.xml
+++ b/core/plugins/codegen-javassist/pom.xml
@@ -59,6 +59,11 @@
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.isis.core</groupId>
diff --git a/core/unittestsupport/pom.xml b/core/unittestsupport/pom.xml
index 53ba654..a8d62d6 100644
--- a/core/unittestsupport/pom.xml
+++ b/core/unittestsupport/pom.xml
@@ -1,97 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.isis.core</groupId>
<artifactId>isis</artifactId>
- <version>${revision}</version>
+ <version>${revision}</version>
</parent>
<artifactId>isis-core-unittestsupport</artifactId>
<name>Apache Isis Unit Test Support</name>
- <properties>
- <jar-plugin.automaticModuleName>org.apache.isis.core.unittestsupport</jar-plugin.automaticModuleName>
- <git-plugin.propertiesDir>org/apache/isis/core/unittestsupport</git-plugin.propertiesDir>
- </properties>
+ <properties>
+ <jar-plugin.automaticModuleName>org.apache.isis.core.unittestsupport</jar-plugin.automaticModuleName>
+ <git-plugin.propertiesDir>org/apache/isis/core/unittestsupport</git-plugin.propertiesDir>
+ </properties>
- <description>
+ <description>
Support for writing unit tests; should be added as a dependency
with scope=test only
</description>
<dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.picocontainer</groupId>
- <artifactId>picocontainer</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit4</artifactId>
+ </dependency>
<!-- JDO API (non transient, provided by plugin) -->
- <dependency>
- <groupId>javax.jdo</groupId>
- <artifactId>jdo-api</artifactId>
- <version>${jdo-api.version}</version>
- <!-- provided by plugins -->
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>javax.jdo</groupId>
+ <artifactId>jdo-api</artifactId>
+ <version>${jdo-api.version}</version>
+ <!-- provided by plugins -->
+ <scope>provided</scope>
+ </dependency>
-
- <dependency>
- <groupId>org.objenesis</groupId>
- <artifactId>objenesis</artifactId>
- <!--<version>1.4</version>-->
- </dependency>
-
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <exclusions>
- <exclusion>
- <!--
- part of JDK 6+
- the version here does not provide getUserData(), setUserData(),
- as needed by xmlsnapshot functionality in isis-core-runtime.
- -->
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- </exclusions>
- <optional>true</optional>
- </dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <exclusions>
+ <exclusion>
+ <!-- part of JDK 6+ the version here does not provide getUserData(),
+ setUserData(), as needed by xmlsnapshot functionality in isis-core-runtime. -->
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ <optional>true</optional>
+ </dependency>
</dependencies>
diff --git a/core/unittestsupport/src/main/java/org/apache/isis/core/unittestsupport/jmocking/JavassistImposteriser.java b/core/unittestsupport/src/main/java/org/apache/isis/core/unittestsupport/jmocking/JavassistImposteriser.java
index fdeb449..75567c8 100644
--- a/core/unittestsupport/src/main/java/org/apache/isis/core/unittestsupport/jmocking/JavassistImposteriser.java
+++ b/core/unittestsupport/src/main/java/org/apache/isis/core/unittestsupport/jmocking/JavassistImposteriser.java
@@ -126,10 +126,6 @@ public class JavassistImposteriser implements Imposteriser {
return proxyObject;
}
- private static Class<?>[] combine(Class<?> first, Class<?>... rest) {
- Class<?>[] all = new Class<?>[rest.length+1];
- all[0] = first;
- System.arraycopy(rest, 0, all, 1, rest.length);
- return all;
- }
+
+
}
diff --git a/core/wrapper/pom.xml b/core/wrapper/pom.xml
index 193cc5d..0a9a7dd 100644
--- a/core/wrapper/pom.xml
+++ b/core/wrapper/pom.xml
@@ -35,11 +35,6 @@
<groupId>org.apache.isis.core</groupId>
<artifactId>isis-core-runtime</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.objenesis</groupId>
- <artifactId>objenesis</artifactId>
- </dependency>
<!-- TEST -->
diff --git a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/util/Util.java b/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/util/Util.java
deleted file mode 100644
index 7cfecbd..0000000
--- a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/util/Util.java
+++ /dev/null
@@ -1,53 +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.isis.core.wrapper.internal.util;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-
-import org.objenesis.ObjenesisHelper;
-
-public final class Util {
-
- private Util(){}
-
- @SuppressWarnings("unchecked")
- public static <T> T createInstance(final Class<T> toProxy, final InvocationHandler handler, final Class<?>... auxiliaryTypes) {
- return (T) Proxy.newProxyInstance(toProxy.getClassLoader(), combine(toProxy, auxiliaryTypes) , handler);
- }
-
- /**
- * Return a new instance of the specified class. The recommended way is
- * without calling any constructor. This is usually done by doing like
- * <code>ObjectInputStream.readObject()</code> which is JVM specific.
- */
- @SuppressWarnings("unchecked")
- public static <T> T createInstance(final Class<T> enhancedClass) {
- return (T) ObjenesisHelper.newInstance(enhancedClass);
- }
-
- private static Class<?>[] combine(Class<?> first, Class<?>... rest) {
- Class<?>[] all = new Class<?>[rest.length+1];
- all[0] = first;
- System.arraycopy(rest, 0, all, 1, rest.length);
- return all;
- }
-
-}
diff --git a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/proxy/ProxyCreator.java b/core/wrapper/src/main/java/org/apache/isis/core/wrapper/proxy/ProxyCreator.java
index 69c11f9..9222180 100644
--- a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/proxy/ProxyCreator.java
+++ b/core/wrapper/src/main/java/org/apache/isis/core/wrapper/proxy/ProxyCreator.java
@@ -19,15 +19,17 @@
package org.apache.isis.core.wrapper.proxy;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.Map;
import org.apache.isis.applib.internal.base._Casts;
+import org.apache.isis.applib.internal.collections._Arrays;
import org.apache.isis.applib.services.wrapper.WrappingObject;
import org.apache.isis.core.commons.lang.ArrayExtensions;
import org.apache.isis.core.metamodel.specloader.classsubstitutor.ProxyEnhanced;
import org.apache.isis.core.runtime.plugins.codegen.ProxyFactory;
import org.apache.isis.core.wrapper.handlers.DelegatingInvocationHandler;
-import org.apache.isis.core.wrapper.internal.util.Util;
import com.google.common.collect.MapMaker;
@@ -51,16 +53,17 @@ public class ProxyCreator {
final T toProxy = handler.getDelegate();
- final Class<T> clazz = (Class<T>) toProxy.getClass();
+ final Class<T> base = (Class<T>) toProxy.getClass();
- if (clazz.isInterface()) {
- //TODO [ahuber] move this logic to ProxyFactory
- return Util.createInstance(clazz, handler, WrappingObject.class);
+ if (base.isInterface()) {
+ return createInstanceForInterface(base, handler, WrappingObject.class);
} else {
- final ProxyFactory<T> proxyFactory = proxyFactoryFor(clazz);
+ final ProxyFactory<T> proxyFactory = proxyFactoryFor(base);
return proxyFactory.createInstance(handler);
}
}
+
+ // -- HELPER
private <T> ProxyFactory<T> proxyFactoryFor(final Class<T> toProxyClass) {
ProxyFactory<T> proxyFactory = _Casts.uncheckedCast(proxyFactoryByClass.get(toProxyClass));
@@ -84,4 +87,10 @@ public class ProxyCreator {
return proxyFactory;
}
+ @SuppressWarnings("unchecked")
+ private static <T> T createInstanceForInterface(
+ final Class<T> base, final InvocationHandler handler, final Class<?>... auxiliaryTypes) {
+ return (T) Proxy.newProxyInstance(base.getClassLoader(), _Arrays.combine(base, auxiliaryTypes) , handler);
+ }
+
}
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.