org.apache.catalina.deploy.ApplicationListener Java Examples

The following examples show how to use org.apache.catalina.deploy.ApplicationListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestWebSocket.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoUpgrade() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an error response
    // No upgrade means it is not treated an as upgrade request so a 404 is
    // generated when the request reaches the Default Servlet.s
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 404"));

    // Finished with the socket
    client.close();
}
 
Example #2
Source File: TestWebSocket.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoConnection() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an error response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 400"));

    // Finished with the socket
    client.close();
}
 
Example #3
Source File: TestWebSocket.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoUpgrade() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an error response
    // No upgrade means it is not treated an as upgrade request so a 404 is
    // generated when the request reaches the Default Servlet.s
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 404"));

    // Finished with the socket
    client.close();
}
 
Example #4
Source File: TestWebSocket.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoConnection() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an error response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 400"));

    // Finished with the socket
    client.close();
}
 
Example #5
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void addApplicationListener(ApplicationListener listener) { /* NO-OP */ }
 
Example #6
Source File: Runner.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
private Context makeContext(Tomcat tomcat, File noSuchBaseDir, int port) throws IOException {

    File contextPath = new File(noSuchBaseDir, "context");
    if (!contextPath.mkdirs()) {
      throw new IOException("Could not create " + contextPath);
    }

    String contextPathURIBase = config.getContextPath();
    Context context = 
        tomcat.addContext(contextPathURIBase == null ? "" : contextPathURIBase, contextPath.getAbsolutePath());
    context.addApplicationListener(new ApplicationListener(InitListener.class.getName(), false));
    context.setWebappVersion("3.0");
    context.addWelcomeFile("index.jspx");
    addErrorPages(context);

    ServletContext servletContext = context.getServletContext();
    servletContext.setAttribute(InitListener.INSTANCE_ID_KEY, config.getInstanceID());
    servletContext.setAttribute(InitListener.BUCKET_KEY, config.getBucket());
    servletContext.setAttribute(InitListener.RESCORER_PROVIDER_CLASS_KEY, config.getRescorerProviderClassName());
    servletContext.setAttribute(InitListener.CLIENT_THREAD_CLASS_KEY, config.getClientThreadClassName());    
    servletContext.setAttribute(InitListener.LOCAL_INPUT_DIR_KEY, config.getLocalInputDir());
    servletContext.setAttribute(InitListener.PORT_KEY, port);
    servletContext.setAttribute(InitListener.READ_ONLY_KEY, config.isReadOnly());
    servletContext.setAttribute(InitListener.ALL_PARTITIONS_SPEC_KEY, config.getAllPartitionsSpecification());
    servletContext.setAttribute(InitListener.PARTITION_KEY, config.getPartition());

    boolean needHTTPS = config.getKeystoreFile() != null;
    boolean needAuthentication = config.getUserName() != null;

    if (needHTTPS || needAuthentication) {

      SecurityCollection securityCollection = new SecurityCollection("Protected Resources");
      if (config.isConsoleOnlyPassword()) {
        securityCollection.addPattern("/index.jspx");
      } else {
        securityCollection.addPattern("/*");
      }
      SecurityConstraint securityConstraint = new SecurityConstraint();
      securityConstraint.addCollection(securityCollection);

      if (needHTTPS) {
        securityConstraint.setUserConstraint("CONFIDENTIAL");
      }

      if (needAuthentication) {

        LoginConfig loginConfig = new LoginConfig();
        loginConfig.setAuthMethod("DIGEST");
        loginConfig.setRealmName(InMemoryRealm.NAME);
        context.setLoginConfig(loginConfig);

        securityConstraint.addAuthRole(InMemoryRealm.AUTH_ROLE);

        context.addSecurityRole(InMemoryRealm.AUTH_ROLE);
        DigestAuthenticator authenticator = new DigestAuthenticator();
        authenticator.setNonceValidity(10 * 1000L); // Shorten from 5 minutes to 10 seconds
        authenticator.setNonceCacheSize(20000); // Increase from 1000 to 20000
        context.getPipeline().addValve(authenticator);
      }

      context.addConstraint(securityConstraint);
    }

    context.setCookies(false);

    return context;
  }
 
