You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Tim McConnell <ti...@gmail.com> on 2007/02/10 10:23:09 UTC

GERONIMO-2816 patch

Hi, I've attached a patch and two new classes to the GERONIMO-2816 JIRA 
that provides support for the @EJB and @EJBs
annotations if anyone would like to review. The intent is to demonstrate a 
final/permanent technique that can be extended and used throughout Geronimo 
to support annotations for JSR-88. This patch and new code works for Tomcat 
and circumvents the annotation processing that is currently in 
EjbRefBuilder (which did not update the deployment descriptor with the 
discovered annotations, but only updated the JNDI references). I'd 
appreciate some feedback before I start propagating this technique to the 
other module builders to support the remainder of the annotations. I 
already have another subclass ready to support the @Resource annotations 
but I didn't want to include it in this example since it doesn't 
demonstrate anything different than the EJBAnnotationHelper subclass, and 
I'd like to get some feedback first on the the technique. The general 
technique, which we've discussed before, is pretty straightforward and is 
summarized here for reference:

1 -- Discover the annotations: I had hoped that we could centralize the 
discovery of annotations in the Deployer class prior to the createModule 
phase of deployment, but as David Blevins pointed out this is almost 
impossible. So it has to be pushed down into the installModule phase of 
deployment after the necessary classloader(s) and module context(s) have 
been established (see the changes for AbstractWebModuleBuilder for an 
example).

2 -- Process the annotations: This just means to update the existing 
deployment descriptor (or create a new one) with the discovered annotations.

3 -- Set metadata-complete in the deployment descriptor to prevent repeated 
processing of annotations (see the EjbRefBuilder changes for an example)

4 -- Update the deployment descriptor in the module so that it can flow 
through the remainder of the deployment process much as before (for JNDI 
naming and resolution, and to remain with module in support of the JSR-77 
requirements for management).

  --
Thanks,
Tim McConnell

Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
Hi David, thanks for reviewing:

-- Yes we should be able to eliminate the annotation processing method in 
EjbRefBuidler as it will now get a metadata-complete deployment descriptor. 
I just didn't feel comfortable doing that for this review patch, but I can 
do it in the patch that gets committed.

-- I haven't quite yet settled on the final demarcation of the annotations 
that will be supported by each AnnotationHelper subclass, but I'm hoping I 
can do it in such a manner that the classfinder would be instantiated only 
once per builder. That may be impractical though, and I really like the two 
alternatives you mention. So, I'll consider each as I encapsulate more 
annotation functions.

Thanks

David Blevins wrote:
> 
> On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:
> 
>> Hi, I've attached a patch and two new classes to the GERONIMO-2816 
>> JIRA that provides support for the @EJB and @EJBs
>> annotations if anyone would like to review. The intent is to 
>> demonstrate a final/permanent technique that can be extended and used 
>> throughout Geronimo to support annotations for JSR-88. This patch and 
>> new code works for Tomcat and circumvents the annotation processing 
>> that is currently in EjbRefBuilder (which did not update the 
>> deployment descriptor with the discovered annotations, but only 
>> updated the JNDI references). I'd appreciate some feedback before I 
>> start propagating this technique to the other module builders to 
>> support the remainder of the annotations. I already have another 
>> subclass ready to support the @Resource annotations but I didn't want 
>> to include it in this example since it doesn't demonstrate anything 
>> different than the EJBAnnotationHelper subclass, and I'd like to get 
>> some feedback first on the the technique. The general technique, which 
>> we've discussed before, is pretty straightforward and is summarized 
>> here for reference:
>>
>> 1 -- Discover the annotations: I had hoped that we could centralize 
>> the discovery of annotations in the Deployer class prior to the 
>> createModule phase of deployment, but as David Blevins pointed out 
>> this is almost impossible. So it has to be pushed down into the 
>> installModule phase of deployment after the necessary classloader(s) 
>> and module context(s) have been established (see the changes for 
>> AbstractWebModuleBuilder for an example).
>>
>> 2 -- Process the annotations: This just means to update the existing 
>> deployment descriptor (or create a new one) with the discovered 
>> annotations.
>>
>> 3 -- Set metadata-complete in the deployment descriptor to prevent 
>> repeated processing of annotations (see the EjbRefBuilder changes for 
>> an example)
>>
>> 4 -- Update the deployment descriptor in the module so that it can 
>> flow through the remainder of the deployment process much as before 
>> (for JNDI naming and resolution, and to remain with module in support 
>> of the JSR-77 requirements for management).
> 
> Hey Tim, very clean and well documented code.  I think we'll have to 
> strip out all the documentation to comply with Geronimo's strict no 
> javadoc policy ;)
> 
> Couple notes.  We should be able to get rid of the @EJB for Web 
> processing in the EjbRefBuilder, no?  That was there as temporary hack 
> and wasn't meant to last.  You definitely have all the right code in the 
> EJBAnnotationHelper for Web/@EJB processsing.
> 
> Other note is you definitely want to construct the ClassFinder exactly 
> once for a module as each time it's constructed we'll have to reparse 
> all the class definitions in the entire module which is especially nasty 
> for web modules as there tend to be a lot of libraries in WEB-INF/lib 
> and WEB-INF/classes.  I mention that as a cautionary note as from the 
> looks of where you're going each AnnotationHelper would create it's own 
> finder in it's constructor.  We may want to create the ClassFinder and 
> pass it into the AnnotationHelpers and/or put it in the Module somewhere 
> for all to use if they need it.
> 
> -David
> 
>>
>>  --
>> Thanks,
>> Tim McConnell
>>
> 
> 

