当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

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


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

示例1: assertExistsPrivateCtor

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Test
public void assertExistsPrivateCtor() {
    reflections.getSubTypesOf(Object.class).stream()
        .filter(clazz -> !clazz.isAnnotationPresent(Configuration.class))
        .filter(clazz -> !clazz.isAnnotationPresent(Component.class))
        .filter(clazz -> !clazz.isAnnotationPresent(SpringBootApplication.class))
        .filter(clazz -> !clazz.getName().endsWith("Test"))
        .filter(clazz -> !clazz.isInterface())
        .filter(clazz ->
            Arrays.stream(clazz.getDeclaredFields())
                .allMatch(field -> Modifier.isStatic(field.getModifiers())))
        .forEach(clazz -> {
            System.out.println("Expecting class "+clazz.getName()+" to :");
            System.out.print("\t-> be final ");
            assertThat(clazz).isFinal();
            System.out.println("[*]");
            System.out.print("\t-> have exactly one constructor ");
            Constructor<?>[] constructors = clazz.getDeclaredConstructors();
            assertThat(constructors).hasSize(1);
            System.out.println("[*]");
            System.out.print("\t-> and that this constructor is private ");
            assertThat(Modifier.isPrivate(constructors[0].getModifiers()));
            System.out.println("[*]");
        });
}
 
开发者ID:Tristan971,项目名称:EasyFXML,代码行数:26,代码来源:PrivateConstructorTest.java

示例2: createMediaContract

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
private MediaContract createMediaContract() throws ServiceException {
    LOG.debug("createMediaContract called");
    final com.microsoft.windowsazure.Configuration configuration = MediaConfiguration
            .configureWithOAuthAuthentication(
                    MediaServicesProperties.MEDIA_SERVICE_URI,
                    MediaServicesProperties.OAUTH_URI,
                    mediaServicesProperties.getAccountName(),
                    mediaServicesProperties.getAccountKey(),
                    MediaServicesProperties.SCOPE);

    if (nonNull(mediaServicesProperties.getProxyHost())
            && nonNull(mediaServicesProperties.getProxyPort())) {
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_HOST, mediaServicesProperties.getProxyHost());
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_PORT, mediaServicesProperties.getProxyPort());
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_SCHEME, mediaServicesProperties.getProxyScheme());
    } else if (nonNull(mediaServicesProperties.getProxyHost()) && isNull(mediaServicesProperties.getProxyPort())) {
        throw new ServiceException("Please Set Network Proxy port in application.properties");
    } else if (nonNull(mediaServicesProperties.getProxyPort()) && isNull(mediaServicesProperties.getProxyHost())) {
        throw new ServiceException("Please Set Network Proxy host in application.properties");
    }
    return MediaService.create(configuration);
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:23,代码来源:MediaServicesAutoConfiguration.java

示例3: jGitRepository

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
@Primary
@SneakyThrows
public JGitRepository jGitRepository(ApplicationProperties applicationProperties, HazelcastInstance hazelcastInstance) {

    return new JGitRepository(applicationProperties.getGit(), new ReentrantLock()) {
        @Override
        protected void initRepository(){};
        @Override
        protected void pull(){};
        @Override
        protected void commitAndPush(String commitMsg){};
        @Override
        public List<com.icthh.xm.ms.configuration.domain.Configuration> findAll(){
            return emptyList();
        }
    };
}
 
开发者ID:xm-online,项目名称:xm-ms-config,代码行数:19,代码来源:TestConfiguration.java