Example #7
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void addApplicationListener(ApplicationListener listener) {
    // NO-OP
}
 
Example #8
Source File: TestWebSocket.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testKey() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 101"));

    String accept = null;
    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        if(responseHeaderLine.startsWith("Sec-WebSocket-Accept: ")) {
            accept = responseHeaderLine.substring(responseHeaderLine.indexOf(':')+2);
            break;
        }
        responseHeaderLine = client.reader.readLine();
    }
    assertTrue(accept != null);
    MessageDigest sha1Helper = MessageDigest.getInstance("SHA1");
    sha1Helper.reset();
    sha1Helper.update("TODO".getBytes(B2CConverter.ISO_8859_1));
    String source = Base64.encode(sha1Helper.digest(WS_ACCEPT));
    assertEquals(source,accept);

    sha1Helper.reset();
    sha1Helper.update("TOD".getBytes(B2CConverter.ISO_8859_1));
    source = Base64.encode(sha1Helper.digest(WS_ACCEPT));
    assertFalse(source.equals(accept));
    // Finished with the socket
    client.close();
}
 
Example #9
Source File: TestWebSocket.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testDetectWrongVersion() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 8" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 426"));

    List<String> headerlines = new ArrayList<String>();

    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        headerlines.add(responseHeaderLine);
        responseHeaderLine = client.reader.readLine();
    }

    assertTrue(headerlines.contains("Sec-WebSocket-Version: 13"));
    // Finished with the socket
    client.close();
}
 
Example #10
Source File: TestWebSocket.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testSimple() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client = new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: keep-alive, upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 101"));

    // Swallow the headers
    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        responseHeaderLine = client.reader.readLine();
    }

    // Now we can do WebSocket
    client.sendMessage("foo", false);
    client.sendMessage("foo", true);

    assertEquals("foofoo", client.readMessage());

    // Finished with the socket
    client.close();
}
 
Example #11
Source File: TldConfig.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Scan for and configure all tag library descriptors found in this
 * web application.
 * 
 * This supports a Tomcat-specific extension to the TLD search
 * order defined in the JSP spec. It allows tag libraries packaged as JAR
 * files to be shared by web applications by simply dropping them in a 
 * location that all web applications have access to (e.g.,
 * <CATALINA_HOME>/lib). It also supports some of the weird and
 * wonderful arrangements present when Tomcat gets embedded.
 *
 * The set of shared JARs to be scanned for TLDs is narrowed down by
 * the <tt>noTldJars</tt> class variable, which contains the names of JARs
 * that are known not to contain any TLDs.
 */
@SuppressWarnings("deprecation") // Context.addApplicationListener(ApplicationListener) is deprecated.
public void execute() {
    long t1=System.currentTimeMillis();

    /*
     * Priority order of URIs required by spec is:
     * 1. J2EE platform taglibs - Tomcat doesn't provide these
     * 2. web.xml entries
     * 3. JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority)
     * 4. Additional entries from the container
     * 
     * Keep processing order in sync with o.a.j.compiler.TldLocationsCache
     */
    
    // Stage 2 - web.xml entries
    tldScanWebXml();
    
    // Stage 3a - TLDs under WEB-INF (not lib or classes)
    tldScanResourcePaths(WEB_INF);

    // Stages 3b & 4
    JarScanner jarScanner = context.getJarScanner();
    
    TldJarScannerCallback tldCallBack = new TldJarScannerCallback();
    jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(),
            tldCallBack, noTldJars);
    if(tldCallBack.scanFoundNoTLDs()){
        log.info(sm.getString("tldConfig.noTldSummary"));
    }
    // Now add all the listeners we found to the listeners for this context
    String list[] = getTldListeners();

    if( log.isDebugEnabled() )
        log.debug(sm.getString("tldConfig.addListeners",
                Integer.valueOf(list.length)));

    for( int i=0; i<list.length; i++ ) {
        context.addApplicationListener(
                new ApplicationListener(list[i], true));
    }

    long t2=System.currentTimeMillis();
    if( context instanceof StandardContext ) {
        ((StandardContext)context).setTldScanTime(t2-t1);
    }

}
 