-- 
Thanks,
Tim McConnell

Re: GERONIMO-2816 patch

Posted by David Blevins <da...@visi.com>.
On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:

> Hi, I've attached a patch and two new classes to the GERONIMO-2816  
> JIRA that provides support for the @EJB and @EJBs
> annotations if anyone would like to review. The intent is to  
> demonstrate a final/permanent technique that can be extended and  
> used throughout Geronimo to support annotations for JSR-88. This  
> patch and new code works for Tomcat and circumvents the annotation  
> processing that is currently in EjbRefBuilder (which did not update  
> the deployment descriptor with the discovered annotations, but only  
> updated the JNDI references). I'd appreciate some feedback before I  
> start propagating this technique to the other module builders to  
> support the remainder of the annotations. I already have another  
> subclass ready to support the @Resource annotations but I didn't  
> want to include it in this example since it doesn't demonstrate  
> anything different than the EJBAnnotationHelper subclass, and I'd  
> like to get some feedback first on the the technique. The general  
> technique, which we've discussed before, is pretty straightforward  
> and is summarized here for reference:
>
> 1 -- Discover the annotations: I had hoped that we could centralize  
> the discovery of annotations in the Deployer class prior to the  
> createModule phase of deployment, but as David Blevins pointed out  
> this is almost impossible. So it has to be pushed down into the  
> installModule phase of deployment after the necessary classloader 
> (s) and module context(s) have been established (see the changes  
> for AbstractWebModuleBuilder for an example).
>
> 2 -- Process the annotations: This just means to update the  
> existing deployment descriptor (or create a new one) with the  
> discovered annotations.
>
> 3 -- Set metadata-complete in the deployment descriptor to prevent  
> repeated processing of annotations (see the EjbRefBuilder changes  
> for an example)
>
> 4 -- Update the deployment descriptor in the module so that it can  
> flow through the remainder of the deployment process much as before  
> (for JNDI naming and resolution, and to remain with module in  
> support of the JSR-77 requirements for management).

Hey Tim, very clean and well documented code.  I think we'll have to  
strip out all the documentation to comply with Geronimo's strict no  
javadoc policy ;)

Couple notes.  We should be able to get rid of the @EJB for Web  
processing in the EjbRefBuilder, no?  That was there as temporary  
hack and wasn't meant to last.  You definitely have all the right  
code in the EJBAnnotationHelper for Web/@EJB processsing.

Other note is you definitely want to construct the ClassFinder  
exactly once for a module as each time it's constructed we'll have to  
reparse all the class definitions in the entire module which is  
especially nasty for web modules as there tend to be a lot of  
libraries in WEB-INF/lib and WEB-INF/classes.  I mention that as a  
cautionary note as from the looks of where you're going each  
AnnotationHelper would create it's own finder in it's constructor.   
We may want to create the ClassFinder and pass it into the  
AnnotationHelpers and/or put it in the Module somewhere for all to  
use if they need it.

-David

>
>  --
> Thanks,
> Tim McConnell
>


Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
Great, let me know what they are and I'll incorporate....


Thanks,
Tim McConnell


David Blevins wrote:
> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
> 
>> Great, I'll work on these changes today. Thanks much
>>
> 
> Reviewing the new patch!  There are a few spec things that need to be 
> fixed but it looks pretty great overall.
> 
> -David
> 
> 
> 
> 

