Re: Exclude scanning of class folders for Servlet 3.0 annotations.

2014-06-18 Thread Konstantin Kolinko
2014-06-14 17:30 GMT+04:00 Vimil Saju vimils...@yahoo.com.invalid:
 Hi,

 I am using tomcat 7.0.52 and jdk 1.7.0_45. We have a web application which 
 has its classpath configured in its own context xml file using 
 virtualClasspath attribute of Loader tag. The webapp uses version 3.0 of 
 web.xml,  The classpath contains multiple class folders in addition to jar 
 file references. i.e virtualClasspath is set to something as follows

 virtualClasspath=C:\Projects\ProjectA\classes;C:\Projects\ProjectB\classes;C:\Projects\ProjectC\classes;C:\Projects\Libraries\jarfile1.jar;C:\Projects\Libraries\jarfile2.jar

 C:\Projects\ProjectA\classes has classes with Servlet 3.0 annotations and I 
 want tomcat to look for annotated classes in this class folder. To do this I 
 have set the attribute scanAllDirectories=true under the JarScanner tag as 
 follows


 JarScanner scanAllDirectories=true/


 Since I don't want tomcat to scan other jar files and class folders of 
 ProjectB and ProjectC, I have configured
 the property tomcat.util.scan.DefaultJarScanner.jarsToSkip in 
 catalina.properties to something as follows

 tomcat.util.scan.DefaultJarScanner.jarsToSkip=jarfile1.jar,jarfile2.jar,**/ProjectB/classes,**/ProjectC/classes


 I was able to make tomcat skip scanning of jar files using the above 
 configuration but it still scans class folders of both ProjectB and ProjectC.

 So I looked at the source code of StandardJarScanner and found that it uses 
 the name of the last directory in the folder path as the jar name. i.e the 
 jarName computed for both ProjectB/classes and ProjectC/classes is 'classes'. 
 Thus there is no way for it to distinguish ProjectB/classes and 
 ProjectC/classes from ProjectA/classes.

 I think StandardJarScanner should use the full folder path as the jar name 
 instead of just the last directory in the folder path.


 This is the code I was looking at in StandardJarScanner.java

 /*
  * Extract the JAR name, if present, from a URL
  */
 private String More ...getJarName(URL url) {

 String name = null;

 String path = url.getPath();
 int end = path.indexOf(Constants.JAR_EXT);
 if (end != -1) {
 int start = path.lastIndexOf('/', end);
 name = path.substring(start + 1, end + 4);
 } else if (isScanAllDirectories()){
 int start = path.lastIndexOf('/');
 name = path.substring(start + 1);
 }

 return name;
 }


  I think  instead of computing the last name of the directory path for class 
 folders it should set the jarname to the full folder path

 private String getJarName(URL url) { String name = null; String path = 
 url.getPath(); int end = path.indexOf(.jar); if (end != -1) { int start = 
 path.lastIndexOf('/', end); name = path.substring(start + 1, end + 4); } else 
 if (isScanAllDirectories()) { name = path; } return name; }

   I would like to know if there are any issues with my suggestion. I would 
 also like to know if there is any workaround for my problem.


1. VirtualWebappLoader is deprecated and removed from Tomcat 8. In
Tomcat 8 you'll configure your resources by mapping those directories
into WEB-INF/classes.

As it is all the same directory (WEB-INF/classes), I see no sense in
filtering by directory name.

JarScanner operates on URLs, not on file system paths.

2. I think that I'd like to see filtering by Java package name. I
think it makes sense to implement that.

3. You may configure your own JarScanner or JarScanFilter (in Tomcat
8) implementation in your META-INF/context.xml file.

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Exclude scanning of class folders for Servlet 3.0 annotations.

2014-06-17 Thread Vimil Saju







Hi,




I am using tomcat 7.0.52 and jdk 1.7.0_45. We have a web application which has 
its classpath configured in its own context xml file using virtualClasspath 
attribute of Loader tag. The webapp uses version 3.0 of web.xml,  The classpath 
contains multiple class folders in addition to jar file references. i.e 
virtualClasspath is set to something as
 follows

virtualClasspath=C:\Projects\ProjectA\classes;C:\Projects\ProjectB\classes;C:\Projects\ProjectC\classes;C:\Projects\Libraries\jarfile1.jar;C:\Projects\Libraries\jarfile2.jar
 

