⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jahiaconsole.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
/********************************************************************//* JAHIA                                                            *//* Class Name   :   JahiaConsole                                    *//* Function     :   Manages Jahia console messages                  *//* Created      :   08-10-2000                                      *//* Author       :   Eric Vassalli                                   *//* Interface    :                                                   *//*      print( String )     : prints a message in console           *//*      println( String )   : prints a message in console with \n   *//*      startup()           : displays cool startup message :)      *//*                                         Copyright 2002 Jahia Ltd *//********************************************************************/package org.jahia.utils;import javax.servlet.*;import java.io.*;public class JahiaConsole {    /**     * Constants for logging levels {     */    public static final int DEFAULT_LOGGING_LEVEL = 3;    public static final int MAX_LOGGING_LEVEL = 10;    public static final int CONSOLE_LOGGING_LEVEL = 9;    /**     * }     */    private static String  prefix  = "Jahia > ";    private static GenericServlet servlet = null;    private static int currentLoggingLevel = 0;    /***        * constructor        * EV    08.10.2000        *        */    private JahiaConsole()    {        println( "JahiaConsole", "***** Starting Jahia Console" );    } // end constructor    public static void setServlet(GenericServlet servletRef) {        servlet = servletRef;    }    public static void setLoggingLevel(int level) {        currentLoggingLevel = level;    }    /***        * print        * EV    08.10.2000        *        */    public static void print( String origin, String msg )    {        if (servlet != null) {            if (currentLoggingLevel >= DEFAULT_LOGGING_LEVEL) {              servlet.log(origin + " > " + msg);            }        }//        System.out.print( prefix + origin + " > " + msg );    } // end print    /***        * println        * EV    08.10.2000        *        */    public static void println( String origin, String msg )    {        if (servlet != null) {            if (currentLoggingLevel >= DEFAULT_LOGGING_LEVEL) {                servlet.log(origin + " > " + msg);            }            if (currentLoggingLevel >= CONSOLE_LOGGING_LEVEL) {                System.out.println (origin + "> " + msg);            }        }    } // end println    /**     * Small utility function to print stack trace on the Jahia console.     * @param origin a String representing the origin of the message. Recommended     * format is class.method     * @param t the exception whose stack trace will be dumped into the Jahia     * Console.     * @author Serge Huber.     */    public static void printe( String origin, Throwable t ) {        String msg;        StringWriter strWriter = new StringWriter();        PrintWriter ptrWriter = new PrintWriter(strWriter);        t.printStackTrace(ptrWriter);        msg = strWriter.toString();        if (servlet != null) {            if (currentLoggingLevel >= DEFAULT_LOGGING_LEVEL) {                servlet.log(origin + " > " + msg);            }            if (currentLoggingLevel >= CONSOLE_LOGGING_LEVEL) {                System.out.println (origin + "> " + msg);            }        }    }   /**    * Prints a message on the console.    * THIS METHOD SHOULD BE CALLED ONLY IF YOU WANT YOUR MESSAGE TO BE DISPLAYED IN THE    * RELEASE VERSION OF JAHIA.  Don't abuse ;-)    */    public static synchronized void finalPrintln( String origin, String msg )    {        System.out.println (origin + "> " + msg);    } // end println    public static synchronized void finalPrint( String origin, String msg )    {        System.out.print (origin + "> " + msg);    } // end println    /***        * startup        * EV    08.10.2000        *        */    public static void startup( int buildNumber )    {        String msg = "";        msg += "***********************************\n";        msg += "   Starting Jahia - Build " + buildNumber + "\n";        msg += "       \"Today's a great day ! \"\n";        msg += "***********************************\n";        JahiaConsole.println("JahiaConsole.startup","\n\n" + msg + "\n" );        println( "Jahia", "***** Starting Jahia *****" );    } // end startup    /***        * startupWithTrust        * AK    20.01.2001        *        */    public static void startupWithTrust( int buildNumber )    {        Integer      buildNumberInteger  = new Integer(buildNumber);        String       buildString         = buildNumberInteger.toString();        StringBuffer buildBuffer         = new StringBuffer();        for(int i=0; i < buildString.length(); i++) {            buildBuffer.append(" ");            buildBuffer.append(buildString.substring(i, i+1));        }        StringBuffer msg = new StringBuffer ("\n\n\n\n");        msg.append ("                                  ____.\n");        msg.append ("                      __/\\ ______|    |__/\\.     _______\n");        msg.append ("           __   .____|    |       \\   |    +----+       \\\n");        msg.append ("   _______|  /--|    |    |    -   \\  _    |    :    -   \\_________\n");        msg.append ("  \\\\______: :---|    :    :           |    :    |         \\________>\n");        msg.append ("          |__\\---\\_____________:______:    :____|____:_____\\\n");        msg.append ("                                     /_____|\n");        msg.append ("\n");        msg.append ("      . . . s t a r t i n g   j a h i a   b u i l d  " + buildBuffer.toString() + " . . .\n");        msg.append ("\n\n");        msg.append ("     Copyright 2002 - jahia http://www.jahia.org - all rights reserved\n");        msg.append ("\n\n");        msg.append (" **************************************************************************\n");        msg.append (" * The contents of this file, or the files included with this file, are   *\n");        msg.append (" * subject to the current version of JAHIA Community Source License for   *\n");        msg.append (" * the Jahia Portal Server (the \"License\"); You may not use this file     *\n");        msg.append (" * except in compliance with the License. You may obtain a copy of the    *\n");        msg.append (" * License at http://www.jahia.org. See the License for the rights,       *\n");        msg.append (" * obligations and limitations governing use of the contents of the file. *\n");        msg.append (" * The Original and Upgraded Code is the Jahia Portal Server. The         *\n");        msg.append (" * developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA Ltd.   *\n");        msg.append (" * owns the copyrights in the portions it created. All Rights Reserved.   *\n");        msg.append (" **************************************************************************\n");        msg.append ("\n\n");        System.out.println (msg.toString());        System.out.flush();    } // end startupWithTrust}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -