Coverage Report - org.seasar.teeda.core.ProductInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
ProductInfo
0%
0/15
0%
0/2
2.333
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core;
 17  
 
 18  
 import java.io.InputStream;
 19  
 import java.net.URL;
 20  
 import java.util.Properties;
 21  
 
 22  
 /**
 23  
  * @author shot
 24  
  * @author manhole
 25  
  */
 26  0
 public class ProductInfo {
 27  
 
 28  
     private static final String POM_PROPERTIES_NAME = "META-INF/maven/org.seasar.teeda/teeda-core/pom.properties";
 29  
 
 30  
     private static final String UNKNOWN_VERSION = "unknown";
 31  
 
 32  
     public static String getProductName() {
 33  0
         return "Teeda";
 34  
     }
 35  
 
 36  
     public static String getVersion() {
 37  
         try {
 38  0
             final URL url = Thread.currentThread().getContextClassLoader()
 39  
                     .getResource(POM_PROPERTIES_NAME);
 40  0
             if (url == null) {
 41  0
                 return UNKNOWN_VERSION;
 42  
             }
 43  0
             final InputStream is = url.openStream();
 44  
             try {
 45  0
                 Properties props = new Properties();
 46  0
                 props.load(is);
 47  0
                 return props.getProperty("version");
 48  
             } finally {
 49  0
                 is.close();
 50  
             }
 51  0
         } catch (Exception e) {
 52  0
             e.printStackTrace();
 53  0
             return UNKNOWN_VERSION;
 54  
         }
 55  
     }
 56  
 
 57  
     /*
 58  
      * MANIFEST.MFのmain-classに指定しておき、jarを実行するとバージョン番号が
 59  
      * コンソールへ出力されるようにする。
 60  
      */
 61  
     public static void main(final String[] args) {
 62  0
         System.out.println("teeda.version: " + getVersion());
 63  0
     }
 64  
 
 65  
 }