當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationException類代碼示例

本文整理匯總了Java中org.apache.logging.log4j.core.config.ConfigurationException的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationException類的具體用法?Java ConfigurationException怎麽用?Java ConfigurationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConfigurationException類屬於org.apache.logging.log4j.core.config包,在下文中一共展示了ConfigurationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createInstance

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
/**
 * Creates an instance of {@link BatchEmitter} using one of available {@link BatchEmitterFactory} services. A check
 * for compatibility of given {@link ClientObjectFactory} with available services is performed.
 * <p>
 * NOTE: Currently the first found and compatible {@link BatchEmitterFactory} is selected as the {@link
 * BatchEmitter} provider. This is subject to change after new config features are added in future releases (
 * priority-based selection will be available to provide more flexible extension capabilities).
 *
 * @param batchSize           number of elements in a current batch that should trigger a delivery, regardless of
 *                            the delivery interval value
 * @param deliveryInterval    number of millis between two time-triggered deliveries, regardless of the batch size
 *                            value
 * @param clientObjectFactory client-specific objects provider
 * @param failoverPolicy      sink for failed batch items
 * @return T configured {@link BatchEmitter}
 */
public BatchEmitter createInstance(int batchSize,
                                   int deliveryInterval,
                                   ClientObjectFactory clientObjectFactory,
                                   FailoverPolicy failoverPolicy) {

    ServiceLoader<BatchEmitterFactory> loader = ServiceLoader.load(BatchEmitterFactory.class);
    Iterator<BatchEmitterFactory> it = loader.iterator();
    while (it.hasNext()) {
        BatchEmitterFactory factory = it.next();
        LOG.info("BatchEmitterFactory class found {}", factory);
        if (factory.accepts(clientObjectFactory.getClass())) {
            LOG.info("Using {} as BatchEmitterFactoryProvider", factory);
            return factory.createInstance(batchSize, deliveryInterval, clientObjectFactory, failoverPolicy);
        }
    }

    throw new ConfigurationException(String.format("No compatible BatchEmitter implementations for %s found", clientObjectFactory.getClass()));

}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:36,代碼來源:BatchEmitterServiceProvider.java

示例2: loadClasspathResource

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
private String loadClasspathResource() {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(
                ClassLoader.getSystemClassLoader().getResourceAsStream(
                        path.replace(CLASSPATH_PREFIX, "")),
                "UTF-8"));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
            sb.append('\n');
        }
        return sb.toString();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:18,代碼來源:IndexTemplate.java

示例3: throwsExceptionOnUnresolvedAppender

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Test(expected = ConfigurationException.class)
public void throwsExceptionOnUnresolvedAppender() {

    // given
    Appender appender = mock(Appender.class);
    when(appender.isStarted()).thenReturn(true);
    Configuration configuration = mock(Configuration.class);
    String testAppenderRef = "testAppenderRef";
    when(configuration.getAppender(testAppenderRef)).thenReturn(null);

    FailoverPolicy<String> failoverPolicy = createTestFailoverPolicy(testAppenderRef, configuration);

    String failedMessage = "test failed message";

    // when
    failoverPolicy.deliver(failedMessage);

}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:19,代碼來源:AppenderRefFailoverPolicyTest.java

示例4: createAppender

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
private AppenderComponentBuilder createAppender(final String key, final Properties properties) {
    final String name = (String) properties.remove(CONFIG_NAME);
    if (Strings.isEmpty(name)) {
        throw new ConfigurationException("No name attribute provided for Appender " + key);
    }
    final String type = (String) properties.remove(CONFIG_TYPE);
    if (Strings.isEmpty(type)) {
        throw new ConfigurationException("No type attribute provided for Appender " + key);
    }
    final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, type);
    addFiltersToComponent(appenderBuilder, properties);
    final Properties layoutProps = PropertiesUtil.extractSubset(properties, "layout");
    if (layoutProps.size() > 0) {
        appenderBuilder.add(createLayout(name, layoutProps));
    }

    return processRemainingProperties(appenderBuilder, properties);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:19,代碼來源:PropertiesConfigurationBuilder.java

