APISonar


javax.servlet.ServletContext.log

> javax > servlet > ServletContext > log
javax APIs servlet APIs ServletContext APIs log APIs

Example 1
private ServletContext m_impl;

    public void log(String arg0)
    {
        m_impl.log(arg0);
    }
Example 2
protected ServletContext context;

    public void log(String message, Throwable throwable) {
        //We can't assume that Servlet.log( message, null )
        //is the same as Servlet.log( message ), since API
        //doesn't seem to say so.
        if (throwable != null) {
            context.log(message, throwable);
        } else {
            context.log(message);
        }
    }
Example 3
private ServletContext context = null;

    private void log(String message) {

	if (context != null)
	    context.log("ContextListener: " + message);
	else
	    System.out.println("ContextListener: " + message);

    }
Example 4
private final ServletContext realContext;

  public void log(Exception exception, String msg) {
    if (shouldLog(exception, msg)) {
      realContext.log(exception, msg);
    }
  }
Example 5
private final ServletContext realContext;

  public void log(String msg, Throwable throwable) {
    if (shouldLog(throwable, msg)) {
      realContext.log(msg, throwable);
    }
  }
Example 6
private final ServletContext context;

  public void publish(LogRecord record) {
    Formatter formatter = getFormatter();
    String message;
    if (formatter == null) {
      message = record.getMessage();
    } else {
      message = formatter.format(record);
    }
    Throwable throwable = record.getThrown();
    if (throwable == null) {
      context.log(message);
    } else {
      context.log(message, throwable);
    }
  }
Example 7
private ServletContext _servletContext;

    public void log(final String message, final Throwable exception)
    {
        checkNull(message, "message");
        checkNull(exception, "exception");
        _servletContext.log(message, exception);
    }
Example 8
ServletContext _context;

    private void debug(String string, Throwable th)
    {
        if (_debug)
        {
            if (th instanceof ContinuationThrowable)
                _context.log(string+":"+th);
            else
                _context.log(string,th);
        }
    }
Example 9
private final ServletContext ctx;

  protected void doLog(int indexOfLogEntryWithinParentLogger, Type type,
      String msg, Throwable caught, HelpInfo helpInfo) {
    if (caught != null) {
      ctx.log(msg, caught);
    } else {
      ctx.log(msg);
    }
  }
