Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 54924 invoked by uid 500); 24 Apr 2003 20:15:18 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 54913 invoked by uid 500); 24 Apr 2003 20:15:18 -0000 Received: (qmail 54909 invoked from network); 24 Apr 2003 20:15:18 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 24 Apr 2003 20:15:18 -0000 Received: (qmail 65393 invoked by uid 1152); 24 Apr 2003 20:15:17 -0000 Date: 24 Apr 2003 20:15:17 -0000 Message-ID: <20030424201517.65392.qmail@icarus.apache.org> From: bloritsch@apache.org To: avalon-excalibur-cvs@apache.org Subject: cvs commit: avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/factory package.html X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bloritsch 2003/04/24 13:15:17 Added: fortress/src/java/org/apache/avalon/fortress/impl/factory package.html Log: add documentation Revision Changes Path 1.1 avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/factory/package.html Index: package.html ===================================================================

ObjectFactory wrappers to provide proxied components to the container.

Proxy Factories

There are currently two types of factories available with Fortress: BCEL enabled, and traditional JDK 1.3 proxies. Jakarta BCEL is a library to directly generate Java class bytecode. You do not have to include this library for Fortress to function, however if it is present Fortress will use it.

The Need

Proxies are used both for the protection of the component's lifecycle methods, and for backwards compatibility with Composable components. The proxy automatically adds the Component interface to any component (even if it did not have it in the source code) so that it can be used with your old legacy components. As everyone upgrades, the backwards compatibility concern becomes less of an issue--however protecting a component is still very important.

JDK 1.3 Proxy Code

The Java Proxy code uses reflection to do its dirty work, so despite all the advances in JDK 1.4 introspection code you will still incur a substantial performance bottleneck using this approach. A user did a micro-benchmark and reported that the performance hit is around 4:1 vs. just using the component directly. If your components are not repeatedly called several times in rapid succession as is the case with micro-benchmarks then you probably will barely notice the change. Nevertheless, in some environments (most notably when you are working with Servlets) that performance hit will begin to add up.

BCEL Enabled Proxy Code

The BCEL enabled proxy code creates a wrapper class that directly calls the methods on your component as if you wrote it yourself. As an example, the following two code snippets will show you how the component is proxied:

Component's Interface

  public interface HelloWorldComponent
  {
      String sayHello();
  }
  

Wrapper Class

  public final class HelloWorldComponent$BCELWrapper
  {
      private final HelloWorldComponent m_component;
  
      public HelloWorldComponent$BCELWrapper(HelloWorldComponent base)
      {
          m_component = base;
      }
  
      public String sayHello()
      {
          return m_component.sayHello();
      }
  }
  

The Benefit

The resulting code is much easier for the JVM to use, and does not pose a serious threat to the performance of the component. All you have to do is include the BCEL.jar file, and the choice will be made for you.

--------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org