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

📄 default_web_site_xml.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .////////  Default_Web_Site_Xml////  NK      02.02.2001////package org.jahia.services.webapps_deployer.orion;import java.io.*;import java.util.*;//import com.sun.xml.tree.*;//import com.sun.xml.parser.Parser;import org.xml.sax.helpers.ParserAdapter;import org.w3c.dom.*;import org.xml.sax.*;import org.jahia.exceptions.*;import org.jahia.utils.*;               // JahiaConsoleimport org.jahia.data.xml.*;            // JahiaXmlDocumentimport org.jahia.utils.xml.*;           // XMLParser/** * Holds Informations about the Orion default-web-site.xml file * Need to modify this file to activate web apps * * <pre> *    <web-site host="[ALL]" port="8080" display-name="Default Orion WebSite"> *       <!-- The default web-app for this site, bound to the root --> *       <default-web-app application="default" name="defaultWebApp" /> * *       <!-- Uncomment this to activate the news app --> *       <!-- <web-app application="news" name="news-web" root="/news" /> --> *       <web-app application="AbsenceRequest" name="war-ic" root="/AbsenceRequest" /> *       <web-app application="Bookmark" name="Bookmark" root="/Bookmark" /> * *       <!-- Access Log, where requests are logged to --> *       <access-log path="../log/default-web-access.log" /> *    </web-site> * </pre> * * @author Khue ng * @version 1.0 */public class Default_Web_Site_Xml extends JahiaXmlDocument {   /** The list of <web-app..></web-app> elements **/   private Vector m_WebApps = new Vector();   /** The list of web-app Nodes **/   private Vector m_WebAppNodes = new Vector();	private final static String CLASS_NAME = "Default_Web_Site_Xml";		   /**    * Constructor    *    * @param (String) path, the full path to the server.xml file    */    public Default_Web_Site_Xml (String docPath) throws JahiaException    {      super(docPath);      extractDocumentData();    }   	/**     * Constructor using a gived parser     *      * @param (String) path, the full path to a xml file     * @param (Parser) parser, the parser to use     */	public Default_Web_Site_Xml (String docPath, org.xml.sax.helpers.ParserAdapter parser) 	throws JahiaException {		super(docPath,parser);	}   /**    * Extracts data from the web.xml file.    *    */   public void extractDocumentData() throws JahiaException {      JahiaConsole.println(CLASS_NAME+".extractDocumentData"," started ");       if (m_XMLDocument == null) {          throw new JahiaException( "Default_Web_Site_Xml",                                    "Parsed default-web-site.xml document is null",                                       JahiaException.ERROR,                                       JahiaException.SERVICE_ERROR);       }       if (!m_XMLDocument.hasChildNodes()) {          throw new JahiaException( "Default_Web_Site_Xml",                                       "Main document node has no children",                                       JahiaException.ERROR,                                       JahiaException.SERVICE_ERROR);       }      // get web-site node      Element docElNode = (Element) m_XMLDocument.getDocumentElement();       if (!docElNode.getNodeName().equalsIgnoreCase("web-site")) {          throw new JahiaException(  "Invalid XML format",                                        "web-site tag is not present as starting tag in file",                                        JahiaException.ERROR,                                        JahiaException.SERVICE_ERROR);       }      JahiaConsole.println(CLASS_NAME,"default-web-site.xml file has web-site element");      // get web app elements       Vector appNodes = XMLParser.getChildNodes(docElNode,"web-app");       Node nodeItem = null;       Web_App_Element appEl = null;       NamedNodeMap attribs = null;      String application;      String root;      String name;      String loadOnStartup;      String maxInactivityTime;       String shared;       int size = appNodes.size();       for ( int i=0 ; i<size ; i++ ){          nodeItem = (Node)appNodes.get(i);         JahiaConsole.println(CLASS_NAME,"web app element " + nodeItem.getNodeName());         application           = XMLParser.getAttributeValue(nodeItem,"application");         loadOnStartup         = XMLParser.getAttributeValue(nodeItem,"load-on-startup");         maxInactivityTime     = XMLParser.getAttributeValue(nodeItem,"max-inactivity-time");         name                  = XMLParser.getAttributeValue(nodeItem,"name");         root                  = XMLParser.getAttributeValue(nodeItem,"root");         shared                = XMLParser.getAttributeValue(nodeItem,"shared");         if ( application != null && root != null && name != null){            appEl = new Web_App_Element(                                           application,                                           root,                                           name,                                           loadOnStartup,                                          shared,                                           maxInactivityTime                                       );            m_WebApps.add(appEl);            m_WebAppNodes.add(nodeItem);            JahiaConsole.println(">>"," Web App application       :" + appEl.getApplication());            JahiaConsole.println(">>","         root              :" + appEl.getRoot());            JahiaConsole.println(">>","         name              :" + appEl.getName());            JahiaConsole.println(">>","         loadOnStratup     :" + appEl.getLoadOnStartup());            JahiaConsole.println(">>","         shared            :" + appEl.getShared());            JahiaConsole.println(">>","         maxInactivityTime :" + appEl.getMaxInactivityTime());         }       }      JahiaConsole.println(CLASS_NAME+".extractDocumentData()"," extraction done");   }   /**    * Return the list of Web App Elements    *    * @return (Vector) list of Web App Elements    */   public Vector getWebApps(){      return m_WebApps;   }   /**    * Append a new <web-app..> Element in the xml file    * Add it in the Web App list    *    * @param (Web_App_Element) appEl    */   public boolean addWebApp(Web_App_Element appEl) {      if ( !isDeclared( appEl.getApplication(), appEl.getName() ) ){         Element docElNode = (Element) m_XMLDocument.getDocumentElement();         Element newNode = (Element)m_XMLDocument.createElement("web-app");         XMLParser.setAttribute(newNode, "application",         appEl.getApplication());         XMLParser.setAttribute(newNode, "root",                appEl.getRoot());         XMLParser.setAttribute(newNode, "name",                appEl.getName());         XMLParser.setAttribute(newNode, "loadOnStartup",       appEl.getLoadOnStartup());         XMLParser.setAttribute(newNode, "shared",              appEl.getShared());         XMLParser.setAttribute(newNode, "maxInactivityTime",   appEl.getMaxInactivityTime());         if ( m_WebAppNodes.size()>0 ){	        Node lastAppNode = (Node)m_WebAppNodes.get( (m_WebAppNodes.size()-1) );	        docElNode.insertBefore(newNode,lastAppNode);         } else {	        docElNode.appendChild(newNode);		 }         m_WebApps.add(appEl);         m_WebAppNodes.add(newNode);         return true;      }      return false;   }   /**    * Check if a web app is already declared    *    * @param (String) appName, application name    * @param (String) webAppName, web app name    */   public boolean isDeclared( String appName, String webAppName ){      Web_App_Element webApp = null;      int size = m_WebApps.size();      for( int i=0 ; i<size ; i++ ){         webApp =(Web_App_Element)m_WebApps.get(i);         if ( webApp.getApplication().equals(appName) && webApp.getName().equals(webAppName)){            return true;         }      }      return false;   }} // end Default_Web_Site_Xml

⌨️ 快捷键说明

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