• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OptionHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.qos.logback.core.util.OptionHelper的典型用法代码示例。如果您正苦于以下问题:Java OptionHelper类的具体用法?Java OptionHelper怎么用?Java OptionHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OptionHelper类属于ch.qos.logback.core.util包,在下文中一共展示了OptionHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: fileAppender

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private Appender<ILoggingEvent> fileAppender(LogbackConfigurator config,
		String logFile) {
	RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<ILoggingEvent>();
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	String logPattern = this.patterns.getProperty("file", FILE_LOG_PATTERN);
	encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext()));
	appender.setEncoder(encoder);
	config.start(encoder);

	appender.setFile(logFile);

	FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
	rollingPolicy.setFileNamePattern(logFile + ".%i");
	appender.setRollingPolicy(rollingPolicy);
	rollingPolicy.setParent(appender);
	config.start(rollingPolicy);

	SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
	triggeringPolicy.setMaxFileSize("10MB");
	appender.setTriggeringPolicy(triggeringPolicy);
	config.start(triggeringPolicy);

	config.appender("FILE", appender);
	return appender;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:26,代码来源:DefaultLogbackConfiguration.java


示例2: createConverter

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
 * Attempt to create a converter using the information found in
 * 'converterMap'.
 *
 * @param kn
 * @return
 */
