List of usage examples for org.springframework.core.annotation AnnotationAwareOrderComparator AnnotationAwareOrderComparator
AnnotationAwareOrderComparator
From source file:org.jtransfo.spring.JTransfoSpring.java
/** * Get object finders and type converters from Spring configuration. *//* w w w. ja va 2 s.c om*/ @PostConstruct protected void postConstruct() { if (null != typeConverters) { getTypeConverters().addAll(typeConverters); updateTypeConverters(); } if (null != objectFinders) { getObjectFinders().addAll(objectFinders); updateObjectFinders(); } if (null != convertInterceptors) { Collections.sort(convertInterceptors, new AnnotationAwareOrderComparator()); getConvertInterceptors().addAll(convertInterceptors); updateConvertInterceptors(); } }
From source file:it.tidalwave.northernwind.core.impl.model.FilterSetExpander.java
@PostConstruct /* package */ void initialize() { Collections.sort(filters, new AnnotationAwareOrderComparator()); }
From source file:it.tidalwave.northernwind.frontend.ui.spi.DefaultSiteViewController.java
/******************************************************************************************************************* * * Logs the {@link RequestProcessor}s.// ww w. j a va2 s . c o m * ******************************************************************************************************************/ @PostConstruct /* package */ void initialize() { Collections.sort(requestProcessors, new AnnotationAwareOrderComparator()); log.info(">>>> requestProcessors:"); for (final RequestProcessor requestProcessor : requestProcessors) { log.info(">>>>>>>> {}", requestProcessor); } }
From source file:com.thinkbiganalytics.auth.jaas.config.JaasAuthConfig.java
@Bean(name = "jaasConfiguration") public javax.security.auth.login.Configuration jaasConfiguration( Optional<List<LoginConfiguration>> loginModuleEntries) { // Generally the entries will be null only in situations like unit/integration tests. if (loginModuleEntries.isPresent()) { List<LoginConfiguration> sorted = new ArrayList<>(loginModuleEntries.get()); sorted.sort(new AnnotationAwareOrderComparator()); Map<String, AppConfigurationEntry[]> merged = sorted.stream() .map(c -> c.getAllApplicationEntries().entrySet()).flatMap(s -> s.stream()) .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue(), ArrayUtils::addAll)); return new InMemoryConfiguration(merged); } else {//from ww w . j a v a 2 s . co m return new InMemoryConfiguration(Collections.emptyMap()); } }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoader.java
/** * Customize the {@link ConfigurablePortletApplicationContext} created by this * PortletContextLoader after config locations have been supplied to the context * but before the context is <em>refreshed</em>. * <p>The default implementation {@linkplain #determineContextInitializerClasses(PortletContext) * determines} what (if any) context initializer classes have been specified through * {@linkplain #CONTEXT_INITIALIZER_CLASSES_PARAM context init parameters} and * {@linkplain ApplicationContextInitializer#initialize invokes each} with the * given web application context./*from w ww . j a v a 2s .c o m*/ * <p>Any {@code ApplicationContextInitializers} implementing * {@link org.springframework.core.Ordered Ordered} or marked with @{@link * org.springframework.core.annotation.Order Order} will be sorted appropriately. * @param portletContext the current portlet context * @param applicationContext the newly created application context * @see #createPortletApplicationContext(PortletContext) * @see #CONTEXT_INITIALIZER_CLASSES_PARAM * @see ApplicationContextInitializer#initialize(ConfigurableApplicationContext) */ protected void customizeContext(PortletContext portletContext, ConfigurablePortletApplicationContext applicationContext) { List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> initializerClasses = determineContextInitializerClasses( portletContext); if (initializerClasses.size() == 0) { // no ApplicationContextInitializers have been declared -> nothing to do return; } ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerInstances = new ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>>(); for (Class<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerClass : initializerClasses) { Class<?> contextClass = applicationContext.getClass(); Class<?> initializerContextClass = GenericTypeResolver.resolveTypeArgument(initializerClass, ApplicationContextInitializer.class); Assert.isAssignable(initializerContextClass, contextClass, String.format( "Could not add context initializer [%s] as its generic parameter [%s] " + "is not assignable from the type of application context used by this " + "context loader [%s]", initializerClass.getName(), initializerContextClass, contextClass)); initializerInstances.add(BeanUtils.instantiateClass(initializerClass)); } //TODO remove cast when ContribXmlPortletApplicationContext is merged into super classes ((ConfigurablePortletEnvironment) applicationContext.getEnvironment()) .initPropertySources(this.servletContext, portletContext, null); Collections.sort(initializerInstances, new AnnotationAwareOrderComparator()); for (ApplicationContextInitializer<ConfigurableApplicationContext> initializer : initializerInstances) { initializer.initialize(applicationContext); } }
From source file:com.dhcc.framework.web.context.DhccContextLoader.java
/** * Customize the {@link ConfigurableWebApplicationContext} created by this * ContextLoader after config locations have been supplied to the context * but before the context is <em>refreshed</em>. * <p>The default implementation {@linkplain #determineContextInitializerClasses(ServletContext) * determines} what (if any) context initializer classes have been specified through * {@linkplain #CONTEXT_INITIALIZER_CLASSES_PARAM context init parameters} and * {@linkplain ApplicationContextInitializer#initialize invokes each} with the * given web application context.//w w w. ja va 2s . c o m * <p>Any {@code ApplicationContextInitializers} implementing * {@link org.springframework.core.Ordered Ordered} or marked with @{@link * org.springframework.core.annotation.Order Order} will be sorted appropriately. * @param servletContext the current servlet context * @param applicationContext the newly created application context * @see #createWebApplicationContext(ServletContext, ApplicationContext) * @see #CONTEXT_INITIALIZER_CLASSES_PARAM * @see ApplicationContextInitializer#initialize(ConfigurableApplicationContext) */ protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) { List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> initializerClasses = determineContextInitializerClasses( servletContext); if (initializerClasses.size() == 0) { // no ApplicationContextInitializers have been declared -> nothing to do return; } Class<?> contextClass = applicationContext.getClass(); ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerInstances = new ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>>(); for (Class<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerClass : initializerClasses) { Class<?> initializerContextClass = GenericTypeResolver.resolveTypeArgument(initializerClass, ApplicationContextInitializer.class); if (initializerContextClass != null) { Assert.isAssignable(initializerContextClass, contextClass, String.format( "Could not add context initializer [%s] as its generic parameter [%s] " + "is not assignable from the type of application context used by this " + "context loader [%s]: ", initializerClass.getName(), initializerContextClass.getName(), contextClass.getName())); } initializerInstances.add(BeanUtils.instantiateClass(initializerClass)); } ConfigurableEnvironment env = applicationContext.getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(servletContext, null); } Collections.sort(initializerInstances, new AnnotationAwareOrderComparator()); for (ApplicationContextInitializer<ConfigurableApplicationContext> initializer : initializerInstances) { initializer.initialize(applicationContext); } }
From source file:org.springframework.boot.context.embedded.ServletContextInitializerBeans.java
private int getOrder(Object value) { return new AnnotationAwareOrderComparator() { @Override//from w w w . ja va 2 s .co m public int getOrder(Object obj) { return super.getOrder(obj); } }.getOrder(value); }