List of usage examples for java.lang Package getSpecificationVersion
public String getSpecificationVersion()
From source file:com.cablelabs.sim.PCSim2.java
private static void logPackage() { Package p = Package.getPackage("com.cablelabs.sim"); if (p == null) { logger.info(PC2LogCategory.Parser, subCat, "com.cablelabs.sim not loaded"); return;/*from w w w . j a va 2 s .c om*/ } logger.info(PC2LogCategory.Parser, subCat, "com.cablelabs.sim version " + p.getSpecificationVersion() + " build-" + p.getImplementationVersion()); // if (logFile.exists()) // logDebugInfo(logFile); logger.logConfigSettings(); }
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 2s. c o m*/ 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.//ww w. ja va2s. c om */ @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.apache.ofbiz.solr.webapp.OFBizSolrLoadAdminUiServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { boolean isForwarded = forwardUrl(request, response); if (isForwarded) { return;// www.ja va2 s . co m } // This attribute is set by the SolrDispatchFilter CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer"); InputStream in = getServletContext().getResourceAsStream("/admin.html"); if (in != null && cores != null) { try { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); Writer out = new OutputStreamWriter(response.getOutputStream(), StandardCharsets.UTF_8); String html = IOUtils.toString(in, "UTF-8"); Package pack = SolrCore.class.getPackage(); String[] search = new String[] { "${contextPath}", "${adminPath}", "${version}" }; String[] replace = new String[] { StringEscapeUtils.escapeJavaScript(request.getContextPath()), StringEscapeUtils.escapeJavaScript(CommonParams.CORES_HANDLER_PATH), StringEscapeUtils.escapeJavaScript(pack.getSpecificationVersion()) }; out.write(StringUtils.replaceEach(html, search, replace)); out.flush(); } finally { IOUtils.closeQuietly(in); } } else { response.sendError(404); } }
From source file:org.apache.solr.handler.admin.SystemInfoHandler.java
private static SimpleOrderedMap<Object> getLuceneInfo() throws Exception { SimpleOrderedMap<Object> info = new SimpleOrderedMap<Object>(); String solrImplVersion = ""; String solrSpecVersion = ""; String luceneImplVersion = ""; String luceneSpecVersion = ""; // ---//from w w w. j a v a 2 s .com Package p = SolrCore.class.getPackage(); StringWriter tmp = new StringWriter(); solrImplVersion = p.getImplementationVersion(); if (null != solrImplVersion) { XML.escapeCharData(solrImplVersion, tmp); solrImplVersion = tmp.toString(); } tmp = new StringWriter(); solrSpecVersion = p.getSpecificationVersion(); if (null != solrSpecVersion) { XML.escapeCharData(solrSpecVersion, tmp); solrSpecVersion = tmp.toString(); } p = LucenePackage.class.getPackage(); tmp = new StringWriter(); luceneImplVersion = p.getImplementationVersion(); if (null != luceneImplVersion) { XML.escapeCharData(luceneImplVersion, tmp); luceneImplVersion = tmp.toString(); } tmp = new StringWriter(); luceneSpecVersion = p.getSpecificationVersion(); if (null != luceneSpecVersion) { XML.escapeCharData(luceneSpecVersion, tmp); luceneSpecVersion = tmp.toString(); } // Add it to the list info.add("solr-spec-version", solrSpecVersion); info.add("solr-impl-version", solrImplVersion); info.add("lucene-spec-version", luceneSpecVersion); info.add("lucene-impl-version", luceneImplVersion); return info; }
From source file:org.apache.solr.servlet.LoadAdminUiServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.addHeader("X-Frame-Options", "DENY"); // security: SOLR-7966 - avoid clickjacking for admin interface // This attribute is set by the SolrDispatchFilter String admin = request.getRequestURI().substring(request.getContextPath().length()); CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer"); InputStream in = getServletContext().getResourceAsStream(admin); Writer out = null;/*from w w w. j av a 2 s . c o m*/ if (in != null && cores != null) { try { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); // Protect container owned streams from being closed by us, see SOLR-8933 out = new OutputStreamWriter(new CloseShieldOutputStream(response.getOutputStream()), StandardCharsets.UTF_8); String html = IOUtils.toString(in, "UTF-8"); Package pack = SolrCore.class.getPackage(); String[] search = new String[] { "${contextPath}", "${adminPath}", "${version}" }; String[] replace = new String[] { StringEscapeUtils.escapeJavaScript(request.getContextPath()), StringEscapeUtils.escapeJavaScript(CommonParams.CORES_HANDLER_PATH), StringEscapeUtils.escapeJavaScript(pack.getSpecificationVersion()) }; out.write(StringUtils.replaceEach(html, search, replace)); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } } else { response.sendError(404); } }
From source file:org.eu.gasp.core.bootstrap.Bootstrap.java
public void start() throws GaspException { checkInitDone();/*from ww w . j a v a2s.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 ww . j a v a 2s. com*/ 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(); }
From source file:org.fusesource.mop.commands.Fork.java
/** * Forks a new child JVM and executes the remaining arguments as a child MOP * process//ww w. j a v a 2s. co m */ @Command public void fork(MOP mop, LinkedList<String> args) throws Exception { LOG.info("forking MOP with " + args); // TODO we could try find a mop jar on the URL class loader? Package aPackage = Package.getPackage("org.fusesource.mop"); String version = aPackage.getImplementationVersion(); if (version == null) { version = aPackage.getSpecificationVersion(); } LOG.debug("mop package version: " + version); // TODO LATEST/RELEASE don't tend to work? /* * if (version == null) { version = "RELEASE"; } */ String classpath; if (version != null) { ArtifactId mopArtifactId = mop.parseArtifactId("org.fusesource.mop:mop-core:" + version); mop.setTransitive(false); mop.setArtifactIds(Arrays.asList(mopArtifactId)); classpath = mop.classpath(); } else { classpath = System.getProperty("java.class.path"); if (classpath == null || classpath.length() == 0) { throw new Exception("no java.class.path system property available!"); } } if (isWindows() && classpath.contains(" ")) { classpath = "\"" + classpath + "\""; } List<String> newArgs = new ArrayList<String>(); String javaExe = "java"; if (isWindows()) { javaExe += ".exe"; } newArgs.add(javaExe); //Propagate repository props to the forked process: for (Entry<String, String> entry : mop.getRepository().getRepositorySystemProps().entrySet()) { mop.setSystemProperty(entry.getKey(), entry.getValue()); } mop.addSystemProperties(newArgs); newArgs.add("-D" + MOP.MOP_WORKING_DIR_SYSPROPERTY + "=" + mop.getWorkingDirectory().getAbsolutePath()); newArgs.add("-cp"); newArgs.add(classpath); newArgs.add(MOP.class.getName()); newArgs.addAll(args); LOG.debug("About to execute: " + newArgs); mop.exec(newArgs); }
From source file:org.jboss.confluence.plugin.docbook_tools.docbookimport.DocbookImporter.java
protected static final void printClassInfo(Class<?> clazz, String msg) { Package pack = clazz.getPackage(); StringBuilder sb = new StringBuilder(); sb.append(msg).append(": ").append(clazz.getName()); sb.append(", Specification version: ").append(pack.getSpecificationVersion()); sb.append(", Implementation version: ").append(pack.getImplementationVersion()); log.info(sb.toString());// w ww . j a va2 s .com }