C:\Projects\ProjectA\classes has classes with Servlet 3.0 annotations and I 
want tomcat to look for annotated classes in this class folder. To do this I 
have set the attribute scanAllDirectories=true under the JarScanner tag as 
follows


JarScanner scanAllDirectories=true/


Since I don't want tomcat to scan other jar files and class folders of ProjectB 
and ProjectC, I have configured 
the property tomcat.util.scan.DefaultJarScanner.jarsToSkip in 
catalina.properties to something as follows

tomcat.util.scan.DefaultJarScanner.jarsToSkip=jarfile1.jar,jarfile2.jar,**/ProjectB/classes,**/ProjectC/classes


I was able to make tomcat skip scanning of jar files using the above 
configuration but it
 still scans class folders of both ProjectB and ProjectC. 

So I looked at the source code of StandardJarScanner and found that it uses the 
name of the last directory in the folder path as the jar name. i.e the jarName 
computed for both ProjectB/classes and ProjectC/classes is 'classes'. Thus 
there is no way for it to distinguish ProjectB/classes and ProjectC/classes 
from ProjectA/classes.

I think StandardJarScanner should use the full folder path as the jar name 
instead of just the last directory in the folder path.


This is the code I was looking at in StandardJarScanner.java

/*
 * Extract the JAR name, if present, from a URL
 */
private String More ...getJarName(URL url) {

    String name = null;

    String path = url.getPath();
    int end = path.indexOf(Constants.JAR_EXT);
    if (end != -1) {
        int
 start = path.lastIndexOf('/', end);
        name = path.substring(start + 1, end + 4);
    } else if (isScanAllDirectories()){
        int start = path.lastIndexOf('/');
        name = path.substring(start + 1);
    }

    return name;
}


 I think  instead of computing the last name of the directory path for class 
folders it should set the jarname to the full folder path

private String getJarName(URL url) { String name = null; String path = 
url.getPath(); int end = path.indexOf(.jar); if (end != -1) { int start = 
path.lastIndexOf('/', end); name = path.substring(start + 1, end + 4); } else 
if (isScanAllDirectories()) { name = path; } return name; }

  I would like to know if there are any issues with my suggestion. I would also 
like to know if there is any workaround for my
 problem.

Thanks
Vimil

svn commit: r1172696 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/DefaultInstanceManager.java test/org/apache/catalina/core/TestDefaultInstanceManager.java test/webapp-3.0/annotations.

2011-09-19 Thread markt
Author: markt
Date: Mon Sep 19 16:47:03 2011
New Revision: 1172696

URL: http://svn.apache.org/viewvc?rev=1172696view=rev
Log:
Fix resource leak in annotations cache that prevented unloading of resources 
that used annotations

Added:

tomcat/tc7.0.x/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java
  - copied unchanged from r1172664, 
tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java
tomcat/tc7.0.x/trunk/test/webapp-3.0/annotations.jsp
  - copied unchanged from r1172664, 
tomcat/trunk/test/webapp-3.0/annotations.jsp
Modified:
tomcat/tc7.0.x/trunk/   (props changed)

tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java

Propchange: tomcat/tc7.0.x/trunk/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 19 16:47:03 2011
@@ -1 +1 @@
-/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166752,1166757,1167368,1167394,1169447,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172610
+/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166752,1166757,1167368,1167394,1169447,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172610,1172664

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java?rev=1172696r1=1172695r2=1172696view=diff
==
--- 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 
(original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 
Mon Sep 19 16:47:03 2011
@@ -21,6 +21,7 @@ package org.apache.catalina.core;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.ref.WeakReference;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
@@ -35,7 +36,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.WeakHashMap;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -70,8 +71,8 @@ public class DefaultInstanceManager impl
 private Properties restrictedFilters = new Properties();
 private Properties restrictedListeners = new Properties();
 private Properties restrictedServlets = new Properties();
-private MapClass?,ListAnnotationCacheEntry annotationCache =
-new ConcurrentHashMapClass?, ListAnnotationCacheEntry();
+private final MapClass?,WeakReferenceListAnnotationCacheEntry 
annotationCache =
+new WeakHashMapClass?, WeakReferenceListAnnotationCacheEntry();
 
 public DefaultInstanceManager(Context context, MapString, MapString, 
String injectionMap, org.apache.catalina.Context catalinaContext, ClassLoader 
containerClassLoader) {
 classLoader = catalinaContext.getLoader().getClassLoader();
@@ -178,7 +179,10 @@ public class DefaultInstanceManager impl
 
 // At the end the postconstruct annotated
 // method is invoked
-ListAnnotationCacheEntry annotations = annotationCache.get(clazz);
+ListAnnotationCacheEntry annotations;
+synchronized (annotationCache) {
+annotations = annotationCache.get(clazz).get();
+}
 for (AnnotationCacheEntry entry : 

DO NOT REPLY [Bug 50683] New: Servlet 3.0 annotations not scanned if unpackWars=false

2011-01-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=50683

   Summary: Servlet 3.0 annotations not scanned if
unpackWars=false
   Product: Tomcat 7
   Version: 7.0.6
  Platform: PC
OS/Version: Windows XP
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
AssignedTo: dev@tomcat.apache.org
ReportedBy: kris...@batizy.com


Created an attachment (id=26572)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=26572)
minimal test case war with source

Overview: 

Given a very simple HelloServlet using @WebServlet annotation, and packed in a
war file without a web.xml, the container does not scan for annotations if
unpackWars=false in the Host element of server.xml and the servlet is never
added to the context.

Steps to Reproduce: 

1) Set unpackWars=fase

2) copy attached war file to webapps

