Example usage for java.util.jar Manifest getMainAttributes

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

Introduction

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

Prototype

public Attributes getMainAttributes() 

Source Link

Document

Returns the main Attributes for the Manifest.

Usage

From source file:org.mule.MuleManager.java

/**
 * Returns a formatted string that is a summary of the configuration of the
 * server. This is the brock of information that gets displayed when the
 * server starts//from www.  jav  a  2 s.  c o m
 * 
 * @return a string summary of the server information
 */
protected String getStartSplash() {
    String notset = new Message(Messages.NOT_SET).getMessage();

    List message = new ArrayList();
    Manifest mf = config.getManifest();
    Map att = mf.getMainAttributes();
    if (att.values().size() > 0) {
        message.add(PropertiesHelper.getStringProperty(att, new Attributes.Name("Specification-Title"), notset)
                + " " + new Message(Messages.VERSION).getMessage() + " " + PropertiesHelper
                        .getStringProperty(att, new Attributes.Name("Implementation-Version"), notset));

        message.add(
                PropertiesHelper.getStringProperty(att, new Attributes.Name("Specification-Vendor"), notset));
        message.add(
                PropertiesHelper.getStringProperty(att, new Attributes.Name("Implementation-Vendor"), notset));
    } else {
        message.add(new Message(Messages.VERSION_INFO_NOT_SET).getMessage());
    }
    message.add(" ");
    message.add(new Message(Messages.SERVER_STARTED_AT_X, new Date(getStartDate()).toString()).getMessage());
    message.add("JDK: " + System.getProperty("java.version") + " (" + System.getProperty("java.vm.info") + ")");
    message.add("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", "
            + System.getProperty("os.arch") + ")");
    message.add(" ");
    if (agents.size() == 0) {
        message.add(new Message(Messages.AGENTS_RUNNING).getMessage() + " "
                + new Message(Messages.NONE).getMessage());
    } else {
        message.add(new Message(Messages.AGENTS_RUNNING).getMessage());
        UMOAgent umoAgent;
        for (Iterator iterator = agents.values().iterator(); iterator.hasNext();) {
            umoAgent = (UMOAgent) iterator.next();
            message.add("  " + umoAgent.getDescription());
        }
    }
    return StringMessageHelper.getBoilerPlate(message, '*', 70);
}

From source file:com.liferay.portal.plugin.PluginPackageUtil.java

private PluginPackage _readPluginPackageServletManifest(ServletContext servletContext) throws IOException {
    Attributes attributes = null;

    String servletContextName = servletContext.getServletContextName();

    InputStream inputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");

    if (inputStream != null) {
        Manifest manifest = new Manifest(inputStream);

        attributes = manifest.getMainAttributes();
    } else {//from  w ww . j a v  a  2  s . c  om
        attributes = new Attributes();
    }

    String artifactGroupId = attributes.getValue("Implementation-Vendor-Id");

    if (Validator.isNull(artifactGroupId)) {
        artifactGroupId = attributes.getValue("Implementation-Vendor");
    }

    if (Validator.isNull(artifactGroupId)) {
        artifactGroupId = GetterUtil.getString(attributes.getValue("Bundle-Vendor"), servletContextName);
    }

    String artifactId = attributes.getValue("Implementation-Title");

    if (Validator.isNull(artifactId)) {
        artifactId = GetterUtil.getString(attributes.getValue("Bundle-Name"), servletContextName);
    }

    String version = attributes.getValue("Implementation-Version");

    if (Validator.isNull(version)) {
        version = GetterUtil.getString(attributes.getValue("Bundle-Version"), Version.UNKNOWN);
    }

    if (version.equals(Version.UNKNOWN) && _log.isWarnEnabled()) {
        _log.warn("Plugin package on context " + servletContextName
                + " cannot be tracked because this WAR does not contain a "
                + "liferay-plugin-package.xml file");
    }

    PluginPackage pluginPackage = new PluginPackageImpl(artifactGroupId + StringPool.SLASH + artifactId
            + StringPool.SLASH + version + StringPool.SLASH + "war");

    pluginPackage.setName(artifactId);

    String shortDescription = attributes.getValue("Bundle-Description");

    if (Validator.isNotNull(shortDescription)) {
        pluginPackage.setShortDescription(shortDescription);
    }

    String pageURL = attributes.getValue("Bundle-DocURL");

    if (Validator.isNotNull(pageURL)) {
        pluginPackage.setPageURL(pageURL);
    }

    return pluginPackage;
}

