protected Map<String, Object> createPluginContextAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); String bootVersion = CrshAutoConfiguration.class.getPackage() .getImplementationVersion(); if (bootVersion != null) { attributes.put("spring.boot.version", bootVersion); } attributes.put("spring.version", SpringVersion.getVersion()); if (this.beanFactory != null) { attributes.put("spring.beanfactory", this.beanFactory); } if (this.environment != null) { attributes.put("spring.environment", this.environment); } return attributes; }
private RuntimeEnvironmentInfo(Class spiClass, String implementationName, String implementationVersion, String platformType, String platformApiVersion, String platformClientVersion, String platformHostVersion, Map<String, String> platformSpecificInfo) { Assert.notNull(spiClass, "spiClass is required"); Assert.notNull(implementationName, "implementationName is required"); Assert.notNull(implementationVersion, "implementationVersion is required"); Assert.notNull(platformType, "platformType is required"); Assert.notNull(platformApiVersion, "platformApiVersion is required"); Assert.notNull(platformClientVersion, "platformClientVersion is required"); Assert.notNull(platformHostVersion, "platformHostVersion is required"); this.spiVersion = RuntimeVersionUtils.getVersion(spiClass); this.implementationName = implementationName; this.implementationVersion = implementationVersion; this.platformType = platformType; this.platformApiVersion = platformApiVersion; this.platformClientVersion = platformClientVersion; this.platformHostVersion = platformHostVersion; this.javaVersion = System.getProperty("java.version"); this.springVersion = SpringVersion.getVersion(); this.springBootVersion = RuntimeVersionUtils.getSpringBootVersion(); this.platformSpecificInfo.putAll(platformSpecificInfo); }
@Test public void testCreatingRuntimeEnvironmentInfo() { RuntimeEnvironmentInfo rei = new RuntimeEnvironmentInfo.Builder() .spiClass(AppDeployer.class) .implementationName("TestDeployer") .implementationVersion("1.0.0") .platformClientVersion("1.2.0") .platformHostVersion("1.1.0") .platformType("Test") .platformApiVersion("1") .addPlatformSpecificInfo("foo", "bar") .build(); assertThat(rei.getSpiVersion(), is(RuntimeVersionUtils.getVersion(AppDeployer.class))); assertThat(rei.getImplementationName(), is("TestDeployer")); assertThat(rei.getImplementationVersion(), is("1.0.0")); assertThat(rei.getPlatformType(), is("Test")); assertThat(rei.getPlatformApiVersion(), is("1")); assertThat(rei.getPlatformClientVersion(), is("1.2.0")); assertThat(rei.getPlatformHostVersion(), is("1.1.0")); assertThat(rei.getJavaVersion(), is(System.getProperty("java.version"))); assertThat(rei.getSpringVersion(), is(SpringVersion.getVersion())); assertThat(rei.getSpringBootVersion(), is(RuntimeVersionUtils.getSpringBootVersion())); assertThat(rei.getPlatformSpecificInfo().get("foo"), is("bar")); }
@Override public void initialize(TelemetryContext telemetryContext) { RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(environment); telemetryContext.getTags().put("ai.spring-boot.version", SpringBootVersion.getVersion()); telemetryContext.getTags().put("ai.spring.version", SpringVersion.getVersion()); String ipAddress = relaxedPropertyResolver.getProperty("spring.cloud.client.ipAddress"); if (ipAddress != null) { // if spring-cloud is available we can set ip address telemetryContext.getTags().put(ContextTagKeys.getKeys().getLocationIP(), ipAddress); } }
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ApplicationConfig.class); ctx.refresh(); System.out.println("Spring Framework Version: " + SpringVersion.getVersion()); System.out.println("Spring Boot Version: " + SpringBootVersion.getVersion()); JpaUI ui = ctx.getBean(JpaUI.class); ui.init(); ctx.close(); }
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(SolrApplicationConfig.class); ctx.refresh(); System.out.println("Using Spring Framework Version: " + SpringVersion.getVersion()); System.out.println("Solr Active Profile: " + ctx.getEnvironment().getActiveProfiles()[0]); SolrUI ui = ctx.getBean(SolrUI.class); if (doReIndex(args)) ui.populate(); else ui.init(); ctx.close(); }
private Set<Object> getSources(MergedContextConfiguration mergedConfig) { Set<Object> sources = new LinkedHashSet<Object>(); sources.addAll(Arrays.asList(mergedConfig.getClasses())); sources.addAll(Arrays.asList(mergedConfig.getLocations())); Assert.state(!sources.isEmpty(), "No configuration classes " + "or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need " + "Spring 4.0.3 or better (found " + SpringVersion.getVersion() + ")."); return sources; }
@Override public Map<String, String> getOWIVersion() { LOGGER.info("Using version: " + WifKeys.WIF_KEY_VERSION); LOGGER.info("Spring version: {} ", SpringVersion.getVersion()); LOGGER.info("GeoTools version: {} ", GeoTools.getVersion()); // LOGGER.info("Datastore client version: {} ", // dataStoreClient.getVersion()); versionsMap.put("What-If API", WifKeys.WIF_KEY_VERSION); versionsMap.put("Spring", SpringVersion.getVersion()); versionsMap.put("Geotools", GeoTools.getVersion().toString()); versionsMap.put("DatastoreClient", "N/A"); return versionsMap; }
private Set<Object> getSources(MergedContextConfiguration mergedConfig) { Set<Object> sources = new LinkedHashSet<Object>(); sources.addAll(Arrays.asList(mergedConfig.getClasses())); sources.addAll(Arrays.asList(mergedConfig.getLocations())); Assert.state(sources.size() > 0, "No configuration classes " + "or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need " + "Spring 4.0.3 or better (found " + SpringVersion.getVersion() + ")."); return sources; }
@SuppressWarnings("static-access") public static String getSpringFrameworkVersion() { String version = null; try { SpringVersion springVersion = new SpringVersion(); version = springVersion.getVersion(); } catch (Exception x) {} return version == null ? "3.2.14" : version.replace(".RELEASE", ""); }
private static ConverterManager createDefaultConverterManager() { String springVersion = SpringVersion.getVersion(); if(springVersion == null) { LOG.debug("Could not determine the Spring Version. Guessing > Spring 3.0. If this does not work, please ensure to explicitly set converterManager"); return new ConversionServiceConverterManager(); } else if(springVersion.compareTo("3.0") > 0) { return new ConversionServiceConverterManager(); } else { return new ConverterManagerImpl(); } }
@Test public void springVersionIsNull() { spy(SpringVersion.class); when(SpringVersion.getVersion()).thenReturn(null); DefaultObjectDirectoryMapper mapper = new DefaultObjectDirectoryMapper(); // LDAP-300 assertThat(Whitebox.getInternalState(mapper,"converterManager")).isNotNull(); }
@Test public void testBasic() throws Exception { // this creates a temporary copy of src/test/projects/basic test project File basedir = resources.getBasedir("basic"); // create MavenProject model for the test project MavenProject project = maven.readMavenProject(basedir); // add annotation processor to the test project dependencies (i.e. // classpath) File springContext = new File(Bean.class.getProtectionDomain().getCodeSource().getLocation().toURI()); maven.newDependency(springContext.getCanonicalFile()).setArtifactId("spring-context").addTo(project); File springCore = new File(SpringVersion.class.getProtectionDomain().getCodeSource().getLocation().toURI()); maven.newDependency(springCore.getCanonicalFile()).setArtifactId("spring-core").addTo(project); File springBean = new File(BeanDefinition.class.getProtectionDomain().getCodeSource().getLocation().toURI()); maven.newDependency(springBean.getCanonicalFile()).setArtifactId("spring-bean").addTo(project).addTo(project); File verifiedApi = new File(Verified.class.getProtectionDomain().getCodeSource().getLocation().toURI()); maven.newDependency(verifiedApi.getCanonicalFile()).setArtifactId("verifiedApi").addTo(project); File verifiedImpl = new File( SpringAnnotationParser.class.getProtectionDomain().getCodeSource().getLocation().toURI()); maven.newDependency(verifiedImpl.getCanonicalFile()).setArtifactId("verifiedProcessor").addTo(project); MavenSession session = maven.newMavenSession(project); // run java compiler with annotation processing enabled maven.executeMojo(session, project, "compile", newParameter("compilerId", compilerId), newParameter(PROC, PROC)); File compiledClasses = new File(basedir, "target/classes"); File generatedSources = new File(basedir, "target/generated-sources/annotations"); File configurationSourceFile = (new File(generatedSources, "com/salesforce/aptspring/ComputerHardwareConfiguration_forceInjectData.java")); assertThat(configurationSourceFile).exists().canRead(); File configurationClass = (new File(compiledClasses, "com/salesforce/aptspring/ComputerHardwareConfiguration_forceInjectData.class")); assertThat(configurationClass).exists().canRead(); maven.executeMojo(session, project, "testCompile", newParameter("compilerId", compilerId), newParameter(PROC, PROC)); File compiledTestClasses = new File(basedir, "target/test-classes"); File configurationTestClass = (new File(compiledTestClasses, "com/salesforce/aptspring/RootApplicationConfiguration_forceInjectData.class")); assertThat(configurationTestClass).exists().canRead(); }
@Override public void onStartup(ServletContext servletContext) throws ServletException { initialApplicationContext(servletContext); servletContext.log("==============================================================================="); servletContext.log("Java EE 6 Servlet 3.0"); servletContext.log("Nbone Version: " + NboneVersion.getVersion(NboneVersion.version)); servletContext.log("Spring Version: " + SpringVersion.getVersion()); String encoding = servletContext.getInitParameter("encoding"); servletContext.log("current WebApplication config set character encoding: "+ encoding +" .thinking"); if(!StringUtils.hasText(encoding)){ encoding = CharsetConstant.CHARSET_UTF8; servletContext.log("current WebApplication use default character encoding: "+ encoding +" .thinking"); } servletContext.log("==============================================================================="); //DispatcherServlet initDispatcherServlet(servletContext); //CharacterEncodingFilter initCharacterEncodingFilter(servletContext, encoding); //HiddenHttpMethodFilter initHiddenHttpMethodFilter(servletContext); //HttpPutFormContentFilter initHttpPutFormContentFilter(servletContext); //XXX:ThinkPrepareFilter 特殊情况下开启暂存 request response //initThinkPrepareFilter(servletContext); //RequestContextFilter initRequestContextFilter(servletContext); //GzipFilter initGzipFilter(servletContext); //HibernateLazy initHibernateOpenSessionInViewFilter(servletContext); }
public static void main(String[] args) { System.err.println(SpringVersion.getVersion()); }
/** * Inits the demonstration data. */ @PostConstruct public void init() { LOGGER.info("Initializing version: {} ", WifKeys.WIF_KEY_VERSION); LOGGER.info("Spring version: {} ", SpringVersion.getVersion()); LOGGER.info("GeoTools version: {} ", GeoTools.getVersion()); // LOGGER.info("Datastore client version: {} ", // dataStoreClient.getVersion()); LOGGER.info("loading demonstration data..."); try { // final WifProject project = dataCreator.createDemonstrationModule( // WifKeys.TEST_PROJECT_ID, WifKeys.TEST_SUITABILITY_SCENARIO_ID, // WifKeys.TEST_DEMAND_CONFIG_ID, WifKeys.TEST_DEMAND_SCENARIO_ID, // WifKeys.TEST_ALLOCATION_SCENARIO_ID, // WifKeys.TEST_ALLOCATION_REPORT_ID, // WifKeys.TEST_MANUAL_DEMAND_CONFIG_ID); // Assert.notNull(project, "Default project must not be null"); // LOGGER.info(" successfully loaded all demonstration data!!"); ///new for copying demo project after deploy. Boolean lsw = false; final List<WifProject> wifProjects = projectService.getAllProjects(WifKeys.SHIB_ROLE_NAME); for (final WifProject prj:wifProjects) { if (prj.getRoleOwner().toLowerCase().equals(WifKeys.SHIB_ROLE_NAME.toLowerCase())) { if (prj.getLabel().toLowerCase().equals(WifKeys.DEMO_PROJECT_NAME_ADMIN.toLowerCase())) { lsw = true; } } } if (lsw == false) { final String roleId = WifKeys.SHIB_ROLE_NAME; final ObjectMapper mapper = new ObjectMapper(); final URL jsonsource = getClass().getResource("/wanneroo.json"); final ProjectReport projectReport = mapper.readValue(jsonsource.openStream(),ProjectReport.class); final WifProject wifProject = projectService.restoreProjectConfiguration(projectReport); LOGGER.info("*******>> project default restored with ID ={} ", wifProject.getId()); final WifProject newProject = projectService.getProject(wifProject.getId()); newProject.setName(WifKeys.DEMO_PROJECT_NAME_ADMIN); newProject.setRoleOwner(roleId); //wanneroo table must exists in the database before. newProject.getSuitabilityConfig().setUnifiedAreaZone("wanneroo"); projectService.updateProject(newProject); //pubish Geoserver layer CoordinateReferenceSystem crs = null; crs = CRS.decode(WifKeys.CRS_WANNEROO); //EPSG:28350 projectService.PublishWMSLayer( newProject.getSuitabilityConfig().getUnifiedAreaZone(), crs, newProject.getId()); } ///end new LOGGER.info(" successfully loaded all demonstration data!!"); } catch (final Exception e) { LOGGER.error(" demonstration data could not be loaded!"); } }
@Test public void testSpringVersionGetVersion(){ System.out.print(SpringVersion.getVersion()); }
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Setup Context to Accept Annotated Classes on Input (including plain Spring {@code @Component} // Stereotypes in addition to JSR-330 Compliant Classes using {@code javax.inject} AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); //context.setConfigLocation(APP_CONFIG_LOCATION); context.setConfigLocation(APP_CONFIG_LOCATION); /* * Add a Spring Security Filter using the JEE6 Filter Registration Filter Method from {@code FilterRegistration) that allows filters to be registered * and configured with the specified context */ /* FilterRegistration.Dynamic securityFilter = servletContext.addFilter(ProjectKeyValConsts.SECURITY_FILTER.getKey(), new DelegatingFilterProxy(ProjectKeyValConsts.SECURITY_FILTER.getValue())); securityFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ProjectConsts.BASE_URL_MAPPING_PATTERN.getValue()); // where the filter will be applied */ // Add a Character Encoding Filter that specifies an encoding for mapped requests FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ROOT_CONTEXT); // where the filter will be applied characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", Boolean.TRUE.toString()); characterEncodingFilter.setAsyncSupported(true); servletContext.addListener(new ContextLoaderListener(context)); servletContext.setInitParameter("defaultHtmlEscape", Boolean.TRUE.toString()); DispatcherServlet servlet = new DispatcherServlet(); // no explicit configuration reference here: everything is configured in the root container for simplicity servlet.setContextConfigLocation(""); /* TMT From JEE 6 API Docs: * Registers the given servlet instance with this ServletContext under the given servletName. * The registered servlet may be further configured via the returned ServletRegistration object. */ ServletRegistration.Dynamic appServlet = servletContext.addServlet(APP_SERVLET, servlet); appServlet.setLoadOnStartup(1); appServlet.setAsyncSupported(true); Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException(String.format("The servlet named '%s' cannot be mapped to '/' under Tomcat versions <= 7.0.14", APP_SERVLET)); } // TMT servletContext.addListener(new Log4jConfigListener()); System.out.println("Application inplemented on Spring Version: " + SpringVersion.getVersion()); }
public static Map<TYPE, String> getSpring() { return generateInfo(SpringVersion.class); }
public static void main(String[] args) { System.out.println(JdkVersion.getJavaVersion()); System.out.println(JavaVersion.JAVA_1_8); System.out.println(SpringVersion.getVersion()); }