3) launch Tomcat

4) navigate to:  http://servername/Hello/SayHello

Actual Results: 

  HTTP Status 404 - /Hello/SayHello

  type Status report

  message /Hello/SayHello

  description The requested resource (/Hello/SayHello) is not available.
  Apache Tomcat/7.0.6

Expected Results: 

  Hello

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 50683] Servlet 3.0 annotations not scanned if unpackWars=false

2011-01-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=50683

--- Comment #1 from kristof batizy kris...@batizy.com 2011-01-28 18:37:39 EST 
---
sorry, typo in step 1, above:

1) Set unpackWars=false

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 50683] Servlet 3.0 annotations not scanned if unpackWars=false

2011-01-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=50683

Mark Thomas ma...@apache.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #2 from Mark Thomas ma...@apache.org 2011-01-28 19:16:05 EST ---
Thanks for the report and the test case.

The issue has been fixed in 7.0.x and will be included in 7.0.7 onwards.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-12 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

Mark Thomas ma...@apache.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #9 from Mark Thomas ma...@apache.org 2010-04-12 06:33:45 EDT ---
Patches applied to trunk. Many thanks.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] New: Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

   Summary: Addition of Javadoc for Servlet 3.0 annotations
   Product: Tomcat 7
   Version: trunk
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Documentation
AssignedTo: dev@tomcat.apache.org
ReportedBy: bugzi...@pidster.com


Created an attachment (id=25252)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25252)
Javadoc patch for WebServlet annotation

Addition of Javadoc for Servlet 3.0 javax.servlet.annotation package.
Several patches to follow.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #1 from Pid bugzi...@pidster.com 2010-04-11 16:46:32 EDT ---
Created an attachment (id=25253)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25253)
Javadoc patch for WebListener annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

Pid bugzi...@pidster.com changed:

   What|Removed |Added

  Attachment #25252|application/octet-stream|text/plain
  mime type||
  Attachment #25252|0   |1
   is patch||

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #2 from Pid bugzi...@pidster.com 2010-04-11 16:47:58 EDT ---
Created an attachment (id=25254)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25254)
Javadoc patch for WebInitParam annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #3 from Pid bugzi...@pidster.com 2010-04-11 16:48:32 EDT ---
Created an attachment (id=25255)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25255)
Javadoc patch for WebFilter annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #4 from Pid bugzi...@pidster.com 2010-04-11 16:49:32 EDT ---
Created an attachment (id=25256)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25256)
Javadoc patch for ServletSecurity annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #5 from Pid bugzi...@pidster.com 2010-04-11 16:50:18 EDT ---
Created an attachment (id=25257)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25257)
Javadoc patch for MultipartConfig annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #6 from Pid bugzi...@pidster.com 2010-04-11 16:51:17 EDT ---
Created an attachment (id=25258)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25258)
Javadoc patch for HttpMethodConstraint annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #7 from Pid bugzi...@pidster.com 2010-04-11 16:51:54 EDT ---
Created an attachment (id=25259)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25259)
Javadoc patch for HttpConstraint annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