@SuppressWarnings("unchecked")
DynamicConverter<E> createConverter(SimpleKeywordNode kn) {
  String keyword = (String) kn.getValue();
  String converterClassStr = (String) converterMap.get(keyword);

  if (converterClassStr != null) {
    try {
      return (DynamicConverter) OptionHelper.instantiateByClassName(
              converterClassStr, DynamicConverter.class, context);
    } catch (Exception e) {
      addError("Failed to instantiate converter class [" + converterClassStr
              + "] for keyword ["+keyword+"]", e);
      return null;
    }
  } else {
    addError("There is no conversion class registered for conversion word ["
            + keyword + "]");
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:28,代码来源:Compiler.java


示例3: createCompositeConverter

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
 * Attempt to create a converter using the information found in
 * 'compositeConverterMap'.
 *
 * @param cn
 * @return
 */
@SuppressWarnings("unchecked")
CompositeConverter<E> createCompositeConverter(CompositeNode cn) {
  String keyword = (String) cn.getValue();
  String converterClassStr = (String) converterMap.get(keyword);

  if (converterClassStr != null) {
    try {
      return (CompositeConverter) OptionHelper.instantiateByClassName(
              converterClassStr, CompositeConverter.class, context);
    } catch (Exception e) {
      addError("Failed to instantiate converter class [" + converterClassStr
              + "] as a composite converter for keyword ["+keyword+"]", e);
      return null;
    }
  } else {
    addError("There is no conversion class registered for composite conversion word ["
            + keyword + "]");
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:28,代码来源:Compiler.java


示例4: lookupKey

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private String lookupKey(String key) {
  String value = propertyContainer0.getProperty(key);
  if (value != null)
    return value;

  if (propertyContainer1 != null) {
    value = propertyContainer1.getProperty(key);
    if (value != null)
      return value;
  }

  value = OptionHelper.getSystemProperty(key, null);
  if (value != null)
    return value;

  value = OptionHelper.getEnv(key);
  if (value != null) {
    return value;
  }

  return null;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:NodeToStringTransformer.java


示例5: getInputURL

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
URL getInputURL(InterpretationContext ec, Attributes attributes) {
  String fileAttribute = attributes.getValue(FILE_ATTR);
  String urlAttribute = attributes.getValue(URL_ATTR);
  String resourceAttribute = attributes.getValue(RESOURCE_ATTR);

  if (!OptionHelper.isEmpty(fileAttribute)) {
    this.attributeInUse = ec.subst(fileAttribute);
    return filePathAsURL(attributeInUse);
  }

  if (!OptionHelper.isEmpty(urlAttribute)) {
    this.attributeInUse = ec.subst(urlAttribute);
    return attributeToURL(attributeInUse);
  }

  if (!OptionHelper.isEmpty(resourceAttribute)) {
    this.attributeInUse = ec.subst(resourceAttribute);
    return resourceAsURL(attributeInUse);
  }
  // given previous checkAttributes() check we cannot reach this line
  throw new IllegalStateException("A URL stream should have been returned");

}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:IncludeAction.java


示例6: enabledProtocols

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
 * Gets the set of enabled protocols based on the configuration.
 * @param supportedProtocols protocols supported by the SSL engine 
 * @param defaultProtocols default protocols enabled by the SSL engine
 * @return enabled protocols
 */
private String[] enabledProtocols(String[] supportedProtocols,
    String[] defaultProtocols) {
  if (enabledProtocols == null) {
    // we're assuming that the same engine is used for all configurables
    // so once we determine the enabled set, we won't do it again
    if (OptionHelper.isEmpty(getIncludedProtocols())
        && OptionHelper.isEmpty(getExcludedProtocols())) {
      enabledProtocols = Arrays.copyOf(defaultProtocols, 
          defaultProtocols.length);
    }
    else {
      enabledProtocols = includedStrings(supportedProtocols, 
          getIncludedProtocols(), getExcludedProtocols());
    }
    for (String protocol : enabledProtocols) {
      addInfo("enabled protocol: " + protocol);
     }
  }
  return enabledProtocols;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:27,代码来源:SSLParametersConfiguration.java


示例7: enabledCipherSuites

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
 * Gets the set of enabled cipher suites based on the configuration.
 * @param supportedCipherSuites cipher suites supported by the SSL engine 
 * @param defaultCipherSuites default cipher suites enabled by the SSL engine
 * @return enabled cipher suites
 */
private String[] enabledCipherSuites(String[] supportedCipherSuites,
    String[] defaultCipherSuites) {
  if (enabledCipherSuites == null) {
    // we're assuming that the same engine is used for all configurables
    // so once we determine the enabled set, we won't do it again
    if (OptionHelper.isEmpty(getIncludedCipherSuites())
        && OptionHelper.isEmpty(getExcludedCipherSuites())) {
      enabledCipherSuites = Arrays.copyOf(defaultCipherSuites, 
          defaultCipherSuites.length);
    }
    else {
      enabledCipherSuites = includedStrings(supportedCipherSuites, 
          getIncludedCipherSuites(), getExcludedCipherSuites());
    }
    for (String cipherSuite : enabledCipherSuites) {
      addInfo("enabled cipher suite: " + cipherSuite);
    }
  }
  return enabledCipherSuites;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:27,代码来源:SSLParametersConfiguration.java


示例8: processScanAttrib

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
void processScanAttrib(InterpretationContext ic, Attributes attributes) {
  String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
  if (!OptionHelper.isEmpty(scanAttrib)
          && !"false".equalsIgnoreCase(scanAttrib)) {
    ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
    rocf.setContext(context);
    String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
    if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
      try {
        Duration duration = Duration.valueOf(scanPeriodAttrib);
        rocf.setRefreshPeriod(duration.getMilliseconds());
        addInfo("Setting ReconfigureOnChangeFilter scanning period to "
                + duration);
      } catch (NumberFormatException nfe) {
        addError("Error while converting [" + scanAttrib + "] to long", nfe);
      }
    }
    rocf.start();
    LoggerContext lc = (LoggerContext) context;
    addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
    lc.addTurboFilter(rocf);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:ConfigurationAction.java


示例9: init

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
/**
 * FOR INTERNAL USE. This method is intended for use by  StaticLoggerBinder.
 *  
 * @param defaultLoggerContext
 * @throws ClassNotFoundException
 * @throws NoSuchMethodException
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
public void init(LoggerContext defaultLoggerContext, Object key) throws ClassNotFoundException,
    NoSuchMethodException, InstantiationException, IllegalAccessException,
    InvocationTargetException  {
  if(this.key == null) {
    this.key = key;
  } else if (this.key != key) {
    throw new IllegalAccessException("Only certain classes can access this method.");
  }
  
  
  String contextSelectorStr = OptionHelper
      .getSystemProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR);
  if (contextSelectorStr == null) {
    contextSelector = new DefaultContextSelector(defaultLoggerContext);
  } else if (contextSelectorStr.equals("JNDI")) {
    // if jndi is specified, let's use the appropriate class
    contextSelector = new ContextJNDISelector(defaultLoggerContext);
  } else {
    contextSelector = dynamicalContextSelector(defaultLoggerContext,
        contextSelectorStr);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:33,代码来源:ContextSelectorStaticBinder.java


示例10: begin

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
public void begin(InterpretationContext ic, String name, Attributes attributes) {
  String valueStr = attributes.getValue(VALUE_ATR);

  if (OptionHelper.isEmpty(valueStr)) {
    ic.addError("The literal action requires a value attribute");
    return;
  }

  try {
    Integer i = Integer.valueOf(valueStr);
    ic.pushObject(i);
  } catch (NumberFormatException nfe) {
    ic.addError("The value [" + valueStr
        + "] could not be converted to an Integer", nfe);
    throw nfe;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:LiteralAction.java


示例11: begin

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes) {

  // See LBCLASSIC-225 (the system property is looked up first. Thus, it overrides
  // the equivalent property in the config file. This reversal of scope priority is justified
  // by the use case: the admin trying to chase rogue config file
  String debugAttrib = System.getProperty(DEBUG_SYSTEM_PROPERTY_KEY);
  if (debugAttrib == null) {
    debugAttrib =  attributes.getValue(INTERNAL_DEBUG_ATTR);
  }

  if (OptionHelper.isEmpty(debugAttrib) || debugAttrib.equals("false") || debugAttrib.equals("null")) {
    addInfo(INTERNAL_DEBUG_ATTR + " attribute not set");
  } else {
    OnConsoleStatusListener.addNewInstanceToContext(context);
  }

  new ContextUtil(context).addHostNameAsProperty();

  // the context is appender attachable, so it is pushed on top of the stack
  ec.pushObject(getContext());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:ConfigurationAction.java


示例12: start

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
@Override
public void start() throws LifecycleException {
    super.start();
    ctx.start();
    if (filename == null) {
        filename = OptionHelper.getSystemProperty("logbackAccess.configurationFile");
        if (filename == null) {
            filename = DEFAULT_CONFIG_FILE;
        }
        ctx.getStatusManager().add(new InfoStatus("filename property not set. Assuming [" + filename + "]", this));
    }
    // TODO: Support classpath config
    File configFile = new File(filename);
    if (configFile.exists()) {
        try {
            JoranConfigurator jc = new JoranConfigurator();
            jc.setContext(ctx);
            jc.doConfigure(filename);
        } catch (JoranException e) {
            // TODO can we do better than printing a stack trace on syserr?
            e.printStackTrace();
        }
    } else {
        ctx.getStatusManager().add(new WarnStatus("[" + filename + "] does not exist", this));
    }

    if (!quiet) {
        StatusPrinter.print(ctx.getStatusManager());
    }
    
}
 
开发者ID:goodees,项目名称:goodees,代码行数:32,代码来源:CatalinaValve.java


示例13: init

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
public void init(KonkerLoggerContext defaultLoggerContext, Object key) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    if(this.key == null) {
        this.key = key;
    } else if(this.key != key) {
        throw new IllegalAccessException("Only certain classes can access this method.");
    }

    String contextSelectorStr = OptionHelper.getSystemProperty("logback.ContextSelector");
    if(contextSelectorStr == null) {
        this.contextSelector = new KonkerDefaultContextSelector(defaultLoggerContext);
    } else {
        this.contextSelector = dynamicalContextSelector(defaultLoggerContext, contextSelectorStr);
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:16,代码来源:KonkerSelectorStaticBinder.java


示例14: installIfAsked

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
static void installIfAsked(KonkerLoggerContext loggerContext) {
    String slClass = OptionHelper.getSystemProperty("logback.statusListenerClass");
    if(!OptionHelper.isEmpty(slClass)) {
        addStatusListener(loggerContext, slClass);
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:8,代码来源:KonkerStatusListenerConfigHelper.java


示例15: createListenerPerClassName

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private static StatusListener createListenerPerClassName(KonkerLoggerContext loggerContext,
                                                         String listenerClass) {
    try {
        return (StatusListener)OptionHelper.instantiateByClassName(listenerClass, StatusListener.class, loggerContext);
    } catch (Exception var3) {
        var3.printStackTrace();
        return null;
    }
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:10,代码来源:KonkerStatusListenerConfigHelper.java


示例16: findConfigFileURLFromSystemProperties

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
    String logbackConfigFile = OptionHelper.getSystemProperty("logback.configurationFile");
    if (logbackConfigFile != null) {
        URL result = null;

        URL f;
        try {
            result = new URL(logbackConfigFile);
            URL e = result;
            return e;
        } catch (MalformedURLException var13) {
            result = Loader.getResource(logbackConfigFile, classLoader);
            if (result == null) {
                File f1 = new File(logbackConfigFile);
                if (!f1.exists() || !f1.isFile()) {
                    return null;
                }

                try {
                    result = f1.toURI().toURL();
                    URL e1 = result;
                    return e1;
                } catch (MalformedURLException var12) {
                    return null;
                }
            }

            f = result;
        } finally {
            if (updateStatus) {
                this.statusOnResourceSearch(logbackConfigFile, classLoader, result);
            }

        }

        return f;
    } else {
        return null;
    }
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:41,代码来源:KonkerContextInitializer.java


示例17: begin

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
@Override
public void begin(InterpretationContext ic, 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(ic, name, getValue(source, defaultValue), scope);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:SpringPropertyAction.java


示例18: consoleAppender

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private Appender<ILoggingEvent> consoleAppender(LogbackConfigurator config) {
	ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	String logPattern = this.patterns.getProperty("console", CONSOLE_LOG_PATTERN);
	encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext()));
	encoder.setCharset(UTF8);
	config.start(encoder);
	appender.setEncoder(encoder);
	config.appender("CONSOLE", appender);
	return appender;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:DefaultLogbackConfiguration.java


示例19: acceptsProfiles

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
	String[] profileNames = StringUtils.trimArrayElements(StringUtils
			.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
	if (profileNames.length != 0) {
		for (String profileName : profileNames) {
			OptionHelper.substVars(profileName, ic, this.context);
		}
		return this.environment != null
				&& this.environment.acceptsProfiles(profileNames);
	}
	return false;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:SpringProfileAction.java


示例20: setApplicationName

import ch.qos.logback.core.util.OptionHelper; //导入依赖的package包/类
public static void setApplicationName(String name) throws AuditException {
    if (clientApplication != null && clientApplication.getName().equals(name)) {
        // don't configure again
        return;
    }
    if (clientApplication != null && !clientApplication.getName().equals(name)) {
        throw new IllegalStateException("Application name "
                + clientApplication.getName() + " once set cannot be renamed.");
    }

    if (OptionHelper.isEmpty(name)) {
        throw new IllegalArgumentException(
                "Application name cannot be null or empty");
    } else {

        // logger.info("Naming client application as [" + name + "]");
    }

    try {
        InetAddress address = InetAddress.getLocalHost();
        String fqdn = address.getCanonicalHostName();
        // logger("Client application host is ["+fqdn+"].");
        Application aplication = new Application(name, fqdn);
        // all is nice and dandy
        clientApplication = aplication;
    } catch (UnknownHostException e) {
        throw new IllegalStateException(
                "Failed to determine the hostname for this host", e);
    }

    // defaultAuditor.close();
    defaultAuditor = new Auditor();
    defaultAuditor.setClientApplication(clientApplication);
    defaultAuditor.setName(DEFAULT_AUDITOR_NAME);
    autoConfig(defaultAuditor);
    checkSanity(defaultAuditor);
    AuditorFactory.defaultAuditor = defaultAuditor;
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:39,代码来源:ImprovedAuditorFactory.java



注:本文中的ch.qos.logback.core.util.OptionHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParserAction类代码示例发布时间:2022-05-22
下一篇:
Java SnmpTooBigException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap