Example usage for java.util.jar Manifest read

List of usage examples for java.util.jar Manifest read

Introduction

In this page you can find the example usage for java.util.jar Manifest read.

Prototype

public void read(InputStream is) throws IOException 

Source Link

Document

Reads the Manifest from the specified InputStream.

Usage

From source file:org.zanata.ZanataInit.java

public void initZanata(ServletContext context) throws Exception {
    checkAppServerVersion();/*from  ww w  .ja  v  a 2 s  . c om*/
    String appServerHome = context.getRealPath("/");
    File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
    VersionInfo zanataVersion;
    Attributes atts = null;
    if (manifestFile.canRead()) {
        Manifest mf = new Manifest();
        try (FileInputStream fis = new FileInputStream(manifestFile)) {
            mf.read(fis);
        }
        atts = mf.getMainAttributes();
    }
    zanataVersion = VersionUtility.getVersionInfo(atts, ZanataInit.class);
    this.applicationConfiguration.setVersion(zanataVersion.getVersionNo());
    this.applicationConfiguration.setBuildTimestamp(zanataVersion.getBuildTimeStamp());
    this.applicationConfiguration.setScmDescribe(zanataVersion.getScmDescribe());
    this.applicationConfiguration.applyLoggingConfiguration();
    logBanner(zanataVersion);
    boolean authlogged = false;
    if (applicationConfiguration.isInternalAuth()) {
        log.info("Internal authentication: enabled");
        authlogged = true;
    }
    if (applicationConfiguration.isOpenIdAuth()) {
        log.info("OpenID authentication: enabled");
        authlogged = true;
    }
    if (applicationConfiguration.isKerberosAuth()) {
        log.info("SPNEGO/Kerberos authentication: enabled");
        authlogged = true;
    }
    if (!authlogged) {
        log.info("Using JAAS authentication");
    }
    log.info("Enable copyTrans: {}", this.applicationConfiguration.isCopyTransEnabled());
    String javamelodyDir = System.getProperty("javamelody.storage-directory");
    log.info("JavaMelody stats directory: " + javamelodyDir);
    String indexBase = applicationConfiguration.getHibernateSearchIndexBase();
    log.info("Lucene index directory: " + indexBase);
    if (indexBase != null) {
        checkLuceneLocks(new File(indexBase));
    }
    // Email server information
    log.info("Mail Session (JNDI): {}", EmailBuilder.MAIL_SESSION_JNDI);
    startupEvent.fire(new ServerStarted());
    log.info("Started Zanata...");
}

From source file:tilda.db.ConnectionPool.java

private static void LoadTildaResources(Connection C, boolean Migrate) throws Exception {
    Reader R = null;//  w  w w .j av a  2s .  c  o  m
    InputStream In = null;
    Enumeration<URL> resEnum = ConnectionPool.class.getClassLoader().getResources(JarFile.MANIFEST_NAME);
    List<Schema> TildaList = new ArrayList<Schema>();
    while (resEnum.hasMoreElements()) {
        URL url = (URL) resEnum.nextElement();
        In = url.openStream();
        if (In != null) {
            Manifest Man = new Manifest();
            Man.read(In);
            In.close();
            String Tildas = Man.getMainAttributes().getValue("Tilda");
            if (TextUtil.isNullOrEmpty(Tildas) == false) {
                LOG.debug("Found Tilda(s) " + Tildas + " in " + url.toString());
                String[] parts = Tildas.split(";");
                if (parts != null)
                    for (String p : parts) {
                        if (TextUtil.isNullOrEmpty(p) == true)
                            continue;
                        p = p.trim();
                        In = FileUtil.getResourceAsStream(p);
                        if (In == null)
                            throw new Exception(
                                    "Tilda schema definition '" + p + "' could not be found in the classpath.");
                        LOG.info("Inspecting " + p);
                        R = new BufferedReader(new InputStreamReader(In));
                        Gson gson = new GsonBuilder().setPrettyPrinting().create();
                        Schema S = gson.fromJson(R, Schema.class);
                        S.setOrigin(p);
                        TildaList.add(S);
                        In.close();
                    }
            }
        }
    }
    ReorderTildaListWithDependencies(TildaList);
    // LOG.debug("All Tildas in order of dependencies:");
    // for (Schema S : TildaList)
    // LOG.debug(" "+S._ResourceNameShort);
    if (Migrate == false)
        Migrator.logMigrationWarning();
    int warnings = 0;
    for (Schema S : TildaList) {
        int w = Migrator.migrate(C, S, Migrate);
        if (w != 0 && Migrate == false) {
            warnings += w;
            LOG.warn("There were " + w
                    + " warning(s) issued because schema discrepencies were found but not fixed.");
            Migrator.logMigrationWarning();
            continue;
        }
        LOG.debug("Initializing Schema objects");
        Method M = Class.forName(tilda.generation.java8.Helper.getSupportClassFullName(S))
                .getMethod("initSchema", Connection.class);
        M.invoke(null, C);
        _SchemaPackage.put(S._Name, S._Package);
        C.commit();
    }
    LOG.debug("");
    LOG.debug("Creating/updating Tilda helper stored procedures.");
    if (Migrate == false)
        Migrator.logMigrationWarning();
    else if (C.addHelperFunctions() == false)
        throw new Exception("Cannot upgrade schema by adding the Tilda helper functions.");

    if (warnings != 0 && Migrate == false) {
        LOG.warn("");
        LOG.warn("");
        LOG.warn("There were a total of " + warnings
                + " warning(s) issued because schema discrepencies were found but not fixed.");
        Migrator.logMigrationWarning();
    }

    C.commit();
}