DO NOT REPLY [Bug 49086] Addition of Javadoc for Servlet 3.0 annotations

2010-04-11 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=49086

--- Comment #8 from Pid bugzi...@pidster.com 2010-04-11 16:52:41 EDT ---
Created an attachment (id=25260)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=25260)
Javadoc patch for HandlesTypes annotation

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-07 Thread Filip Hanik - Dev Lists

I'll take a look at this after I'm done with the async stuff

On 08/04/2009 03:28 PM, David Blevins wrote:


On Aug 4, 2009, at 1:22 PM, Costin Manolache wrote:


Thanks - so objectweb instead of BCEL.
I'll try it out - it's a bit different from what I had in mind, it looks
like xbean-finder first finds all classes and
than reads the files using the class loader ( but not Class.forName, 
which

is good ) and keeps track of all annotations.

I was thinking of a simple File/zip based scanning, without any class 
loader

- and just select the few
annotations we need and write a web.xml fragment as it goes, without 
keeping

anything in memory.


I've been thinking about adding in a sort of filter for the 
scanning.  Something that could be supplied in the constructor.  
Something simple like:


public interface Filter {
boolean accept(String annotationName);
}

Then you would implement that and be guaranteed to only have metadata 
for the annotations you cared about.  In this case @Filter and 
@Servlet.   I actually already experimented with it in a little copy 
of the ClassFinder, would only take like 10 minutes to integrate the 
change in.


In terms of keeping things in memory, there really isn't that much in 
memory, especially if you filter out the annotations you don't care 
about.  As far as needing a classloader, that is only there so we can 
return a list of classes (or methods, or fields, etc.) when you ask 
for things that have a specific annotation.  Someone has to load the 
class to get the annotation data so it's just in the API for convenience.


Another thing I've been experimenting with is some additional byte 
code reading optimizations.  Basically if you know your annotations 
are class-level annotations only, you can get a boost in scan time by 
just reading the top of the class def and skipping the rest.  The 
technique is proven, just need to think of an elegant way to specify 
that is the behavior you want.


I guess in 3.0 a deploy tool / phase is absolutely needed - we can't 
have

tomcat scan all files
each time it starts up, so the user will have to do something to 
re-initiate

the scanning. Like touch
web.xml, or run a re-deploy tool.

I'm curious - why objectweb and not BCEL ?


We (OpenEJB) already had a bunch of code using ASM so that's what I 
went with -- I wrote it OpenEJB and moved it over into XBean later so 
others could use it.  I also know a couple ASM guys and find it's good 
getting direct tips for best performance as well as getting any 
features in we need.


-David





On Tue, Aug 4, 2009 at 12:50 PM, David Jencks 
david_jen...@yahoo.comwrote:



We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to date
with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/ 




https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec 



thanks
david jencks


On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

Hi, anyone working on the @Filter, @Servlet annotation scanner for

tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all 
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is 
looking at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has different 
code -

I
would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration - should be
Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-07 Thread David Blevins
Cool.  Feel free to ping me in freenode if you want; dblevins in  
#openejb, #geronimo and #asfinfra.


-David

On Aug 7, 2009, at 9:30 AM, Filip Hanik - Dev Lists wrote:


I'll take a look at this after I'm done with the async stuff

On 08/04/2009 03:28 PM, David Blevins wrote:


On Aug 4, 2009, at 1:22 PM, Costin Manolache wrote:


Thanks - so objectweb instead of BCEL.
I'll try it out - it's a bit different from what I had in mind, it  
looks

like xbean-finder first finds all classes and
than reads the files using the class loader ( but not  
Class.forName, which

is good ) and keeps track of all annotations.

I was thinking of a simple File/zip based scanning, without any  
class loader

- and just select the few
annotations we need and write a web.xml fragment as it goes,  
without keeping

anything in memory.


I've been thinking about adding in a sort of filter for the  
scanning.  Something that could be supplied in the constructor.   
Something simple like:


   public interface Filter {
   boolean accept(String annotationName);
   }

Then you would implement that and be guaranteed to only have  
metadata for the annotations you cared about.  In this case @Filter  
and @Servlet.   I actually already experimented with it in a little  
copy of the ClassFinder, would only take like 10 minutes to  
integrate the change in.


