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

Java ContextAware类代码示例

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

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



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

示例1: createKeyManagers

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
/**
 * Creates key managers using the receiver's key store configuration.
 * @param context context for status messages
 * @return an array of key managers or {@code null} if no key store
 *    configuration was provided
 * @throws NoSuchProviderException if a provider specified for one
 *    of the key manager components is not known to the platform
 * @throws NoSuchAlgorithmException if an algorithm specified for
 *    one of the key manager components is not known to the relevant
 *    provider
 * @throws KeyStoreException if an error occurs in reading a key store
 */
private KeyManager[] createKeyManagers(ContextAware context) 
    throws NoSuchProviderException, NoSuchAlgorithmException, 
    UnrecoverableKeyException, KeyStoreException {
  
  if (getKeyStore() == null) return null;
  
  KeyStore keyStore = getKeyStore().createKeyStore();
  context.addInfo(
      "key store of type '" + keyStore.getType() 
      + "' provider '" + keyStore.getProvider()
      + "': " + getKeyStore().getLocation());          

  KeyManagerFactory kmf = getKeyManagerFactory().createKeyManagerFactory();
  context.addInfo("key manager algorithm '" + kmf.getAlgorithm() 
      + "' provider '" + kmf.getProvider() + "'");
  
  char[] passphrase = getKeyStore().getPassword().toCharArray();
  kmf.init(keyStore, passphrase);
  return kmf.getKeyManagers();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:33,代码来源:SSLContextFactoryBean.java


示例2: createTrustManagers

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
/**
 * Creates trust managers using the receiver's trust store configuration.
 * @param context context for status messages
 * @return an array of trust managers or {@code null} if no trust store
 *    configuration was provided
 * @throws NoSuchProviderException if a provider specified for one
 *    of the trust manager components is not known to the platform
 * @throws NoSuchAlgorithmException if an algorithm specified for
 *    one of the trust manager components is not known to the relevant
 *    provider
 * @throws KeyStoreException if an error occurs in reading a key
 *    store containing trust anchors 
 */
private TrustManager[] createTrustManagers(ContextAware context) 
    throws NoSuchProviderException, NoSuchAlgorithmException, 
    KeyStoreException {
  
  if (getTrustStore() == null) return null;
  
  KeyStore trustStore = getTrustStore().createKeyStore();
  context.addInfo(
      "trust store of type '" + trustStore.getType() 
      + "' provider '" + trustStore.getProvider()
      + "': " + getTrustStore().getLocation());          
  
  TrustManagerFactory tmf = getTrustManagerFactory()
      .createTrustManagerFactory();
  context.addInfo("trust manager algorithm '" + tmf.getAlgorithm() 
      + "' provider '" + tmf.getProvider() + "'");
  
  tmf.init(trustStore);
  return tmf.getTrustManagers();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:34,代码来源:SSLContextFactoryBean.java


示例3: addErrors

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
/**
 * @param contextAware the {@link ContextAware} implementation to which potential errors will be added
 */
public void addErrors(final ContextAware contextAware) {
    if (isEndpointInvalid()) {
        contextAware.addError("endpoint must not be null nor empty");
    }

    if (isApiKeyInvalid()) {
        contextAware.addError("apiKey must not be null nor empty");
    }

    if (isReleaseStageInvalid()) {
        contextAware.addError("releaseStage must not be null nor empty");
    }

    if (isMetaProviderClassNameInValid()) {
        contextAware.addError("Could not instantiate class: " + getMetaDataProviderClassName().get() + ". " +
                "Make sure that you provided the fully qualified class name and that the class has a public " +
                "accessible default constructor.");
    }
}
 
开发者ID:codereligion,项目名称:bugsnag-logback,代码行数:23,代码来源:Configuration.java


示例4: create

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
public static FlumeAvroManager create(
    final List<RemoteFlumeAgent> agents,
    final Properties overrides,
    final Integer batchSize,
    final Long reportingWindow,
    final Integer reporterMaxThreadPoolSize,
    final Integer reporterMaxQueueSize,
    final ContextAware context) {

    if (agents != null && agents.size() > 0) {
      Properties props = buildFlumeProperties(agents);
      props.putAll(overrides);
      return new FlumeAvroManager(props, reportingWindow, batchSize, reporterMaxThreadPoolSize, reporterMaxQueueSize, context);
    } else {
      context.addError("No valid agents configured");
    }

  return null;
}
 
开发者ID:gilt,项目名称:logback-flume-appender,代码行数:20,代码来源:FlumeAvroManager.java


示例5: FlumeAvroManager

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private FlumeAvroManager(final Properties props,
                         final Long reportingWindowReq,
                         final Integer batchSizeReq,
                         final Integer reporterMaxThreadPoolSizeReq,
                         final Integer reporterMaxQueueSizeReq,
                         final ContextAware context) {
  this.loggingContext = context;

  final int reporterMaxThreadPoolSize = reporterMaxThreadPoolSizeReq == null ?
          DEFAULT_REPORTER_MAX_THREADPOOL_SIZE : reporterMaxThreadPoolSizeReq;
  final int reporterMaxQueueSize = reporterMaxQueueSizeReq == null ?
          DEFAULT_REPORTER_MAX_QUEUE_SIZE : reporterMaxQueueSizeReq;

  this.reporter = new EventReporter(props, loggingContext, reporterMaxThreadPoolSize, reporterMaxQueueSize);
  this.evQueue = new ArrayBlockingQueue<Event>(1000);
  final long reportingWindow = hamonizeReportingWindow(reportingWindowReq);
  final int batchSize = batchSizeReq == null ? DEFAULT_BATCH_SIZE : batchSizeReq;
  this.asyncThread = new AsyncThread(evQueue, batchSize, reportingWindow);
  loggingContext.addInfo("Created a new flume agent with properties: " + props.toString());
  asyncThread.start();
}
 
开发者ID:gilt,项目名称:logback-flume-appender,代码行数:22,代码来源:FlumeAvroManager.java


示例6: initAndAddListener

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private static void initAndAddListener(KonkerLoggerContext loggerContext, StatusListener listener) {
    if(listener != null) {
        if(listener instanceof ContextAware) {
            ((ContextAware)listener).setContext(loggerContext);
        }

        if(listener instanceof LifeCycle) {
            ((LifeCycle)listener).start();
        }

        loggerContext.getStatusManager().add(listener);
    }

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


示例7: setContextForConverters

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
public static <E> void setContextForConverters(Context context, Converter<E> head) {
  Converter<E> c = head;
  while (c != null) {
    if (c instanceof ContextAware) {
      ((ContextAware) c).setContext(context);
    }
    c = c.getNext();
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:ConverterUtil.java


示例8: convertArg

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
/**
 * Convert <code>val</code> a String parameter to an object of a given type.
 */
@SuppressWarnings("unchecked")
public static Object convertArg(ContextAware ca, String val, Class<?> type) {
  if (val == null) {
    return null;
  }
  String v = val.trim();
  if (String.class.isAssignableFrom(type)) {
    return v;
  } else if (Integer.TYPE.isAssignableFrom(type)) {
    return new Integer(v);
  } else if (Long.TYPE.isAssignableFrom(type)) {
    return new Long(v);
  } else if (Float.TYPE.isAssignableFrom(type)) {
    return new Float(v);
  } else if (Double.TYPE.isAssignableFrom(type)) {
    return new Double(v);
  } else if (Boolean.TYPE.isAssignableFrom(type)) {
    if ("true".equalsIgnoreCase(v)) {
      return Boolean.TRUE;
    } else if ("false".equalsIgnoreCase(v)) {
      return Boolean.FALSE;
    }
  } else if (type.isEnum()) {
    return convertToEnum(ca, v, (Class<? extends Enum>) type);
  } else if (StringToObjectConverter.followsTheValueOfConvention(type)) {
    return convertByValueOfMethod(ca, type, v);
  } else if (isOfTypeCharset(type)) {
    return convertToCharset(ca, val);
  }

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


示例9: convertToCharset

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
static private Charset convertToCharset(ContextAware ca, String val) {
  try {
    return Charset.forName(val);
  } catch (UnsupportedCharsetException e) {
    ca.addError("Failed to get charset [" + val + "]", e);
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:9,代码来源:StringToObjectConverter.java


示例10: convertByValueOfMethod

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private static Object convertByValueOfMethod(ContextAware ca, Class<?> type,
    String val) {
  try {
    Method valueOfMethod = type.getMethod(CoreConstants.VALUE_OF,
        STING_CLASS_PARAMETER);
    return valueOfMethod.invoke(null, val);
  } catch (Exception e) {
    ca.addError("Failed to invoke " + CoreConstants.VALUE_OF
        + "{} method in class [" + type.getName() + "] with value [" + val
        + "]");
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:14,代码来源:StringToObjectConverter.java


示例11: begin

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
  inError = false;
  String className = attributes.getValue(CLASS_ATTRIBUTE);
  if (OptionHelper.isEmpty(className)) {
    addError("Missing class name for statusListener. Near ["
            + name + "] line " + getLineNumber(ec));
    inError = true;
    return;
  }

  try {
    statusListener = (StatusListener) OptionHelper.instantiateByClassName(
            className, StatusListener.class, context);
    ec.getContext().getStatusManager().add(statusListener);
    if (statusListener instanceof ContextAware) {
      ((ContextAware) statusListener).setContext(context);
    }
    addInfo("Added status listener of type [" + className + "]");
    ec.pushObject(statusListener);
  } catch (Exception e) {
    inError = true;
    addError(
            "Could not create an StatusListener of type [" + className + "].", e);
    throw new ActionException(e);
  }

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


示例12: setSystemProperties

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
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);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:OptionHelper.java


示例13: setSystemProperty

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
public static void setSystemProperty(ContextAware contextAware, String key, String value) {
  try {
    System.setProperty(key, value);
  } catch (SecurityException e) {
    contextAware.addError("Failed to set system property [" + key + "]", e);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:OptionHelper.java


示例14: createSecureRandom

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private SecureRandom createSecureRandom(ContextAware context) 
    throws NoSuchProviderException, NoSuchAlgorithmException {
  
  SecureRandom secureRandom = getSecureRandom().createSecureRandom();
  context.addInfo("secure random algorithm '" + secureRandom.getAlgorithm()
      + "' provider '" + secureRandom.getProvider() + "'");
  
  return secureRandom;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:SSLContextFactoryBean.java


示例15: begin

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:32,代码来源:LoggerContextListenerAction.java


示例16: initAndAddListener

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private static void initAndAddListener(LoggerContext loggerContext, StatusListener listener) {
  if (listener != null) {
    if(listener instanceof ContextAware) // LOGBACK-767
      ((ContextAware) listener).setContext(loggerContext);
    if(listener instanceof LifeCycle)  // LOGBACK-767
      ((LifeCycle) listener).start();
    loggerContext.getStatusManager().add(listener);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:StatusListenerConfigHelper.java


示例17: createContext

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
@Override
public SSLContext createContext(ContextAware context)
    throws NoSuchProviderException, NoSuchAlgorithmException,
    KeyManagementException, UnrecoverableKeyException, KeyStoreException,
    CertificateException {
  contextCreated = true;
  return super.createContext(context);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:9,代码来源:MockSSLConfiguration.java


示例18: postProcessBeforeInitializationInternal

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
@Override
protected ContextAware postProcessBeforeInitializationInternal(ContextAware bean, String beanName) throws Exception {
    bean.setContext(LoggingInitializerRunListener.this.loggerContext);

    if (bean instanceof LoggerContextAware) {
        ((LoggerContextAware) bean).setLoggerContext(LoggingInitializerRunListener.this.loggerContext);
    }

    return bean;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:11,代码来源:LoggingInitializerRunListener.java


示例19: buildLifeCycle

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
private <T extends LifeCycle> T buildLifeCycle(T lifeCycle, boolean start) {
    if (lifeCycle instanceof ContextAware) {
        ((ContextAware) lifeCycle).setContext(this.loggerContext);
    }

    if (start) {
        lifeCycle.start();
    }

    return lifeCycle;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:12,代码来源:LoggingInitializerRunListener.java


示例20: start

import ch.qos.logback.core.spi.ContextAware; //导入依赖的package包/类
/**
 * Starts the sender with the given {@code configuration} and {@code contextAware}.
 *
 * @param configuration the {@link Configuration} to apply
 * @param contextAware the {@link ContextAware} to use for error reporting
 */
public void start(final Configuration configuration, final ContextAware contextAware) {
    this.endpoint = configuration.getEndpointWithProtocol();
    this.contextAware = contextAware;
    this.gsonProvider = new GsonProvider(configuration);
    this.client = createClient();
    this.started = true;
}
 
开发者ID:codereligion,项目名称:bugsnag-logback,代码行数:14,代码来源:Sender.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JaxRsResponse类代码示例发布时间:2022-05-22
下一篇:
Java WebMapServer类代码示例发布时间: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