Re: GERONIMO-2816 patch

Posted by David Blevins <da...@visi.com>.
On Feb 15, 2007, at 7:34 AM, Tim McConnell wrote:

> Yep, I'm still failing here as well. Did the patch for ClassFinder  
> not make it into a new snapshot yet ??

Oops, doing it now.

-David

> Thanks,
> Tim McConnell
>
>
> David Blevins wrote:
>> On Feb 14, 2007, at 1:07 PM, Tim McConnell wrote:
>>> ... and not too surprising--it runs much faster now as well....
>>>
>> I bet :)
>> Hey, so I'm running into an issue with the Jetty JSP Examples  
>> config that seems to be realted to your patch.  Did you see this  
>> or know what it's about?
>> [INFO]  
>> --------------------------------------------------------------------- 
>> ------- [INFO] Building Geronimo Configs :: JSP Examples Jetty
>> [INFO]    task-segment: [clean, install]
>> [INFO]  
>> --------------------------------------------------------------------- 
>> ------- [INFO] [clean:clean]
>> [INFO] Deleting directory /Users/dblevins/work/geronimo-trunk/ 
>> configs/jsp-examples-jetty/target
>> [INFO] Deleting directory /Users/dblevins/work/geronimo-trunk/ 
>> configs/jsp-examples-jetty/target/classes [INFO] Deleting  
>> directory /Users/dblevins/work/geronimo-trunk/configs/jsp-examples- 
>> jetty/target/test-classes [INFO] [tools:require-java-version  
>> {execution: validate-java-version}]
>> [INFO] [tools:copy-legal-files {execution: install-legal-files}]
>> [INFO] Created dir: /Users/dblevins/work/geronimo-trunk/configs/ 
>> jsp-examples-jetty/target/classes/META-INF [INFO] Copying 2 files  
>> to /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/ 
>> target/classes/META-INF [INFO] [resources:resources]
>> [INFO] Using default encoding to copy filtered resources.
>> [INFO] [car:prepare-plan]
>> [INFO] Generated: /Users/dblevins/work/geronimo-trunk/configs/jsp- 
>> examples-jetty/target/plan/plan.xml [INFO] [car:package]
>> [INFO] Packaging module configuration: /Users/dblevins/work/ 
>> geronimo-trunk/configs/jsp-examples-jetty/target/plan/plan.xml  
>> [INFO]  
>> --------------------------------------------------------------------- 
>> ---
>> [ERROR] BUILD ERROR
>> [INFO]  
>> --------------------------------------------------------------------- 
>> ---
>> [INFO] Exception encountered processing annotations for module:  
>> org.apache.geronimo.configs/jsp-examples-jetty/2.0-SNAPSHOT/car
>> -David
>>> Thanks,
>>> Tim McConnell
>>>
>>>
>>> David Blevins wrote:
>>>> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
>>>>> Great, I'll work on these changes today. Thanks much
>>>>>
>>>> Reviewing the new patch!  There are a few spec things that need  
>>>> to be fixed but it looks pretty great overall.
>>>> -David
>>>
>


Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
Yep, I'm still failing here as well. Did the patch for ClassFinder not make it 
into a new snapshot yet ??

Thanks,
Tim McConnell


David Blevins wrote:
> 
> On Feb 14, 2007, at 1:07 PM, Tim McConnell wrote:
> 
>> ... and not too surprising--it runs much faster now as well....
>>
> 
> I bet :)
> 
> Hey, so I'm running into an issue with the Jetty JSP Examples config 
> that seems to be realted to your patch.  Did you see this or know what 
> it's about?
> 
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] Building Geronimo Configs :: JSP Examples Jetty
> [INFO]    task-segment: [clean, install]
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] [clean:clean]
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes 
> 
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/test-classes 
> 
> [INFO] [tools:require-java-version {execution: validate-java-version}]
> [INFO] [tools:copy-legal-files {execution: install-legal-files}]
> [INFO] Created dir: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes/META-INF 
> 
> [INFO] Copying 2 files to 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes/META-INF 
> 
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [car:prepare-plan]
> [INFO] Generated: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/plan/plan.xml 
> 
> [INFO] [car:package]
> [INFO] Packaging module configuration: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/plan/plan.xml 
> 
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Exception encountered processing annotations for module: 
> org.apache.geronimo.configs/jsp-examples-jetty/2.0-SNAPSHOT/car
> 
> 
> 
> -David
> 
>> Thanks,
>> Tim McConnell
>>
>>
>> David Blevins wrote:
>>> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
>>>> Great, I'll work on these changes today. Thanks much
>>>>
>>> Reviewing the new patch!  There are a few spec things that need to be 
>>> fixed but it looks pretty great overall.
>>> -David
>>
> 
> 

Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
Yes, that results from the null pointer exception from ClassFinder when a class 
file is not part of a package. Many of the class files in these examples are not 
part of a package....