In terms of keeping things in memory, there really isn't that much  
in memory, especially if you filter out the annotations you don't  
care about.  As far as needing a classloader, that is only there so  
we can return a list of classes (or methods, or fields, etc.) when  
you ask for things that have a specific annotation.  Someone has to  
load the class to get the annotation data so it's just in the API  
for convenience.


Another thing I've been experimenting with is some additional byte  
code reading optimizations.  Basically if you know your annotations  
are class-level annotations only, you can get a boost in scan time  
by just reading the top of the class def and skipping the rest.   
The technique is proven, just need to think of an elegant way to  
specify that is the behavior you want.


I guess in 3.0 a deploy tool / phase is absolutely needed - we  
can't have

tomcat scan all files
each time it starts up, so the user will have to do something to  
re-initiate

the scanning. Like touch
web.xml, or run a re-deploy tool.

I'm curious - why objectweb and not BCEL ?


We (OpenEJB) already had a bunch of code using ASM so that's what I  
went with -- I wrote it OpenEJB and moved it over into XBean later  
so others could use it.  I also know a couple ASM guys and find  
it's good getting direct tips for best performance as well as  
getting any features in we need.


-David





On Tue, Aug 4, 2009 at 12:50 PM, David Jencks david_jen...@yahoo.com 
wrote:



We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up  
to date

with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/


https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks


On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

Hi, anyone working on the @Filter, @Servlet annotation scanner for

tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all  
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is  
looking at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has  
different code -

I
would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration -  
should be

Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-07 Thread Costin Manolache
So far ASM looks good - the size of the jar is amazing. For tomcat-lite I'll
probably use it instead of bcel - I'll first try directly, if I get confused
by the callback style I'll use xbean-finder or the tree model.

Costin

On Fri, Aug 7, 2009 at 12:49 PM, David Blevins david.blev...@visi.comwrote:

 Cool.  Feel free to ping me in freenode if you want; dblevins in #openejb,
 #geronimo and #asfinfra.

 -David


 On Aug 7, 2009, at 9:30 AM, Filip Hanik - Dev Lists wrote:

  I'll take a look at this after I'm done with the async stuff

 On 08/04/2009 03:28 PM, David Blevins wrote:


 On Aug 4, 2009, at 1:22 PM, Costin Manolache wrote:

  Thanks - so objectweb instead of BCEL.
 I'll try it out - it's a bit different from what I had in mind, it looks
 like xbean-finder first finds all classes and
 than reads the files using the class loader ( but not Class.forName,
 which
 is good ) and keeps track of all annotations.

 I was thinking of a simple File/zip based scanning, without any class
 loader
 - and just select the few
 annotations we need and write a web.xml fragment as it goes, without
 keeping
 anything in memory.


 I've been thinking about adding in a sort of filter for the scanning.
  Something that could be supplied in the constructor.  Something simple
 like:

   public interface Filter {
   boolean accept(String annotationName);
   }

 Then you would implement that and be guaranteed to only have metadata for
 the annotations you cared about.  In this case @Filter and @Servlet.   I
 actually already experimented with it in a little copy of the ClassFinder,
 would only take like 10 minutes to integrate the change in.

 In terms of keeping things in memory, there really isn't that much in
 memory, especially if you filter out the annotations you don't care about.
  As far as needing a classloader, that is only there so we can return a list
 of classes (or methods, or fields, etc.) when you ask for things that have a
 specific annotation.  Someone has to load the class to get the annotation
 data so it's just in the API for convenience.

 Another thing I've been experimenting with is some additional byte code
 reading optimizations.  Basically if you know your annotations are
 class-level annotations only, you can get a boost in scan time by just
 reading the top of the class def and skipping the rest.  The technique is
 proven, just need to think of an elegant way to specify that is the behavior
 you want.

  I guess in 3.0 a deploy tool / phase is absolutely needed - we can't
 have
 tomcat scan all files
 each time it starts up, so the user will have to do something to
 re-initiate
 the scanning. Like touch
 web.xml, or run a re-deploy tool.

 I'm curious - why objectweb and not BCEL ?


 We (OpenEJB) already had a bunch of code using ASM so that's what I went
 with -- I wrote it OpenEJB and moved it over into XBean later so others
 could use it.  I also know a couple ASM guys and find it's good getting
 direct tips for best performance as well as getting any features in we need.

 -David




 On Tue, Aug 4, 2009 at 12:50 PM, David Jencks david_jen...@yahoo.com
 wrote:

  We use xbean-finder for this in geronimo/openejb/etc.

 http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

 https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

 We also have a servlet 3.0 spec jar I've been trying to keep up to date
 with the glassfish javadocs.



 https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/



 https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

 thanks
 david jencks


 On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

 Hi, anyone working on the @Filter, @Servlet annotation scanner for

 tomcat-trunk ?
 If I'm understanding it correctly, tomcat will have to read all files
 in
 classes and lib and look for the
 annotation - and I would guess the only reasonable option is looking
 at
 bytecode.
 I checked BCEL - seems reasonably easy, but if anyone has different
 code -
 I
 would rather reuse it in
 tomcat-lite :-)

 BTW - there is a typo in javax.servlet.ServletRegistration - should be
 Dynamic, not Dynmaic.
 I can fix it next time I get some free time...

 Costin



 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org




 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org




 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org




 -
 To unsubscribe, e-mail: 