From source file:kr.motd.maven.exec.ExecMojo.java

/**
 * Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all
 * classpath elements. Copied from surefire (ForkConfiguration#createJar())
 *
 * @param classPath List<String> of all classpath elements.
 * @return//from  w w w.  j  a v a2  s  .c  o  m
 * @throws IOException
 */
private File createJar(List<String> classPath, String mainClass) throws IOException {
    File file = File.createTempFile("maven-exec", ".jar");
    file.deleteOnExit();
    FileOutputStream fos = new FileOutputStream(file);
    JarOutputStream jos = new JarOutputStream(fos);
    jos.setLevel(JarOutputStream.STORED);
    JarEntry je = new JarEntry("META-INF/MANIFEST.MF");
    jos.putNextEntry(je);

    Manifest man = new Manifest();

    // we can't use StringUtils.join here since we need to add a '/' to
    // the end of directory entries - otherwise the jvm will ignore them.
    StringBuilder cp = new StringBuilder();
    for (String el : classPath) {
        // NOTE: if File points to a directory, this entry MUST end in '/'.
        cp.append(new URL(new File(el).toURI().toASCIIString()).toExternalForm() + " ");
    }

    man.getMainAttributes().putValue("Manifest-Version", "1.0");
    man.getMainAttributes().putValue("Class-Path", cp.toString().trim());
    man.getMainAttributes().putValue("Main-Class", mainClass);

    man.write(jos);
    jos.close();

    return file;
}

From source file:org.stem.ExternalNode.java

private void createNodeJar(File jarFile, String mainClass, File nodeDir) throws IOException {
    File conf = new File(nodeDir, "conf");

    FileOutputStream fos = null;//from  w w  w. j  a  v  a 2s.c o  m
    JarOutputStream jos = null;

    try {
        fos = new FileOutputStream(jarFile);
        jos = new JarOutputStream(fos);
        jos.setLevel(JarOutputStream.STORED);
        jos.putNextEntry(new JarEntry("META-INF/MANIFEST.MF"));

        Manifest man = new Manifest();

        StringBuilder cp = new StringBuilder();
        cp.append(new URL(conf.toURI().toASCIIString()).toExternalForm());
        cp.append(' ');

        log.debug("Adding plugin artifact: " + ArtifactUtils.versionlessKey(mvnContext.pluginArtifact)
                + " to the classpath");
        cp.append(new URL(mvnContext.pluginArtifact.getFile().toURI().toASCIIString()).toExternalForm());
        cp.append(' ');

        log.debug("Adding: " + mvnContext.classesDir + " to the classpath");
        cp.append(new URL(mvnContext.classesDir.toURI().toASCIIString()).toExternalForm());
        cp.append(' ');

        for (Artifact artifact : mvnContext.pluginDependencies) {
            log.info("Adding plugin dependency artifact: " + ArtifactUtils.versionlessKey(artifact)
                    + " to the classpath");
            // NOTE: if File points to a directory, this entry MUST end in '/'.
            cp.append(new URL(artifact.getFile().toURI().toASCIIString()).toExternalForm());
            cp.append(' ');
        }

        man.getMainAttributes().putValue("Manifest-Version", "1.0");
        man.getMainAttributes().putValue("Class-Path", cp.toString().trim());
        man.getMainAttributes().putValue("Main-Class", mainClass);

        man.write(jos);

    } finally {
        IOUtil.close(jos);
        IOUtil.close(fos);
    }
}

From source file:org.jahia.tools.maven.plugins.LegalArtifactAggregator.java