示例5: HttpURLConnectionManager

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
public HttpURLConnectionManager(final Configuration configuration, final LoggerContext loggerContext, final String name,
                                final URL url, final String method, final int connectTimeoutMillis,
                                final int readTimeoutMillis,
                                final Property[] headers,
                                final SslConfiguration sslConfiguration,
                                final boolean verifyHostname) {
    super(configuration, loggerContext, name);
    this.url = url;
    if (!(url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equalsIgnoreCase("https"))) {
        throw new ConfigurationException("URL must have scheme http or https");
    }
    this.isHttps = this.url.getProtocol().equalsIgnoreCase("https");
    this.method = Objects.requireNonNull(method, "method");
    this.connectTimeoutMillis = connectTimeoutMillis;
    this.readTimeoutMillis = readTimeoutMillis;
    this.headers = headers != null ? headers : new Property[0];
    this.sslConfiguration = sslConfiguration;
    if (this.sslConfiguration != null && !isHttps) {
        throw new ConfigurationException("SSL configuration can only be specified with URL scheme https");
    }
    this.verifyHostname = verifyHostname;
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:23,代碼來源:HttpURLConnectionManager.java

示例6: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public BulkProcessorObjectFactory build() {
    if (serverUris == null) {
        throw new ConfigurationException("No serverUris provided for JestClientConfig");
    }
    return new BulkProcessorObjectFactory(Arrays.asList(serverUris.split(";")));
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:8,代碼來源:BulkProcessorObjectFactory.java

示例7: builderFailsIfServerUrisStringIsNull

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Test(expected = ConfigurationException.class)
public void builderFailsIfServerUrisStringIsNull() {

    // given
    Builder builder = createTestObjectFactoryBuilder();
    String serverUris = null;

    // when
    builder.withServerUris(serverUris);
    builder.build();

}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:13,代碼來源:BulkProcessorObjectFactoryTest.java

示例8: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public JestHttpObjectFactory build() {
    if (serverUris == null) {
        throw new ConfigurationException("No serverUris provided for JestClientConfig");
    }
    return new JestHttpObjectFactory(Arrays.asList(serverUris.split(";")), connTimeout, readTimeout, maxTotalConnection, defaultMaxTotalConnectionPerRoute, discoveryEnabled);
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:8,代碼來源:JestHttpObjectFactory.java

示例9: add

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
/**
 * Transforms given items to client-specific model and adds them to provided {@link BatchEmitter}
 *
 * @param log batch item source
 *
 * @deprecated will use configured indexName for backwards compatibility
 */
@Override
public void add(String log) {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for AsyncBatchDelivery");
    }
    add(this.indexName, log);
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:15,代碼來源:AsyncBatchDelivery.java

示例10: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public AsyncBatchDelivery build() {
    if (indexName != null) {
        LOG.warn("AsyncBatchDelivery.indexName attribute has been deprecated and will be removed in 1.3. " +
                "It will NOT be used in AsyncBatchDelivery.add(String indexName,  T logObject) calls. " +
                "Please use IndexName instead.");
    }

    if (clientObjectFactory == null) {
        throw new ConfigurationException("No Elasticsearch client factory [JestHttp|ElasticsearchBulkProcessor] provided for AsyncBatchDelivery");
    }
    return new AsyncBatchDelivery(indexName, batchSize, deliveryInterval, clientObjectFactory, failoverPolicy, indexTemplate);
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:14,代碼來源:AsyncBatchDelivery.java

示例11: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public ElasticsearchAppender build() {
    if (name == null) {
        throw new ConfigurationException("No name provided for Elasticsearch appender");
    }
    if (batchDelivery == null) {
        throw new ConfigurationException("No batchDelivery [AsyncBatchDelivery] provided for Elasticsearch appender");
    }

    if (layout == null) {
        layout = JsonLayout.newBuilder().setCompact(true).build();
    }

    return new ElasticsearchAppender(name, filter, layout, ignoreExceptions, batchDelivery, messageOnly, indexNameFormatter);
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:16,代碼來源:ElasticsearchAppender.java

示例12: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public RollingIndexNameFormatter build() {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for RollingIndexName");
    }
    if (pattern == null) {
        throw new ConfigurationException("No pattern provided for RollingIndexName");
    }
    return new RollingIndexNameFormatter(indexName, pattern, getInitTimeInMillis(), TimeZone.getTimeZone(timeZone));
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:11,代碼來源:RollingIndexNameFormatter.java

示例13: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public IndexTemplate build() {
    if (name == null) {
        throw new ConfigurationException("No name provided for IndexTemplate");
    }
    if ((path == null && source == null) || (path != null && source != null)) {
        throw new ConfigurationException("Either path or source have to be provided for IndexTemplate");
    }
    return new IndexTemplate(name, loadSource());
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:11,代碼來源:IndexTemplate.java

示例14: loadFileSystemResource

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
private String loadFileSystemResource() {
    try {
        return new String(Files.readAllBytes(Paths.get(path)));
    } catch (IOException e){
        throw new ConfigurationException(e.getMessage(), e);
    }
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:8,代碼來源:IndexTemplate.java

示例15: build

import org.apache.logging.log4j.core.config.ConfigurationException; //導入依賴的package包/類
@Override
public NoopIndexNameFormatter build() {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for IndexName");
    }
    return new NoopIndexNameFormatter(indexName);
}
 
開發者ID:rfoltyns,項目名稱:log4j2-elasticsearch,代碼行數:8,代碼來源:NoopIndexNameFormatter.java


注:本文中的org.apache.logging.log4j.core.config.ConfigurationException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。