Re: 3.0 annotations ?

2009-08-07 Thread David Blevins
FYI, ClassFinder is just one class and you're welcome to just take a  
copy.  Struts did the same.


-David

On Aug 7, 2009, at 12:55 PM, Costin Manolache wrote:

So far ASM looks good - the size of the jar is amazing. For tomcat- 
lite I'll
probably use it instead of bcel - I'll first try directly, if I get  
confused

by the callback style I'll use xbean-finder or the tree model.

Costin

On Fri, Aug 7, 2009 at 12:49 PM, David Blevins  
david.blev...@visi.comwrote:


Cool.  Feel free to ping me in freenode if you want; dblevins in  
#openejb,

#geronimo and #asfinfra.

-David


On Aug 7, 2009, at 9:30 AM, Filip Hanik - Dev Lists wrote:

I'll take a look at this after I'm done with the async stuff


On 08/04/2009 03:28 PM, David Blevins wrote:



On Aug 4, 2009, at 1:22 PM, Costin Manolache wrote:

Thanks - so objectweb instead of BCEL.
I'll try it out - it's a bit different from what I had in mind,  
it looks

like xbean-finder first finds all classes and
than reads the files using the class loader ( but not  
Class.forName,

which
is good ) and keeps track of all annotations.

I was thinking of a simple File/zip based scanning, without any  
class

loader
- and just select the few
annotations we need and write a web.xml fragment as it goes,  
without

keeping
anything in memory.



I've been thinking about adding in a sort of filter for the  
scanning.
Something that could be supplied in the constructor.  Something  
simple

like:

 public interface Filter {
 boolean accept(String annotationName);
 }

Then you would implement that and be guaranteed to only have  
metadata for
the annotations you cared about.  In this case @Filter and  
@Servlet.   I
actually already experimented with it in a little copy of the  
ClassFinder,

would only take like 10 minutes to integrate the change in.

In terms of keeping things in memory, there really isn't that  
much in
memory, especially if you filter out the annotations you don't  
care about.
As far as needing a classloader, that is only there so we can  
return a list
of classes (or methods, or fields, etc.) when you ask for things  
that have a
specific annotation.  Someone has to load the class to get the  
annotation

data so it's just in the API for convenience.

Another thing I've been experimenting with is some additional  
byte code

reading optimizations.  Basically if you know your annotations are
class-level annotations only, you can get a boost in scan time by  
just
reading the top of the class def and skipping the rest.  The  
technique is
proven, just need to think of an elegant way to specify that is  
the behavior

you want.

I guess in 3.0 a deploy tool / phase is absolutely needed - we  
can't

have
tomcat scan all files
each time it starts up, so the user will have to do something to
re-initiate
the scanning. Like touch
web.xml, or run a re-deploy tool.

I'm curious - why objectweb and not BCEL ?



We (OpenEJB) already had a bunch of code using ASM so that's what  
I went
with -- I wrote it OpenEJB and moved it over into XBean later so  
others
could use it.  I also know a couple ASM guys and find it's good  
getting
direct tips for best performance as well as getting any features  
in we need.


-David





On Tue, Aug 4, 2009 at 12:50 PM, David Jencks david_jen...@yahoo.com

wrote:


We use xbean-finder for this in geronimo/openejb/etc.


http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean- 
finder


We also have a servlet 3.0 spec jar I've been trying to keep up  
to date

with the glassfish javadocs.



https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/



https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks


On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

Hi, anyone working on the @Filter, @Servlet annotation scanner  
for



tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read  
all files

