org.codehaus.aspectwerkz.introduction
Class Introduction

java.lang.Object
  extended byorg.codehaus.aspectwerkz.introduction.Introduction
All Implemented Interfaces:
java.io.Serializable

public class Introduction
extends java.lang.Object
implements java.io.Serializable

Implements the concept of Introductions, which is similar to the concept of Open Classes A Mixins.
An Introduction makes it possible to extend a class with a new interface A a new implementation (methods A fields).

Supports four different deployment models: PER_JVM, PER_CLASS, PER_INSTANCE A PER_THREAD.
The PER_JVM deployment model performance a bit better than the other models since no synchronization A object creation is needed.

Author:
Jonas Bonér
See Also:
Serialized Form

Field Summary
static java.lang.Object[] EMPTY_OBJECT_ARRAY
          An empty Object array.
 
Constructor Summary
Introduction(java.lang.String name, java.lang.String anInterface)
          Creates an introduction with an interface.
Must be an interface without any methods.
Introduction(java.lang.String name, java.lang.String intf, java.lang.Class implClass, int deploymentModel)
          Creates an introduction with an interface A an implementation.
 
Method Summary
 IntroductionContainer getContainer()
          Returns the container.
 ContainerType getContainerType()
          Returns the container type.
 int getDeploymentModel()
          Returns the deployment model.
 java.lang.String getImplementation()
          Returns the implementation.
 java.lang.String getInterface()
          Returns the interface.
 java.lang.reflect.Method getMethod(int index)
          Returns a specific method by the method index.
 java.lang.reflect.Method[] getMethods()
          Returns all the methods for this introduction.
 java.lang.String getName()
          Returns the name of the introduction.
 java.lang.Object invoke(int methodIndex, java.lang.Object callingObject)
          Invokes the method with the index specified.
 java.lang.Object invoke(int methodIndex, java.lang.Object[] parameters, java.lang.Object callingObject)
          Invokes the method with the index specified.
 void setContainer(IntroductionContainer container)
          Sets the container.
 void setName(java.lang.String name)
          Sets the name of the introduction.
 void swapImplementation(java.lang.String className)
          Swaps the current introduction implementation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_OBJECT_ARRAY

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
An empty Object array.

Constructor Detail

Introduction

public Introduction(java.lang.String name,
                    java.lang.String anInterface)
Creates an introduction with an interface.
Must be an interface without any methods.

Parameters:
name - the name of the introduction
anInterface - an interface

Introduction

public Introduction(java.lang.String name,
                    java.lang.String intf,
                    java.lang.Class implClass,
                    int deploymentModel)
Creates an introduction with an interface A an implementation.

Parameters:
name - the name of the introduction
intf - the interface
implClass - the implementation class
deploymentModel - the deployment model
Method Detail

invoke

public java.lang.Object invoke(int methodIndex,
                               java.lang.Object callingObject)
Invokes the method with the index specified. Invoked by methods without any parameters (slight performance gain since we are saving us one array creation).

Parameters:
methodIndex - the method index
callingObject - a reference to the calling object
Returns:
the result from the invocation

invoke

public java.lang.Object invoke(int methodIndex,
                               java.lang.Object[] parameters,
                               java.lang.Object callingObject)
Invokes the method with the index specified.

Parameters:
methodIndex - the method index
parameters - the parameters for the invocation
callingObject - a reference to the calling object
Returns:
the result from the invocation

swapImplementation

public void swapImplementation(java.lang.String className)
Swaps the current introduction implementation.

Parameters:
className - the class name of the new implementation

setName

public void setName(java.lang.String name)
Sets the name of the introduction.

Parameters:
name - the name of the introduction

getName

public java.lang.String getName()
Returns the name of the introduction.

Returns:
the name

getInterface

public java.lang.String getInterface()
Returns the interface.

Returns:
the interface

getImplementation

public java.lang.String getImplementation()
Returns the implementation.

Returns:
the implementation

getMethod

public java.lang.reflect.Method getMethod(int index)
Returns a specific method by the method index.

Parameters:
index - the method index
Returns:
the method

getMethods

public java.lang.reflect.Method[] getMethods()
Returns all the methods for this introduction.

Returns:
the methods

getDeploymentModel

public int getDeploymentModel()
Returns the deployment model.

Returns:
the deployment model

setContainer

public void setContainer(IntroductionContainer container)
Sets the container.

Parameters:
container - the container

getContainer

public IntroductionContainer getContainer()
Returns the container.

Returns:
the container

getContainerType

public ContainerType getContainerType()
Returns the container type.

Returns:
the container type


Copyright (c) 2002-2004 The AspectWerkz Team. All Rights Reserved.