Example 10
private ServletContext sc = null;

    public void myPreDestroy() {
        sc.log("contextDestroyed");
        try {
            FileOutputStream fos = new FileOutputStream("/tmp/mytest");
            OutputStreamWriter osw = new OutputStreamWriter(fos);
            osw.write("SUCCESS");
            osw.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Example 11
public void contextInitialized(ServletContextEvent event) {
        ServletContext context = event.getServletContext();
        context.log("Creating ActiveMQ Broker...");
        brokerContainer = createBroker(context);

        context.log("Starting ActiveMQ Broker");
        try {
            brokerContainer.start();

            context.log("Started ActiveMQ Broker");
        }
        catch (Exception e) {
            context.log("Failed to start ActiveMQ broker: " + e, e);
        }
    }
Example 12
public void requestInitialized(ServletRequestEvent sre) {
        Map<String, String[]> paramMap = sre.getServletRequest().getParameterMap();
        ServletContext servletContext = sre.getServletContext();

        // to see log messages at runtime, check the terminal window where you started JBoss EAP.
        servletContext.log("ParameterDumpingRequestListener: request has been initialized. It has " + paramMap.size()
            + " parameters:");
        for (Map.Entry<String, String[]> entry : paramMap.entrySet()) {
            for (String val : entry.getValue()) {
                servletContext.log("  " + entry.getKey() + "=" + val);
            }
        }
    }
Example 13
private ServletContext context;

    public void saveBytecode(String className, String classFileName) {
        byte[] bytecode = getBytecode(className);
        if (bytecode != null) {
            try {
                FileOutputStream fos = new FileOutputStream(classFileName);
                fos.write(bytecode);
                fos.close();
            } catch (IOException ex) {
                context.log("Error in saving bytecode for " + className +
                    " to " + classFileName, ex);
            }
        }
    }
Example 14
private final ServletContext context;

    int getResampleAlgorithmFromRequest() {
        Object algorithm = originalRequest.getAttribute(ATTRIB_IMAGE_RESAMPLE_ALGORITHM);
        if (algorithm instanceof Integer && ((Integer) algorithm == Image.SCALE_SMOOTH || (Integer) algorithm == Image.SCALE_FAST || (Integer) algorithm == Image.SCALE_DEFAULT)) {
            return (Integer) algorithm;
        }
        else {
            if (algorithm != null) {
                context.log("WARN: Illegal image resampling algorithm: " + algorithm);
            }

            return BufferedImage.SCALE_DEFAULT;
        }
    }
Example 15
protected void doUnexpectedFailure(Throwable e) {
    ServletContext servletContext = getServletContext();
    servletContext.log("Exception while dispatching incoming RPC call", e);

    // Send GENERIC_FAILURE_MSG with 500 status.
    //
    respondWithFailure(getThreadLocalResponse());
  }
Example 16
private void logException(String msg, Exception e,
      HttpServletResponse response) {
    ServletContext servletContext = getServletContext();
    servletContext.log(msg, e);
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
Example 17
private final ServletContext servletContext;

    private static File getRootFile(ServletContext servletContext, String rootPath) {
        String containerRootPath = servletContext.getRealPath(rootPath);
        servletContext.log("rootPath: " + rootPath);
        return new File(containerRootPath);
    }
Example 18
private final ServletContext servletContext;

    public void append(final LogEvent event) {
        final String serialized = ((AbstractStringLayout) getLayout()).toSerializable(event);
        if (logThrowables) {
            servletContext.log(serialized, event.getThrown());
        } else {
            servletContext.log(serialized);
        }
    }
Example 19
protected BrokerService createBroker(ServletContext context) {
        String brokerURI = context.getInitParameter(INIT_PARAM_BROKER_URI);
        if (brokerURI == null) {
            brokerURI = "activemq.xml";
        }
        context.log("Loading ActiveMQ Broker configuration from: " + brokerURI);
        Resource resource = new ServletContextResource(context, brokerURI);
        BrokerFactoryBean factory = new BrokerFactoryBean(resource);
        try {
            factory.afterPropertiesSet();
        } catch (Exception e) {
            context.log("Failed to create broker: " + e, e);
        }
        return factory.getBroker();
    }
Example 20
public void contextDestroyed(ServletContextEvent event) {
        ServletContext context = event.getServletContext();
        if (brokerContainer != null) {
            try {
                brokerContainer.stop();
            } catch (Exception e) {
                context.log("Failed to stop the ActiveMQ Broker: " + e, e);
            }
            brokerContainer = null;
        }
    }
Example 21
public void init(FilterConfig filterConfig) throws ServletException {

        ServletContext sc = filterConfig.getServletContext();
    
        try {

            int loginTimeout = ds1.getLoginTimeout();
            sc.log("ds1-login-timeout=" + loginTimeout);

        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
Example 22
private static ServletContext sc;

  public void contextDestroyed(ServletContextEvent event) {
    // App Engine does not currently invoke this method.
    if (connection == null) {
      return;
    }
    try {
      connection.close();
    } catch (IOException io) {
      if (sc != null) {
        sc.log("contextDestroyed ", io);
      }
    }
    connection = null;
  }
Example 23
private List<Resource> getResource(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext,
                    String locations) {
        List<Resource> resources = new LinkedList<>();
        String[] configFileLocations = locations == null ? DEFAULT_PROFILE_CONFIG_FILE_LOCATIONS : StringUtils
                        .commaDelimitedListToStringArray(locations);
        for (String location : configFileLocations) {
            location = applicationContext.getEnvironment().resolvePlaceholders(location);
            servletContext.log("Testing for YAML resources at: " + location);
            Resource resource = applicationContext.getResource(location);
            if (resource != null && resource.exists()) {
                resources.add(resource);
            }
        }
        return resources;
    }
Example 24
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

        Writer writer = response.getWriter();

        ServletContext servletContext = getServletContext();

        servletContext.log("MyServlet2 doGet ...");

        writer.write("<html><body>Hello,World From MyServlet2</body></html>");

    }
Example 25
public void contextDestroyed(ServletContextEvent event) {
        if (logConfigurators != null && logConfigurators.length > 0) {
            ServletContext servletContext = event.getServletContext();
            servletContext.log("Shutting down log system");

            for (LogConfigurator logConfigurator : logConfigurators) {
                logConfigurator.shutdown();
            }
        }
    }