How to get Websphere profile port related information ?
There are actually two ways of getting the port related information used by a Websphere profile.
The first and foremost is to read through AboutThisProfile.txt from /logs .
Second one is to understand the serverindex.xml file inside the profile path .
Sample Path / Location for this file is : C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\nc9118041010Node01Cell\nodes\nc9118041010Node01\serverindex.xml
Java Class which get this ports info is shown below ... using XML DOM parser code is written.
Using Java to read serverindex.xml file to get WAS ports information
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* This class is used to collect different port information for a profile.
* For example this class have been used in Ant xml file "config/install/abc/abc_config.xml".
*
*
*/
public class GetWASProfilePortInfo extends Task
{
private String profilePath = null;
private String endpointName = null;
private String portValue = null;
public void setProfilePath(String profilePath)
{
this.profilePath = profilePath;
}
public void setEndpointName(String endpointName)
{
this.endpointName = endpointName;
}
public void setPortValue(String portValue)
{
if(portValue != "")
{
this.portValue = portValue;
}
}
public void execute() throws BuildException
{
try
{
collectPortInfo();
}
catch(Exception e)
{
e.printStackTrace();
throw new BuildException(e);
}
}
private void collectPortInfo() throws ParserConfigurationException, SAXException, IOException
{
ExistingWASProfileInfo profile = new ExistingWASProfileInfo(profilePath);
String cellName = profile.getCellName();
String nodeName = profile.getNodeName();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
char fs = File.separatorChar;
File serverIndexXML = new File(profilePath + fs + "config" + fs + "cells" + fs + cellName + fs + "nodes" + fs + nodeName + fs + "serverindex.xml");
Document doc = docBuilder.parse(serverIndexXML);
Element docElement = doc.getDocumentElement();
NodeList list = docElement.getElementsByTagName("specialEndpoints");
int size = list.getLength();
for(int i=0; i {
Node specialEndpointsNode = list.item(i);
Node endpointNode = specialEndpointsNode.getAttributes().getNamedItem("endPointName");
String endPointNameFromXML = endpointNode.getNodeValue();
if(this.endpointName.equals(endPointNameFromXML))
{
NodeList childNodes = specialEndpointsNode.getChildNodes();
int childNodeSize = childNodes.getLength();
for(int j=0; j {
Node childNode = childNodes.item(j);
if(childNode.getNodeName().equals("endPoint"))
{
Node portNode = childNode.getAttributes().getNamedItem("port");
String portValueFromXML = portNode.getNodeValue();
getProject().setProperty(portValue, portValueFromXML);
}
}
}
}
}
}
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* This class is used to collect different port information for a profile.
* For example this class have been used in Ant xml file "config/install/abc/abc_config.xml".
*
*
*/
public class GetWASProfilePortInfo extends Task
{
private String profilePath = null;
private String endpointName = null;
private String portValue = null;
public void setProfilePath(String profilePath)
{
this.profilePath = profilePath;
}
public void setEndpointName(String endpointName)
{
this.endpointName = endpointName;
}
public void setPortValue(String portValue)
{
if(portValue != "")
{
this.portValue = portValue;
}
}
public void execute() throws BuildException
{
try
{
collectPortInfo();
}
catch(Exception e)
{
e.printStackTrace();
throw new BuildException(e);
}
}
private void collectPortInfo() throws ParserConfigurationException, SAXException, IOException
{
ExistingWASProfileInfo profile = new ExistingWASProfileInfo(profilePath);
String cellName = profile.getCellName();
String nodeName = profile.getNodeName();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
char fs = File.separatorChar;
File serverIndexXML = new File(profilePath + fs + "config" + fs + "cells" + fs + cellName + fs + "nodes" + fs + nodeName + fs + "serverindex.xml");
Document doc = docBuilder.parse(serverIndexXML);
Element docElement = doc.getDocumentElement();
NodeList list = docElement.getElementsByTagName("specialEndpoints");
int size = list.getLength();
for(int i=0; i
Node specialEndpointsNode = list.item(i);
Node endpointNode = specialEndpointsNode.getAttributes().getNamedItem("endPointName");
String endPointNameFromXML = endpointNode.getNodeValue();
if(this.endpointName.equals(endPointNameFromXML))
{
NodeList childNodes = specialEndpointsNode.getChildNodes();
int childNodeSize = childNodes.getLength();
for(int j=0; j
Node childNode = childNodes.item(j);
if(childNode.getNodeName().equals("endPoint"))
{
Node portNode = childNode.getAttributes().getNamedItem("port");
String portValueFromXML = portNode.getNodeValue();
getProject().setProperty(portValue, portValueFromXML);
}
}
}
}
}
}
Popular Posts
-
The best solution to know about these init levels is to understand the " man init " command output on Unix. There are basically 8...
-
How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ? How to unlock BSNL 3G data card( Model no : LW272 )us...
-
How to transfer bike registration from one State to other (Karnataka to Andhra)?? Most of us having two wheelers purchased and registered in...
-
ఓం శ్రీ స్వామియే శరణం ఆయ్యప్ప!! Related posts : Trip to Sabarimala - Part 1 Trip to Sabarimala - Part 2 Ayappa Deeksha required things...
-
Following are some of interesting blogs I found till now ...please comment to add your blog here. Blogs in English : http://nitawriter.word...
Popular posts
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- init 0, init 1, init 2 ..
- Java-J2EE interview preparation
- mCheck Application jar or jad download
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Pilgrimages
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix best practices
- Unix FAQs