Thanks,
Tim McConnell


David Blevins wrote:
> 
> On Feb 14, 2007, at 1:07 PM, Tim McConnell wrote:
> 
>> ... and not too surprising--it runs much faster now as well....
>>
> 
> I bet :)
> 
> Hey, so I'm running into an issue with the Jetty JSP Examples config 
> that seems to be realted to your patch.  Did you see this or know what 
> it's about?
> 
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] Building Geronimo Configs :: JSP Examples Jetty
> [INFO]    task-segment: [clean, install]
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] [clean:clean]
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes 
> 
> [INFO] Deleting directory 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/test-classes 
> 
> [INFO] [tools:require-java-version {execution: validate-java-version}]
> [INFO] [tools:copy-legal-files {execution: install-legal-files}]
> [INFO] Created dir: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes/META-INF 
> 
> [INFO] Copying 2 files to 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/classes/META-INF 
> 
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [car:prepare-plan]
> [INFO] Generated: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/plan/plan.xml 
> 
> [INFO] [car:package]
> [INFO] Packaging module configuration: 
> /Users/dblevins/work/geronimo-trunk/configs/jsp-examples-jetty/target/plan/plan.xml 
> 
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Exception encountered processing annotations for module: 
> org.apache.geronimo.configs/jsp-examples-jetty/2.0-SNAPSHOT/car
> 
> 
> 
> -David
> 
>> Thanks,
>> Tim McConnell
>>
>>
>> David Blevins wrote:
>>> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
>>>> Great, I'll work on these changes today. Thanks much
>>>>
>>> Reviewing the new patch!  There are a few spec things that need to be 
>>> fixed but it looks pretty great overall.
>>> -David
>>
> 
> 

Re: GERONIMO-2816 patch

Posted by David Blevins <da...@visi.com>.
On Feb 14, 2007, at 1:07 PM, Tim McConnell wrote:

> ... and not too surprising--it runs much faster now as well....
>

I bet :)

Hey, so I'm running into an issue with the Jetty JSP Examples config  
that seems to be realted to your patch.  Did you see this or know  
what it's about?

[INFO]  
------------------------------------------------------------------------ 
----
[INFO] Building Geronimo Configs :: JSP Examples Jetty
[INFO]    task-segment: [clean, install]
[INFO]  
------------------------------------------------------------------------ 
----
[INFO] [clean:clean]
[INFO] Deleting directory /Users/dblevins/work/geronimo-trunk/configs/ 
jsp-examples-jetty/target
[INFO] Deleting directory /Users/dblevins/work/geronimo-trunk/configs/ 
jsp-examples-jetty/target/classes
[INFO] Deleting directory /Users/dblevins/work/geronimo-trunk/configs/ 
jsp-examples-jetty/target/test-classes
[INFO] [tools:require-java-version {execution: validate-java-version}]
[INFO] [tools:copy-legal-files {execution: install-legal-files}]
[INFO] Created dir: /Users/dblevins/work/geronimo-trunk/configs/jsp- 
examples-jetty/target/classes/META-INF
[INFO] Copying 2 files to /Users/dblevins/work/geronimo-trunk/configs/ 
jsp-examples-jetty/target/classes/META-INF
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [car:prepare-plan]
[INFO] Generated: /Users/dblevins/work/geronimo-trunk/configs/jsp- 
examples-jetty/target/plan/plan.xml
[INFO] [car:package]
[INFO] Packaging module configuration: /Users/dblevins/work/geronimo- 
trunk/configs/jsp-examples-jetty/target/plan/plan.xml
[INFO]  
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]  
------------------------------------------------------------------------
[INFO] Exception encountered processing annotations for module:  
org.apache.geronimo.configs/jsp-examples-jetty/2.0-SNAPSHOT/car



-David

> Thanks,
> Tim McConnell
>
>
> David Blevins wrote:
>> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
>>> Great, I'll work on these changes today. Thanks much
>>>
>> Reviewing the new patch!  There are a few spec things that need to  
>> be fixed but it looks pretty great overall.
>> -David
>


Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
... and not too surprising--it runs much faster now as well....

