org.springframework.core.annotation.Order Java Examples
The following examples show how to use
org.springframework.core.annotation.Order.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobsAutoConfiguration.java From genie with Apache License 2.0 | 6 votes |
/** * Create an Job Kickoff Task bean that runs the job. * * @param jobsProperties The various jobs properties * @param executor An instance of an executor * @param genieHostInfo Info about the host Genie is running on * @param registry The metrics registry to use * @param jobDirectoryManifestCreatorService The manifest creation service * @return An application task object */ @Bean @Order(value = 6) @ConditionalOnMissingBean(JobKickoffTask.class) public JobKickoffTask jobKickoffTask( final JobsProperties jobsProperties, final Executor executor, final GenieHostInfo genieHostInfo, final MeterRegistry registry, final JobDirectoryManifestCreatorService jobDirectoryManifestCreatorService ) { return new JobKickoffTask( jobsProperties.getUsers().isRunAsUserEnabled(), jobsProperties.getUsers().isCreationEnabled(), executor, genieHostInfo.getHostname(), registry, jobDirectoryManifestCreatorService ); }
Example #2
Source File: SessionListener.java From webanno with Apache License 2.0 | 6 votes |
@EventListener @Order(Ordered.HIGHEST_PRECEDENCE) public void onSessionCreated(HttpSessionCreatedEvent aEvent) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { log.trace("Session created for anonymous user [{}]", aEvent.getSession().getId()); // We don't register anonymous un-authorized sessions. // If this were a pre-authenticated session, we'd have an authentication by now. // If it is using the form-based login, the login page handles registering the // session. return; } String username = authentication.getName(); log.trace("Session created for user [{}] [{}]", username, aEvent.getSession().getId()); sessionRegistry.registerNewSession(aEvent.getSession().getId(), username); }
Example #3
Source File: BaseWebClientTests.java From spring-cloud-gateway with Apache License 2.0 | 6 votes |
@Bean @Order(500) public GlobalFilter modifyResponseFilter() { return (exchange, chain) -> { log.info("modifyResponseFilter start"); String value = exchange.getAttributeOrDefault(GATEWAY_HANDLER_MAPPER_ATTR, "N/A"); if (!exchange.getResponse().isCommitted()) { exchange.getResponse().getHeaders().add(HANDLER_MAPPER_HEADER, value); } Route route = exchange.getAttributeOrDefault(GATEWAY_ROUTE_ATTR, null); if (route != null) { if (!exchange.getResponse().isCommitted()) { exchange.getResponse().getHeaders().add(ROUTE_ID_HEADER, route.getId()); } } return chain.filter(exchange); }; }
Example #4
Source File: JacksonConfig.java From BigDataPlatform with GNU General Public License v3.0 | 6 votes |
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public Jackson2ObjectMapperBuilderCustomizer customJackson() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.failOnUnknownProperties(false); builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } }; }
Example #5
Source File: SaveData.java From Cleanstone with MIT License | 6 votes |
@Order(value = 50) @EventListener public void onTerminate(AsyncPlayerTerminationEvent e) { Player player = e.getPlayer(); if (player.getEntity() == null) { return; } EntityData entityData = new EntityData(player.getEntity().getPosition(), player.getEntity().getWorld().getID(), player.getGameMode(), player.isFlying()); try { playerManager.getPlayerDataSource().setPlayerData(player, StandardPlayerDataType.ENTITY_DATA, entityData); } catch (IOException e1) { log.error("Failed to save player data for " + player, e1); } }
Example #6
Source File: JacksonConfig.java From mall with MIT License | 6 votes |
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public Jackson2ObjectMapperBuilderCustomizer customJackson() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.failOnUnknownProperties(false); builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } }; }
Example #7
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 6 votes |
@SuppressWarnings("unchecked") private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass, Class<?> rootDeclaringClass, Class<?> declaringClass, String name, Class<? extends Annotation> composedAnnotationType) { Class<Component> annotationType = Component.class; UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( startClass, Service.class, annotationType, Order.class, Transactional.class); assertNotNull("UntypedAnnotationDescriptor should not be null", descriptor); assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass()); assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass()); assertEquals("annotationType", annotationType, descriptor.getAnnotationType()); assertEquals("component name", name, ((Component) descriptor.getAnnotation()).value()); assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation()); assertEquals("composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType()); }
Example #8
Source File: TitusExceptionHandlers.java From titus-control-plane with Apache License 2.0 | 6 votes |
@ExceptionHandler(value = {SchedulerException.class}) @Order(Ordered.HIGHEST_PRECEDENCE) public ResponseEntity<ErrorResponse> handleException(SchedulerException e, WebRequest request) { ErrorResponse.ErrorResponseBuilder errorBuilder = ErrorResponse.newError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()) .clientRequest(request) .serverContext() .exceptionContext(e); switch (e.getErrorCode()) { case InvalidArgument: case SystemSelectorAlreadyExists: case SystemSelectorEvaluationError: errorBuilder.status(HttpServletResponse.SC_BAD_REQUEST); break; case SystemSelectorNotFound: errorBuilder.status(HttpServletResponse.SC_NOT_FOUND); break; default: errorBuilder.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } ErrorResponse errorResponse = errorBuilder.build(); return ResponseEntity.status(errorResponse.getStatusCode()).body(errorResponse); }
Example #9
Source File: BeanFactoryHelperTest.java From eclair with Apache License 2.0 | 6 votes |
@Bean({"two", "two1", "two2"}) @Order(2) public Printer two() { return new Printer() { @Override public boolean supports(Class<?> clazz) { return clazz == String.class; } @Override protected String serialize(Object input) { return "2"; } }; }
Example #10
Source File: ExecutionAutoConfiguration.java From genie with Apache License 2.0 | 6 votes |
/** * Create a {@link ConfigureExecutionStage} bean if one is not already defined. * * @param jobRequestConverter the job request converter * @param jobRequestArguments the job request arguments group * @param runtimeConfigurationArguments the runtime configuration arguments group * @param cleanupArguments the cleanup arguments group */ @Bean @Lazy @Order(30) @ConditionalOnMissingBean(ConfigureExecutionStage.class) ConfigureExecutionStage configureExecutionStage( final JobRequestConverter jobRequestConverter, final ArgumentDelegates.JobRequestArguments jobRequestArguments, final ArgumentDelegates.RuntimeConfigurationArguments runtimeConfigurationArguments, final ArgumentDelegates.CleanupArguments cleanupArguments ) { return new ConfigureExecutionStage( jobRequestConverter, jobRequestArguments, runtimeConfigurationArguments, cleanupArguments ); }
Example #11
Source File: JacksonConfig.java From litemall with MIT License | 6 votes |
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public Jackson2ObjectMapperBuilderCustomizer customJackson() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.failOnUnknownProperties(false); builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } }; }
Example #12
Source File: GatewayConfig.java From iot-dc3 with Apache License 2.0 | 6 votes |
@Bean @Order(-100) public GlobalFilter globalFilter() { return (exchange, chain) -> { //调用请求之前统计时间 Long startTime = System.currentTimeMillis(); ServerHttpRequest request = exchange.getRequest(); String remoteIp = Objects.requireNonNull(request.getRemoteAddress()).getHostString(); R<Boolean> blackIpValid = blackIpClient.checkBlackIpValid(remoteIp); if (blackIpValid.isOk()) { log.error("Forbidden Ip: {}", remoteIp); exchange.getResponse().setStatusCode(HttpStatus.FORBIDDEN); return exchange.getResponse().setComplete(); } return chain.filter(exchange).then().then(Mono.fromRunnable(() -> { //调用请求之后统计时间 Long endTime = System.currentTimeMillis(); log.info("Remote Ip: {}; Request url: {}; Response code: {}; Time: {}ms", remoteIp, request.getURI().getRawPath(), exchange.getResponse().getStatusCode(), (endTime - startTime)); })); }; }
Example #13
Source File: CacheConfigurationCustomizerEnabledAppendTest.java From camel-spring-boot with Apache License 2.0 | 6 votes |
@Order(Ordered.HIGHEST_PRECEDENCE) @Bean public ComponentCustomizer<EhcacheComponent> customizer() { return new ComponentCustomizer<EhcacheComponent>() { @Override public void customize(EhcacheComponent component) { component.addCachesConfigurations(Collections.singletonMap( CACHE_CONFIG_ID, CacheConfigurationBuilder.newCacheConfigurationBuilder( String.class, String.class, ResourcePoolsBuilder.newResourcePoolsBuilder() .heap(2100, EntryUnit.ENTRIES) .offheap(2, MemoryUnit.MB)) .build() )); } }; }
Example #14
Source File: LocMetricsAutoConfigure.java From loc-framework with MIT License | 5 votes |
@Bean @Order(2) public MeterFilter denyUriMeterFilter() { return MeterFilter.deny(id -> { String uri = id.getTag(URI); return StringUtils.isNotBlank(uri) && EXCLUDE_PATH_PREFIX.stream().anyMatch(uri::startsWith); }); }
Example #15
Source File: GatewayApplication.java From microservice-recruit with Apache License 2.0 | 5 votes |
@Primary @Bean @Order(Ordered.HIGHEST_PRECEDENCE) public ErrorWebExceptionHandler errorWebExceptionHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider, ServerCodecConfigurer serverCodecConfigurer) { ExceptionHandle jsonExceptionHandler = new ExceptionHandle(); jsonExceptionHandler.setViewResolvers(viewResolversProvider.getIfAvailable(Collections::emptyList)); jsonExceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters()); jsonExceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders()); return jsonExceptionHandler; }
Example #16
Source File: MoveFilePipeTest.java From iaf with Apache License 2.0 | 5 votes |
@Test @Order(3) public void appendFileToFileInAnotherDirectoryWithoutWildcardTest() throws ConfigurationException, PipeStartException, PipeRunException { pipe.setMove2dir(destFolderPath); pipe.setDirectory(sourceFolderPath); pipe.setFilename("toAppend1.txt"); pipe.setMove2file("toBeAppended.txt"); pipe.setAppend(true); pipe.configure(); pipe.start(); PipeRunResult res = pipe.doPipe(null, session); assertEquals(pipeForwardThen, res.getPipeForward().getName()); }
Example #17
Source File: ErrorHandlerConfig.java From open-capacity-platform with Apache License 2.0 | 5 votes |
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) { JsonExceptionHandler exceptionHandler = new JsonExceptionHandler( errorAttributes, this.resourceProperties, this.serverProperties.getError(), this.applicationContext); exceptionHandler.setViewResolvers(this.viewResolvers); exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters()); exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders()); return exceptionHandler; }
Example #18
Source File: EmbeddedCacheManagerCustomizerOverrideTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Order(Ordered.HIGHEST_PRECEDENCE) @Bean public ComponentCustomizer<InfinispanComponent> customizer() { return new ComponentCustomizer<InfinispanComponent>() { @Override public void customize(InfinispanComponent component) { component.getConfiguration().setCacheContainer(CACHE_MANAGER); } }; }
Example #19
Source File: DemoMybatisAutoConfiguration.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * 数据权限插件 * * @return DataScopeInterceptor */ @Order(10) @Bean @ConditionalOnProperty(prefix = DatabaseProperties.PREFIX, name = "isDataScope", havingValue = "true", matchIfMissing = true) public DataScopeInterceptor dataScopeInterceptor() { return new DataScopeInterceptor((userId) -> SpringUtils.getBean(UserApi.class).getDataScopeById(userId)); }
Example #20
Source File: FreemarkerConfigAwareListener.java From halo with GNU General Public License v3.0 | 5 votes |
@EventListener @Order(Ordered.HIGHEST_PRECEDENCE + 1) public void onApplicationStartedEvent(ApplicationStartedEvent applicationStartedEvent) throws TemplateModelException { log.debug("Received application started event"); loadThemeConfig(); loadOptionsConfig(); loadUserConfig(); }
Example #21
Source File: AbstractWindow.java From cuba with Apache License 2.0 | 5 votes |
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10) @Subscribe protected void init(InitEvent initEvent) { Map<String, Object> params = new HashMap<>(0); ScreenOptions options = initEvent.getOptions(); if (options instanceof MapScreenOptions) { params = ((MapScreenOptions) options).getParams(); } initEnableEditingActionStub(); init(params); }
Example #22
Source File: JobsAutoConfiguration.java From genie with Apache License 2.0 | 5 votes |
/** * Create an Command Task bean that processes the command needed for a job. * * @param registry The metrics registry to use * @param fts File transfer implementation * @return An command task object */ @Bean @Order(value = 4) @ConditionalOnMissingBean(CommandTask.class) public CommandTask commandProcessorTask( final MeterRegistry registry, @Qualifier("cacheGenieFileTransferService") final GenieFileTransferService fts ) { return new CommandTask(registry, fts); }
Example #23
Source File: JenkinsStatusUpdateTrigger.java From seppb with MIT License | 5 votes |
@EventListener @Order() @Override public void onApplicationReady(ApplicationReadyEvent event) { if (jenkinsProperties.isEnableSyncStatus()) { schedule(); } }
Example #24
Source File: ServiceConfig.java From microservice-integration with MIT License | 5 votes |
@Bean @Order(100) public CustomRemoteTokenServices customRemoteTokenServices(RestTemplate restTemplate) { CustomRemoteTokenServices resourceServerTokenServices = new CustomRemoteTokenServices(restTemplate); resourceServerTokenServices.setCheckTokenEndpointUrl(resource.getResource().getTokenInfoUri()); resourceServerTokenServices.setClientId(resource.getClient().getClientId()); resourceServerTokenServices.setClientSecret(resource.getClient().getClientSecret()); resourceServerTokenServices.setLoadBalancerClient(loadBalancerClient); return resourceServerTokenServices; }
Example #25
Source File: MessageInterceptorBeanPostProcessor.java From synapse with Apache License 2.0 | 5 votes |
private int getOrder(final Method method) { final int order; Order ann = AnnotationUtils.findAnnotation(method, Order.class); if (ann != null) { order = ann.value(); } else { order = LOWEST_PRECEDENCE; } return order; }
Example #26
Source File: MetaAnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void findAnnotationDescriptorForTypesForClassWithMetaAnnotatedInterface() { Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class); UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes( ClassWithMetaAnnotatedInterface.class, Service.class, Component.class, Order.class, Transactional.class); assertNotNull(descriptor); assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass()); assertEquals(Meta1.class, descriptor.getDeclaringClass()); assertEquals(rawAnnotation, descriptor.getAnnotation()); assertEquals(Meta1.class, descriptor.getComposedAnnotation().annotationType()); }
Example #27
Source File: MsgsMybatisAutoConfiguration.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * 数据权限插件 * * @return DataScopeInterceptor */ @Order(10) @Bean @ConditionalOnProperty(prefix = DatabaseProperties.PREFIX, name = "isDataScope", havingValue = "true", matchIfMissing = true) public DataScopeInterceptor dataScopeInterceptor() { return new DataScopeInterceptor((userId) -> SpringUtils.getBean(UserApi.class).getDataScopeById(userId)); }
Example #28
Source File: SynapseAutoConfiguration.java From synapse with Apache License 2.0 | 5 votes |
/** * Configures a {@link de.otto.synapse.endpoint.MessageInterceptor} that is used to add some default * message headers when messages are received by a {@link de.otto.synapse.endpoint.receiver.MessageReceiverEndpoint}. * * @param synapseProperties properties used to configure the interceptor * @return DefaultReceiverHeadersInterceptor */ @Bean @Order(LOWEST_PRECEDENCE) @ConditionalOnMissingBean @ConditionalOnProperty( prefix = "synapse.receiver.default-headers", name = "enabled", havingValue = "true", matchIfMissing = true) public DefaultReceiverHeadersInterceptor defaultReceiverHeadersInterceptor(final SynapseProperties synapseProperties) { return new DefaultReceiverHeadersInterceptor(synapseProperties); }
Example #29
Source File: ClientCacheManager.java From cuba with Apache License 2.0 | 5 votes |
@EventListener(AppContextInitializedEvent.class) @Order(Events.LOWEST_PLATFORM_PRECEDENCE - 120) public void initialize(AppContextInitializedEvent event) { ApplicationContext applicationContext = event.getApplicationContext(); Map<String, CachingStrategy> cachingStrategyMap = applicationContext.getBeansOfType(CachingStrategy.class); for (Map.Entry<String, CachingStrategy> entry : cachingStrategyMap.entrySet()) { addCachedObject(entry.getKey(), entry.getValue()); } }
Example #30
Source File: StorageAutoConfiguration.java From cola-cloud with MIT License | 5 votes |
/** * 默认配置用户目录作为存储目录 * * @return */ @Bean @Order(2) @ConditionalOnMissingBean(FileStorage.class) public LocalFileStorage defaultLocalStorage() { return new LocalFileStorage(System.getProperty("user.home" )); }