private void processJarFile(InputStream inputStream, String jarFilePath, JarMetadata contextJarMetadata,
        boolean processMavenPom, int level, boolean lookForNotice, boolean lookForLicense,
        boolean processingSources) throws IOException {
    // if we don't need to find either a license or notice, don't process the jar at all
    if (!lookForLicense && !lookForNotice) {
        return;//ww w  .java  2  s  .  c  om
    }

    final String indent = getIndent(level);
    output(indent, "Processing JAR " + jarFilePath + "...", false, true);

    // JarFile realJarFile = new JarFile(jarFile);
    JarInputStream jarInputStream = new JarInputStream(inputStream);
    String bundleLicense = null;
    Manifest manifest = jarInputStream.getManifest();
    if (manifest != null && manifest.getMainAttributes() != null) {
        bundleLicense = manifest.getMainAttributes().getValue("Bundle-License");
        if (bundleLicense != null) {
            output(indent, "Found Bundle-License attribute with value:" + bundleLicense);
            KnownLicense knownLicense = getKnowLicenseByName(bundleLicense);
            // this data is not reliable, especially on the ServiceMix repackaged bundles
        }
    }
    String pomFilePath = null;
    byte[] pomByteArray = null;

    final String jarFileName = getJarFileName(jarFilePath);
    if (contextJarMetadata == null) {
        contextJarMetadata = jarDatabase.get(jarFileName);
        if (contextJarMetadata == null) {
            // compute project name
            contextJarMetadata = new JarMetadata(jarFilePath, jarFileName);
        }
        jarDatabase.put(jarFileName, contextJarMetadata);
    }

    Notice notice;
    JarEntry curJarEntry = null;
    while ((curJarEntry = jarInputStream.getNextJarEntry()) != null) {

        if (!curJarEntry.isDirectory()) {
            final String fileName = curJarEntry.getName();
            if (lookForNotice && isNotice(fileName, jarFilePath)) {

                output(indent, "Processing notice found in " + curJarEntry + "...");

                InputStream noticeInputStream = jarInputStream;
                List<String> noticeLines = IOUtils.readLines(noticeInputStream);
                notice = new Notice(noticeLines);

                Map<String, Notice> notices = contextJarMetadata.getNoticeFiles();
                if (notices == null) {
                    notices = new TreeMap<>();
                    notices.put(fileName, notice);
                    output(indent, "Found first notice " + curJarEntry);
                } else if (!notices.containsValue(notice)) {
                    output(indent, "Found additional notice " + curJarEntry);
                    notices.put(fileName, notice);
                } else {
                    output(indent, "Duplicated notice in " + curJarEntry);
                    notices.put(fileName, notice);
                    duplicatedNotices.add(jarFilePath);
                }

                // IOUtils.closeQuietly(noticeInputStream);
            } else if (processMavenPom && fileName.endsWith("pom.xml")) {
                // remember pom file path in case we need it
                pomFilePath = curJarEntry.getName();
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                IOUtils.copy(jarInputStream, byteArrayOutputStream);
                pomByteArray = byteArrayOutputStream.toByteArray();

            } else if (lookForLicense && isLicense(fileName, jarFilePath)) {

                output(indent, "Processing license found in " + curJarEntry + "...");
                InputStream licenseInputStream = jarInputStream;
                List<String> licenseLines = IOUtils.readLines(licenseInputStream);

                LicenseFile licenseFile = new LicenseFile(jarFilePath, fileName, jarFilePath, licenseLines);

                resolveKnownLicensesByText(licenseFile);

                if (StringUtils.isNotBlank(licenseFile.getAdditionalLicenseText())
                        && StringUtils.isNotBlank(licenseFile.getAdditionalLicenseText().trim())) {
                    KnownLicense knownLicense = new KnownLicense();
                    knownLicense.setId(FilenameUtils.getBaseName(jarFilePath) + "-additional-terms");
                    knownLicense
                            .setName("Additional license terms from " + FilenameUtils.getBaseName(jarFilePath));
                    List<TextVariant> textVariants = new ArrayList<>();
                    TextVariant textVariant = new TextVariant();
                    textVariant.setId("default");
                    textVariant.setDefaultVariant(true);
                    textVariant.setText(Pattern.quote(licenseFile.getAdditionalLicenseText()));
                    textVariants.add(textVariant);
                    knownLicense.setTextVariants(textVariants);
                    knownLicense.setTextToUse(licenseFile.getAdditionalLicenseText());
                    knownLicense.setViral(licenseFile.getText().toLowerCase().contains("gpl"));
                    knownLicenses.getLicenses().put(knownLicense.getId(), knownLicense);
                    licenseFile.getKnownLicenses().add(knownLicense);
                    licenseFile.getKnownLicenseKeys().add(knownLicense.getId());
                }

                for (KnownLicense knownLicense : licenseFile.getKnownLicenses()) {
                    SortedSet<LicenseFile> licenseFiles = knownLicensesFound.get(knownLicense);
                    if (licenseFiles != null) {
                        if (!licenseFiles.contains(licenseFile)) {
                            licenseFiles.add(licenseFile);
                        }
                        knownLicensesFound.put(knownLicense, licenseFiles);
                    } else {
                        licenseFiles = new TreeSet<>();
                        licenseFiles.add(licenseFile);
                        knownLicensesFound.put(knownLicense, licenseFiles);
                    }
                }

                Map<String, LicenseFile> licenseFiles = contextJarMetadata.getLicenseFiles();
                if (licenseFiles == null) {
                    licenseFiles = new TreeMap<>();
                }
                if (licenseFiles.containsKey(fileName)) {
                    // warning we already have a license file here, what should we do ?
                    output(indent, "License file already exists for " + jarFilePath + " will override it !",
                            true, false);
                    licenseFiles.remove(fileName);
                }
                licenseFiles.put(fileName, licenseFile);

                // IOUtils.closeQuietly(licenseInputStream);

            } else if (fileName.endsWith(".jar")) {
                InputStream embeddedJarInputStream = jarInputStream;
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                IOUtils.copy(embeddedJarInputStream, byteArrayOutputStream);
                final JarMetadata embeddedJarMetadata = new JarMetadata(jarFilePath, getJarFileName(fileName));

                if (embeddedJarMetadata != null) {
                    embeddedJarMetadata.setJarContents(byteArrayOutputStream.toByteArray());
                    contextJarMetadata.getEmbeddedJars().add(embeddedJarMetadata);
                }
            } else if (fileName.endsWith(".class")) {
                String className = fileName.substring(0, fileName.length() - ".class".length()).replaceAll("/",
                        ".");
                int lastPoint = className.lastIndexOf(".");
                String packageName = null;
                if (lastPoint > 0) {
                    packageName = className.substring(0, lastPoint);
                    SortedSet<String> currentJarPackages = jarDatabase
                            .get(FilenameUtils.getBaseName(jarFilePath)).getPackages();
                    if (currentJarPackages == null) {
                        currentJarPackages = new TreeSet<>();
                    }
                    currentJarPackages.add(packageName);
                }
            }

        }
        jarInputStream.closeEntry();
    }

    jarInputStream.close();
    jarInputStream = null;

    if (!contextJarMetadata.getEmbeddedJars().isEmpty()) {
        for (JarMetadata embeddedJarMetadata : contextJarMetadata.getEmbeddedJars()) {
            if (embeddedJarMetadata.getJarContents() != null) {
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
                        embeddedJarMetadata.getJarContents());
                processJarFile(byteArrayInputStream, contextJarMetadata.toString(), null, true, level, true,
                        true, processingSources);
            } else {
                output(indent, "Couldn't find dependency for embedded JAR " + contextJarMetadata, true, false);
            }
        }
    }

    if (processMavenPom) {
        if (pomFilePath == null) {
            output(indent, "No POM found in " + jarFilePath);
        } else {
            output(indent, "Processing POM found at " + pomFilePath + " in " + jarFilePath + "...");
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(pomByteArray);
            processJarPOM(byteArrayInputStream, pomFilePath, jarFilePath, contextJarMetadata, lookForNotice,
                    lookForLicense, contextJarMetadata.getEmbeddedJars(), level + 1, processingSources);
        }
    }

    if (lookForLicense || lookForNotice) {
        if (lookForLicense) {
            output(indent, "No license found in " + jarFilePath);
        }
        if (lookForNotice) {
            output(indent, "No notice found in " + jarFilePath);
        }

        if (pomFilePath == null && lookForLicense && lookForNotice) {
            if (StringUtils.isBlank(contextJarMetadata.getVersion())) {
                output(indent, "Couldn't resolve version for JAR " + contextJarMetadata
                        + ", can't query Maven Central repository without version !");
            } else {
                List<Artifact> mavenCentralArtifacts = findArtifactInMavenCentral(contextJarMetadata.getName(),
                        contextJarMetadata.getVersion(), contextJarMetadata.getClassifier());
                if (mavenCentralArtifacts != null && mavenCentralArtifacts.size() == 1) {
                    Artifact mavenCentralArtifact = mavenCentralArtifacts.get(0);
                    Artifact resolvedArtifact = resolveArtifact(mavenCentralArtifact, level);
                    if (resolvedArtifact != null) {
                        // we have a copy of the local artifact, let's request the sources for it.
                        if (!processingSources && !"sources".equals(contextJarMetadata.getClassifier())) {
                            final Artifact artifact = new DefaultArtifact(resolvedArtifact.getGroupId(),
                                    resolvedArtifact.getArtifactId(), "sources", "jar",
                                    resolvedArtifact.getVersion());
                            File sourceJar = getArtifactFile(artifact, level);
                            if (sourceJar != null && sourceJar.exists()) {
                                FileInputStream sourceJarInputStream = new FileInputStream(sourceJar);
                                processJarFile(sourceJarInputStream, sourceJar.getPath(), contextJarMetadata,
                                        false, level + 1, lookForNotice, lookForLicense, true);
                                IOUtils.closeQuietly(sourceJarInputStream);
                            }
                        } else {
                            // we are already processing a sources artifact, we need to load the pom artifact to extract information from there
                            final Artifact artifact = new DefaultArtifact(resolvedArtifact.getGroupId(),
                                    resolvedArtifact.getArtifactId(), null, "pom",
                                    resolvedArtifact.getVersion());
                            File artifactPom = getArtifactFile(artifact, level);
                            if (artifactPom != null && artifactPom.exists()) {
                                output(indent, "Processing POM for " + artifact + "...");
                                processPOM(lookForNotice, lookForLicense, jarFilePath, contextJarMetadata,
                                        contextJarMetadata.getEmbeddedJars(), level + 1,
                                        new FileInputStream(artifactPom), processingSources);
                            }
                        }
                    } else {
                        output(indent, "===>  Couldn't resolve artifact " + mavenCentralArtifact
                                + " in Maven Central. Please resolve license and notice files manually!", false,
                                true);
                    }
                } else {
                    output(indent, "===>  Couldn't find nor POM, license or notice. Please check manually!",
                            false, true);
                }
            }
        }
    }

    output(indent, "Done processing JAR " + jarFilePath + ".", false, true);

}

