FileDocCategorySizeDatePackage
IIOPListener.javaAPI DocGlassfish v2 API8021Fri May 04 22:35:10 BST 2007com.sun.enterprise.tools.upgrade.transform.elements

IIOPListener

public class IIOPListener extends BaseElement
author
prakash

Fields Summary
private final String
IIOP_LISTENER_PORT_PROPERTY_NAME
Constructors Summary
Methods Summary
protected java.util.ListgetNonTransferList(org.w3c.dom.Element element)

        java.util.Vector notToTransferAttrList = new java.util.Vector();
        if(commonInfoModel.getCurrentCluster() != null){
            if(element.getAttribute("id").equals("orb-listener-1")){
                // In this case iiop-cluster processing transforms the port nos.  So, dont change the port no here.
                notToTransferAttrList.add("port");            
            }
        }        
        return notToTransferAttrList;
    
private booleanisAppserver71EE(org.w3c.dom.Element source)

        Element docEle = source.getOwnerDocument().getDocumentElement();
        NodeList iiopClusters = docEle.getElementsByTagName("iiop-cluster");
        if((iiopClusters == null) || (iiopClusters.getLength() == 0)){
            return false;
        }
        return true;
    
protected voidtransferAttributes(org.w3c.dom.Element source, org.w3c.dom.Element result, java.util.List nonTransferList)

        if(!UpgradeConstants.EDITION_PE.equals(commonInfoModel.getSourceEdition())){
            if(UpgradeConstants.VERSION_7X.equals(commonInfoModel.getSourceVersion())){
                if(source.getAttribute("id").equals("orb-listener-1") && source.getAttribute("port").equals("3700")){
                    // If server-config has 3700 as port no. for orb-listener-1
		    // set it with the port no. that this listener has got.
                    // If switching is done, then it is ok to transfer the port 3700 from source to target.

                    String serverID = source.getOwnerDocument().getDocumentElement().getAttribute("name");
                    //result.getAttribute("port") may return ${IIOP_LISTENER_PORT}....need to check
                    // If the source is AS70 EE do not transfer the port. Do this only if the source is SE or 7.1EE
                    if(UpgradeConstants.EDITION_SE.equals(commonInfoModel.getSourceEdition()) || 
                            this.isAppserver71EE(source)){
                        UpgradeUtils.getUpgradeUtils(commonInfoModel).
                            switchedIIOPPorts(serverID, result.getAttribute("port"),
                                result.getOwnerDocument().getDocumentElement());                    
                    }
                }
            }
        }
        super.transferAttributes(source,result,nonTransferList);
    
public voidtransform(org.w3c.dom.Element element, org.w3c.dom.Element parentSource, org.w3c.dom.Element parentResult)

    
           
        
        String elementTagName = element.getTagName();
        NodeList resultElements = parentResult.getElementsByTagName(elementTagName);
        Element resultElement = null;
        for(int lh =0; lh < resultElements.getLength(); lh++){
            Element itElement = ((Element)resultElements.item(lh));
            if((element.getAttribute("id")).equals(((Element)resultElements.item(lh)).getAttribute("id"))){
                resultElement = (Element)resultElements.item(lh);
                break;
            }
        }
        java.util.List notToTransferAttrList = this.getNonTransferList(element);            
        if(resultElement == null){
            resultElement = parentResult.getOwnerDocument().createElement(elementTagName);
            if(commonInfoModel.getCurrentCluster() != null){
                notToTransferAttrList.add("port");
                String propertyName = element.getAttribute("id")+"_IIOP_LISTENER_PORT";
                UpgradeUtils.getUpgradeUtils(commonInfoModel).
                        updateListenerPortsForClusteredInstances(parentResult.getOwnerDocument().getDocumentElement(),
                            propertyName, element.getAttribute("port"), this);
                resultElement.setAttribute("port", "${"+propertyName+"}");
            }
            this.transferAttributes(element, resultElement, notToTransferAttrList);
            this.appendElementToParent(parentResult,resultElement);  
        }else {            
            if(commonInfoModel.getCurrentCluster() == null){
                // This is for stand alone servers.  Lets not change the port nos. directly in config.  
		// Rather set it in system property
                if(!UpgradeConstants.EDITION_PE.equals(commonInfoModel.getSourceEdition())){
                    String instanceName = commonInfoModel.getCurrentSourceInstance();
                    if((instanceName != null) &&(!("".equals(instanceName.trim())))){
                        if(element.getAttribute("id").equals("orb-listener-1")){
                            notToTransferAttrList.add("port");    
                            String propertyValue = element.getAttribute("port");
                            NodeList servers = parentResult.getOwnerDocument().
                                getDocumentElement().getElementsByTagName("servers");
                            NodeList serverList = ((Element)servers.item(0)).getElementsByTagName("server");
                            UpgradeUtils.getUpgradeUtils(commonInfoModel).
                                addOrUpdateSystemPropertyToServer(instanceName, serverList, 
                                    IIOP_LISTENER_PORT_PROPERTY_NAME, element.getAttribute("port"), this);
                        }
                    }
                }
            }
            this.transferAttributes(element, resultElement, notToTransferAttrList);
        } 
        super.transform(element,  parentSource, resultElement);