Thanks,
Tim McConnell


David Blevins wrote:
> On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:
> 
>> Great, I'll work on these changes today. Thanks much
>>
> 
> Reviewing the new patch!  There are a few spec things that need to be 
> fixed but it looks pretty great overall.
> 
> -David
> 
> 
> 
> 

Re: GERONIMO-2816 patch

Posted by David Blevins <da...@visi.com>.
On Feb 12, 2007, at 5:14 AM, Tim McConnell wrote:

> Great, I'll work on these changes today. Thanks much
>

Reviewing the new patch!  There are a few spec things that need to be  
fixed but it looks pretty great overall.

-David




Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
Great, I'll work on these changes today. Thanks much

David Blevins wrote:
> 
> On Feb 11, 2007, at 6:12 PM, Tim McConnell wrote:
> 
>> HI Dain, thanks for reviewing. Yes, you're right--I am scanning all 
>> the classes in the web module for annotations, which might be 
>> excessive. I'll take a look at the OpenEJB AnnotationDeployer and 
>> DeploymentLoader classes tomorrow and see if I can discern the 
>> technique you mention (and then try to emulate it). If I have 
>> questions, which is likely, I'll ask. Thanks much
> 
> It's pretty easy.  Essentially I made it so ClassFinder can be 
> constructed with a var-arg list of classes (may also support a plain 
> List, can't remember).  When that is done it only searches that set for 
> annotations and doesn't do the whole asm routine to come up with a list 
> of annotated classes.
> 
> And now that I mention it, if you were to shift to that style of 
> annotation searching you could disregard the comment I made earlier 
> about constructing the ClassFinder exactly once per codebase -- if you 
> could pretty much construct them and throw them away as you like.
> 
> As far as the patch, there's nothing in there that can't be easily fixed 
> and we're all on the same page, so I can check it in and you can work on 
> your updates or I can wait for a revised patch.  Whichever is easiest 
> for you.  Let me know.
> 
> -David
> 
>>
>> Dain Sundstrom wrote:
>>> Are you sure you must scan all classes in the web module for @EJB 
>>> annotations?  I don't think it is necessary or what you want to do.  
>>> I believe that you should only be checking specific classes for the 
>>> annotation such as all known servlets.  This is how we process 
>>> annotations for EJBs.  First we find all EJBs, either listed in the 
>>> ejb-jar.xml or found by scanning for @Stateless, @Stateful and 
>>> @MessageDriven.  Once we have the list of EJBs we check each class 
>>> for the presence of the @EJB annotation.
>>> In your case, I believe you are scanning for all classes that have 
>>> the @EJB annotation which will be a much larger number of classes 
>>> then just the servlets.  This over processing of classes can easily 
>>> lead to naming conflicts.  Also, I do not believe that servlet 2.5 
>>> has an @Servlet annotation, so I don't think you have to do any 
>>> general purpose scanning like EJB module must do, which should make 
>>> web deployment much more efficient.
>>> Other than that, the patches look good :)  One minor thing to note is 
>>> we don't use prefixes such as "m_" for variables.
>>> Good job,
>>> -dain
>>> On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:
>>>> Hi, I've attached a patch and two new classes to the GERONIMO-2816 
>>>> JIRA that provides support for the @EJB and @EJBs
>>>> annotations if anyone would like to review. The intent is to 
>>>> demonstrate a final/permanent technique that can be extended and 
>>>> used throughout Geronimo to support annotations for JSR-88. This 
>>>> patch and new code works for Tomcat and circumvents the annotation 
>>>> processing that is currently in EjbRefBuilder (which did not update 
>>>> the deployment descriptor with the discovered annotations, but only 
>>>> updated the JNDI references). I'd appreciate some feedback before I 
>>>> start propagating this technique to the other module builders to 
>>>> support the remainder of the annotations. I already have another 
>>>> subclass ready to support the @Resource annotations but I didn't 
>>>> want to include it in this example since it doesn't demonstrate 
>>>> anything different than the EJBAnnotationHelper subclass, and I'd 
>>>> like to get some feedback first on the the technique. The general 
>>>> technique, which we've discussed before, is pretty straightforward 
>>>> and is summarized here for reference:
>>>>
>>>> 1 -- Discover the annotations: I had hoped that we could centralize 
>>>> the discovery of annotations in the Deployer class prior to the 
>>>> createModule phase of deployment, but as David Blevins pointed out 
>>>> this is almost impossible. So it has to be pushed down into the 
>>>> installModule phase of deployment after the necessary classloader(s) 
>>>> and module context(s) have been established (see the changes for 
>>>> AbstractWebModuleBuilder for an example).
>>>>
>>>> 2 -- Process the annotations: This just means to update the existing 
>>>> deployment descriptor (or create a new one) with the discovered 
>>>> annotations.
>>>>
>>>> 3 -- Set metadata-complete in the deployment descriptor to prevent 
>>>> repeated processing of annotations (see the EjbRefBuilder changes 
>>>> for an example)
>>>>
>>>> 4 -- Update the deployment descriptor in the module so that it can 
>>>> flow through the remainder of the deployment process much as before 
>>>> (for JNDI naming and resolution, and to remain with module in 
>>>> support of the JSR-77 requirements for management).
>>>>
>>>>  --
>>>> Thanks,
>>>> Tim McConnell
>>
>> --Thanks,
>> Tim McConnell
>>
> 
> 