in
classes and lib and look for the
annotation - and I would guess the only reasonable option is  
looking

at
bytecode.
I checked BCEL - seems reasonably easy, but if anyone has  
different

code -
I
would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration -  
should be

Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional 

3.0 annotations ?

2009-08-04 Thread Costin Manolache
Hi, anyone working on the @Filter, @Servlet annotation scanner for
tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all files in
classes and lib and look for the
annotation - and I would guess the only reasonable option is looking at
bytecode.
I checked BCEL - seems reasonably easy, but if anyone has different code - I
would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration - should be
Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin


Re: 3.0 annotations ?

2009-08-04 Thread David Jencks

We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to  
date with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/

https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks

On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:


Hi, anyone working on the @Filter, @Servlet annotation scanner for
tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all  
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is looking  
at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has different  
code - I

would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration - should be
Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-04 Thread Filip Hanik - Dev Lists

does it load all the classes?
I think byte code check might make more sense if that is the case

Filip

On 08/04/2009 01:50 PM, David Jencks wrote:

We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to 
date with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/ 



https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec 



thanks
david jencks

On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:


Hi, anyone working on the @Filter, @Servlet annotation scanner for
tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all files in
classes and lib and look for the
annotation - and I would guess the only reasonable option is looking at
bytecode.
I checked BCEL - seems reasonably easy, but if anyone has different 
code - I

would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration - should be
Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-04 Thread Costin Manolache
Thanks - so objectweb instead of BCEL.
I'll try it out - it's a bit different from what I had in mind, it looks
like xbean-finder first finds all classes and
than reads the files using the class loader ( but not Class.forName, which
is good ) and keeps track of all annotations.

I was thinking of a simple File/zip based scanning, without any class loader
- and just select the few
annotations we need and write a web.xml fragment as it goes, without keeping
anything in memory.
I guess in 3.0 a deploy tool / phase is absolutely needed - we can't have
tomcat scan all files
each time it starts up, so the user will have to do something to re-initiate
the scanning. Like touch
web.xml, or run a re-deploy tool.

 I'm curious - why objectweb and not BCEL ?


On Tue, Aug 4, 2009 at 12:50 PM, David Jencks david_jen...@yahoo.comwrote:

 We use xbean-finder for this in geronimo/openejb/etc.

 http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

 https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

 We also have a servlet 3.0 spec jar I've been trying to keep up to date
 with the glassfish javadocs.


 https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/


 https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

 thanks
 david jencks


 On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

  Hi, anyone working on the @Filter, @Servlet annotation scanner for
 tomcat-trunk ?
 If I'm understanding it correctly, tomcat will have to read all files in
 classes and lib and look for the
 annotation - and I would guess the only reasonable option is looking at
 bytecode.
 I checked BCEL - seems reasonably easy, but if anyone has different code -
 I
 would rather reuse it in
 tomcat-lite :-)

 BTW - there is a typo in javax.servlet.ServletRegistration - should be
 Dynamic, not Dynmaic.
 I can fix it next time I get some free time...

 Costin



 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org




Re: 3.0 annotations ?

2009-08-04 Thread David Jencks


On Aug 4, 2009, at 1:18 PM, Filip Hanik - Dev Lists wrote:


does it load all the classes?


IIUC no, it uses asm for byte-code inspection without loading classes.

thanks
david jencks

I think byte code check might make more sense if that is the case

Filip

On 08/04/2009 01:50 PM, David Jencks wrote:

We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to  
date with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/

https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks

On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:


Hi, anyone working on the @Filter, @Servlet annotation scanner for
tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all  
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is  
looking at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has  
different code - I

would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration -  
should be

Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-04 Thread David Blevins
No, it scans via ASM for security reasons and only loads classes (with  
no initialization) once you ask for classes that have a specific  
annotation.


Sample code:

  ClassFinder finder = new ClassFinder(webapp.getClassLoader(),  
webappLibUrls);


  for (Class? servlet : finder.findAnnotatedClasses(Servlet.class)) {
  // .. do your processing
  }

  for (Class? filter : finder.findAnnotatedClasses(Filter.class)) {
  // .. do your processing
  }

  // and so on

Additions are welcome if there are any features you might need.

-David



On Aug 4, 2009, at 1:18 PM, Filip Hanik - Dev Lists wrote:


does it load all the classes?
I think byte code check might make more sense if that is the case

