You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2010/03/13 00:24:06 UTC

svn commit: r922452 - in /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc: internal/services/ services/

Author: hlship
Date: Fri Mar 12 23:24:06 2010
New Revision: 922452

URL: http://svn.apache.org/viewvc?rev=922452&view=rev
Log:
TAP5-685: Allow services defined by module tapestry-ioc to be advised and decorated

Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AspectDecoratorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingDecoratorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ServiceOverrideImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/UpdateListenerHubImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AspectDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AspectDecoratorImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AspectDecoratorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AspectDecoratorImpl.java Fri Mar 12 23:24:06 2010
@@ -1,10 +1,10 @@
-// Copyright 2008, 2009 The Apache Software Foundation
+// Copyright 2008, 2009, 2010 The Apache Software Foundation
 //
 // Licensed 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
+// 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,
@@ -14,20 +14,23 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.lang.reflect.Method;
+
 import org.apache.tapestry5.ioc.MethodAdvice;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.internal.util.Defense;
 import org.apache.tapestry5.ioc.services.AspectDecorator;
 import org.apache.tapestry5.ioc.services.AspectInterceptorBuilder;
 import org.apache.tapestry5.ioc.services.Builtin;
 import org.apache.tapestry5.ioc.services.ClassFactory;
 
-import java.lang.reflect.Method;
-
+@PreventServiceDecoration
 public class AspectDecoratorImpl implements AspectDecorator
 {
     private final ClassFactory classFactory;
 
-    public AspectDecoratorImpl(@Builtin ClassFactory classFactory)
+    public AspectDecoratorImpl(@Builtin
+    ClassFactory classFactory)
     {
         this.classFactory = classFactory;
     }
@@ -44,13 +47,13 @@ public class AspectDecoratorImpl impleme
     }
 
     public <T> AspectInterceptorBuilder<T> createBuilder(final Class<T> serviceInterface, final T delegate,
-                                                         final String description)
+            final String description)
     {
         Defense.notNull(serviceInterface, "serviceInterface");
         Defense.notNull(delegate, "delegate");
         Defense.notBlank(description, "description");
 
-        // Defer creating the real builder until a method gets advised.  If no method is advised then
+        // Defer creating the real builder until a method gets advised. If no method is advised then
         // the delegate can be used unchanged.
 
         return new AspectInterceptorBuilder<T>()
@@ -80,8 +83,7 @@ public class AspectDecoratorImpl impleme
             private AspectInterceptorBuilder<T> getBuilder()
             {
                 if (builder == null)
-                    builder = new AspectInterceptorBuilderImpl<T>(classFactory, serviceInterface, delegate,
-                                                                  description);
+                    builder = new AspectInterceptorBuilderImpl<T>(classFactory, serviceInterface, delegate, description);
 
                 return builder;
             }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java Fri Mar 12 23:24:06 2010
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -14,14 +14,16 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.util.Set;
+
 import org.apache.tapestry5.ioc.ScopeConstants;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
 
-import java.util.Set;
-
 @Scope(ScopeConstants.PERTHREAD)
+@PreventServiceDecoration
 public class ExceptionTrackerImpl implements ExceptionTracker
 {
     private final Set<Throwable> exceptions = CollectionFactory.newSet();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java Fri Mar 12 23:24:06 2010
@@ -1,10 +1,10 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2010 The Apache Software Foundation
 //
 // Licensed 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
+// 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,
@@ -14,17 +14,19 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.lang.reflect.Method;
+
 import org.apache.tapestry5.ioc.Invocation;
 import org.apache.tapestry5.ioc.MethodAdvice;
 import org.apache.tapestry5.ioc.MethodAdviceReceiver;
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.ioc.annotations.NotLazy;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.services.LazyAdvisor;
 import org.apache.tapestry5.ioc.services.ThunkCreator;
 
-import java.lang.reflect.Method;
-
+@PreventServiceDecoration
 public class LazyAdvisorImpl implements LazyAdvisor
 {
     private final ThunkCreator thunkCreator;
@@ -47,9 +49,8 @@ public class LazyAdvisorImpl implements 
     {
         final Class thunkType = method.getReturnType();
 
-        final String description = String.format("<%s Thunk for %s>",
-                                                 thunkType.getName(),
-                                                 InternalUtils.asString(method));
+        final String description = String.format("<%s Thunk for %s>", thunkType.getName(), InternalUtils
+                .asString(method));
 
         MethodAdvice advice = new MethodAdvice()
         {
@@ -82,13 +83,16 @@ public class LazyAdvisorImpl implements 
 
     private boolean filter(Method method)
     {
-        if (method.getAnnotation(NotLazy.class) != null) return false;
+        if (method.getAnnotation(NotLazy.class) != null)
+            return false;
 
-        if (!method.getReturnType().isInterface()) return false;
+        if (!method.getReturnType().isInterface())
+            return false;
 
         for (Class extype : method.getExceptionTypes())
         {
-            if (!RuntimeException.class.isAssignableFrom(extype)) return false;
+            if (!RuntimeException.class.isAssignableFrom(extype))
+                return false;
         }
 
         return true;

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java Fri Mar 12 23:24:06 2010
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2010 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -16,10 +16,12 @@ package org.apache.tapestry5.ioc.interna
 
 import org.apache.tapestry5.ioc.MethodAdvice;
 import org.apache.tapestry5.ioc.MethodAdviceReceiver;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
 import org.apache.tapestry5.ioc.services.LoggingAdvisor;
 import org.slf4j.Logger;
 
+@PreventServiceDecoration
 public class LoggingAdvisorImpl implements LoggingAdvisor
 {
     private final ExceptionTracker exceptionTracker;

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingDecoratorImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingDecoratorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingDecoratorImpl.java Fri Mar 12 23:24:06 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
 //
 // Licensed 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
+// 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,
@@ -14,12 +14,14 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.services.AspectDecorator;
 import org.apache.tapestry5.ioc.services.AspectInterceptorBuilder;
 import org.apache.tapestry5.ioc.services.LoggingAdvisor;
 import org.apache.tapestry5.ioc.services.LoggingDecorator;
 import org.slf4j.Logger;
 
+@PreventServiceDecoration
 public class LoggingDecoratorImpl implements LoggingDecorator
 {
     private final AspectDecorator aspectDecorator;
@@ -34,15 +36,11 @@ public class LoggingDecoratorImpl implem
 
     public <T> T build(Class<T> serviceInterface, T delegate, String serviceId, final Logger logger)
     {
-        AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate,
-                                                                            String.format(
-                                                                                    "<Logging interceptor for %s(%s)>",
-                                                                                    serviceId,
-                                                                                    serviceInterface.getName()));
+        AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, String.format(
+                "<Logging interceptor for %s(%s)>", serviceId, serviceInterface.getName()));
         advisor.addLoggingAdvice(logger, builder);
 
         return builder.build();
     }
 
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ServiceOverrideImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ServiceOverrideImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ServiceOverrideImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ServiceOverrideImpl.java Fri Mar 12 23:24:06 2010
@@ -1,10 +1,10 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2010 The Apache Software Foundation
 //
 // Licensed 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
+// 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,
@@ -14,13 +14,15 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.util.Map;
+
 import org.apache.tapestry5.ioc.AnnotationProvider;
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.ObjectProvider;
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.services.ServiceOverride;
 
-import java.util.Map;
-
+@PreventServiceDecoration
 public class ServiceOverrideImpl implements ServiceOverride
 {
     private final Map<Class, Object> configuration;

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/UpdateListenerHubImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/UpdateListenerHubImpl.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/UpdateListenerHubImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/UpdateListenerHubImpl.java Fri Mar 12 23:24:06 2010
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -14,13 +14,15 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.util.List;
+
+import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.Defense;
 import org.apache.tapestry5.services.UpdateListener;
 import org.apache.tapestry5.services.UpdateListenerHub;
 
-import java.util.List;
-
+@PreventServiceDecoration
 public class UpdateListenerHubImpl implements UpdateListenerHub
 {
     private final List<UpdateListener> listeners = CollectionFactory.newThreadSafeList();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java?rev=922452&r1=922451&r2=922452&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java Fri Mar 12 23:24:06 2010
@@ -39,7 +39,6 @@ import java.util.concurrent.TimeUnit;
  * Defines the base set of services for the Tapestry IOC container.
  */
 @Marker(Builtin.class)
-@PreventServiceDecoration
 public final class TapestryIOCModule
 {
     public static void bind(ServiceBinder binder)
@@ -77,6 +76,7 @@ public final class TapestryIOCModule
      * accessed via this service (and its mapped configuration). Only proxiable services (those with explicit service
      * interfaces) can be managed in terms of a lifecycle.
      */
+    @PreventServiceDecoration
     public static ServiceLifecycleSource build(Map<String, ServiceLifecycle> configuration)
     {
         final Map<String, ServiceLifecycle2> lifecycles = CollectionFactory.newCaseInsensitiveMap();