From source file:com.liferay.blade.cli.command.CreateCommandTest.java

@Test
public void testCreateWorkspaceGradleServiceBuilderProjectDefault() throws Exception {
    File workspace = new File(_rootDir, "workspace");

    File modulesDir = new File(workspace, "modules");

    String projectPath = modulesDir.getAbsolutePath();

    String[] args = { "create", "-d", projectPath, "-t", "service-builder", "-p", "com.liferay.sample",
            "sample" };

    _makeWorkspace(workspace);/* w ww  .  j av a  2 s.c  o m*/

    TestUtil.runBlade(workspace, _extensionsDir, args);

    _checkFileExists(projectPath + "/sample/build.gradle");

    _checkFileDoesNotExists(projectPath + "/sample/settings.gradle");

    _checkFileExists(projectPath + "/sample/sample-api/build.gradle");

    _checkFileExists(projectPath + "/sample/sample-service/build.gradle");

    File file = _checkFileExists(projectPath + "/sample/sample-service/build.gradle");

    _contains(file, ".*compileOnly project\\(\":modules:sample:sample-api\"\\).*");

    BuildTask buildService = GradleRunnerUtil.executeGradleRunner(workspace.getPath(), "buildService");

    GradleRunnerUtil.verifyGradleRunnerOutput(buildService);

    BuildTask buildTask = GradleRunnerUtil.executeGradleRunner(workspace.getPath(), "jar");

    GradleRunnerUtil.verifyGradleRunnerOutput(buildTask);

    GradleRunnerUtil.verifyBuildOutput(projectPath + "/sample/sample-api", "com.liferay.sample.api-1.0.0.jar");
    GradleRunnerUtil.verifyBuildOutput(projectPath + "/sample/sample-service",
            "com.liferay.sample.service-1.0.0.jar");

    File serviceJar = new File(projectPath,
            "sample/sample-service/build/libs/com.liferay.sample.service-1.0.0.jar");

    _verifyImportPackage(serviceJar);

    try (JarFile serviceJarFile = new JarFile(serviceJar)) {
        Manifest manifest = serviceJarFile.getManifest();

        Attributes mainAttributes = manifest.getMainAttributes();

        String springContext = mainAttributes.getValue("Liferay-Spring-Context");

        Assert.assertTrue(springContext.equals("META-INF/spring"));
    }
}

