Refine search
public void begin(InterpretationContext ec, String name, Attributes attributes) { inError = false; LoggerContext loggerContext = (LoggerContext) this.context; root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); String levelStr = ec.subst(attributes.getValue(ActionConst.LEVEL_ATTRIBUTE)); if (!OptionHelper.isEmpty(levelStr)) { Level level = Level.toLevel(levelStr); addInfo("Setting level of ROOT logger to " + level); root.setLevel(level); } ec.pushObject(root); }
@Override public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException { inError = false; String className = attributes.getValue(CLASS_ATTRIBUTE); if (OptionHelper.isEmpty(className)) { addError("Mandatory \"" + CLASS_ATTRIBUTE + "\" attribute not set for <loggerContextListener> element"); inError = true; return; } try { lcl = (LoggerContextListener) OptionHelper.instantiateByClassName(className, LoggerContextListener.class, context); if (lcl instanceof ContextAware) { ((ContextAware) lcl).setContext(context); } ec.pushObject(lcl); addInfo("Adding LoggerContextListener of type [" + className + "] to the object stack"); } catch (Exception oops) { inError = true; addError("Could not create LoggerContextListener of type " + className + "].", oops); } }
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) { if (this.environment == null) { return false; } String[] profileNames = StringUtils.trimArrayElements(StringUtils .commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE))); if (profileNames.length == 0) { return false; } for (int i = 0; i < profileNames.length; i++) { profileNames[i] = OptionHelper.substVars(profileNames[i], ic, this.context); } return this.environment.acceptsProfiles(Profiles.of(profileNames)); }
/** * Search for value of DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY in the web-app first, then as a system property and * as an environment variable last. * * @param ctx * @return True if value of DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY is available and set to "true", false otherwise. */ boolean isDisabledByConfiguration(ServletContext ctx) { String disableAttributeStr = null; Object disableAttribute = ctx.getInitParameter(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); if (disableAttribute instanceof String) { disableAttributeStr = (String) disableAttribute; } if (OptionHelper.isEmpty(disableAttributeStr)) { disableAttributeStr = OptionHelper.getSystemProperty(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); } if (OptionHelper.isEmpty(disableAttributeStr)) { disableAttributeStr = OptionHelper.getEnv(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); } if (OptionHelper.isEmpty(disableAttributeStr)) return false; return disableAttributeStr.equalsIgnoreCase("true"); }
@Override public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException { SaxEventRecorder recorder = new SaxEventRecorder(context); this.attributeInUse = null; this.optional = OptionHelper.toBoolean(attributes.getValue(OPTIONAL_ATTR), false); if (!checkAttributes(attributes)) { return; } InputStream in = getInputStream(ec, attributes); try { if (in != null) { parseAndRecord(in, recorder); // remove the <included> tag from the beginning and </included> from the end trimHeadAndTail(recorder); // offset = 2, because we need to get past this element as well as the end element ec.getJoranInterpreter().getEventPlayer().addEventsDynamically(recorder.saxEventList, 2); } } catch (JoranException e) { addError("Error while parsing " + attributeInUse, e); } finally { close(in); } }
public void begin(InterpretationContext ec, String name, Attributes attributes) { String envEntryName = ec.subst(attributes.getValue(ENV_ENTRY_NAME_ATTR)); String asKey = ec.subst(attributes.getValue(AS_ATTR)); String scopeStr = attributes.getValue(SCOPE_ATTRIBUTE); Scope scope = ActionUtil.stringToScope(scopeStr); if (OptionHelper.isEmpty(envEntryName)) { String lineColStr = getLineColStr(ec); addError("[" + ENV_ENTRY_NAME_ATTR + "] missing, around " + lineColStr); if (OptionHelper.isEmpty(asKey)) { String lineColStr = getLineColStr(ec); addError("[" + AS_ATTR + "] missing, around " + lineColStr); Context ctx = JNDIUtil.getInitialContext(); envEntryValue = JNDIUtil.lookup(ctx, envEntryName); if (OptionHelper.isEmpty(envEntryValue)) { addError("[" + envEntryName + "] has null or empty value"); } else {
@Override public void begin(InterpretationContext context, String elementName, Attributes attributes) throws ActionException { String name = attributes.getValue(NAME_ATTRIBUTE); String source = attributes.getValue(SOURCE_ATTRIBUTE); Scope scope = ActionUtil.stringToScope(attributes.getValue(SCOPE_ATTRIBUTE)); String defaultValue = attributes.getValue(DEFAULT_VALUE_ATTRIBUTE); if (OptionHelper.isEmpty(name) || OptionHelper.isEmpty(source)) { addError( "The \"name\" and \"source\" attributes of <springProperty> must be set"); } ActionUtil.setProperty(context, name, getValue(source, defaultValue), scope); }
ic.pushObject(this); if(!EnvUtil.isJaninoAvailable()) { addError(MISSING_JANINO_MSG); String conditionAttribute = attributes.getValue(CONDITION_ATTR); if (!OptionHelper.isEmpty(conditionAttribute)) { conditionAttribute = OptionHelper.substVars(conditionAttribute, ic, context); PropertyEvalScriptBuilder pesb = new PropertyEvalScriptBuilder(ic); pesb.setContext(context);
@Override public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException { this.attributeInUse = null; this.optional = OptionHelper.toBoolean(attributes.getValue(OPTIONAL_ATTR), false); if (!checkAttributes(attributes)) { return; } try { URL url = getInputURL(ec, attributes); if (url != null) { processInclude(ec, url); } } catch (JoranException e) { optionalWarning("Error while parsing " + attributeInUse, e); } }
static public void setProperty(InterpretationContext ic, String key, String value, Scope scope) { switch (scope) { case LOCAL: ic.addSubstitutionProperty(key, value); break; case CONTEXT: ic.getContext().putProperty(key, value); break; case SYSTEM: OptionHelper.setSystemProperty(ic, key, value); } }
/** * Add all the properties found in the argument named 'props' to an * InterpretationContext. */ static public void setProperties(InterpretationContext ic, Properties props, Scope scope) { switch (scope) { case LOCAL: ic.addSubstitutionProperties(props); break; case CONTEXT: ContextUtil cu = new ContextUtil(ic.getContext()); cu.addProperties(props); break; case SYSTEM: OptionHelper.setSystemProperties(ic, props); } }
public static String propertyLookup(String key, PropertyContainer pc1, PropertyContainer pc2) { String value = null; // first try the props passed as parameter value = pc1.getProperty(key); // then try the pc2 if (value == null && pc2 != null) { value = pc2.getProperty(key); } // then try in System properties if (value == null) { value = getSystemProperty(key, null); } if (value == null) { value = getEnv(key); } return value; }
private Appender<ILoggingEvent> consoleAppender(LogbackConfigurator config) { ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>(); PatternLayoutEncoder encoder = new PatternLayoutEncoder(); String logPattern = this.patterns.getProperty("logging.pattern.console", CONSOLE_LOG_PATTERN); encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext())); config.start(encoder); appender.setEncoder(encoder); config.appender("CONSOLE", appender); return appender; }
static void installIfAsked(LoggerContext loggerContext) { String slClass = OptionHelper.getSystemProperty( ContextInitializer.STATUS_LISTENER_CLASS); if (!OptionHelper.isEmpty(slClass)) { addStatusListener(loggerContext, slClass); } }
private static StatusListener createListenerPerClassName(LoggerContext loggerContext, String listenerClass) { try { return (StatusListener) OptionHelper.instantiateByClassName( listenerClass, StatusListener.class, loggerContext); } catch (Exception e) { // printing on the console is the best we can do e.printStackTrace(); return null; } } }
private Session buildSessionFromProperties() { Properties props = new Properties(OptionHelper.getSystemProperties()); if (smtpHost != null) { props.put("mail.smtp.host", smtpHost);
public static Object instantiateByClassName(String className, Class<?> superClass, ClassLoader classLoader) throws IncompatibleClassException, DynamicClassLoadingException { return instantiateByClassNameAndParameter(className, superClass, classLoader, null, null); }
private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) { String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY); if (logbackConfigFile != null) { URL result = null; try { result = new URL(logbackConfigFile); return result; } catch (MalformedURLException e) { // so, resource is not a URL: // attempt to get the resource from the class path result = Loader.getResource(logbackConfigFile, classLoader); if (result != null) { return result; } File f = new File(logbackConfigFile); if (f.exists() && f.isFile()) { try { result = f.toURI().toURL(); return result; } catch (MalformedURLException e1) { } } } finally { if (updateStatus) { statusOnResourceSearch(logbackConfigFile, classLoader, result); } } } return null; }
public static void setSystemProperties(ContextAware contextAware, Properties props) { for (Object o : props.keySet()) { String key = (String) o; String value = props.getProperty(key); setSystemProperty(contextAware, key, value); } }