Java 类org.springframework.context.annotation.Scope 实例源码

项目:spring-security-oauth2-boot    文件:OAuth2RestOperationsConfiguration.java   
@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;
}
项目:spring-microservice-sample    文件:DataJpaConfig.java   
@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()
    );

}
项目:OAuth-2.0-Cookbook    文件:FacebookConfiguration.java   
@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;
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * 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);
}
项目:eventapis    文件:StoreApi.java   
@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);
}
项目:bean-grid    文件:BeanGridConfiguration.java   
@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;
}
项目:cassandra-client    文件:CassandraClientUIConfiguration.java   
@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;
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * 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;
}
项目:proxylive    文件:StreamProcessorFactory.java   
@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;

}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * 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;
}
项目:Spring-5.0-Cookbook    文件:BeanConfig.java   
@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;
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * 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;
}
项目:redirector    文件:IntegrationTestBeans.java   
@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();
}
项目:xm-commons    文件:LepSpringConfiguration.java   
@Bean
@Scope(SCOPE_SINGLETON)
protected LepManager lepManager() {
    return new SpringLepManager(extensionService(),
                                lepExecutor(),
                                applicationLepProcessingEventPublisher(),
                                lepResourceService());
}
项目:talchain    文件:FramingTest.java   
@Bean
@Scope("prototype")
public MessageCodec messageCodec() {
    MessageCodec codec = new MessageCodec();
    codec.setMaxFramePayloadSize(16);
    System.out.println("SysPropConfig1.messageCodec");
    return codec;
}
项目:talchain    文件:FramingTest.java   
@Bean
@Scope("prototype")
public MessageCodec messageCodec() {
    MessageCodec codec = new MessageCodec();
    codec.setMaxFramePayloadSize(16);
    System.out.println("SysPropConfig2.messageCodec");
    return codec;
}
项目:OAuth-2.0-Cookbook    文件:GoogleConfigurerAdapter.java   
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Google google(final ConnectionRepository repository) {
    final Connection<Google> connection = repository
            .findPrimaryConnection(Google.class);
    return connection != null ? connection.getApi() : null;
}
项目:OAuth-2.0-Cookbook    文件:GitHubConfiguration.java   
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public GitHub gitHub(ConnectionRepository repository) {
    Connection<GitHub> connection = repository
            .findPrimaryConnection(GitHub.class);
    return connection != null ? connection.getApi() : null;
}
项目:syndesis    文件:Application.java   
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Bean(name = "verifier-context", initMethod = "start", destroyMethod = "stop")
public static CamelContext verifierContext() {
    CamelContext context = new DefaultCamelContext();
    context.setNameStrategy(new ExplicitCamelContextNameStrategy("verifier-context"));
    context.disableJMX();

    return context;
}
项目:syndesis    文件:TwitterVerifierAutoConfiguration.java   
@Bean("twitter")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy
@ConditionalOnProperty(prefix = "io.syndesis.connector.twitter.verifier", name = "enabled", matchIfMissing = true)
public Verifier twitterVerifier() {
    return new TwitterVerifier();
}
项目:jaffa-framework    文件:PropertyPlaceholderConfig.java   
/**
 * Load the properties files used in application contexts here
 *
 * @return the initialized instance of the PropertyPlaceholderConfigurer class
 */
@Bean(name="properties")
@Scope(BeanDefinition.SCOPE_SINGLETON)
public PropertyPlaceholderConfigurer conversionService() {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    Resource resource1 = new ClassPathResource("application_file_1.properties");
    Resource resource2 = new ClassPathResource("application_file_2.properties");
    configurer.setLocations(resource1, resource2);
    return configurer;
}
项目:happylifeplat-tcc    文件:MyConfiguration.java   
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
    return Feign.builder()
            .requestInterceptor(new TccRestTemplateInterceptor())
            .invocationHandlerFactory(invocationHandlerFactory());
}
项目:azure-spring-boot    文件:AADAuthenticationFilterAutoConfiguration.java   
/**
 * Declare AADAuthenticationFilter bean.
 *
 * @return AADAuthenticationFilter bean
 */
