dsm.removeTouchedSession(session.getId()); session.commit(); if (dsm.getTheContext().getLogger().isDebugEnabled()) { dsm.getTheContext().getLogger().debug(session + ": Committed."); if (dsm.getTheContext().getLogger().isDebugEnabled()) { dsm.getTheContext().getLogger().debug(session + ": Not valid so not committing.");
/** * Gets the catalina log destination. * * @param ctx the ctx * @param application the application * @return the catalina log destination */ private LogDestination getCatalinaLogDestination(Context ctx, Application application) { Object log = ctx.getLogger(); if (log != null) { CatalinaLoggerAccessor logAccessor = new CatalinaLoggerAccessor(); logAccessor.setTarget(log); logAccessor.setApplication(application); if (logAccessor.getFile().exists()) { return logAccessor; } } return null; }
/** * Gets the commons log destination. * * @param ctx the ctx * @param application the application * @param logIndex the log index * @return the commons log destination */ private LogDestination getCommonsLogDestination(Context ctx, Application application, String logIndex) { Object contextLogger = ctx.getLogger(); CommonsLoggerAccessor commonsAccessor = new CommonsLoggerAccessor(); commonsAccessor.setTarget(contextLogger); commonsAccessor.setApplication(application); return commonsAccessor.getDestination(logIndex); }
Application application = ApplicationUtils.getApplication(ctx, getContainerWrapper()); ClassLoader cl = ctx.getLoader().getClassLoader(); Object contextLogger = ctx.getLogger(); if (contextLogger != null) { if (contextLogger.getClass().getName().startsWith("org.apache.commons.logging")) {
public class LambdaFunctionHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream inputStream, OutputStream output, Context context) throws IOException { byte serializedSpeechletRequest[] = IOUtils.toByteArray(inputStream); SpeechletRequestEnvelope requestEnvelope = SpeechletRequestEnvelope.fromJson(serializedSpeechletRequest); SpeechletRequest speechletRequest = requestEnvelope.getRequest(); if (speechletRequest instanceof IntentRequest) { IntentRequest ir = (IntentRequest) speechletRequest; String outString = "IntentRequest name: " + ir.getIntent().getName(); context.getLogger().log(outString); output.write(outString.getBytes()); } } }
/** * Set the JNDI name of a DataSource-factory to use for db access * * @param dataSourceName The JNDI name of the DataSource-factory */ public void setDataSourceName(String dataSourceName) { if (dataSourceName == null || "".equals(dataSourceName.trim())) { manager.getContext().getLogger().warn( sm.getString(getStoreName() + ".missingDataSourceName")); return; } this.dataSourceName = dataSourceName; }
/** * Set the JNDI name of a DataSource-factory to use for db access * * @param dataSourceName The JNDI name of the DataSource-factory */ public void setDataSourceName(String dataSourceName) { if (dataSourceName == null || "".equals(dataSourceName.trim())) { manager.getContext().getLogger().warn( sm.getString(getStoreName() + ".missingDataSourceName")); return; } this.dataSourceName = dataSourceName; }
/** * Set the JNDI name of a DataSource-factory to use for db access * * @param dataSourceName The JNDI name of the DataSource-factory */ public void setDataSourceName(String dataSourceName) { if (dataSourceName == null || "".equals(dataSourceName.trim())) { manager.getContext().getLogger().warn( sm.getString(getStoreName() + ".missingDataSourceName")); return; } this.dataSourceName = dataSourceName; }
/** * Release the Filter instance associated with this FilterConfig, * if there is one. */ void release() { if (this.filter != null){ if( System.getSecurityManager() != null) { try{ SecurityUtil.doAsPrivilege("destroy", filter); } catch(java.lang.Exception ex){ context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex); } SecurityUtil.remove(filter); } else { filter.destroy(); } } this.filter = null; }
/** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged * @param t Associated exception */ protected void log(String message, Throwable t) { message = neutralizeForLog(message); org.apache.catalina.Logger logger = context.getLogger(); if (logger != null) { logger.log("Authenticator[" + context.getPath() + "]: " + message, t, org.apache.catalina.Logger.WARNING); } else { String msg = MessageFormat.format(rb.getString(LogFacade.AUTHENTICATOR_INFO), new Object[] {context.getPath(), message}); log.log(Level.WARNING, msg, t); } }
/** * Log a message on the Logger associated with our Container (if any). * * @param message Message to be logged */ protected void log(String message) { message = neutralizeForLog(message); org.apache.catalina.Logger logger = context.getLogger(); if (logger != null) { logger.log("Authenticator[" + context.getPath() + "]: " + message); } else { if (log.isLoggable(Level.INFO)) { log.log(Level.INFO, LogFacade.AUTHENTICATOR_INFO, new Object[] {context.getPath(), message}); } } }
/** * Remove the Session with the specified session identifier from * this Store, if present. If no such Session is present, this method * takes no action. * * @param id Session identifier of the Session to be removed * * @exception IOException if an input/output error occurs */ @Override public void remove(String id) throws IOException { File file = file(id); if (file == null) { return; } if (manager.getContext().getLogger().isDebugEnabled()) { manager.getContext().getLogger().debug(sm.getString(getStoreName() + ".removing", id, file.getAbsolutePath())); } if (file.exists() && !file.delete()) { throw new IOException(sm.getString("fileStore.deleteSessionFailed", file)); } }
/** * Save the specified Session into this Store. Any previously saved * information for the associated session identifier is replaced. * * @param session Session to be saved * * @exception IOException if an input/output error occurs */ @Override public void save(Session session) throws IOException { // Open an output stream to the specified pathname, if any File file = file(session.getIdInternal()); if (file == null) { return; } if (manager.getContext().getLogger().isDebugEnabled()) { manager.getContext().getLogger().debug(sm.getString(getStoreName() + ".saving", session.getIdInternal(), file.getAbsolutePath())); } try (FileOutputStream fos = new FileOutputStream(file.getAbsolutePath()); ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(fos))) { ((StandardSession)session).writeObjectData(oos); } }
/** * Remove the Session with the specified session identifier from * this Store, if present. If no such Session is present, this method * takes no action. * * @param id Session identifier of the Session to be removed * * @exception IOException if an input/output error occurs */ @Override public void remove(String id) throws IOException { File file = file(id); if (file == null) { return; } if (manager.getContext().getLogger().isDebugEnabled()) { manager.getContext().getLogger().debug(sm.getString(getStoreName()+".removing", id, file.getAbsolutePath())); } file.delete(); }
/** * Check the connection associated with this store, if it's * <code>null</code> or closed try to reopen it. * Returns <code>null</code> if the connection could not be established. * * @return <code>Connection</code> if the connection succeeded */ protected Connection getConnection() { Connection conn = null; try { conn = open(); if (conn == null || conn.isClosed()) { manager.getContext().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBClosed")); conn = open(); if (conn == null || conn.isClosed()) { manager.getContext().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBReOpenFail")); } } } catch (SQLException ex) { manager.getContext().getLogger().error(sm.getString(getStoreName() + ".checkConnectionSQLException", ex.toString())); } return conn; }
/** * Check the connection associated with this store, if it's * <code>null</code> or closed try to reopen it. * Returns <code>null</code> if the connection could not be established. * * @return <code>Connection</code> if the connection succeeded */ protected Connection getConnection() { Connection conn = null; try { conn = open(); if (conn == null || conn.isClosed()) { manager.getContext().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBClosed")); conn = open(); if (conn == null || conn.isClosed()) { manager.getContext().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBReOpenFail")); } } } catch (SQLException ex) { manager.getContext().getLogger().error(sm.getString(getStoreName() + ".checkConnectionSQLException", ex.toString())); } return conn; }
/** * Attempt to load a class using the given Container's class loader. If the * class cannot be loaded, a debug level log message will be written to the * Container's log and null will be returned. * @param context The class loader of this context will be used to attempt * to load the class * @param className The class name * @return the loaded class or <code>null</code> if loading failed */ public static Class<?> loadClass(Context context, String className) { ClassLoader cl = context.getLoader().getClassLoader(); Log log = context.getLogger(); Class<?> clazz = null; try { clazz = cl.loadClass(className); } catch (ClassNotFoundException | NoClassDefFoundError | ClassFormatError e) { log.debug(sm.getString("introspection.classLoadFailed", className), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.debug(sm.getString("introspection.classLoadFailed", className), t); } return clazz; }
public DefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, org.apache.catalina.Context catalinaContext, ClassLoader containerClassLoader) { classLoader = catalinaContext.getLoader().getClassLoader(); privileged = catalinaContext.getPrivileged(); this.containerClassLoader = containerClassLoader; ignoreAnnotations = catalinaContext.getIgnoreAnnotations(); Log log = catalinaContext.getLogger(); Set<String> classNames = new HashSet<>(); loadProperties(classNames, "org/apache/catalina/core/RestrictedServlets.properties", "defaultInstanceManager.restrictedServletsResource", log); loadProperties(classNames, "org/apache/catalina/core/RestrictedListeners.properties", "defaultInstanceManager.restrictedListenersResource", log); loadProperties(classNames, "org/apache/catalina/core/RestrictedFilters.properties", "defaultInstanceManager.restrictedFiltersResource", log); restrictedClasses = Collections.unmodifiableSet(classNames); this.context = context; this.injectionMap = injectionMap; this.postConstructMethods = catalinaContext.findPostConstructMethods(); this.preDestroyMethods = catalinaContext.findPreDestroyMethods(); }
/** * Perform the internal processing required to passivate * this session. */ public void passivate() { // Notify interested session event listeners fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null); // Notify ActivationListeners HttpSessionEvent event = null; String keys[] = keys(); for (int i = 0; i < keys.length; i++) { Object attribute = attributes.get(keys[i]); if (attribute instanceof HttpSessionActivationListener) { if (event == null) event = new HttpSessionEvent(getSession()); try { ((HttpSessionActivationListener)attribute) .sessionWillPassivate(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); manager.getContext().getLogger().error (sm.getString("standardSession.attributeEvent"), t); } } } }
/** * Attempt to load a class using the given Container's class loader. If the * class cannot be loaded, a debug level log message will be written to the * Container's log and null will be returned. */ public static Class<?> loadClass(Context context, String className) { ClassLoader cl = context.getLoader().getClassLoader(); Log log = context.getLogger(); Class<?> clazz = null; try { clazz = cl.loadClass(className); } catch (ClassNotFoundException e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (NoClassDefFoundError e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (ClassFormatError e) { log.debug(sm.getString("introspection.classLoadFailed"), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.debug(sm.getString("introspection.classLoadFailed"), t); } return clazz; }