1 //
2 // ========================================================================
3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.annotations;
20
21 import org.eclipse.jetty.servlet.ServletContextHandler.Decorator;
22 import org.eclipse.jetty.webapp.WebAppContext;
23
24 /**
25 * AnnotationDecorator
26 *
27 *
28 */
29 public class AnnotationDecorator implements Decorator
30 {
31 AnnotationIntrospector _introspector = new AnnotationIntrospector();
32
33 /**
34 * @param context
35 */
36 public AnnotationDecorator(WebAppContext context)
37 {
38 _introspector.registerHandler(new ResourceAnnotationHandler(context));
39 _introspector.registerHandler(new ResourcesAnnotationHandler(context));
40 _introspector.registerHandler(new RunAsAnnotationHandler(context));
41 _introspector.registerHandler(new PostConstructAnnotationHandler(context));
42 _introspector.registerHandler(new PreDestroyAnnotationHandler(context));
43 _introspector.registerHandler(new DeclareRolesAnnotationHandler(context));
44 _introspector.registerHandler(new MultiPartConfigAnnotationHandler(context));
45 _introspector.registerHandler(new ServletSecurityAnnotationHandler(context));
46 }
47
48 /**
49 * Look for annotations that can be discovered with introspection:
50 * <ul>
51 * <li> Resource
52 * <li> Resources
53 * <li> PostConstruct
54 * <li> PreDestroy
55 * <li> ServletSecurity?
56 * </ul>
57 * @param o
58 */
59 protected void introspect (Object o)
60 {
61 _introspector.introspect(o.getClass());
62 }
63
64 @Override
65 public Object decorate(Object o)
66 {
67 introspect(o);
68 return o;
69 }
70
71 @Override
72 public void destroy(Object o)
73 {
74
75 }
76 }