View | Details | Raw Unified | Return to bug 54450
Collapse All | Expand All

(-)java/org/apache/catalina/core/DefaultInstanceManager.java (-2 / +2 lines)
Lines 349-357 Link Here
349
                                annotations.add(new AnnotationCacheEntry(
349
                                annotations.add(new AnnotationCacheEntry(
350
                                        method.getName(),
350
                                        method.getName(),
351
                                        method.getParameterTypes(),
351
                                        method.getParameterTypes(),
352
                                        injections.get(method.getName()),
352
                                        injections.get(fieldName),
353
                                        AnnotationCacheEntryType.SETTER));
353
                                        AnnotationCacheEntryType.SETTER));
354
                                break;
354
                                continue;
355
                            }
355
                            }
356
                        }
356
                        }
357
                        if (method.isAnnotationPresent(Resource.class)) {
357
                        if (method.isAnnotationPresent(Resource.class)) {
(-)test/org/apache/catalina/startup/TestContextConfig.java (+20 lines)
Lines 126-131 Link Here
126
        assertPageContains("/test/testServlet", "postConstruct1()");
126
        assertPageContains("/test/testServlet", "postConstruct1()");
127
    }
127
    }
128
128
129
    @Test
130
    public void testBug54448() throws Exception {
131
        Tomcat tomcat = getTomcatInstance();
132
133
        File appDir = new File("test/webapp-3.0-fragments");
134
        Context context = tomcat.addWebapp(null, "/test",
135
                appDir.getAbsolutePath());
136
137
        Tomcat.addServlet(context, "TestServlet",
138
                "org.apache.catalina.startup.TesterServletWithAnnotations");
139
        context.addServletMapping("/testServlet", "TestServlet");
140
141
        tomcat.enableNaming();
142
143
        tomcat.start();
144
145
        assertPageContains("/test/testServlet",
146
                "envEntry: 1 envEntry1: 2 envEntry2: 33 envEntry3: 4");
147
    }
148
129
    private static class CustomDefaultServletSCI
149
    private static class CustomDefaultServletSCI
130
            implements ServletContainerInitializer {
150
            implements ServletContainerInitializer {
131
151
(-)test/webapp-3.0-fragments/WEB-INF/web.xml (+19 lines)
Lines 57-60 Link Here
57
    <lifecycle-callback-class>org.apache.catalina.startup.TesterServletWithLifeCycleMethods</lifecycle-callback-class>
57
    <lifecycle-callback-class>org.apache.catalina.startup.TesterServletWithLifeCycleMethods</lifecycle-callback-class>
58
    <lifecycle-callback-method>preDestroy1</lifecycle-callback-method>
58
    <lifecycle-callback-method>preDestroy1</lifecycle-callback-method>
59
  </pre-destroy>
59
  </pre-destroy>
60
61
  <env-entry>
62
    <env-entry-name>envEntry1</env-entry-name>
63
    <env-entry-type>java.lang.Integer</env-entry-type>
64
    <env-entry-value>2</env-entry-value>
65
    <injection-target>
66
      <injection-target-class>org.apache.catalina.startup.TesterServletWithAnnotations</injection-target-class>
67
      <injection-target-name>envEntry1</injection-target-name>
68
    </injection-target>
69
  </env-entry>
70
  <env-entry>
71
    <env-entry-name>envEntry2</env-entry-name>
72
    <env-entry-type>java.lang.Integer</env-entry-type>
73
    <env-entry-value>33</env-entry-value>
74
    <injection-target>
75
      <injection-target-class>org.apache.catalina.startup.TesterServletWithAnnotations</injection-target-class>
76
      <injection-target-name>envEntry2</injection-target-name>
77
    </injection-target>
78
  </env-entry>
60
</web-app>
79
</web-app>
(-)test/org/apache/catalina/startup/TesterServletWithAnnotations.java (+66 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
package org.apache.catalina.startup;
19
20
import java.io.IOException;
21
22
import javax.annotation.Resource;
23
import javax.servlet.ServletException;
24
import javax.servlet.http.HttpServlet;
25
import javax.servlet.http.HttpServletRequest;
26
import javax.servlet.http.HttpServletResponse;
27
28
public class TesterServletWithAnnotations extends HttpServlet {
29
30
    private static final long serialVersionUID = 1L;
31
32
    @Resource(mappedName = "1")
33
    private int envEntry;
34
35
    private int envEntry1;
36
37
    private int envEntry2;
38
39
    private int envEntry3;
40
41
    @Override
42
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
43
            throws ServletException, IOException {
44
        resp.setContentType("text/plain");
45
        resp.getWriter().print("envEntry: " + envEntry);
46
        resp.getWriter().print(" envEntry1: " + envEntry1);
47
        resp.getWriter().print(" envEntry2: " + envEntry2);
48
        resp.getWriter().print(" envEntry3: " + envEntry3);
49
    }
50
51
    public void setEnvEntry1(int envEntry1) {
52
        this.envEntry1 = envEntry1;
53
    }
54
55
    @Resource(mappedName = "3")
56
    public void setEnvEntry2(int envEntry2) {
57
        this.envEntry2 = envEntry2;
58
    }
59
60
    @Resource(mappedName = "4")
61
    public void setEnvEntry3(int envEntry3) {
62
        this.envEntry3 = envEntry3;
63
    }
64
65
}
66
native

Return to bug 54450