FileDocCategorySizeDatePackage
LogService.javaAPI DocGlassfish v2 API7666Thu Jul 19 23:55:50 BST 2007com.sun.enterprise.tools.upgrade.transform.elements

LogService

public class LogService extends BaseElement
author
prakash

Fields Summary
Constructors Summary
public LogService()
Creates a new instance of Element

    
Methods Summary
private voidsetLogLevelAttribute(org.w3c.dom.Element sourceLogService, java.lang.String srcEle, java.lang.String srcAttrName, org.w3c.dom.Element moduleLogLevels, java.lang.String targetAttrName)

        NodeList srcEles = sourceLogService.getOwnerDocument().getElementsByTagName(srcEle);
        if((srcEles != null) && (srcEles.getLength() > 0)){
            String logLevelAttrValue = ((Element)srcEles.item(0)).getAttribute(srcAttrName);
            if((logLevelAttrValue != null) && (!logLevelAttrValue.trim().equals(""))){
                if(logLevelAttrValue.equals("ALERT") || logLevelAttrValue.equals("FATAL")){
                    logLevelAttrValue = "SEVERE";
                }
                moduleLogLevels.setAttribute(targetAttrName, logLevelAttrValue);
            }
        }
    
private voidsetModuleLevelLogs(org.w3c.dom.Element sourceLogService, org.w3c.dom.Element resultLogService)

        // This method is called only for AS 7.x.  log-levels are defined for many source attributes, that need to be set to module level. in target
        NodeList modLogLevels = resultLogService.getElementsByTagName("module-log-levels");
        Element moduleLogLevels = null;
        if(modLogLevels.getLength() == 0){
            moduleLogLevels = resultLogService.getOwnerDocument().createElement("module-log-levels");
            resultLogService.appendChild(moduleLogLevels);
        }else{
            moduleLogLevels = (Element)modLogLevels.item(0);
        }
        // ejb-container from source
        //(http-service , iiop-service , admin-service? , web-container , ejb-container , mdb-container , jms-service , log-service , security-service , transaction-service , java-config , resources , applications , availability-service? , property*)
        //root, server, ejb-container, cmp-container, mdb-container, web-container, classloader, configuration, naming, security, jts, jta, admin, deployment, verifier, jaxr, jaxrpc, saaj, corba, javamail, jms, connector, jdo, cmp, util, resource-adapter, synchronization, node-agent
        setLogLevelAttribute(sourceLogService,"ejb-container", "log-level", moduleLogLevels, "ejb-container");
        setLogLevelAttribute(sourceLogService,"web-container", "log-level", moduleLogLevels, "web-container");
        setLogLevelAttribute(sourceLogService,"mdb-container", "log-level", moduleLogLevels, "mdb-container");
        setLogLevelAttribute(sourceLogService,"orb", "log-level", moduleLogLevels, "corba");
        setLogLevelAttribute(sourceLogService,"admin-service", "log-level", moduleLogLevels, "admin");
        setLogLevelAttribute(sourceLogService,"jms-service", "log-level", moduleLogLevels, "jms");
        setLogLevelAttribute(sourceLogService,"log-service", "level", moduleLogLevels, "server");
        setLogLevelAttribute(sourceLogService,"log-service", "level", moduleLogLevels, "root");
        setLogLevelAttribute(sourceLogService,"security-service", "log-level", moduleLogLevels, "security");
        setLogLevelAttribute(sourceLogService,"transaction-service", "log-level", moduleLogLevels, "jts");
    
protected voidtransferAttributes(org.w3c.dom.Element source, org.w3c.dom.Element result, java.util.List nonTransferList)

        // Transfer only appropriate attributes.
        //result.setAttribute("echo-log-messages-to-stderr", source.getAttribute("echo-log-messages-to-stderr"));

        //result.setAttribute("create-console",source.getAttribute("create-console"));
        //result.setAttribute("log-virtual-server-id",source.getAttribute("log-virtual-server-id"));

        // if source is 8.0 transfer all the elements
        if(commonInfoModel.getSourceVersion().equals(com.sun.enterprise.tools.upgrade.common.UpgradeConstants.VERSION_7X)){
            result.setAttribute("use-system-logging",source.getAttribute("use-system-logging"));
            this.setModuleLevelLogs(source,result);
        }else{
            nonTransferList = new java.util.Vector();
            // You dont want to change the log file name.
            nonTransferList.add("file");
            super.transferAttributes(source, result, nonTransferList);
        }
    
public voidtransform(org.w3c.dom.Element element, org.w3c.dom.Element parentSource, org.w3c.dom.Element parentResult)
element - log-service parentSource - parent server of element parentResult - domain


        logger.log(Level.FINE, stringManager.getString("upgrade.transform.transformingMSG", this.getClass().getName(), element.getTagName()));
        NodeList logServs = parentResult.getElementsByTagName("log-service");
        Element logService = null;
        logger.log(Level.FINE, this.getClass().getName() +  ":: logServs.getLength() ", logServs.getLength());
        if(logServs.getLength() == 0){
            NodeList config = parentResult.getElementsByTagName("config");
            logService = parentResult.getOwnerDocument().createElement("log-service");
            this.transferAttributes(element, logService, null);
            this.appendElementToParent((Element)config.item(0),logService);
        }else {
            logService = (Element)logServs.item(0);
            this.transferAttributes(element, logService, null);
        }

        super.transform(element,  parentSource, logService);