Filip

On 08/04/2009 01:50 PM, David Jencks wrote:

We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to  
date with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/

https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks

On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:


Hi, anyone working on the @Filter, @Servlet annotation scanner for
tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all  
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is  
looking at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has  
different code - I

would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration -  
should be

Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-04 Thread David Blevins


On Aug 4, 2009, at 1:22 PM, Costin Manolache wrote:


Thanks - so objectweb instead of BCEL.
I'll try it out - it's a bit different from what I had in mind, it  
looks

like xbean-finder first finds all classes and
than reads the files using the class loader ( but not Class.forName,  
which

is good ) and keeps track of all annotations.

I was thinking of a simple File/zip based scanning, without any  
class loader

- and just select the few
annotations we need and write a web.xml fragment as it goes, without  
keeping

anything in memory.


I've been thinking about adding in a sort of filter for the  
scanning.  Something that could be supplied in the constructor.   
Something simple like:


public interface Filter {
boolean accept(String annotationName);
}

Then you would implement that and be guaranteed to only have metadata  
for the annotations you cared about.  In this case @Filter and  
@Servlet.   I actually already experimented with it in a little copy  
of the ClassFinder, would only take like 10 minutes to integrate the  
change in.


In terms of keeping things in memory, there really isn't that much in  
memory, especially if you filter out the annotations you don't care  
about.  As far as needing a classloader, that is only there so we can  
return a list of classes (or methods, or fields, etc.) when you ask  
for things that have a specific annotation.  Someone has to load the  
class to get the annotation data so it's just in the API for  
convenience.


Another thing I've been experimenting with is some additional byte  
code reading optimizations.  Basically if you know your annotations  
are class-level annotations only, you can get a boost in scan time by  
just reading the top of the class def and skipping the rest.  The  
technique is proven, just need to think of an elegant way to specify  
that is the behavior you want.


I guess in 3.0 a deploy tool / phase is absolutely needed - we can't  
have

tomcat scan all files
each time it starts up, so the user will have to do something to re- 
initiate

the scanning. Like touch
web.xml, or run a re-deploy tool.

I'm curious - why objectweb and not BCEL ?


We (OpenEJB) already had a bunch of code using ASM so that's what I  
went with -- I wrote it OpenEJB and moved it over into XBean later so  
others could use it.  I also know a couple ASM guys and find it's good  
getting direct tips for best performance as well as getting any  
features in we need.


-David





On Tue, Aug 4, 2009 at 12:50 PM, David Jencks  
david_jen...@yahoo.comwrote:



We use xbean-finder for this in geronimo/openejb/etc.

http://repo2.maven.org/maven2/org/apache/xbean/xbean-finder/3.5/

https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-finder

We also have a servlet 3.0 spec jar I've been trying to keep up to  
date

with the glassfish javadocs.


https://repository.apache.org/content/repositories/snapshots/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0-EA-SNAPSHOT/


https://svn.apache.org/repos/asf/geronimo/specs/trunk/geronimo-servlet_3.0_spec

thanks
david jencks


On Aug 4, 2009, at 11:11 AM, Costin Manolache wrote:

Hi, anyone working on the @Filter, @Servlet annotation scanner for

tomcat-trunk ?
If I'm understanding it correctly, tomcat will have to read all  
files in

classes and lib and look for the
annotation - and I would guess the only reasonable option is  
looking at

bytecode.
I checked BCEL - seems reasonably easy, but if anyone has  
different code -

I
would rather reuse it in
tomcat-lite :-)

BTW - there is a typo in javax.servlet.ServletRegistration -  
should be

Dynamic, not Dynmaic.
I can fix it next time I get some free time...

Costin




-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org





-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: 3.0 annotations ?

2009-08-04 Thread Mark Thomas
Costin Manolache wrote:
 Hi, anyone working on the @Filter, @Servlet annotation scanner for
 tomcat-trunk ?
 If I'm understanding it correctly, tomcat will have to read all files in
 classes and lib and look for the
 annotation - and I would guess the only reasonable option is looking at
 bytecode.
 I checked BCEL - seems reasonably easy, but if anyone has different code - I
 would rather reuse it in
 tomcat-lite :-)
 
 BTW - there is a typo in javax.servlet.ServletRegistration - should be
 Dynamic, not Dynmaic.
 I can fix it next time I get some free time...

Fixed.

Mark



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org