From source file:org.sipfoundry.openfire.plugin.presence.SipXOpenfirePlugin.java

void loadExtras(ClassLoader classLoader, File extrasDir) {
    // inspect all jars in the extras dir
    File[] jars = extrasDir.listFiles(new FilenameFilter() {
        @Override//  w  w w . java  2s . c o m
        public boolean accept(File dir, String name) {
            return name.endsWith(".jar");
        }
    });
    if (jars != null) {
        for (File jar : jars) {
            // find all classes that are packet interceptors
            try {
                log.info("loadExtras considering jar: " + jar.getName());
                JarFile jarFile = new JarFile(jar);
                // Get the manifest and its attributes
                Manifest manifest = jarFile.getManifest();
                Attributes attribs = manifest.getMainAttributes();
                String messageInterceptorClassName = attribs.getValue("MessageInterceptorClass");
                if (messageInterceptorClassName != null) {
                    log.info("Found an extra MessageInterceptorClass " + messageInterceptorClassName);

                    Class packetInterceptorClass = Class.forName(messageInterceptorClassName, true,
                            classLoader);
                    AbstractMessagePacketInterceptor abstractMessagePacketInterceptor = (AbstractMessagePacketInterceptor) packetInterceptorClass
                            .newInstance();
                    abstractMessagePacketInterceptor.start(this);
                    InterceptorManager.getInstance().addInterceptor(abstractMessagePacketInterceptor);
                    abstractMessagePacketInterceptors.add(abstractMessagePacketInterceptor);
                }
            } catch (Throwable e) {
                log.error("loadExtras caught exception:", e);
            }
        }
    }
}

