java类org.springframework.context.annotation.Scope的实例源码

OAuth2RestOperationsConfiguration.java 文件源码 项目:spring-security-oauth2-boot 阅读 41 收藏 0 点赞 0 评论 0
@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;
}
DataJpaConfig.java 文件源码 项目:spring-microservice-sample 阅读 35 收藏 0 点赞 0 评论 0
@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()
    );

}
FacebookConfiguration.java 文件源码 项目:OAuth-2.0-Cookbook 阅读 40 收藏 0 点赞 0 评论 0
@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;
}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 38 收藏 0 点赞 0 评论 0
/**
 * 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);
}
StoreApi.java 文件源码 项目:eventapis 阅读 42 收藏 0 点赞 0 评论 0
@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);
}
BeanGridConfiguration.java 文件源码 项目:bean-grid 阅读 36 收藏 0 点赞 0 评论 0
@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;
}
CassandraClientUIConfiguration.java 文件源码 项目:cassandra-client 阅读 53 收藏 0 点赞 0 评论 0
@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;
}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 40 收藏 0 点赞 0 评论 0
/**
 * 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;
}
StreamProcessorFactory.java 文件源码 项目:proxylive 阅读 37 收藏 0 点赞 0 评论 0
@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;

}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 38 收藏 0 点赞 0 评论 0
/**
 * 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;
}
BeanConfig.java 文件源码 项目:Spring-5.0-Cookbook 阅读 38 收藏 0 点赞 0 评论 0
@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;
}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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;
}
IntegrationTestBeans.java 文件源码 项目:redirector 阅读 32 收藏 0 点赞 0 评论 0
@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();
}
LepSpringConfiguration.java 文件源码 项目:xm-commons 阅读 33 收藏 0 点赞 0 评论 0
@Bean
@Scope(SCOPE_SINGLETON)
protected LepManager lepManager() {
    return new SpringLepManager(extensionService(),
                                lepExecutor(),
                                applicationLepProcessingEventPublisher(),
                                lepResourceService());
}
FramingTest.java 文件源码 项目:talchain 阅读 37 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public MessageCodec messageCodec() {
    MessageCodec codec = new MessageCodec();
    codec.setMaxFramePayloadSize(16);
    System.out.println("SysPropConfig1.messageCodec");
    return codec;
}
FramingTest.java 文件源码 项目:talchain 阅读 36 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public MessageCodec messageCodec() {
    MessageCodec codec = new MessageCodec();
    codec.setMaxFramePayloadSize(16);
    System.out.println("SysPropConfig2.messageCodec");
    return codec;
}
GoogleConfigurerAdapter.java 文件源码 项目:OAuth-2.0-Cookbook 阅读 36 收藏 0 点赞 0 评论 0
@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;
}
GitHubConfiguration.java 文件源码 项目:OAuth-2.0-Cookbook 阅读 38 收藏 0 点赞 0 评论 0
@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;
}
Application.java 文件源码 项目:syndesis 阅读 33 收藏 0 点赞 0 评论 0
@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;
}
TwitterVerifierAutoConfiguration.java 文件源码 项目:syndesis 阅读 39 收藏 0 点赞 0 评论 0
@Bean("twitter")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy
@ConditionalOnProperty(prefix = "io.syndesis.connector.twitter.verifier", name = "enabled", matchIfMissing = true)
public Verifier twitterVerifier() {
    return new TwitterVerifier();
}
PropertyPlaceholderConfig.java 文件源码 项目:jaffa-framework 阅读 37 收藏 0 点赞 0 评论 0
/**
 * 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;
}
MyConfiguration.java 文件源码 项目:happylifeplat-tcc 阅读 35 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
    return Feign.builder()
            .requestInterceptor(new TccRestTemplateInterceptor())
            .invocationHandlerFactory(invocationHandlerFactory());
}
AADAuthenticationFilterAutoConfiguration.java 文件源码 项目:azure-spring-boot 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Declare AADAuthenticationFilter bean.
 *
 * @return AADAuthenticationFilter bean
 */
@Bean
@Scope("singleton")
@ConditionalOnMissingBean(AADAuthenticationFilter.class)
public AADAuthenticationFilter azureADJwtTokenFilter() {
    LOG.info("AzureADJwtTokenFilter Constructor.");
    return new AADAuthenticationFilter(aadAuthFilterProperties);
}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 35 收藏 0 点赞 0 评论 0
/**
 * 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;
}
JaffaRulesConfig.java 文件源码 项目:jaffa-framework 阅读 46 收藏 0 点赞 0 评论 0
/**
 * 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;
}
AppConfig.java 文件源码 项目:training-sample 阅读 34 收藏 0 点赞 0 评论 0
@Scope("prototype")
@Bean(name = "prototypeBean")
public ExampleScopeBean prototypeBean() {
    ExampleScopeBean exampleScopeBean = new ExampleScopeBean();
    exampleScopeBean.setMessage("hello");
    return exampleScopeBean;
}
EventApisFactory.java 文件源码 项目:eventapis 阅读 33 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public RequestInterceptor opIdInterceptor(@Autowired OperationContext operationContext) {
    return template -> {
        String key = operationContext.getContext();
        if (key != null)
            template.header("opId", key.toString());
    };
}
FeignHelper.java 文件源码 项目:eventapis 阅读 37 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public RequestInterceptor opIdInterceptor() {
    return (template) -> {
        String key = this.operationContext.getContext();
        if (key != null) {
            template.header("opId", key);
        }

    };
}
NexmoConfig.java 文件源码 项目:travel-agency 阅读 35 收藏 0 点赞 0 评论 0
@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);
}
JvmControlServiceImplTest.java 文件源码 项目:jwala 阅读 37 收藏 0 点赞 0 评论 0
@Bean
@Scope("prototype")
public JvmControlService getJvmControlService() {
    reset(mockJvmCommandFactory, mockSshConfig, mockShellCommandFactory, mockHistoryFacadeService,
            mockJvmStateService, mockRemoteCommandExecutorService, mockSshConfig,
            mockJvmPersistenceService);

    return new JvmControlServiceImpl(
            mockJvmPersistenceService,
            mockJvmStateService,
            mockHistoryFacadeService);
}


问题


面经


文章

微信
公众号

扫码关注公众号