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


Java Scope类代码示例

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


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

示例1: DefaultAccessTokenRequest

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public DefaultOAuth2ClientContext oauth2ClientContext() {
	DefaultOAuth2ClientContext context = new DefaultOAuth2ClientContext(
			new DefaultAccessTokenRequest());
	Authentication principal = SecurityContextHolder.getContext()
			.getAuthentication();
	if (principal instanceof OAuth2Authentication) {
		OAuth2Authentication authentication = (OAuth2Authentication) principal;
		Object details = authentication.getDetails();
		if (details instanceof OAuth2AuthenticationDetails) {
			OAuth2AuthenticationDetails oauthsDetails = (OAuth2AuthenticationDetails) details;
			String token = oauthsDetails.getTokenValue();
			context.setAccessToken(new DefaultOAuth2AccessToken(token));
		}
	}
	return context;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:19,代码来源:OAuth2RestOperationsConfiguration.java

示例2: auditorAware

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public AuditorAware<Username> auditorAware() {

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    log.debug("current authentication:" + authentication);

    if (authentication == null || !authentication.isAuthenticated()) {
        return () -> Optional.<Username>empty();
    }

    return () -> Optional.of(
        Username.builder()
            .username(((UserDetails) authentication.getPrincipal()).getUsername())
            .build()
    );

}
 
开发者ID:hantsy,项目名称:spring-microservice-sample,代码行数:20,代码来源:DataJpaConfig.java

示例3: facebook

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Facebook.class)
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
	Connection<Facebook> connection = repository
			.findPrimaryConnection(Facebook.class);
	return connection != null ? connection.getApi() : null;
}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:9,代码来源:FacebookConfiguration.java

示例4: aopFolderWatcher

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
/**
 * Configures the AOP file System watcher to observe the paths passed in for the
 * jboss aop folder.
 */
@Bean
@Scope(BeanDefinition.SCOPE_SINGLETON)
@Autowired
public AopXmlLoader aopFolderWatcher(Environment env) throws JaffaRulesFrameworkException {

    // Check to see if this is supported. If explicitly disabled, then return early.
    if (env.containsProperty("jaffa.aop.springconfig.disabled") &&
            env.getProperty("jaffa.aop.springconfig.disabled").equals("true")) {
        return null;
    }

    String aopPath =
            env.containsProperty("jboss.aop.path") ?
                    env.getProperty("jboss.aop.path") :
                    AopConstants.DEFAULT_AOP_PATTERN;

    List<String> paths = Arrays.asList(aopPath.split(";"));
    return new AopXmlLoader(paths);
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:24,代码来源:JaffaRulesConfig.java

示例5: createIgnite

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope("singleton")
@Qualifier("operationIgniteClient")
@ConditionalOnMissingBean(KafkaOperationRepository.class)
public Ignite createIgnite(ApplicationContext applicationContext) throws IgniteCheckedException {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setClientMode(true);
    cfg.setPeerClassLoadingEnabled(false);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Arrays.asList(clientAddress.split(",")));
    discoSpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    cfg.setMetricsLogFrequency(0);
    return IgniteSpring.start(cfg,applicationContext);
}
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:17,代码来源:StoreApi.java

示例6: configureBeanGrid

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(scopeName = "prototype")
@SuppressWarnings("unchecked")
public <ITEM> Grid<ITEM> configureBeanGrid(DependencyDescriptor dependencyDescriptor) {
	logger.debug("Configuring Vaadin Grid as bean");

	long timestamp = System.currentTimeMillis();

	ResolvableType injectionPointType = dependencyDescriptor.getResolvableType();
	if (!injectionPointType.hasGenerics()) {
		throw new IllegalStateException("Grid injection point is expected to declare a static item type");
	}

	ResolvableType genericType = injectionPointType.getGeneric();
	Class<ITEM> itemType = (Class<ITEM>) genericType.resolve();

	logger.debug("Vaadin Grid will use " + itemType.getCanonicalName() + " as item type");

	Grid<ITEM> grid = configureGridInstance(itemType);
	long configTime = System.currentTimeMillis() - timestamp;
	logger.debug("Done configuring Grid for " + itemType.getName() + " in " + configTime + "ms");

	return grid;
}
 
开发者ID:peterl1084,项目名称:bean-grid,代码行数:25,代码来源:BeanGridConfiguration.java