From source file:org.echocat.nodoodle.classloading.FileClassLoader.java

/**
 * This is a copy of {@link URLClassLoader#getPermissions(CodeSource)}.
 *
 * Defines a new package by name in this ClassLoader. The attributes contained in the specified Manifest will be used to obtain package version and sealing
 * information. For sealed packages, the additional URL specifies the code source URL from which the package was loaded.
 *
 * @param name the package name/*from  w  w  w .  j  a v a2s  .  c  o m*/
 * @param man the Manifest containing package version and sealing information
 * @param url the code source url for the package, or null if none
 * @return the newly defined Package object
 * @throws IllegalArgumentException if the package name duplicates an existing package either in this class loader or one of its ancestors
 */
protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException {
    final String path = name.replace('.', '/').concat("/");
    String specTitle = null;
    String specVersion = null;
    String specVendor = null;
    String implTitle = null;
    String implVersion = null;
    String implVendor = null;
    String sealed = null;
    URL sealBase = null;

    Attributes attr = man.getAttributes(path);
    if (attr != null) {
        specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
        specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        specVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
        implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
        implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        sealed = attr.getValue(Name.SEALED);
    }
    attr = man.getMainAttributes();
    if (attr != null) {
        if (specTitle == null) {
            specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
        }
        if (specVersion == null) {
            specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
        }
        if (specVendor == null) {
            specVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
        }
        if (implTitle == null) {
            implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
        }
        if (implVersion == null) {
            implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
        }
        if (implVendor == null) {
            implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
        }
        if (sealed == null) {
            sealed = attr.getValue(Name.SEALED);
        }
    }
    if ("true".equalsIgnoreCase(sealed)) {
        sealBase = url;
    }
    return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor,
            sealBase);
}

From source file:ca.uhn.fhir.rest.server.RestfulServer.java

public RestulfulServerConfiguration createConfiguration() {
    RestulfulServerConfiguration result = new RestulfulServerConfiguration();
    result.setResourceBindings(getResourceBindings());
    result.setServerBindings(getServerBindings());
    result.setImplementationDescription(getImplementationDescription());
    result.setServerVersion(getServerVersion());
    result.setServerName(getServerName());
    result.setFhirContext(getFhirContext());
    result.setServerAddressStrategy(myServerAddressStrategy);
    InputStream inputStream = null;
    try {//from w w w.  jav  a 2s.  c o m
        inputStream = getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
        if (inputStream != null) {
            Manifest manifest = new Manifest(inputStream);
            result.setConformanceDate(manifest.getMainAttributes().getValue("Build-Time"));
        }
    } catch (IOException e) {
        // fall through
    } finally {
        if (inputStream != null) {
            IOUtils.closeQuietly(inputStream);
        }
    }
    return result;
}