-- 
Thanks,
Tim McConnell

Re: GERONIMO-2816 patch

Posted by David Blevins <da...@visi.com>.
On Feb 11, 2007, at 6:12 PM, Tim McConnell wrote:

> HI Dain, thanks for reviewing. Yes, you're right--I am scanning all  
> the classes in the web module for annotations, which might be  
> excessive. I'll take a look at the OpenEJB AnnotationDeployer and  
> DeploymentLoader classes tomorrow and see if I can discern the  
> technique you mention (and then try to emulate it). If I have  
> questions, which is likely, I'll ask. Thanks much

It's pretty easy.  Essentially I made it so ClassFinder can be  
constructed with a var-arg list of classes (may also support a plain  
List, can't remember).  When that is done it only searches that set  
for annotations and doesn't do the whole asm routine to come up with  
a list of annotated classes.

And now that I mention it, if you were to shift to that style of  
annotation searching you could disregard the comment I made earlier  
about constructing the ClassFinder exactly once per codebase -- if  
you could pretty much construct them and throw them away as you like.

As far as the patch, there's nothing in there that can't be easily  
fixed and we're all on the same page, so I can check it in and you  
can work on your updates or I can wait for a revised patch.   
Whichever is easiest for you.  Let me know.

-David

>
> Dain Sundstrom wrote:
>> Are you sure you must scan all classes in the web module for @EJB  
>> annotations?  I don't think it is necessary or what you want to  
>> do.  I believe that you should only be checking specific classes  
>> for the annotation such as all known servlets.  This is how we  
>> process annotations for EJBs.  First we find all EJBs, either  
>> listed in the ejb-jar.xml or found by scanning for @Stateless,  
>> @Stateful and @MessageDriven.  Once we have the list of EJBs we  
>> check each class for the presence of the @EJB annotation.
>> In your case, I believe you are scanning for all classes that have  
>> the @EJB annotation which will be a much larger number of classes  
>> then just the servlets.  This over processing of classes can  
>> easily lead to naming conflicts.  Also, I do not believe that  
>> servlet 2.5 has an @Servlet annotation, so I don't think you have  
>> to do any general purpose scanning like EJB module must do, which  
>> should make web deployment much more efficient.
>> Other than that, the patches look good :)  One minor thing to note  
>> is we don't use prefixes such as "m_" for variables.
>> Good job,
>> -dain
>> On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:
>>> Hi, I've attached a patch and two new classes to the  
>>> GERONIMO-2816 JIRA that provides support for the @EJB and @EJBs
>>> annotations if anyone would like to review. The intent is to  
>>> demonstrate a final/permanent technique that can be extended and  
>>> used throughout Geronimo to support annotations for JSR-88. This  
>>> patch and new code works for Tomcat and circumvents the  
>>> annotation processing that is currently in EjbRefBuilder (which  
>>> did not update the deployment descriptor with the discovered  
>>> annotations, but only updated the JNDI references). I'd  
>>> appreciate some feedback before I start propagating this  
>>> technique to the other module builders to support the remainder  
>>> of the annotations. I already have another subclass ready to  
>>> support the @Resource annotations but I didn't want to include it  
>>> in this example since it doesn't demonstrate anything different  
>>> than the EJBAnnotationHelper subclass, and I'd like to get some  
>>> feedback first on the the technique. The general technique, which  
>>> we've discussed before, is pretty straightforward and is  
>>> summarized here for reference:
>>>
>>> 1 -- Discover the annotations: I had hoped that we could  
>>> centralize the discovery of annotations in the Deployer class  
>>> prior to the createModule phase of deployment, but as David  
>>> Blevins pointed out this is almost impossible. So it has to be  
>>> pushed down into the installModule phase of deployment after the  
>>> necessary classloader(s) and module context(s) have been  
>>> established (see the changes for AbstractWebModuleBuilder for an  
>>> example).
>>>
>>> 2 -- Process the annotations: This just means to update the  
>>> existing deployment descriptor (or create a new one) with the  
>>> discovered annotations.
>>>
>>> 3 -- Set metadata-complete in the deployment descriptor to  
>>> prevent repeated processing of annotations (see the EjbRefBuilder  
>>> changes for an example)
>>>
>>> 4 -- Update the deployment descriptor in the module so that it  
>>> can flow through the remainder of the deployment process much as  
>>> before (for JNDI naming and resolution, and to remain with module  
>>> in support of the JSR-77 requirements for management).
>>>
>>>  --
>>> Thanks,
>>> Tim McConnell
>
> -- 
> Thanks,
> Tim McConnell
>


