use of org.eclipse.jetty.annotations.AnnotationParser.Handler in project jetty.project by eclipse.
the class AnnotationConfiguration method parseBundle.
protected void parseBundle(WebAppContext context, AnnotationParser parser, Bundle webbundle, Bundle bundle) throws Exception {
Resource bundleRes = parser.getResource(bundle);
Set<Handler> handlers = new HashSet<Handler>();
handlers.addAll(_discoverableAnnotationHandlers);
if (_classInheritanceHandler != null)
handlers.add(_classInheritanceHandler);
handlers.addAll(_containerInitializerAnnotationHandlers);
if (_parserTasks != null) {
BundleParserTask task = new BundleParserTask(parser, handlers, bundleRes);
_parserTasks.add(task);
if (LOG.isDebugEnabled())
task.setStatistic(new TimeStatistic());
}
}
use of org.eclipse.jetty.annotations.AnnotationParser.Handler in project jetty.project by eclipse.
the class AnnotationConfiguration method parseWebInfLib.
/**
* Scan jars in WEB-INF/lib
*
* @param context the context for the scan
* @param parser the annotation parser to use
* @throws Exception if unable to scan and/or parse
*/
public void parseWebInfLib(final WebAppContext context, final AnnotationParser parser) throws Exception {
List<FragmentDescriptor> frags = context.getMetaData().getFragments();
//email from Rajiv Mordani jsrs 315 7 April 2010
//jars that do not have a web-fragment.xml are still considered fragments
//they have to participate in the ordering
ArrayList<URI> webInfUris = new ArrayList<URI>();
List<Resource> jars = null;
if (context.getMetaData().getOrdering() != null)
jars = context.getMetaData().getOrderedWebInfJars();
else
//No ordering just use the jars in any order
jars = context.getMetaData().getWebInfJars();
_webInfLibStats = new CounterStatistic();
for (Resource r : jars) {
//for each jar, we decide which set of annotations we need to parse for
final Set<Handler> handlers = new HashSet<Handler>();
FragmentDescriptor f = getFragmentFromJar(r, frags);
//or if it has a fragment we scan it if it is not metadata complete
if (f == null || !isMetaDataComplete(f) || _classInheritanceHandler != null || !_containerInitializerAnnotationHandlers.isEmpty()) {
//register the classinheritance handler if there is one
if (_classInheritanceHandler != null)
handlers.add(_classInheritanceHandler);
//register the handlers for the @HandlesTypes values that are themselves annotations if there are any
handlers.addAll(_containerInitializerAnnotationHandlers);
//only register the discoverable annotation handlers if this fragment is not metadata complete, or has no fragment descriptor
if (f == null || !isMetaDataComplete(f))
handlers.addAll(_discoverableAnnotationHandlers);
if (_parserTasks != null) {
ParserTask task = new ParserTask(parser, handlers, r);
_parserTasks.add(task);
_webInfLibStats.increment();
if (LOG.isDebugEnabled())
task.setStatistic(new TimeStatistic());
}
}
}
}
use of org.eclipse.jetty.annotations.AnnotationParser.Handler in project jetty.project by eclipse.
the class AnnotationConfiguration method parseContainerPath.
/**
* Scan jars on container path.
*
* @param context the context for the scan
* @param parser the parser to scan with
* @throws Exception if unable to scan
*/
public void parseContainerPath(final WebAppContext context, final AnnotationParser parser) throws Exception {
//always parse for discoverable annotations as well as class hierarchy and servletcontainerinitializer related annotations
final Set<Handler> handlers = new HashSet<Handler>();
handlers.addAll(_discoverableAnnotationHandlers);
handlers.addAll(_containerInitializerAnnotationHandlers);
if (_classInheritanceHandler != null)
handlers.add(_classInheritanceHandler);
_containerPathStats = new CounterStatistic();
for (Resource r : context.getMetaData().getContainerResources()) {
//queue it up for scanning if using multithreaded mode
if (_parserTasks != null) {
ParserTask task = new ParserTask(parser, handlers, r);
_parserTasks.add(task);
_containerPathStats.increment();
if (LOG.isDebugEnabled())
task.setStatistic(new TimeStatistic());
}
}
}
use of org.eclipse.jetty.annotations.AnnotationParser.Handler in project jetty.project by eclipse.
the class TestAnnotationParser method testHiddenFilesInJar.
@Test
public void testHiddenFilesInJar() throws Exception {
File badClassesJar = MavenTestingUtils.getTestResourceFile("bad-classes.jar");
AnnotationParser parser = new AnnotationParser();
Set<Handler> emptySet = Collections.emptySet();
parser.parse(emptySet, badClassesJar.toURI());
// only the valid classes inside bad-classes.jar should be parsed. If any invalid classes are parsed and exception would be thrown here
}
use of org.eclipse.jetty.annotations.AnnotationParser.Handler in project jetty.project by eclipse.
the class AnnotationConfiguration method parseWebInfClasses.
/**
* Scan classes in WEB-INF/classes
*
* @param context the context for the scan
* @param parser the annotation parser to use
* @throws Exception if unable to scan and/or parse
*/
public void parseWebInfClasses(final WebAppContext context, final AnnotationParser parser) throws Exception {
Set<Handler> handlers = new HashSet<Handler>();
handlers.addAll(_discoverableAnnotationHandlers);
if (_classInheritanceHandler != null)
handlers.add(_classInheritanceHandler);
handlers.addAll(_containerInitializerAnnotationHandlers);
_webInfClassesStats = new CounterStatistic();
for (Resource dir : context.getMetaData().getWebInfClassesDirs()) {
if (_parserTasks != null) {
ParserTask task = new ParserTask(parser, handlers, dir);
_parserTasks.add(task);
_webInfClassesStats.increment();
if (LOG.isDebugEnabled())
task.setStatistic(new TimeStatistic());
}
}
}
Aggregations