This is an automated email from the ASF dual-hosted git repository. thiagohp pushed a commit to branch 5.4.x in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit 08b03f47676ee10b827ae65f81c50a8a3e244e94 Author: Thiago H. de Paula Figueiredo <[email protected]> AuthorDate: Sat Feb 23 20:13:37 2019 -0300 Revert "TAP5-2582: Service creation for Hibernate Session results in" This reverts commit d7cc7c7daed3e8d38472d211ceecfa2218793503. --- .../internal/plastic/PlasticClassImpl.java | 124 ++------------------- .../tapestry5/plastic/MethodDescription.java | 15 --- .../org/apache/tapestry5/plastic/PlasticClass.java | 11 -- tapestry-ioc/build.gradle | 6 +- .../apache/tapestry5/ioc/internal/ModuleImpl.java | 9 +- .../specs/AspectInterceptorBuilderImplSpec.groovy | 2 +- .../tapestry5/ioc/internal/AdviceModule.java | 21 ---- 7 files changed, 15 insertions(+), 173 deletions(-) diff --git a/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java b/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java index 9683e1c..264825a 100644 --- a/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java +++ b/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java @@ -621,37 +621,11 @@ public class PlasticClassImpl extends Lockable implements PlasticClass, Internal introduceInterface(interfaceType); - // TAP5-2582: avoiding adding/delegating the same method more than once -// for (Method m : interfaceType.getMethods()) -// { -// introduceMethod(m).delegateTo(field); -// } - - Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); - for (MethodSignature methodSignature : map.keySet()) + for (Method m : interfaceType.getMethods()) { - introduceMethod(map.get(methodSignature)).delegateTo(field); + introduceMethod(m).delegateTo(field); } - - return this; - } - - @Override - public PlasticClass proxyInterface(Class interfaceType, PlasticMethod method) - { - check(); - assert method != null; - - introduceInterface(interfaceType); - - // TAP5-2582: avoiding adding/delegating the same method more than once - Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); - for (MethodSignature methodSignature : map.keySet()) - { - introduceMethod(map.get(methodSignature)).delegateTo(method); - } - return this; } @@ -1436,7 +1410,7 @@ public class PlasticClassImpl extends Lockable implements PlasticClass, Internal if (!interfaceType.isInterface()) throw new IllegalArgumentException(String.format( - "Class %s is not an interface; only interfaces may be introduced.", interfaceType.getName())); + "Class %s is not an interface; ony interfaces may be introduced.", interfaceType.getName())); String interfaceName = nameCache.toInternalName(interfaceType); @@ -1457,19 +1431,14 @@ public class PlasticClassImpl extends Lockable implements PlasticClass, Internal addClassAnnotations(interfaceClassNode); Set<PlasticMethod> introducedMethods = new HashSet<PlasticMethod>(); - - Map<MethodSignature, MethodDescription> map = createMethodSignatureMap(interfaceType); - - // for (Method m : interfaceType.getMethods()) - for (MethodSignature methodSignature : map.keySet()) + + for (Method m : interfaceType.getMethods()) { - // MethodDescription description = new MethodDescription(m); - final MethodDescription description = map.get(methodSignature); + MethodDescription description = new MethodDescription(m); - if (!isMethodImplemented(description) && !isDefaultMethod(methodSignature.method)) + if (!isMethodImplemented(description) && !isDefaultMethod(m)) { - // introducedMethods.add(introduceMethod(m)); - introducedMethods.add(introduceMethod(description)); + introducedMethods.add(introduceMethod(m)); } } @@ -1478,83 +1447,6 @@ public class PlasticClassImpl extends Lockable implements PlasticClass, Internal return introducedMethods; } - private Map<MethodSignature, MethodDescription> createMethodSignatureMap(Class interfaceType) { - // TAP-2582: preprocessing the method list so we don't add duplicated - // methods, something that happens when an interface has superinterfaces - // and they define the same method signature. - // In addition, we collect all the thrown checked exceptions, just in case. - Map<MethodSignature, MethodDescription> map = new HashMap<MethodSignature, MethodDescription>(); - for (Method m : interfaceType.getMethods()) - { - final MethodSignature methodSignature = new MethodSignature(m); - final MethodDescription newMethodDescription = new MethodDescription(m); - if (!map.containsKey(methodSignature)) - { - map.put(methodSignature, newMethodDescription); - } - else - { - if (newMethodDescription.checkedExceptionTypes != null && newMethodDescription.checkedExceptionTypes.length > 0) - { - final MethodDescription methodDescription = map.get(methodSignature); - final Set<String> checkedExceptionTypes = new HashSet<String>(); - checkedExceptionTypes.addAll(Arrays.asList(methodDescription.checkedExceptionTypes)); - checkedExceptionTypes.addAll(Arrays.asList(newMethodDescription.checkedExceptionTypes)); - map.put(methodSignature, new MethodDescription( - methodDescription, - checkedExceptionTypes.toArray(new String[checkedExceptionTypes.size()]))); - } - } - } - return map; - } - - final private static class MethodSignature implements Comparable<MethodSignature>{ - - final private Method method; - final private String name; - final private Class<?>[] parameterTypes; - - public MethodSignature(Method method) { - this.method = method; - this.name = method.getName(); - this.parameterTypes = method.getParameterTypes(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(parameterTypes); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MethodSignature other = (MethodSignature) obj; - if (!Arrays.equals(parameterTypes, other.parameterTypes)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public int compareTo(MethodSignature o) { - return method.getName().compareTo(o.method.getName()); - } - } - @Override public PlasticClass addToString(final String toStringValue) { diff --git a/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java b/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java index 5f8b88f..e0b7d2a 100644 --- a/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java +++ b/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java @@ -72,21 +72,6 @@ public class MethodDescription implements Comparable<MethodDescription> { this(Modifier.PUBLIC, returnType, methodName, argumentTypes, null, null); } - - /** - * Convenience constructor for copying a MethodDescription with - * different exception types. - * @since 5.4.4 - */ - public MethodDescription(MethodDescription description, String[] checkedExceptionTypes) - { - this.argumentTypes = description.argumentTypes; - this.checkedExceptionTypes = checkedExceptionTypes; - this.genericSignature = description.genericSignature; - this.methodName = description.methodName; - this.modifiers = description.modifiers; - this.returnType = description.returnType; - } /** * @param modifiers diff --git a/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticClass.java b/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticClass.java index 2168456..e212fe5 100644 --- a/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticClass.java +++ b/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticClass.java @@ -163,17 +163,6 @@ public interface PlasticClass extends AnnotationAccess * @return this plastic class, for further configuration */ PlasticClass proxyInterface(Class interfaceType, PlasticField field); - - /** - * Introduces the interface, and then invokes {@link PlasticMethod#delegateTo(PlasticMethod)} on each method - * defined by the interface. - * - * @param interfaceType defines the interface to proxy - * @param method method to delegate to - * @return this plastic class, for further configuration - * @since 5.4.4 - */ - PlasticClass proxyInterface(Class interfaceType, PlasticMethod method); /** * Conditionally adds an implementation of <code>toString()</code> to the class, but only if it is not already diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle index b208818..8113a23 100644 --- a/tapestry-ioc/build.gradle +++ b/tapestry-ioc/build.gradle @@ -15,10 +15,8 @@ dependencies { compile "org.slf4j:slf4j-api:${versions.slf4j}" - testCompile "org.apache.commons:commons-lang3:3.4" - testCompile "org.hibernate:hibernate-core:5.2.10.Final" - testRuntime "org.hsqldb:hsqldb:2.2.8" - + testCompile "commons-lang:commons-lang:2.6" + provided "org.testng:testng:${versions.testng}", { transitive = false } } diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java index 51f864c..48bf24d 100644 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java @@ -509,11 +509,10 @@ public class ModuleImpl implements Module } }); - plasticClass.proxyInterface(serviceInterface, delegateMethod); -// for (Method m : serviceInterface.getMethods()) -// { -// plasticClass.introduceMethod(m).delegateTo(delegateMethod); -// } + for (Method m : serviceInterface.getMethods()) + { + plasticClass.introduceMethod(m).delegateTo(delegateMethod); + } plasticClass.introduceMethod(WRITE_REPLACE).changeImplementation(new InstructionBuilderCallback() { diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/AspectInterceptorBuilderImplSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/AspectInterceptorBuilderImplSpec.groovy index b614c38..e543482 100644 --- a/tapestry-ioc/src/test/groovy/ioc/specs/AspectInterceptorBuilderImplSpec.groovy +++ b/tapestry-ioc/src/test/groovy/ioc/specs/AspectInterceptorBuilderImplSpec.groovy @@ -1,6 +1,6 @@ package ioc.specs -import org.apache.commons.lang3.StringUtils +import org.apache.commons.lang.StringUtils import org.apache.tapestry5.ioc.internal.services.TextTransformer import org.apache.tapestry5.ioc.services.AspectDecorator import org.apache.tapestry5.plastic.MethodAdvice diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/AdviceModule.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/AdviceModule.java index f943152..0e0a186 100644 --- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/AdviceModule.java +++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/AdviceModule.java @@ -13,15 +13,9 @@ // limitations under the License. package org.apache.tapestry5.ioc.internal; - import org.apache.tapestry5.ioc.MethodAdviceReceiver; -import org.apache.tapestry5.ioc.ObjectLocator; -import org.apache.tapestry5.ioc.Registry; -import org.apache.tapestry5.ioc.RegistryBuilder; import org.apache.tapestry5.ioc.ServiceBinder; import org.apache.tapestry5.ioc.annotations.Advise; -import org.hibernate.Session; -import org.hibernate.cfg.Configuration; public class AdviceModule { @@ -51,19 +45,4 @@ public class AdviceModule final MethodAdviceReceiver methodAdviceReceiver) { methodAdviceReceiver.adviseAllMethods(new TestAdvice()); } - -// public static void main(String[] args) { -// Registry registry = RegistryBuilder.buildAndStartupRegistry(AdviceModule.class); -// Session session = registry.getService(Session.class); -// } - - // TAP5-2582 - public static Session buildHibernateSession( - ObjectLocator objectLocator - ) { - return new Configuration() - .configure("hibernate.cfg.xml") - .buildSessionFactory() - .openSession(); - } }
