You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/07/27 20:22:38 UTC
svn commit: r426187 - in /tapestry/tapestry5/tapestry-core/trunk/src:
main/java/org/apache/tapestry/internal/ioc/
main/java/org/apache/tapestry/internal/ioc/services/
main/java/org/apache/tapestry/ioc/
main/java/org/apache/tapestry/ioc/services/ site/a...
Author: hlship
Date: Thu Jul 27 11:22:38 2006
New Revision: 426187
URL: http://svn.apache.org/viewvc?rev=426187&view=rev
Log:
Move LoggingDecorator interface to org.apache.tapestry.ioc.services.
Update decorator documentation to reflect proper package and service naming.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/LoggingDecorator.java
- copied, changed from r426092, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LoggingDecorator.java
Removed:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LoggingDecorator.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/TapestryIOCModule.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/index.apt
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImplTest.java
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/TapestryIOCModule.java?rev=426187&r1=426186&r2=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/TapestryIOCModule.java Thu Jul 27 11:22:38 2006
@@ -16,11 +16,11 @@
import org.apache.tapestry.internal.ioc.services.ClassFactoryImpl;
import org.apache.tapestry.internal.ioc.services.LoggingDecoratorImpl;
-import org.apache.tapestry.ioc.LoggingDecorator;
import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.annotations.InjectService;
import org.apache.tapestry.ioc.annotations.Lifecycle;
import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.LoggingDecorator;
/**
* Defines the base set of services for the Tapestry IOC container.
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImpl.java?rev=426187&r1=426186&r2=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImpl.java Thu Jul 27 11:22:38 2006
@@ -19,10 +19,10 @@
import java.lang.reflect.Modifier;
import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.LoggingDecorator;
import org.apache.tapestry.ioc.services.ClassFab;
import org.apache.tapestry.ioc.services.ClassFabUtils;
import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.LoggingDecorator;
import org.apache.tapestry.ioc.services.MethodIterator;
import org.apache.tapestry.ioc.services.MethodSignature;
import org.apache.tapestry.util.BodyBuilder;
Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/LoggingDecorator.java (from r426092, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LoggingDecorator.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/LoggingDecorator.java?p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/LoggingDecorator.java&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LoggingDecorator.java&r1=426092&r2=426187&rev=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LoggingDecorator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/services/LoggingDecorator.java Thu Jul 27 11:22:38 2006
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc;
+package org.apache.tapestry.ioc.services;
import org.apache.commons.logging.Log;
Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt?rev=426187&r1=426186&r2=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt Thu Jul 27 11:22:38 2006
@@ -10,15 +10,15 @@
Instead, a new object is placed <around> the existing object. The rest of the world
sees this new object, termed an <<interceptor>>. The interceptor implements the
- same service interface as the underlying service.
+ same interface as the underlying object being decorated.
A common example for this is the Java I/O library. The abstract InputStream
base class has a very simple API for reading bytes from a stream (and a few
other things). Subclasses of InputStream provide a wide array of other options
- such as buffering, encrypting or decrypting, as well as control over the source
+ such as buffering, encryption or decryption, as well as control over the source
of data read by the stream. All of these <concerns> are encapsulated in different
- implementations of InputStream, and all can be connected together using
- the common InputStream API.
+ implementations of InputStream, and all can be connected together in a kind of
+ pipline, using the common InputStream API.
Tapestry IoC uses a similar approach, where a one or more of interceptor objects,
all implementing the service interface, are strung together. The service's
@@ -29,6 +29,8 @@
some operations before and after re-invoking the same method on the
core service implementation. This is another design pattern: <delegation>. An interceptor
can even catch exceptions thrown by the underlying implementation and react to them.
+ A sufficiently clever interceptor could retry a method if an exception is thrown, or
+ could "soften" a checked exception by wrapping it in a RuntimeException.
Decorators often are used in the context of <cross-cutting concerns>, such as logging or
transaction management. This approach is a kind of <aspect oriented design>.
@@ -56,7 +58,7 @@
package org.example.myapp.services;
import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.services.LoggingInterceptorFactory;
+import org.apache.tapestry.ioc.services.LoggingDecorator;
@Id("myapp")
public class MyAppModule
@@ -69,9 +71,9 @@
public <T> T decorateIndexer(Class<T> serviceInterface, T delegate,
String serviceId, Log serviceLog,
@InjectService("tapestry.ioc.LoggingDecorator")
- LoggingInterceptorFactory factory)
+ LoggingDecorator decorator)
{
- return factory.createLoggingInterceptor(serviceInterface, delegate, serviceId, serviceLog);
+ return decorator.createLoggingInterceptor(serviceInterface, delegate, serviceId, serviceLog);
}
}
+---------------------+
@@ -111,16 +113,16 @@
package org.example.myapp.services;
import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.services.LoggingInterceptorFactory;
+import org.apache.tapestry.ioc.services.LoggingDecorator;
@Id("myapp")
public class MyAppModule
{
public Indexer buildIndexer(Class serviceInterface, Log serviceLog,
- @InjectService("tapestry.ioc.LoggingInterceptorFactory")
- LoggingInterceptorFactory factory)
+ @InjectService("tapestry.ioc.LoggingDecorator")
+ LoggingInterceptorFactory decorator)
{
- return factory.createLoggingInterceptor(serviceInterface, serviceLog, new IndexerImpl());
+ return decorator.createLoggingInterceptor(serviceInterface, serviceLog, new IndexerImpl());
}
}
+---------------------+
@@ -145,9 +147,9 @@
public <T> T decorateLogging(Class<T> serviceInterface, T delegate,
String serviceId, Log serviceLog,
@InjectService("tapestry.ioc.LoggingDecorator")
- LoggingInterceptorFactory factory)
+ LoggingDecorator decorator)
{
- return factory.createLoggingInterceptor(serviceInterface, delegate, serviceId, serviceLog);
+ return decorator.createLoggingInterceptor(serviceInterface, delegate, serviceId, serviceLog);
}
+---------------------+
Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/index.apt?rev=426187&r1=426186&r2=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/index.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/index.apt Thu Jul 27 11:22:38 2006
@@ -195,5 +195,6 @@
<<Dependencies>> are other services (or other objects) that are needed by a service implementation. These
dependencies can be <<injected>> into a service builder method and provided, from there, to a service implementation via
- its constructor, or via methods on the service implementation.
+ its constructor, or via methods on the service implementation. These may also be referred to as <<collaborators>>, especially
+ in the context of writing unit tests.
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImplTest.java?rev=426187&r1=426186&r2=426187&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/services/LoggingDecoratorImplTest.java Thu Jul 27 11:22:38 2006
@@ -15,7 +15,7 @@
package org.apache.tapestry.internal.ioc.services;
import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.LoggingDecorator;
+import org.apache.tapestry.ioc.services.LoggingDecorator;
import org.apache.tapestry.test.BaseTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;