Example usage for java.lang Package getSpecificationTitle

List of usage examples for java.lang Package getSpecificationTitle

Introduction

In this page you can find the example usage for java.lang Package getSpecificationTitle.

Prototype

public String getSpecificationTitle() 

Source Link

Document

Return the title of the specification that this package implements.

Usage

From source file:Main.java

public static void main(String[] args) {

    // get the java lang package
    Package pack = Package.getPackage("java.lang");

    // print the specification title for this package
    System.out.println(pack.getSpecificationTitle());

}

From source file:PackageInfo.java

public static void main(String[] args) {
    Package p = Package.getPackage("java.lang");

    System.out.println("Name = " + p.getName());

    System.out.println("Implementation title = " + p.getImplementationTitle());

    System.out.println("Implementation vendor = " + p.getImplementationVendor());

    System.out.println("Implementation version = " + p.getImplementationVersion());

    System.out.println("Specification title = " + p.getSpecificationTitle());

    System.out.println("Specification vendor = " + p.getSpecificationVendor());

    System.out.println("Specification version = " + p.getSpecificationVersion());
}

From source file:PackageInfo.java

static void pkgInfo(ClassLoader classLoader, String pkgName, String className) {

    try {/*from  ww w. jav a2s .  c  o m*/
        classLoader.loadClass(pkgName + "." + className);

        Package p = Package.getPackage(pkgName);
        if (p == null) {
            System.out.println("WARNING: Package.getPackage(" + pkgName + ") is null");
        } else {
            System.out.println(p);
            System.out.println("Specification Title = " + p.getSpecificationTitle());
            System.out.println("Specification Vendor = " + p.getSpecificationVendor());
            System.out.println("Specification Version = " + p.getSpecificationVersion());

            System.out.println("Implementation Vendor = " + p.getImplementationVendor());
            System.out.println("Implementation Version = " + p.getImplementationVersion());
        }
    } catch (ClassNotFoundException e) {
        System.out.println("Unable to load " + pkgName);
    }

    System.out.println();
}

From source file:com.github.wolf480pl.mias4j.core.runtime.BMClassLoader.java

protected Package copyPackage(Package pkg, CodeSource cs) {
    return definePackage(pkg.getName(), pkg.getSpecificationTitle(), pkg.getSpecificationVersion(),
            pkg.getSpecificationVendor(), pkg.getImplementationTitle(), pkg.getImplementationVersion(),
            pkg.getImplementationVendor(), pkg.isSealed() ? cs.getLocation() : null);
}

From source file:adalid.util.info.JavaInfo.java

public void printPackageDetails(String name) {
    Package pack = Package.getPackage(name);
    out.println("Package " + name + ": " + pack);
    if (pack != null) {
        out.println("\t" + Attributes.Name.IMPLEMENTATION_TITLE + ":   " + pack.getImplementationTitle());
        out.println("\t" + Attributes.Name.IMPLEMENTATION_VENDOR + ":  " + pack.getImplementationVendor());
        out.println("\t" + Attributes.Name.IMPLEMENTATION_VERSION + ": " + pack.getImplementationVersion());
        out.println("\t" + Attributes.Name.SPECIFICATION_TITLE + ":    " + pack.getSpecificationTitle());
        out.println("\t" + Attributes.Name.SPECIFICATION_VENDOR + ":   " + pack.getSpecificationVendor());
        out.println("\t" + Attributes.Name.SPECIFICATION_VERSION + ":  " + pack.getSpecificationVersion());
        out.println();/*from  w ww  . java2s  .co  m*/
    }
}

From source file:net.chaosserver.timelord.swingui.Timelord.java

/**
 * Shows the about dialog that tells about the application.
 *//*from   w  w  w. j  a v a  2  s . c  om*/
public void showAboutDialog() {
    Package packageInfo = Package.getPackage("net.chaosserver.timelord.swingui");

    if (log.isTraceEnabled()) {
        if (packageInfo != null) {
            StringBuffer sb = new StringBuffer();
            sb.append(packageInfo.getClass().getName());
            sb.append(" [name=");
            sb.append(packageInfo.getName());
            sb.append(", specificationTitle=");
            sb.append(packageInfo.getSpecificationTitle());
            sb.append(", specificationVersion=");
            sb.append(packageInfo.getSpecificationVersion());
            sb.append(", specificationVendor=");
            sb.append(packageInfo.getSpecificationVendor());
            sb.append(", implementationTitle=");
            sb.append(packageInfo.getImplementationTitle());
            sb.append(", implementationVersion=");
            sb.append(packageInfo.getImplementationVersion());
            sb.append(", implementationVendor=");
            sb.append(packageInfo.getImplementationVendor());
            sb.append("]");
            log.trace(sb.toString());
        }
    }

    StringBuffer sb = new StringBuffer();
    sb.append("Timelord");

    if ((packageInfo != null) && (packageInfo.getImplementationVersion() != null)) {
        sb.append(" [");
        sb.append(packageInfo.getImplementationVersion());
        sb.append("]");
    } else {
        Properties appProperties = getAppProperties();
        if (appProperties != null) {
            sb.append(" ");
            sb.append(appProperties.getProperty("implementation.version", "[Unknown Version]"));
        } else {
            sb.append(" [Unknown Version]");
        }
    }

    sb.append("\n");
    sb.append(resourceBundle.getString(RROOT + ".about"));

    JOptionPane.showMessageDialog(applicationFrame, sb.toString(), "About Timelord",
            JOptionPane.INFORMATION_MESSAGE, applicationIcon);
}