Re: GERONIMO-2816 patch

Posted by Tim McConnell <ti...@gmail.com>.
HI Dain, thanks for reviewing. Yes, you're right--I am scanning all the 
classes in the web module for annotations, which might be excessive. I'll 
take a look at the OpenEJB AnnotationDeployer and DeploymentLoader classes 
tomorrow and see if I can discern the technique you mention (and then try 
to emulate it). If I have questions, which is likely, I'll ask. Thanks much

Dain Sundstrom wrote:
> Are you sure you must scan all classes in the web module for @EJB 
> annotations?  I don't think it is necessary or what you want to do.  I 
> believe that you should only be checking specific classes for the 
> annotation such as all known servlets.  This is how we process 
> annotations for EJBs.  First we find all EJBs, either listed in the 
> ejb-jar.xml or found by scanning for @Stateless, @Stateful and 
> @MessageDriven.  Once we have the list of EJBs we check each class for 
> the presence of the @EJB annotation.
> 
> In your case, I believe you are scanning for all classes that have the 
> @EJB annotation which will be a much larger number of classes then just 
> the servlets.  This over processing of classes can easily lead to naming 
> conflicts.  Also, I do not believe that servlet 2.5 has an @Servlet 
> annotation, so I don't think you have to do any general purpose scanning 
> like EJB module must do, which should make web deployment much more 
> efficient.
> 
> 
> Other than that, the patches look good :)  One minor thing to note is we 
> don't use prefixes such as "m_" for variables.
> 
> Good job,
> 
> -dain
> 
> 
> On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:
> 
>> Hi, I've attached a patch and two new classes to the GERONIMO-2816 
>> JIRA that provides support for the @EJB and @EJBs
>> annotations if anyone would like to review. The intent is to 
>> demonstrate a final/permanent technique that can be extended and used 
>> throughout Geronimo to support annotations for JSR-88. This patch and 
>> new code works for Tomcat and circumvents the annotation processing 
>> that is currently in EjbRefBuilder (which did not update the 
>> deployment descriptor with the discovered annotations, but only 
>> updated the JNDI references). I'd appreciate some feedback before I 
>> start propagating this technique to the other module builders to 
>> support the remainder of the annotations. I already have another 
>> subclass ready to support the @Resource annotations but I didn't want 
>> to include it in this example since it doesn't demonstrate anything 
>> different than the EJBAnnotationHelper subclass, and I'd like to get 
>> some feedback first on the the technique. The general technique, which 
>> we've discussed before, is pretty straightforward and is summarized 
>> here for reference:
>>
>> 1 -- Discover the annotations: I had hoped that we could centralize 
>> the discovery of annotations in the Deployer class prior to the 
>> createModule phase of deployment, but as David Blevins pointed out 
>> this is almost impossible. So it has to be pushed down into the 
>> installModule phase of deployment after the necessary classloader(s) 
>> and module context(s) have been established (see the changes for 
>> AbstractWebModuleBuilder for an example).
>>
>> 2 -- Process the annotations: This just means to update the existing 
>> deployment descriptor (or create a new one) with the discovered 
>> annotations.
>>
>> 3 -- Set metadata-complete in the deployment descriptor to prevent 
>> repeated processing of annotations (see the EjbRefBuilder changes for 
>> an example)
>>
>> 4 -- Update the deployment descriptor in the module so that it can 
>> flow through the remainder of the deployment process much as before 
>> (for JNDI naming and resolution, and to remain with module in support 
>> of the JSR-77 requirements for management).
>>
>>  --
>> Thanks,
>> Tim McConnell
> 
> 