Example #12
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void addApplicationListener(ApplicationListener listener) { /* NO-OP */ }
 
Example #13
Source File: TesterContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void addApplicationListener(ApplicationListener listener) {
    // NO-OP
}
 
Example #14
Source File: TestWebSocket.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testKey() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 101"));

    String accept = null;
    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        if(responseHeaderLine.startsWith("Sec-WebSocket-Accept: ")) {
            accept = responseHeaderLine.substring(responseHeaderLine.indexOf(':')+2);
            break;
        }
        responseHeaderLine = client.reader.readLine();
    }
    assertTrue(accept != null);
    MessageDigest sha1Helper = MessageDigest.getInstance("SHA1");
    sha1Helper.reset();
    sha1Helper.update("TODO".getBytes(B2CConverter.ISO_8859_1));
    String source = Base64.encode(sha1Helper.digest(WS_ACCEPT));
    assertEquals(source,accept);

    sha1Helper.reset();
    sha1Helper.update("TOD".getBytes(B2CConverter.ISO_8859_1));
    source = Base64.encode(sha1Helper.digest(WS_ACCEPT));
    assertFalse(source.equals(accept));
    // Finished with the socket
    client.close();
}
 
Example #15
Source File: TestWebSocket.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testDetectWrongVersion() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client= new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 8" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 426"));

    List<String> headerlines = new ArrayList<String>();

    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        headerlines.add(responseHeaderLine);
        responseHeaderLine = client.reader.readLine();
    }

    assertTrue(headerlines.contains("Sec-WebSocket-Version: 13"));
    // Finished with the socket
    client.close();
}
 
Example #16
Source File: TestWebSocket.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testSimple() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addApplicationListener(new ApplicationListener(
            TesterEchoServer.Config.class.getName(), false));

    Tomcat.addServlet(ctx, "default", new DefaultServlet());
    ctx.addServletMapping("/", "default");

    tomcat.start();

    WebSocketClient client = new WebSocketClient(getPort());

    // Send the WebSocket handshake
    client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
    client.writer.write("Host: foo" + CRLF);
    client.writer.write("Upgrade: websocket" + CRLF);
    client.writer.write("Connection: keep-alive, upgrade" + CRLF);
    client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
    client.writer.write("Sec-WebSocket-Key: TODO" + CRLF);
    client.writer.write(CRLF);
    client.writer.flush();

    // Make sure we got an upgrade response
    String responseLine = client.reader.readLine();
    assertTrue(responseLine.startsWith("HTTP/1.1 101"));

    // Swallow the headers
    String responseHeaderLine = client.reader.readLine();
    while (!responseHeaderLine.equals("")) {
        responseHeaderLine = client.reader.readLine();
    }

    // Now we can do WebSocket
    client.sendMessage("foo", false);
    client.sendMessage("foo", true);

    assertEquals("foofoo", client.readMessage());

    // Finished with the socket
    client.close();
}
 
Example #17
Source File: TldConfig.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Scan for and configure all tag library descriptors found in this
 * web application.
 * 
 * This supports a Tomcat-specific extension to the TLD search
 * order defined in the JSP spec. It allows tag libraries packaged as JAR
 * files to be shared by web applications by simply dropping them in a 
 * location that all web applications have access to (e.g.,
 * <CATALINA_HOME>/lib). It also supports some of the weird and
 * wonderful arrangements present when Tomcat gets embedded.
 *
 * The set of shared JARs to be scanned for TLDs is narrowed down by
 * the <tt>noTldJars</tt> class variable, which contains the names of JARs
 * that are known not to contain any TLDs.
 */