From source file:org.aitools.programd.Core.java

/**
 * Initializes and starts up the Core.//w  w  w  . j  a v  a  2  s .  c  o m
 */
@SuppressWarnings("boxing")
protected void start() {
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());

    // Set up the XML parsing feature settings.
    this._xmlParserFeatureSettings = new HashMap<String, Boolean>(6);
    this._xmlParserFeatureSettings.put("http://xml.org/sax/features/use-entity-resolver2",
            this._settings.xmlParserUseEntityResolver2());
    this._xmlParserFeatureSettings.put("http://xml.org/sax/features/validation",
            this._settings.xmlParserUseValidation());
    this._xmlParserFeatureSettings.put("http://apache.org/xml/features/validation/schema",
            this._settings.xmlParserUseSchemaValidation());
    this._xmlParserFeatureSettings.put("http://apache.org/xml/features/honour-all-schemaLocations",
            this._settings.xmlParserHonourAllSchemaLocations());
    this._xmlParserFeatureSettings.put("http://apache.org/xml/features/xinclude",
            this._settings.xmlParserUseXInclude());
    this._xmlParserFeatureSettings.put("http://apache.org/xml/features/validate-annotations",
            this._settings.xmlParserValidateAnnotations());

    // Use the stdout and stderr appenders in a special way, if they are defined.
    ConsoleStreamAppender stdOutAppender = ((ConsoleStreamAppender) Logger.getLogger("programd")
            .getAppender("stdout"));
    if (stdOutAppender != null) {
        if (!stdOutAppender.isWriterSet()) {
            stdOutAppender.setWriter(new OutputStreamWriter(System.out));
        }
    }

    ConsoleStreamAppender stdErrAppender = ((ConsoleStreamAppender) Logger.getLogger("programd")
            .getAppender("stderr"));
    if (stdErrAppender != null) {
        if (!stdErrAppender.isWriterSet()) {
            stdErrAppender.setWriter(new OutputStreamWriter(System.err));
        }
    }

    // Set up an interception of calls to the JDK logging system and re-route to log4j.
    JDKLogHandler.setupInterception();

    this._logger.info(String.format("Base URL for Program D Core: \"%s\".", this._baseURL));

    this._aimlProcessorRegistry = new AIMLProcessorRegistry();

    this._graphmapper = Classes.getSubclassInstance(Graphmapper.class,
            this._settings.getGraphmapperImplementation(), "Graphmapper implementation", this);
    this._bots = new Bots();
    this._processes = new ManagedProcesses(this);

    // Get an instance of the settings-specified PredicateManager.
    this._predicateManager = Classes.getSubclassInstance(PredicateManager.class,
            this._settings.getPredicateManagerImplementation(), "PredicateManager", this);

    // Get the hostname (used occasionally).
    try {
        this._hostname = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        this._hostname = "unknown hostname";
    }

    // Load the plugin config.
    URL pluginConfigURL = this._settings.getPluginConfigURL();
    if (pluginConfigURL != null) {
        pluginConfigURL = URLTools.contextualize(this._baseURL, pluginConfigURL);
        try {
            if (pluginConfigURL.openStream() != null) {
                this._pluginConfig = JDOM.getDocument(pluginConfigURL, this._logger);
            }
        } catch (IOException e) {
            // Don't load plugin config.
        }
    }

    // TODO: Make this work even if the classes aren't in a jar.
    Package pkg = Package.getPackage("org.aitools.programd");
    this._logger.info(String.format("Starting %s version %s [%s].", pkg.getSpecificationTitle(),
            pkg.getSpecificationVersion(), pkg.getImplementationVersion()));
    this._logger.info(UserSystem.jvmDescription());
    this._logger.info(UserSystem.osDescription());
    this._logger.info(UserSystem.memoryReport());
    this._logger.info("Predicates with no values defined will return: \""
            + this._settings.getPredicateEmptyDefault() + "\".");

    try {
        // Create the AIMLWatcher if configured to do so.
        if (this._settings.useAIMLWatcher()) {
            this._aimlWatcher = new AIMLWatcher(this);
        }

        // Setup a JavaScript interpreter if supposed to.
        setupInterpreter();

        // Start the AIMLWatcher if configured to do so.
        startWatcher();

        this._logger.info("Starting up the Graphmaster.");

        // Start loading bots.
        URL botConfigURL = this._settings.getBotConfigURL();
        if (botConfigURL != null) {
            loadBotConfig(botConfigURL);
        } else {
            this._logger.warn("No bot config URL specified; no bots will be loaded.");
        }

        // Request garbage collection.
        System.gc();

        this._logger.info(UserSystem.memoryReport());

        // Start the heart, if enabled.
        startHeart();
    } catch (DeveloperError e) {
        alert("developer error", e);
    } catch (UserError e) {
        alert("user error", e);
    } catch (RuntimeException e) {
        alert("unforeseen runtime exception", e);
    } catch (Throwable e) {
        alert("unforeseen problem", e);
    }

    // Set the status indicator.
    this._status = Status.READY;

    // Exit immediately if configured to do so (for timing purposes).
    if (this._settings.exitImmediatelyOnStartup()) {
        shutdown();
    }
}

