Java 类org.springframework.core.SpringVersion 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CrshAutoConfiguration.java   
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;
}
项目:spring-cloud-deployer    文件:RuntimeEnvironmentInfo.java   
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);
}
项目:spring-cloud-deployer    文件:RuntimeEnvironmentInfoBuilderTests.java   
@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"));
}
项目:spring-boot-concourse    文件:CrshAutoConfiguration.java   
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;
}
项目:contestparser    文件:CrshAutoConfiguration.java   
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;
}
项目:azure-application-insights-spring-boot-starter    文件:SpringBootContextInitializer.java   
@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);
    }
}
项目:nixmash-blog    文件:JpaLauncher.java   
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();
    }
项目:nixmash-blog    文件:SolrLauncher.java   
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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationContextLoader.java   
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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringBootContextLoader.java   
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;
}
项目:spring-boot-concourse    文件:SpringApplicationContextLoader.java   
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;
}
项目:spring-boot-concourse    文件:SpringBootContextLoader.java   
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;
}
项目:online-whatif    文件:OWIServiceImpl.java   
@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;
}
项目:contestparser    文件:SpringApplicationContextLoader.java   
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;
}
项目:madsonic-server-5.1    文件:VersionChecker.java   
@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", "");
   }
项目:spring-ldap    文件:DefaultObjectDirectoryMapper.java   
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();
    }
}
项目:spring-ldap    文件:DefaultObjectDirectoryMapperTest.java   
@Test
public void springVersionIsNull() {
    spy(SpringVersion.class);
    when(SpringVersion.getVersion()).thenReturn(null);

    DefaultObjectDirectoryMapper mapper = new DefaultObjectDirectoryMapper();

    // LDAP-300
    assertThat(Whitebox.getInternalState(mapper,"converterManager")).isNotNull();
}
项目:AptSpring    文件:TakariIncrementalCompileTests.java   
@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();
}
项目:nbone    文件:SpringWebApplicationInitializer.java   
@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);


}
项目:eclipse.jdt.ls    文件:InternalBar.java   
public static void main(String[] args) {
    System.err.println(SpringVersion.getVersion());
}
项目:online-whatif    文件:OWIServiceImpl.java   
/**
 * 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!");
  }
}
项目:example-java    文件:SpringCoreTest.java   
@Test
public void testSpringVersionGetVersion(){
    System.out.print(SpringVersion.getVersion());
}
项目:dynamicbeanloader    文件:WebAppinitializer.java   
@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());

    }
项目:pmcms    文件:ToolVersionInfo.java   
public static Map<TYPE, String> getSpring() {
    return generateInfo(SpringVersion.class);
}
项目:nbone    文件:Test.java   
public static void main(String[] args) {

    System.out.println(JdkVersion.getJavaVersion());
    System.out.println(JavaVersion.JAVA_1_8);
    System.out.println(SpringVersion.getVersion());

}