Omaha #4392 Updates to configure new QPID json file.
Former-commit-id:9f488920a1
[formerly ef2c2f94c7dc30fb0313ce8df295c52ea3c22e85] Former-commit-id:531944303c
This commit is contained in:
parent
3a4731daff
commit
f2e5ab25dc
4 changed files with 64 additions and 134 deletions
|
@ -4,6 +4,7 @@ Bundle-Name: Wes2Bridge Manager
|
|||
Bundle-SymbolicName: com.raytheon.wes2bridge.manager
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: com.raytheon.wes2bridge.common;bundle-version="1.0.0",
|
||||
org.apache.commons.lang;bundle-version="2.3.0"
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
org.codehaus.jackson;bundle-version="1.7.3"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
|
||||
<attribute name="Rsrc-Main-Class" value="com.raytheon.wes2bridge.manager.Wes2BridgeManager"/>
|
||||
<attribute name="Class-Path" value="."/>
|
||||
<attribute name="Rsrc-Class-Path" value="./ commons-collections-3.2.jar geronimo-jms_1.1_spec-1.1.1.jar org.eclipse.ui_3.8.2.v20121018-234953.jar org.eclipse.swt_3.8.1.v3836b.jar org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar org.eclipse.jface_3.8.0.v20120912-135020.jar org.eclipse.core.commands_3.6.1.v20120912-135020.jar org.eclipse.ui.workbench_3.8.2.v20121128-133708.jar org.eclipse.core.runtime_3.8.0.v20120521-2346.jar org.eclipse.osgi_3.8.2.v20130124-134944.jar org.eclipse.equinox.common_3.6.100.v20120522-1841.jar org.eclipse.core.jobs_3.5.200.v20120521-2346.jar runtime_registry_compatibility.jar org.eclipse.equinox.registry_3.5.200.v20120522-1841.jar org.eclipse.equinox.preferences_3.5.1.v20121031-182809.jar org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar org.eclipse.equinox.app_1.3.100.v20120522-1841.jar log4j-1.2.16.jar log4j.extras-1.0.jar commons-beanutils-1.8.3.jar commons-digester-1.8.1.jar commons-lang-2.3.jar commons-configuration-1.6.jar"/>
|
||||
<attribute name="Rsrc-Class-Path" value="./ commons-collections-3.2.jar geronimo-jms_1.1_spec-1.1.1.jar org.eclipse.ui_3.8.2.v20121018-234953.jar org.eclipse.swt_3.8.1.v3836b.jar org.eclipse.swt.gtk.linux.x86_3.8.1.v3836b.jar org.eclipse.jface_3.8.0.v20120912-135020.jar org.eclipse.core.commands_3.6.1.v20120912-135020.jar org.eclipse.ui.workbench_3.8.2.v20121128-133708.jar org.eclipse.core.runtime_3.8.0.v20120521-2346.jar org.eclipse.osgi_3.8.2.v20130124-134944.jar org.eclipse.equinox.common_3.6.100.v20120522-1841.jar org.eclipse.core.jobs_3.5.200.v20120521-2346.jar runtime_registry_compatibility.jar org.eclipse.equinox.registry_3.5.200.v20120522-1841.jar org.eclipse.equinox.preferences_3.5.1.v20121031-182809.jar org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar org.eclipse.equinox.app_1.3.100.v20120522-1841.jar log4j-1.2.16.jar log4j.extras-1.0.jar commons-beanutils-1.8.3.jar commons-digester-1.8.1.jar commons-lang-2.3.jar commons-configuration-1.6.jar jackson-core-asl-1.7.3.jar jackson-mapper-asl-1.7.3.jar jackson-xc-1.7.3.jar"/>
|
||||
</manifest>
|
||||
<zipfileset src="${basedir}/../build.wes2bridge.utility/lib/jar-in-jar-loader.zip"/>
|
||||
<zipfileset dir="${baseline.directory}/org.apache.commons.collections" includes="commons-collections-3.2.jar"/>
|
||||
|
@ -36,6 +36,9 @@
|
|||
<zipfileset dir="${baseline.directory}/org.apache.commons.beanutils" includes="commons-beanutils-1.8.3.jar"/>
|
||||
<zipfileset dir="${baseline.directory}/org.apache.commons.digester" includes="commons-digester-1.8.1.jar"/>
|
||||
<zipfileset dir="${baseline.directory}/org.apache.commons.lang" includes="commons-lang-2.3.jar"/>
|
||||
<zipfileset dir="${baseline.directory}/org.codehaus.jackson" includes="jackson-core-asl-1.7.3.jar"/>
|
||||
<zipfileset dir="${baseline.directory}/org.codehaus.jackson" includes="jackson-mapper-asl-1.7.3.jar"/>
|
||||
<zipfileset dir="${baseline.directory}/org.codehaus.jackson" includes="jackson-xc-1.7.3.jar"/>
|
||||
<fileset dir="${baseline.directory}/com.raytheon.wes2bridge.common/${bin.dir}"/>
|
||||
<fileset dir="${baseline.directory}/com.raytheon.wes2bridge.manager/${bin.dir}"/>
|
||||
</jar>
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.wes2bridge.manager;
|
||||
|
||||
/**
|
||||
* Identifies XML tag names of interest as constants within the qpid config.xml
|
||||
* configuration.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 17, 2013 bkowal Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bkowal
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IQpidConfigurationXML {
|
||||
public static final String XML_BROKER = "broker";
|
||||
public static final String XML_CONNECTOR = "connector";
|
||||
public static final String XML_MANAGEMENT = "management";
|
||||
public static final String XML_JMXPORT = "jmxport";
|
||||
public static final String XML_HTTP = "http";
|
||||
public static final String XML_REGISTRY_SERVER = "registryServer";
|
||||
public static final String XML_PORT = "port";
|
||||
}
|
|
@ -26,27 +26,17 @@ import java.io.BufferedReader;
|
|||
import java.io.FileWriter;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.TransformerFactoryConfigurationError;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
|
||||
import com.raytheon.wes2bridge.manager.IQpidConfigurationXML;
|
||||
import com.raytheon.wes2bridge.common.configuration.Wes2BridgeCase;
|
||||
import com.raytheon.wes2bridge.configuration.jaxb.Wes2BridgeJaxbManager;
|
||||
|
||||
|
@ -73,6 +63,7 @@ import com.raytheon.wes2bridge.configuration.jaxb.Wes2BridgeJaxbManager;
|
|||
* Aug 14, 2014 3521 bkowal Updated to use Wes2BridgeCase. Eliminated
|
||||
* configuration that is no longer used and
|
||||
* updated EDEX re-configuration.
|
||||
* Apr 15, 2015 4392 dlovely Updates the new qpid json configuration now
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -101,6 +92,16 @@ public class Wes2BridgeManager {
|
|||
|
||||
private String wes2BridgeScripts = null;
|
||||
|
||||
private static final TypeReference<Map<String, Object>> MAP_TYPE_REFERENCE = new TypeReference<Map<String, Object>>()
|
||||
{
|
||||
};
|
||||
|
||||
public static final String QPID_NAME = "name";
|
||||
public static final String QPID_AMQP = "AMQP";
|
||||
public static final String QPID_HTTP = "HTTP";
|
||||
public static final String QPID_PORT = "port";
|
||||
public static final String QPID_PORTS = "ports";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -409,87 +410,60 @@ public class Wes2BridgeManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void reconfigureQPID() throws FileNotFoundException, IOException,
|
||||
ParserConfigurationException, SAXException,
|
||||
TransformerFactoryConfigurationError, TransformerException {
|
||||
public void reconfigureQPID() throws FileNotFoundException, IOException {
|
||||
final String srcQpidDirectory = AWIPSII + "/" + "qpid";
|
||||
final String qpidDirectory = WES2BRIDGE_DIRECTORY + "/"
|
||||
+ this.wes2BridgeCase.getName() + "/" + "qpid";
|
||||
|
||||
this.updateQpidConfigXML(srcQpidDirectory, qpidDirectory);
|
||||
this.updateQpidConfigJSON(srcQpidDirectory, qpidDirectory);
|
||||
this.updateQPIDD(qpidDirectory);
|
||||
}
|
||||
|
||||
/* Updates qpid config.xml */
|
||||
private void updateQpidConfigXML(String srcQpidDirectory,
|
||||
String qpidDirectory) throws FileNotFoundException, IOException,
|
||||
ParserConfigurationException, SAXException,
|
||||
TransformerFactoryConfigurationError, TransformerException {
|
||||
String srcconfig_xml = srcQpidDirectory + "/etc/config.xml";
|
||||
String config_xml = qpidDirectory + "/etc/config.xml";
|
||||
/* Updates qpid config.json */
|
||||
private void updateQpidConfigJSON(String srcQpidDirectory,
|
||||
String qpidDirectory) throws FileNotFoundException, IOException {
|
||||
String srcconfig_json = srcQpidDirectory + "/config.json";
|
||||
String config_json = qpidDirectory + "/config.json";
|
||||
|
||||
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
|
||||
.newDocumentBuilder();
|
||||
Document document = documentBuilder.parse(srcconfig_xml);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
// Get the root broker node.
|
||||
Node brokerNode = document.getElementsByTagName(
|
||||
IQpidConfigurationXML.XML_BROKER).item(0);
|
||||
// Get the connector node.
|
||||
Node connectorNode = this.getChildNodeByName(brokerNode,
|
||||
IQpidConfigurationXML.XML_CONNECTOR);
|
||||
// Get the management node.
|
||||
Node managementNode = this.getChildNodeByName(brokerNode,
|
||||
IQpidConfigurationXML.XML_MANAGEMENT);
|
||||
// Get the jmxport node.
|
||||
Node jmxPortNode = this.getChildNodeByName(managementNode,
|
||||
IQpidConfigurationXML.XML_JMXPORT);
|
||||
// Get the http port node.
|
||||
Node httpPortNode = this.getChildNodeByName(managementNode,
|
||||
IQpidConfigurationXML.XML_HTTP);
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
br = this.getBufferedReader(srcconfig_json);
|
||||
bw = this.getBufferedWriter(config_json);
|
||||
|
||||
Node portNode = null;
|
||||
String line = StringUtils.EMPTY;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while( ( line = br.readLine() ) != null ) {
|
||||
stringBuilder.append( line );
|
||||
}
|
||||
|
||||
// Get the connector port node.
|
||||
portNode = this.getChildNodeByName(connectorNode,
|
||||
IQpidConfigurationXML.XML_PORT);
|
||||
portNode.setTextContent(Integer.toString(this.wes2BridgeCase
|
||||
.getJmsPort()));
|
||||
// Get the jmxport registryServer node
|
||||
portNode = this.getChildNodeByName(jmxPortNode,
|
||||
IQpidConfigurationXML.XML_REGISTRY_SERVER);
|
||||
portNode.setTextContent(Integer.toString(this.wes2BridgeCase
|
||||
.getQpidJmxPort()));
|
||||
// Get the http port node.
|
||||
portNode = this.getChildNodeByName(httpPortNode,
|
||||
IQpidConfigurationXML.XML_PORT);
|
||||
portNode.setTextContent(Integer.toString(this.wes2BridgeCase
|
||||
.getQpidHttpPort()));
|
||||
Map<String, Object> attributesMap = mapper.readValue(stringBuilder.toString(), MAP_TYPE_REFERENCE);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<Object> ports = (ArrayList<Object>) attributesMap.get(QPID_PORTS);
|
||||
|
||||
for(int x = 0; x < ports.size(); x++) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> port = (Map<String, Object>) ports.get(x);
|
||||
String name = (String) port.get(QPID_NAME);
|
||||
if (QPID_AMQP.equals(name)) {
|
||||
port.put(QPID_PORT, this.wes2BridgeCase.getQpidJmxPort());
|
||||
} else if (QPID_HTTP.equals(name)) {
|
||||
port.put(QPID_PORT, this.wes2BridgeCase.getQpidHttpPort());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the updated configuration file to its destination.
|
||||
*/
|
||||
Transformer transformer = TransformerFactory.newInstance()
|
||||
.newTransformer();
|
||||
DOMSource domSource = new DOMSource(document);
|
||||
StreamResult streamResult = new StreamResult(new File(config_xml));
|
||||
transformer.transform(domSource, streamResult);
|
||||
}
|
||||
mapper.defaultPrettyPrintingWriter().writeValue(bw, attributesMap);
|
||||
|
||||
private Node getChildNodeByName(Node parentNode, String childName) {
|
||||
if (parentNode.hasChildNodes() == false) {
|
||||
return null;
|
||||
} finally {
|
||||
br.close();
|
||||
bw.close();
|
||||
}
|
||||
|
||||
NodeList nodeList = parentNode.getChildNodes();
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
if (node.getNodeName().equals(childName)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateQPIDD(String qpidDirectory)
|
||||
|
|
Loading…
Add table
Reference in a new issue