From source file:org.eu.gasp.core.bootstrap.Bootstrap.java

public void start() throws GaspException {
    checkInitDone();// w  w w  . ja  va 2 s .c  o m

    log.debug("Starting application");
    final Package pkg = getClass().getPackage();
    final String title = pkg.getSpecificationTitle();
    final String version = pkg.getSpecificationVersion();
    if (!StringUtils.isBlank(title) && !StringUtils.isBlank(version)) {
        // print version in the log
        log.info("Using: " + title + " " + version);
    }

    final PluginRegistry pluginRegistry = PluginManager.instance().getPluginRegistry();

    for (final String pluginDesc : pluginsToStart) {
        try {
            final String pluginId = getPluginId(pluginDesc);
            final Version pluginVersion = getPluginVersion(pluginDesc);
            pluginRegistry.activate(pluginId, pluginVersion);
        } catch (Exception e) {
            throw new GaspException("Error while starting plugin: " + pluginDesc, e);
        }
    }

    log.info("Platform is up and running");
}

From source file:org.eu.gasp.core.bootstrap.Runner.java

@SuppressWarnings("static-access")
public void run(String... args) throws Exception {
    // options for command line
    final Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("base").withArgName("directory").hasArg()
            .withDescription("set the base directory").create('b'));
    options.addOption(OptionBuilder.withLongOpt("log4j").withArgName("file").hasArg()
            .withDescription("path to the log4j property file").create('l'));
    options.addOption(OptionBuilder.withLongOpt("property").withArgName("file").hasArg()
            .withDescription("path to the Gasp property file").create('p'));
    options.addOption(OptionBuilder.withLongOpt("security").withArgName("file").hasArg()
            .withDescription("path to the Java security policy file").create('s'));
    options.addOption(OptionBuilder.withLongOpt("version").withDescription("print version").create("v"));
    options.addOption(OptionBuilder.withLongOpt("help").withDescription("show this help").create("h"));

    // default values for arguments
    String homeDir = System.getProperty("gasp.home", System.getProperty("user.dir"));
    String propFilePath = null;// w  w  w  .  java  2 s .  c  o m
    String log4jFilePath = null;
    String policyFilePath = null;

    // parsing options from command line
    final CommandLine line = new PosixParser().parse(options, args);
    if (line.hasOption("l")) {
        log4jFilePath = line.getOptionValue("l");
    }
    if (line.hasOption("p")) {
        propFilePath = line.getOptionValue("p");
    }
    if (line.hasOption("s")) {
        policyFilePath = line.getOptionValue("s");
    }
    if (line.hasOption("b")) {
        homeDir = line.getOptionValue("b");
    }
    if (line.hasOption("h")) {
        // print help to the standard output
        final HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp(APPLICATION_NAME, options);
        System.exit(0);
    }
    if (line.hasOption("v")) {
        // print version
        final Package pkg = Runner.class.getPackage();
        String app = StringUtils.defaultString(pkg.getSpecificationTitle(), APPLICATION_NAME);
        String version = StringUtils.defaultString(pkg.getSpecificationVersion(), "<?>");

        System.out.println(app + " " + version);
        System.exit(0);
    }

    // we are ready to go!
    final Bootstrap bootstrap = new Bootstrap(homeDir, policyFilePath, log4jFilePath, propFilePath);
    final Thread thread = new BootstrapThread(bootstrap);
    thread.start();
    thread.join();
}