-- 
Thanks,
Tim McConnell

Re: GERONIMO-2816 patch

Posted by Paul McMahan <pa...@gmail.com>.
Tomcat enables resource injection by looking for annotations in
servlets, filters, and listeners.  It's pretty efficient because it
already knows which classes implement those interfaces from processing
web.xml.  See http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/WebAnnotationSet.java

Best wishes,
Paul

On 2/10/07, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
> On 2/10/07, Dain Sundstrom <da...@iq80.com> wrote:
> > Are you sure you must scan all classes in the web module for @EJB
> > annotations?
>
> I haven't checked the patch, but what Dain said made me think we could
> overdo the annotation processing. Not all classes might get annotated
> with @EJB(s). Perhaps there's a way to ask a web container for special
> classes and check them out whether they use annotation or not? Does
> Tomcat 6 provide a annotation processing facility?
>
> Jacek
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>

Re: GERONIMO-2816 patch

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 2/10/07, Dain Sundstrom <da...@iq80.com> wrote:
> Are you sure you must scan all classes in the web module for @EJB
> annotations?

I haven't checked the patch, but what Dain said made me think we could
overdo the annotation processing. Not all classes might get annotated
with @EJB(s). Perhaps there's a way to ask a web container for special
classes and check them out whether they use annotation or not? Does
Tomcat 6 provide a annotation processing facility?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: GERONIMO-2816 patch

Posted by Dain Sundstrom <da...@iq80.com>.
Are you sure you must scan all classes in the web module for @EJB  
annotations?  I don't think it is necessary or what you want to do.   
I believe that you should only be checking specific classes for the  
annotation such as all known servlets.  This is how we process  
annotations for EJBs.  First we find all EJBs, either listed in the  
ejb-jar.xml or found by scanning for @Stateless, @Stateful and  
@MessageDriven.  Once we have the list of EJBs we check each class  
for the presence of the @EJB annotation.

In your case, I believe you are scanning for all classes that have  
the @EJB annotation which will be a much larger number of classes  
then just the servlets.  This over processing of classes can easily  
lead to naming conflicts.  Also, I do not believe that servlet 2.5  
has an @Servlet annotation, so I don't think you have to do any  
general purpose scanning like EJB module must do, which should make  
web deployment much more efficient.


Other than that, the patches look good :)  One minor thing to note is  
we don't use prefixes such as "m_" for variables.

Good job,

-dain


On Feb 10, 2007, at 1:23 AM, Tim McConnell wrote:

> Hi, I've attached a patch and two new classes to the GERONIMO-2816  
> JIRA that provides support for the @EJB and @EJBs
> annotations if anyone would like to review. The intent is to  
> demonstrate a final/permanent technique that can be extended and  
> used throughout Geronimo to support annotations for JSR-88. This  
> patch and new code works for Tomcat and circumvents the annotation  
> processing that is currently in EjbRefBuilder (which did not update  
> the deployment descriptor with the discovered annotations, but only  
> updated the JNDI references). I'd appreciate some feedback before I  
> start propagating this technique to the other module builders to  
> support the remainder of the annotations. I already have another  
> subclass ready to support the @Resource annotations but I didn't  
> want to include it in this example since it doesn't demonstrate  
> anything different than the EJBAnnotationHelper subclass, and I'd  
> like to get some feedback first on the the technique. The general  
> technique, which we've discussed before, is pretty straightforward  
> and is summarized here for reference:
>
> 1 -- Discover the annotations: I had hoped that we could centralize  
> the discovery of annotations in the Deployer class prior to the  
> createModule phase of deployment, but as David Blevins pointed out  
> this is almost impossible. So it has to be pushed down into the  
> installModule phase of deployment after the necessary classloader 
> (s) and module context(s) have been established (see the changes  
> for AbstractWebModuleBuilder for an example).
>
> 2 -- Process the annotations: This just means to update the  
> existing deployment descriptor (or create a new one) with the  
> discovered annotations.
>
> 3 -- Set metadata-complete in the deployment descriptor to prevent  
> repeated processing of annotations (see the EjbRefBuilder changes  
> for an example)
>
> 4 -- Update the deployment descriptor in the module so that it can  
> flow through the remainder of the deployment process much as before  
> (for JNDI naming and resolution, and to remain with module in  
> support of the JSR-77 requirements for management).
>
>  --
> Thanks,
> Tim McConnell