示例4: start

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
public void start() throws Exception {
  org.apache.activemq.artemis.core.config.Configuration configuration = new ConfigurationImpl();

  HashSet<TransportConfiguration> transports = new HashSet<>();
  transports.add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
  configuration.setAcceptorConfigurations(transports);
  configuration.setSecurityEnabled(false);

  File targetDir = new File(System.getProperty("user.dir") + "/target");
  configuration.setBrokerInstance(targetDir);

  ActiveMQServer temp = new ActiveMQServerImpl(configuration);
  temp.start();

  server = temp;
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:17,代码来源:JmsArtemisManualServerTest.java

示例5: userMapping

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public TypeMapConfigurer<User, UserDto> userMapping() {
    return new TypeMapConfigurer<User, UserDto>() {

        @Override
        public org.modelmapper.config.Configuration getConfiguration() {
            return new InheritingConfiguration().setSkipNullEnabled(true);
        }

        @Override
        public void configure(TypeMap<User, UserDto> typeMap) {
            typeMap.addMapping(User::getAge, UserDto::setAge);
            typeMap.addMapping(User::getName, UserDto::setFirstName);
            typeMap.addMapping(User::getName, UserDto::setLastName);
        }
    };
}
 
开发者ID:rozidan,项目名称:modelmapper-spring-boot-starter,代码行数:18,代码来源:TypeMapConfigurationTest.java

示例6: buildConfigurationDeserializer

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
private JsonDeserializer<io.redlink.smarti.model.config.Configuration > buildConfigurationDeserializer(ObjectMapper objectMapper) {
    return new JsonDeserializer<io.redlink.smarti.model.config.Configuration>() {
        @Override
        public io.redlink.smarti.model.config.Configuration deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {

            final TypeFactory tf = ctxt.getTypeFactory();
            final MapLikeType smartiConfigType = tf.constructMapLikeType(Map.class,
                    tf.constructType(String.class),
                    tf.constructCollectionLikeType(List.class,
                            ComponentConfiguration.class));

            final io.redlink.smarti.model.config.Configuration configuration = new io.redlink.smarti.model.config.Configuration();
            configuration.setConfig(objectMapper.readerFor(smartiConfigType).readValue(p, smartiConfigType));
            return configuration;
        }

    };
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:19,代码来源:RestServiceConfiguration.java

示例7: dslContext

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
/**
 * Can we re-use DSLContext as a Spring bean (singleton)? Yes, the Spring tutorial of
 * Jooq also does it that way, but only if we do not change anything about the
 * config after the init (which we don't do anyways) and if the ConnectionProvider
 * does not store any shared state (we use DataSourceConnectionProvider of Jooq, so no problem).
 *
 * Some sources and discussion:
 * - http://www.jooq.org/doc/3.6/manual/getting-started/tutorials/jooq-with-spring/
 * - http://jooq-user.narkive.com/2fvuLodn/dslcontext-and-threads
 * - https://groups.google.com/forum/#!topic/jooq-user/VK7KQcjj3Co
 * - http://stackoverflow.com/questions/32848865/jooq-dslcontext-correct-autowiring-with-spring
 */
@Bean
public DSLContext dslContext() {
    initDataSource();

    Settings settings = new Settings()
            // Normally, the records are "attached" to the Configuration that created (i.e. fetch/insert) them.
            // This means that they hold an internal reference to the same database connection that was used.
            // The idea behind this is to make CRUD easier for potential subsequent store/refresh/delete
            // operations. We do not use or need that.
            .withAttachRecords(false)
            // To log or not to log the sql queries, that is the question
            .withExecuteLogging(CONFIG.getDb().isSqlLogging());

    // Configuration for JOOQ
    org.jooq.Configuration conf = new DefaultConfiguration()
            .set(SQLDialect.MYSQL)
            .set(new DataSourceConnectionProvider(dataSource))
            .set(settings);

    return DSL.using(conf);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:34,代码来源:BeanConfiguration.java

示例8: groupHeartbeatService

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public GroupHeartbeatService groupHeartbeatService() throws BeansException,
		UnknownHostException {

	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);
	final AgentConfiguration conf = beanFactory
			.getBean(AgentConfiguration.class);

	long initialDelay = 10000L;

	long checkFrequency = configuration.getLong(
			AgentProperties.HEARTBEAT_FREQUENCY.toString(), 300000L);

	int port = (int) conf.getMonitoringPort();

	AgentStatus status = beanFactory.getBean(AgentStatus.class);
	LOG.info("USING status: " + status);

	GroupHeartbeatService service = new GroupHeartbeatService(
			beanFactory.getBean(GroupKeeper.class),
			Group.GroupStatus.Type.AGENT, status, port, initialDelay,
			checkFrequency, 10000L, beanFactory.getBean(StatusExtrasBuilder.class));

	return service;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:AgentDI.java

示例9: logRolloverCheck

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public LogRolloverCheck logRolloverCheck() {
	org.apache.commons.configuration.Configuration conf = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	long rolloverTime = conf.getLong(
			CollectorProperties.WRITER.LOG_ROTATE_TIME.toString(),
			(Long) CollectorProperties.WRITER.LOG_ROTATE_TIME
					.getDefaultValue());

	long inactiveTime = conf.getLong(
			CollectorProperties.WRITER.LOG_ROTATE_INACTIVE_TIME.toString(),
			(Long) CollectorProperties.WRITER.LOG_ROTATE_INACTIVE_TIME
					.getDefaultValue());

	long logSizeMb = conf
			.getLong(CollectorProperties.WRITER.LOG_SIZE_MB.toString(),
					(Long) CollectorProperties.WRITER.LOG_SIZE_MB
							.getDefaultValue());

	LOG.info("Using LogRollover: inactiveTime: " + inactiveTime
			+ " rolloverTime: " + rolloverTime + " logSizeMb: " + logSizeMb);

	return new SimpleLogRolloverCheck(rolloverTime, logSizeMb, inactiveTime);

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:LogWriterDI.java

示例10: compressionPoolFactory

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public CompressionPoolFactory compressionPoolFactory() {

	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	int decompressorPoolSize = configuration
			.getInt(CollectorProperties.WRITER.COLLECTOR_DECOMPRESSOR_POOLSIZE
					.toString(),
					(Integer) CollectorProperties.WRITER.COLLECTOR_DECOMPRESSOR_POOLSIZE
							.getDefaultValue());
	int compressorPoolSize = configuration
			.getInt(CollectorProperties.WRITER.COLLECTOR_COMPRESSOR_POOLSIZE
					.toString(),
					(Integer) CollectorProperties.WRITER.COLLECTOR_COMPRESSOR_POOLSIZE
							.getDefaultValue());

	return new CompressionPoolFactoryImpl(decompressorPoolSize,
			compressorPoolSize, beanFactory.getBean(CollectorStatus.class));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:22,代码来源:LogWriterDI.java

示例11: getStatusExtrasBuilder

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public StatusExtrasBuilder getStatusExtrasBuilder() {
	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	String baseDir = configuration.getString(
			CollectorProperties.WRITER.BASE_DIR.toString(),
			CollectorProperties.WRITER.BASE_DIR.getDefaultValue()
					.toString());

	return new StatusExtrasBuilder(
			beanFactory.getBean(CollectorStatus.class), baseDir,
			(CounterMetric) beanFactory
					.getBean("connectionsReceivedMetric"),
			(CounterMetric) beanFactory
					.getBean("connectionsProcessedMetric"),
			(CounterMetric) beanFactory.getBean("kilobytesWrttenMetric"),
			(CounterMetric) beanFactory.getBean("errorsMetric"));
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:20,代码来源:CollectorDI.java

示例12: OrphanedFilesCheck

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public OrphanedFilesCheck OrphanedFilesCheck() {
	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	String baseDir = configuration.getString(
			CollectorProperties.WRITER.BASE_DIR.toString(),
			CollectorProperties.WRITER.BASE_DIR.getDefaultValue()
					.toString());

	long lowerMod = configuration.getLong(
			CollectorProperties.WRITER.ORPHANED_FILE_LOWER_MODE.toString(),
			(Long) CollectorProperties.WRITER.ORPHANED_FILE_LOWER_MODE
					.getDefaultValue());

	File file = new File(baseDir);

	return new OrphanedFilesCheckImpl(file,
			beanFactory.getBean(LogRolloverCheck.class),
			beanFactory.getBean(LogFileNameExtractor.class),
			beanFactory.getBean(LogRollover.class), beanFactory.getBean(
					FileOutputStreamPoolFactory.class).getPoolForKey(
					"orphanedFiles"), lowerMod);

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:26,代码来源:CollectorDI.java

示例13: logFileNameExtractor

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public LogFileNameExtractor logFileNameExtractor() throws Exception {

	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	String cls = configuration
			.getString(CollectorProperties.WRITER.LOG_NAME_EXTRACTOR
					.toString());

	LogFileNameExtractor nameExtractor = null;
	if (cls == null) {
		String keys = configuration.getString(
				CollectorProperties.WRITER.LOG_NAME_KEYS.toString(),
				CollectorProperties.WRITER.LOG_NAME_KEYS.getDefaultValue()
						.toString());

		String[] splits = keys.split(",");
		nameExtractor = new DateHourFileNameExtractor(splits);
	} else {
		nameExtractor = (LogFileNameExtractor) Thread.currentThread()
				.getContextClassLoader().loadClass(cls).newInstance();
	}

	return nameExtractor;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:CollectorDI.java

示例14: restletPingComponent

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
/**
 * Configures a restlet ping component
 * 
 * @return
 */
@Bean
public Component restletPingComponent() {
	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);
	Component component = new Component();

	component.getServers().add(
			org.restlet.data.Protocol.HTTP,
			configuration.getInt(CollectorProperties.WRITER.PING_PORT
					.toString(),
					(Integer) CollectorProperties.WRITER.PING_PORT
							.getDefaultValue()));
	component.getDefaultHost().attach(restletPingApplication());

	return component;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:22,代码来源:CollectorDI.java

示例15: lockTimeoutCheckAppService

import org.springframework.context.annotation.Configuration; //导入依赖的package包/类
@Bean
public LockTimeoutCheckAppService lockTimeoutCheckAppService() {

	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	long lockTimeoutPeriod = configuration
			.getLong(
					CoordinationProperties.PROP.COORDINATION_LOCK_TIMEOUTCHECK_PERIOD
							.toString(),
					(Long) CoordinationProperties.PROP.COORDINATION_LOCK_TIMEOUTCHECK_PERIOD
							.getDefaultValue());

	long lockTimeout = configuration.getLong(
			CoordinationProperties.PROP.COORDINATION_LOCK_TIMEOUT
					.toString(),
			(Long) CoordinationProperties.PROP.COORDINATION_LOCK_TIMEOUT
					.getDefaultValue());

	return new LockTimeoutCheckAppService(lockTimeoutPeriod, lockTimeout,
			beanFactory.getBean(LockMemory.class));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:24,代码来源:CoordinationDI.java


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