Bugs item #1000087, was opened at 2004-07-29 22:51
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1000087&group_id=22866

Category: Javassist
Group: CVS HEAD
Status: Open
Resolution: None
Priority: 5
Submitted By: Brett Randall (brett_s_r)
Assigned to: Shigeru Chiba (chiba)
Summary: Prop. enh., javassist.reflect constructor interceptio

Initial Comment:
I have posted a proposed enhancement to the 
javassist.reflect package, to support constructor 
interception.

The enhancement provides the following additional 
features:

An event is generated prior to the calling of a reflected 
class's super constructor.
An event is generated prior to the calling of a reflected 
class's constructor body.  This event has access to the 
object under-construction, and can optionally bypass 
the constructor body if required (the default behaviour 
is to execute the constructor body.
An event is generated at the completion of the reflected 
class's constructor body.  The entire body is wrapped in 
a try/catch block that will catch unchecked Throwables 
(RuntimeException and Error), as well as any checked 
Exceptions declared in the constructor.  The caught 
Throwables are available to the event along with the 
object under-construction, and by default they are re-
thrown, or they can optionally remain caught. 

The three events are available as three new callback 
methods in ClassMetaobject:

[code]public void trapBeforeSuperConstructor() throws 
Throwable {}
public boolean trapBeforeClassConstructor(Object 
underConstruction) throws Throwable {} // return false 
to bypass constructor body
public boolean trapAfterClassConstructor(Object 
underConstruction, Throwable threw) throws Throwable 
{} // return false to prevent re-throw[/code]

Initially I had though to attempt to wrap the 
constructors using CtNewWrappedConstructor or similar, 
or replicating the constructors as a static factory 
method.  This was less attractive when I considered the 
additional difficulty of actually replacing the object 
constructed in memory.

The main TODO is to make the constructor arguments 
available to the events as Object[].  I guess this would 
be fairly easy with a WrappedConstructor, but another 
construction is not what I was after.

This proposed enhancement is posted on Sourceforge 
for review.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1000087&group_id=22866


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to