@Bean
@Scope("singleton")
@ConditionalOnMissingBean(AADAuthenticationFilter.class)
public AADAuthenticationFilter azureADJwtTokenFilter() {
    LOG.info("AzureADJwtTokenFilter Constructor.");
    return new AADAuthenticationFilter(aadAuthFilterProperties);
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * Configure the CaseType Validator
 *
 * @return CaseType Validator
 */
@Bean(name = "case-type")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public CaseTypeValidator caseTypeValidator() {
    CaseTypeValidator validator = new CaseTypeValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * Configure the Pattern Validator
 *
 * @return Pattern Validator
 */
@Bean(name = "pattern")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public PatternValidator patternValidator() {
    PatternValidator validator = new PatternValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
项目:training-sample    文件:AppConfig.java   
@Scope("prototype")
@Bean(name = "prototypeBean")
public ExampleScopeBean prototypeBean() {
    ExampleScopeBean exampleScopeBean = new ExampleScopeBean();
    exampleScopeBean.setMessage("hello");
    return exampleScopeBean;
}
项目:eventapis    文件:EventApisFactory.java   
@Bean
@Scope("prototype")
public RequestInterceptor opIdInterceptor(@Autowired OperationContext operationContext) {
    return template -> {
        String key = operationContext.getContext();
        if (key != null)
            template.header("opId", key.toString());
    };
}
项目:eventapis    文件:FeignHelper.java   
@Bean
@Scope("prototype")
public RequestInterceptor opIdInterceptor() {
    return (template) -> {
        String key = this.operationContext.getContext();
        if (key != null) {
            template.header("opId", key);
        }

    };
}
项目:travel-agency    文件:NexmoConfig.java   
@Bean
@Scope("singleton")
public NexmoClient nexmoClientBean() throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, IOException {
    AuthMethod tokenAuthMethod = new TokenAuthMethod(this.apiKey, this.apiSecret);
    AuthMethod jwtAuthMethod = new JWTAuthMethod(this.applicationId, new File(this.pathPrivateKey).toPath());
    return new NexmoClient(tokenAuthMethod, jwtAuthMethod);
}
项目:jwala    文件:JvmControlServiceImplTest.java   
@Bean
@Scope("prototype")
public JvmControlService getJvmControlService() {
    reset(mockJvmCommandFactory, mockSshConfig, mockShellCommandFactory, mockHistoryFacadeService,
            mockJvmStateService, mockRemoteCommandExecutorService, mockSshConfig,
            mockJvmPersistenceService);

    return new JvmControlServiceImpl(
            mockJvmPersistenceService,
            mockJvmStateService,
            mockHistoryFacadeService);
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * Configure the validator factory
 *
 * @return validator factory
 */
@Bean(name = "ruleValidatorFactory")
@Scope(BeanDefinition.SCOPE_SINGLETON)
public RuleValidatorFactory ruleValidatorFactory() {
    RuleValidatorFactory factory = new RuleValidatorFactory();
    factory.addValidatorTypes("mandatory", "max-length", "min-length", "case-type", "max-value", "min-value",
            "candidate-key", "comment", "foreign-key", "generic-foreign-key", "in-list",
            "not-in-list", "partial-foreign-key", "pattern", "primary-key");
    return factory;
}
项目:jwala    文件:BinaryDistributionServiceImplTest.java   
@Bean
@Scope("prototype")
public BinaryDistributionService getBinaryDistributionService() {
    reset(mockBinaryDistributionControlService, mockBinaryDistributionLockManager,
            historyFacadeService, mockSshConfig, mockSshConfiguration, mockRemoteCommandExecutorService);
    return new BinaryDistributionServiceImpl();
}
项目:kalinka    文件:ContextConfiguration.java   
@SuppressWarnings("rawtypes")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Bean
public IMessagePublisher messagePublisher(final String className) {

    return createObject(className, IMessagePublisher.class);
}
项目:cassandra-client    文件:CassandraConfiguration.java   
@Bean
@Lazy
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public CassandraMappingContext cassandraMapping(Cluster cluster, String keyspace) throws ClassNotFoundException {
    BasicCassandraMappingContext mappingContext = new BasicCassandraMappingContext();
    mappingContext.setBeanClassLoader(classLoader);
    mappingContext.setInitialEntitySet(CassandraEntityClassScanner.scan(getEntityBasePackages()));
    CustomConversions customConversions = customConversions();
    mappingContext.setCustomConversions(customConversions);
    mappingContext.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
    mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(cluster, keyspace));
    return mappingContext;
}
项目:jaffa-framework    文件:JaffaRulesConfig.java   
/**
 * Configure the MinValue Validator
 *
 * @return MinValue Validator
 */
@Bean(name = "min-value")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public MinValueValidator minValueValidator() {
    MinValueValidator validator = new MinValueValidator();
    validator.setRuleEvaluator(ruleHelper());
    return validator;
}
项目:cassandra-client    文件:CassandraClientUIConfiguration.java   
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public Menu helpMenu() {
    Menu file = new Menu(localeService.getMessage("ui.menu.help"));
    file.setMnemonicParsing(false);

    MenuItem about = new MenuItem(localeService.getMessage("ui.menu.help.about"));
    about.setMnemonicParsing(false);
    about.setOnAction(event -> aboutBox());

    file.getItems().add(about);
    return file;
}
项目:mongodb-rdbms-sync    文件:MvcConfiguration.java   
@Bean
@Scope(value = "prototype")
public JobDetailFactoryBean getMonitorJob(){
    JobDetailFactoryBean bean = new JobDetailFactoryBean();
    bean.setJobClass(NodeMonitorJob.class);
    return bean;
}
项目:mongodb-rdbms-sync    文件:MvcConfiguration.java   
@Bean
@Scope(value = "prototype")
public JobDetailFactoryBean getEventJob(){
    JobDetailFactoryBean bean = new JobDetailFactoryBean();
    bean.setJobClass(EventJob.class);
    return bean;
}
项目:Lyrebird    文件:FrontendComponents.java   
/**
 * Containerize {@link FxmlLoader} so we can add our resource bundle.

 */
@Bean
@Scope(scopeName = SCOPE_PROTOTYPE)
public FxmlLoader fxmlLoader(final ApplicationContext context, final ResourceBundle resourceBundle) {
    final FxmlLoader loader = new FxmlLoader();
    loader.setControllerFactory(context::getBean);
    loader.setResources(resourceBundle);
    return loader;
}
项目:happylifeplat-transaction    文件:RestTemplateConfiguration.java   
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
    return Feign.builder().requestInterceptor(new RestTemplateInterceptor());
}