/** * Sets the type of Spring {@link ApplicationContext} that will be created. If not * specified defaults to {@link #DEFAULT_SERVLET_WEB_CONTEXT_CLASS} for web based * applications or {@link AnnotationConfigApplicationContext} for non web based * applications. * @param applicationContextClass the context class to set */ public void setApplicationContextClass( Class<? extends ConfigurableApplicationContext> applicationContextClass) { this.applicationContextClass = applicationContextClass; this.webApplicationType = WebApplicationType .deduceFromApplicationContext(applicationContextClass); }
static WebApplicationType deduceFromApplicationContext( Class<?> applicationContextClass) { if (isAssignable(SERVLET_APPLICATION_CONTEXT_CLASS, applicationContextClass)) { return WebApplicationType.SERVLET; } if (isAssignable(REACTIVE_APPLICATION_CONTEXT_CLASS, applicationContextClass)) { return WebApplicationType.REACTIVE; } return WebApplicationType.NONE; }
protected void onApplicationReadyEvent(ApplicationReadyEvent event) { final SpringApplication springApplication = event.getSpringApplication(); if (!WebApplicationType.NONE.equals(springApplication.getWebApplicationType())) { return; } await(); }
/** * Create a new {@link SpringApplication} instance. The application context will load * beans from the specified primary sources (see {@link SpringApplication class-level} * documentation for details. The instance can be customized before calling * {@link #run(String...)}. * @param resourceLoader the resource loader to use * @param primarySources the primary bean sources * @see #run(Class, String[]) * @see #setSources(Set) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { this.resourceLoader = resourceLoader; Assert.notNull(primarySources, "PrimarySources must not be null"); this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources)); this.webApplicationType = WebApplicationType.deduceFromClasspath(); setInitializers((Collection) getSpringFactoriesInstances( ApplicationContextInitializer.class)); setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); this.mainApplicationClass = deduceMainApplicationClass(); }
@Override public void onApplicationEvent(ApplicationReadyEvent event) { if (!WebApplicationType.NONE.equals(event.getSpringApplication().getWebApplicationType())) { List<ProcessDefinition> processDefinitions = converter.from(repositoryService.createProcessDefinitionQuery().list()); for (ProcessDefinition processDefinition : processDefinitions) { ProcessDeployedEventImpl processDeployedEvent = new ProcessDeployedEventImpl(processDefinition); for (ProcessRuntimeEventListener<ProcessDeployedEvent> listener : listeners) { listener.onEvent(processDeployedEvent); } } } }
protected void onApplicationReadyEvent(ApplicationReadyEvent event) { final SpringApplication springApplication = event.getSpringApplication(); if (!WebApplicationType.NONE.equals(springApplication.getWebApplicationType())) { return; } await(); }
@Override public void onApplicationEvent(ApplicationReadyEvent event) { if (!WebApplicationType.NONE.equals(event.getSpringApplication().getWebApplicationType())) { List<ProcessDefinition> processDefinitions = converter.from(repositoryService.createProcessDefinitionQuery().list()); for (ProcessDefinition processDefinition : processDefinitions) { ProcessDeployedEventImpl processDeployedEvent = new ProcessDeployedEventImpl(processDefinition); for (ProcessRuntimeEventListener<ProcessDeployedEvent> listener : listeners) { listener.onEvent(processDeployedEvent); } } } }