本文整理匯總了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");
}
};
}
示例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());
}
}
}
}
}
示例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);
}
示例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
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
}
示例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
}
示例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");
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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");
}
示例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);
}
}
}
示例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/");
}
}