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


Java Order类代码示例

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


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

示例1: customDiscoveryClient

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Bean
@Order(1)
public DiscoveryClient customDiscoveryClient() {
	return new DiscoveryClient() {
		@Override
		public String description() {
			return "A custom discovery client";
		}

		@Override
		public List<ServiceInstance> getInstances(String serviceId) {
			if (serviceId.equals("custom")) {
				ServiceInstance s1 = new DefaultServiceInstance("custom", "host",
						123, false);
				return Arrays.asList(s1);
			}
			return Collections.emptyList();
		}

		@Override
		public List<String> getServices() {
			return Arrays.asList("custom");
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:26,代码来源:CompositeDiscoveryClientTests.java

示例2: findAndRegisterAnnotatedDelegateMethods

import org.springframework.core.annotation.Order; //导入依赖的package包/类
private void findAndRegisterAnnotatedDelegateMethods(Object bean,
                                                     Method method) {
    RequestMapping requestMapping = method
            .getAnnotation(RequestMapping.class);
    if (requestMapping != null) {
        String[] paths = requestMapping.value();
        for (String path : paths) {
            if (path != null && !path.isEmpty()) {
                DelegateMethodInvoker delegate = new DelegateMethodInvoker(
                        bean, method,
                        findMatchingArgumentResolvers(method),
                        findMatchingReturnValueHandler(method));
                Order order = method.getAnnotation(Order.class);
                if (order == null) {
                    registerDelegate(path, delegate);
                } else {
                    registerDelegate(path, delegate, order.value());
                }
            }
        }
    }
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:23,代码来源:RestDelegateMappingRegistry.java

示例3: handleUncaughtException

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@ResponseBody
@Order(Ordered.HIGHEST_PRECEDENCE)
@ExceptionHandler(Throwable.class)
public final ResponseEntity<Result<String>> handleUncaughtException(final Throwable exception, final WebRequest
        request) {
    // adds information about encountered error to application log
    LOG.error(MessageHelper.getMessage("logger.error", request.getDescription(true)), exception);
    HttpStatus code = HttpStatus.OK;

    String message;
    if (exception instanceof FileNotFoundException) {
        // any details about real path of a resource should be normally prevented to send to the client
        message = MessageHelper.getMessage("error.io.not.found");
    } else if (exception instanceof DataAccessException) {
        // any details about data access error should be normally prevented to send to the client,
        // as its message can contain information about failed SQL query or/and database schema
        if (exception instanceof BadSqlGrammarException) {
            // for convenience we need to provide detailed information about occurred BadSqlGrammarException,
            // but it can be retrieved
            SQLException root = ((BadSqlGrammarException) exception).getSQLException();
            if (root.getNextException() != null) {
                LOG.error(MessageHelper.getMessage("logger.error.root.cause", request.getDescription(true)),
                    root.getNextException());
            }
            message = MessageHelper.getMessage("error.sql.bad.grammar");
        } else {
            message = MessageHelper.getMessage("error.sql");
        }
    } else if (exception instanceof UnauthorizedClientException) {
        message = exception.getMessage();
        code = HttpStatus.UNAUTHORIZED;
    } else {
        message = exception.getMessage();
    }

    return new ResponseEntity<>(Result.error(StringUtils.defaultString(StringUtils.trimToNull(message),
                                   MessageHelper.getMessage("error" + ".default"))), code);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:39,代码来源:ExceptionHandlerAdvice.java

示例4: configure

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Override
@Order(1)
protected void configure(HttpSecurity http) throws Exception {
    http
            .authorizeRequests()
                .antMatchers(publicPath)
                .permitAll()
                .and()
            .formLogin()
                .loginPage("/auth/login")
                .successForwardUrl("/auth/status")
                .failureForwardUrl("/auth/status")
                .permitAll()
                .and()
            .logout()
                .logoutUrl("/auth/logout")
                .logoutSuccessUrl("/")
                .invalidateHttpSession(true)
                .deleteCookies()
                .and()
            .sessionManagement()
                .maximumSessions(1)
                .maxSessionsPreventsLogin(false)
    ;// END HTTP CONFIG

}
 
开发者ID:Dawn-Team,项目名称:dawn,代码行数:27,代码来源:SecurityConfig.java

示例5: findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes() throws Exception {
	Class<?> startClass = MetaConfigWithDefaultAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
		ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class[] { MetaConfig.DevConfig.class, MetaConfig.ProductionConfig.class },
		descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:MetaAnnotationUtilsTests.java

示例6: findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() throws Exception {
	Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
		ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class[] { MetaAnnotationUtilsTests.class },
		descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:MetaAnnotationUtilsTests.java

示例7: statViewServlet

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Bean
@Order
public ServletRegistrationBean statViewServlet() {
	StatViewServlet servlet = new StatViewServlet();
	ServletRegistrationBean bean = new ServletRegistrationBean(servlet, "/druid/*");
	return bean;
}
 
开发者ID:mazhaoyong,项目名称:api-server-seed,代码行数:8,代码来源:WebConfig.java

示例8: handleWorkspaceStatusEvent

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Order(Ordered.HIGHEST_PRECEDENCE + 3)
@EventListener
public void handleWorkspaceStatusEvent(WorkspaceStatusEvent event) {
    String spaceKey = event.getSpaceKey();

    if (event instanceof WorkspaceOnlineEvent) {
        updateWorkingStatus(spaceKey, Online);
        watch(spaceKey);
    } else if (event instanceof WorkspaceOfflineEvent) {
        if (!wsRepo.isDeleted(spaceKey)) {
            updateWorkingStatus(spaceKey, Offline);
        }
        unwatch(spaceKey);
    } else if (event instanceof WorkspaceDeleteEvent) {
        updateWorkingStatus(spaceKey, Deleted);
        unwatch(spaceKey);
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:19,代码来源:WorkspaceManagerImpl.java

示例9: configure

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Override
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected void configure(final HttpSecurity httpSecurity) throws Exception {
    httpSecurity
            .authorizeRequests()
            .antMatchers("/fonts/**").permitAll()
            .antMatchers("/register").permitAll()
            .anyRequest().authenticated()
            .and()
            .formLogin().loginPage("/login").permitAll()
            .and()
            .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll()
            .and()
            .exceptionHandling().accessDeniedPage("/access?error")
            .and().headers().xssProtection().block(false).xssProtectionEnabled(false).and() // Default setting for Spring Boot to activate XSS Protection (dont fix!)
            .and().csrf().disable(); // FIXME [dh] Enabling CSRF prevents file upload, must be fixed
}
 
开发者ID:Omegapoint,项目名称:facepalm,代码行数:18,代码来源:SecurityConfig.java

示例10: onAppLoggedOut

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void onAppLoggedOut(AppLoggedOutEvent event) {
    if (webIdpConfig.getIdpEnabled()
            && event.getLoggedOutSession() != null
            && event.getLoggedOutSession().getAttribute(IdpService.IDP_USER_SESSION_ATTRIBUTE) != null
            && event.getRedirectUrl() == null) {

        RequestContext requestContext = RequestContext.get();
        if (requestContext != null) {
            requestContext.getSession().removeAttribute(IDP_SESSION_ATTRIBUTE);
        }

        String idpBaseURL = webIdpConfig.getIdpBaseURL();
        if (!Strings.isNullOrEmpty(idpBaseURL)) {
            event.setRedirectUrl(getIdpLogoutUrl());
        } else {
            log.error("Application property cuba.web.idp.url is not set");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:IdpLoginLifecycleManager.java

示例11: appStarted

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void appStarted(AppStartedEvent event) {
    App app = event.getApp();
    Locale locale = app.getLocale();

    Principal principal = getSessionPrincipal();

    // Login on start only on first request from user
    if (isTryLoginOnStart()
            && principal != null
            && webAuthConfig.getExternalAuthentication()) {

        String userName = principal.getName();
        log.debug("Trying to login after external authentication as {}", userName);
        try {
            app.getConnection().loginAfterExternalAuthentication(userName, locale);
        } catch (LoginException e) {
            log.trace("Unable to login on start", e);
        } finally {
            // Close attempt login on start
            setTryLoginOnStart(false);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:LegacyLoginEventsForwarder.java

示例12: pingExternalAuthentication

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void pingExternalAuthentication(SessionHeartbeatEvent event) {
    Connection connection = event.getSource().getConnection();

    if (connection.isAuthenticated()
            && isLoggedInWithExternalAuth(connection.getSessionNN())) {
        try {
            // Ping external authentication
            if (webAuthConfig.getExternalAuthentication()) {
                UserSession session = connection.getSession();
                if (session != null) {
                    authProvider.pingUserSession(session);
                }
            }
        } catch (NoUserSessionException ignored) {
            // ignore no user session exception
        } catch (Exception e) {
            log.warn("Exception while external authenticated session ping", e);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:LegacyLoginEventsForwarder.java

示例13: initMetadata

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@EventListener(AppContextInitializedEvent.class)
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
protected void initMetadata() {
    if (session != null) {
        log.warn("Repetitive initialization\n" + StackTrace.asString());
        return;
    }

    log.info("Initializing metadata");
    long startTime = System.currentTimeMillis();

    MetadataLoader metadataLoader = (MetadataLoader) applicationContext.getBean(MetadataLoader.NAME);
    metadataLoader.loadMetadata();
    rootPackages = metadataLoader.getRootPackages();
    session = new CachingMetadataSession(metadataLoader.getSession());
    SessionImpl.setSerializationSupportSession(session);

    log.info("Metadata initialized in " + (System.currentTimeMillis() - startTime) + "ms");
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:MetadataImpl.java

示例14: init

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@EventListener(AppContextInitializedEvent.class)
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 100)
public void init() {
    String iconSetsProp = AppContext.getProperty("cuba.iconsConfig");
    if (StringUtils.isEmpty(iconSetsProp))
        return;

    for (String iconSetFqn : Splitter.on(' ').omitEmptyStrings().trimResults().split(iconSetsProp)) {
        try {
            Class<?> iconSetClass = ReflectionHelper.loadClass(iconSetFqn);

            if (!Icon.class.isAssignableFrom(iconSetClass)) {
                log.warn(iconSetClass + " is does not implement Icon");
                continue;
            }

            //noinspection unchecked
            iconSets.add((Class<? extends Icon>) iconSetClass);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(String.format("Unable to load icon set class: %s", iconSetFqn), e);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:IconsImpl.java

示例15: resourceUrlEncodingFilter

import org.springframework.core.annotation.Order; //导入依赖的package包/类
@Bean
@Order(value = 1)
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {

    // システムプロパティーが設定されていればデフォルト実装を使う
    String prop = System.getProperty("ResourceUrlEncodingFilter");
    if (StringUtils.equals(prop, "original")) {
        logger.info("using ResourceUrlEncodingFilter");
        return new ResourceUrlEncodingFilter();
    }
    // そうでなければCachingResourceUrlEncodingFilterを使う
    else {
        logger.info("using CachingResourceUrlEncodingFilter");
        return new CachingResourceUrlEncodingFilter("/static/");
    }
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:17,代码来源:WebConfig.java


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