@SuppressWarnings("deprecation") // Context.addApplicationListener(ApplicationListener) is deprecated.
public void execute() {
    long t1=System.currentTimeMillis();

    /*
     * Priority order of URIs required by spec is:
     * 1. J2EE platform taglibs - Tomcat doesn't provide these
     * 2. web.xml entries
     * 3. JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority)
     * 4. Additional entries from the container
     * 
     * Keep processing order in sync with o.a.j.compiler.TldLocationsCache
     */
    
    // Stage 2 - web.xml entries
    tldScanWebXml();
    
    // Stage 3a - TLDs under WEB-INF (not lib or classes)
    tldScanResourcePaths(WEB_INF);

    // Stages 3b & 4
    JarScanner jarScanner = context.getJarScanner();
    
    TldJarScannerCallback tldCallBack = new TldJarScannerCallback();
    jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(),
            tldCallBack, noTldJars);
    if(tldCallBack.scanFoundNoTLDs()){
        log.info(sm.getString("tldConfig.noTldSummary"));
    }
    // Now add all the listeners we found to the listeners for this context
    String list[] = getTldListeners();

    if( log.isDebugEnabled() )
        log.debug(sm.getString("tldConfig.addListeners",
                Integer.valueOf(list.length)));

    for( int i=0; list!=null && i<list.length; i++ ) {
        context.addApplicationListener(
                new ApplicationListener(list[i], true));
    }

    long t2=System.currentTimeMillis();
    if( context instanceof StandardContext ) {
        ((StandardContext)context).setTldScanTime(t2-t1);
    }

}
 
Example #18
Source File: Context.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * Add a new Listener class name to the set of Listeners configured for this
 * application.
 *
 * <p>
 * The {@link ApplicationListener} class is used to pass an additional
 * parameter that allows to differentiate listeners to Web Application added
 * via configuration (web.xml or annotations) vs. ones added by frameworks,
 * such as listeners declared in JSP tag libraries (TLD files) that are
 * added by Jasper JSP Engine.
 *
 * <p>
 * The recommended method to call for the first use case is
 * {@link #addApplicationListener(String)}. The recommended replacement for
 * the second use case is to use {@code addListener(...)} methods in
 * {@link javax.servlet.ServletContext}.
 *
 * @param listener
 *            Definition of a listener, including its java class name.
 * @deprecated This method is removed from Tomcat 8.0.9 onwards. Use
 *             {@link #addApplicationListener(String)} or
 *             {@link javax.servlet.ServletContext#addListener(String)}.
 */
@Deprecated
public void addApplicationListener(ApplicationListener listener);
 
Example #19
Source File: Context.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * Add a new Listener class name to the set of Listeners configured for this
 * application.
 *
 * <p>
 * The {@link ApplicationListener} class is used to pass an additional
 * parameter that allows to differentiate listeners to Web Application added
 * via configuration (web.xml or annotations) vs. ones added by frameworks,
 * such as listeners declared in JSP tag libraries (TLD files) that are
 * added by Jasper JSP Engine.
 *
 * <p>
 * The recommended method to call for the first use case is
 * {@link #addApplicationListener(String)}. The recommended replacement for
 * the second use case is to use {@code addListener(...)} methods in
 * {@link javax.servlet.ServletContext}.
 *
 * @param listener
 *            Definition of a listener, including its java class name.
 * @deprecated This method is removed from Tomcat 8.0.9 onwards. Use
 *             {@link #addApplicationListener(String)} or
 *             {@link javax.servlet.ServletContext#addListener(String)}.
 */
@Deprecated
public void addApplicationListener(ApplicationListener listener);