示例7: fileMenu

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public Menu fileMenu() {
    Menu file = new Menu(localeService.getMessage("ui.menu.file"));
    file.setMnemonicParsing(false);

    MenuItem connect = new MenuItem(localeService.getMessage("ui.menu.file.connect"));
    connect.setMnemonicParsing(false);
    connect.setOnAction(event -> newConnectionBox(getMainView().getPrimaryStage(),
            (data) -> getMainController().loadTables(data)));

    MenuItem manager = new MenuItem(localeService.getMessage("ui.menu.file.manager"));
    manager.setMnemonicParsing(false);
    manager.setOnAction(event -> connectionManager());
    file.getItems().addAll(connect, manager);
    return file;
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:18,代码来源:CassandraClientUIConfiguration.java

示例8: maxValueValidator

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
/**
 * Configure the MaxValue Validator
 *
 * @return MaxValue Validator
 */
@Bean(name = "max-value")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public MaxValueValidator maxValueValidator() {
    MaxValueValidator validator = new MaxValueValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:13,代码来源:JaffaRulesConfig.java

示例9: StreamProcessor

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(value = "prototype")
public IStreamProcessor StreamProcessor(int mode, String clientIdentifier, String channel, String profile) {
    String identifier = new Date().getTime() + clientIdentifier;
    String identifier64 = new String(Base64.getEncoder().encode(identifier.getBytes()));

    HttpSoureStreamProcessor sourceStreamProcessor = (HttpSoureStreamProcessor) context.getBean("HttpSoureStreamProcessor", identifier64, channel);

    IStreamProcessor streamProcessor = null;
    if (profile==null) {
        streamProcessor = sourceStreamProcessor;
    } else {
        //streamProcessor = (IStreamProcessor) context.getBean("TranscodedStreamProcessor", identifier64, sourceStreamProcessor, profile);
        streamProcessor = (IStreamProcessor) context.getBean("DirectTranscodedStreamProcessor", identifier64, channel, profile);
    }
    IStreamProcessor postStreamProcessor = null;
    switch (mode) {
        case ProxyLiveConstants.HLS_MODE:
            postStreamProcessor = (IStreamProcessor) context.getBean("HLSStreamProcessor", identifier64, streamProcessor);
            break;
        case ProxyLiveConstants.STREAM_MODE:
            postStreamProcessor = streamProcessor;
            break;
    }
    return postStreamProcessor;

}
 
开发者ID:segator,项目名称:proxylive,代码行数:28,代码来源:StreamProcessorFactory.java

示例10: minLengthValidator

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
/**
 * Configure the MinLength Validator
 *
 * @return MinLength Validator
 */
@Bean(name = "min-length")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public MinLengthValidator minLengthValidator() {
    MinLengthValidator validator = new MinLengthValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:13,代码来源:JaffaRulesConfig.java

示例11: getEmpRecord2

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean(name="empRec2")
@Scope("prototype")
public Employee getEmpRecord2(){
	Employee empRec2 = new Employee();
	empRec2.setFirstName("Juan");
	empRec2.setLastName("Luna");
	empRec2.setAge(50);
	empRec2.setBirthdate(new Date(45,9,30));
	empRec2.setPosition("historian");
	empRec2.setSalary(100000.00);
	empRec2.setDept(getDept2());
	return empRec2;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:14,代码来源:BeanConfig.java

示例12: genericForeignKeyValidator

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
/**
 * Configure the GenericForeignKey Validator
 *
 * @return GenericForeignKey Validator
 */
@Bean(name = "generic-foreign-key")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public GenericForeignKeyValidator genericForeignKeyValidator() {
    GenericForeignKeyValidator validator = new GenericForeignKeyValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:13,代码来源:JaffaRulesConfig.java

示例13: modelFacade

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(AppScope.APP_SCOPE)
IAppModelFacade modelFacade(String appName, IDataSourceConnector connector, IDataChangePoller dataChangePoller,
                            IWebServiceClient dataFacadeWebServiceClient, ZKConfig config) {
    return new AppModelRestFacade.Builder()
            .withConnector(connector)
            .forApplication(appName)
            .withDataChangePoller(dataChangePoller)
            .withWebServiceClient(dataFacadeWebServiceClient)
            .withZkConfig(config)
            .build();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:13,代码来源:IntegrationTestBeans.java

示例14: lepManager

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope(SCOPE_SINGLETON)
protected LepManager lepManager() {
    return new SpringLepManager(extensionService(),
                                lepExecutor(),
                                applicationLepProcessingEventPublisher(),
                                lepResourceService());
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:9,代码来源:LepSpringConfiguration.java

示例15: messageCodec

import org.springframework.context.annotation.Scope; //导入依赖的package包/类
@Bean
@Scope("prototype")
public MessageCodec messageCodec() {
    MessageCodec codec = new MessageCodec();
    codec.setMaxFramePayloadSize(16);
    System.out.println("SysPropConfig1.messageCodec");
    return codec;
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:9,代码来源:FramingTest.java


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