當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。