[jboss-svn-commits] JBL Code SVN: r16175 - labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 30 17:42:46 EDT 2007
Author: tcunning
Date: 2007-10-30 17:42:46 -0400 (Tue, 30 Oct 2007)
New Revision: 16175
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
Log:
bug:JBESB-832
Rewrite tokens for ${jboss.bind.address} replacement.
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2007-10-30 20:52:28 UTC (rev 16174)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2007-10-30 21:42:46 UTC (rev 16175)
@@ -22,9 +22,13 @@
package org.jboss.internal.soa.esb.dependencies;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.net.URI;
import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Properties;
import javax.naming.InitialContext;
@@ -39,14 +43,18 @@
public class JuddiRMIService extends ServiceMBeanSupport implements JuddiRMIServiceMBean
{
private Logger logger = Logger.getLogger(this.getClass());
+ public static final String JBOSS_BIND_ADDRESS_TOKEN = "jboss.bind.address";
+
public static final String PROPNAME_JAVA_NAMING_FACTORY_INITIAL = "java.naming.factory.initial";
public static final String PROPNAME_JAVA_NAMING_PROVIDER_URL = "java.naming.provider.url";
public static final String PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS = "java.naming.factory.url.pkgs";
-
+
private static final String DEFAULT_PROPERTIES_RESOURCE_FILE = "esb.juddi.xml";
private static final String JUDDI_PROPERTIES_RESOURCE_FILE = "esb.juddi.properties";
private static final String JUDDI_PROPERTY_FILE_COMMENTS = "Auto generated property file, do not edit" ;
+ private Hashtable<String, String> tokenHash;
+
private String propertiesResourceFile ;
public String getPropertiesResourceFile()
@@ -59,10 +67,16 @@
this.propertiesResourceFile = propertiesResourceFile;
}
+ public void initializeTokenHash() {
+ tokenHash = new Hashtable<String,String>();
+ String bindAddress = System.getProperty("jboss.bind.address");
+ tokenHash.put("${" + JBOSS_BIND_ADDRESS_TOKEN + "}", bindAddress);
+ }
+
protected void startService() throws Exception
{
logger.info("starting juddi RMI service");
- final String propertiesResourceFileVal ;
+ final String propertiesResourceFileVal ;
if (propertiesResourceFile == null)
{
propertiesResourceFileVal = DEFAULT_PROPERTIES_RESOURCE_FILE ;
@@ -76,7 +90,7 @@
final File xmlPropertyFile ;
if (baseFile.isAbsolute())
{
- xmlPropertyFile = baseFile ;
+ xmlPropertyFile = baseFile;
}
else
{
@@ -92,17 +106,44 @@
System.setProperty("juddi.propertiesFile", juddiPropertyFile.getAbsolutePath());
System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+ // Support token replacement
+ initializeTokenHash();
+ for (Enumeration e = xmlProperties.keys(); e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ String value = xmlProperties.getProperty(key);
+ for (String tokenKey : tokenHash.keySet()) {
+ String tokenValue = tokenHash.get(tokenKey);
+ if (value.contains(tokenKey)) {
+ value = value.replace(tokenKey, tokenValue);
+ System.setProperty(key, value);
+ xmlProperties.setProperty(key, value);
+ }
+ }
+ }
+
+ // Rewrite for token replacement
+ FileOutputStream rewritePropertyOS = new FileOutputStream(juddiPropertyFile) ;
+ try {
+ rewritePropertyOS = new FileOutputStream(juddiPropertyFile);
+ final BufferedOutputStream bos = new BufferedOutputStream(rewritePropertyOS) ;
+ xmlProperties.store(bos, JUDDI_PROPERTY_FILE_COMMENTS) ;
+ bos.flush() ;
+ } finally {
+ rewritePropertyOS.close();
+ }
+
// Read properties from file and if they exist - pass them on to juddi as system properties
+ // Do not pass back the properties back if
String factoryInitial = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_FACTORY_INITIAL, null);
String providerURL = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_PROVIDER_URL, null);
String factoryURLPkgs = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, null);
- if (factoryInitial != null) {
+ if ((factoryInitial != null) {
System.setProperty(PROPNAME_JAVA_NAMING_FACTORY_INITIAL, factoryInitial);
- }
- if (providerURL != null) {
+ }
+ if ((providerURL != null) {
System.setProperty(PROPNAME_JAVA_NAMING_PROVIDER_URL, providerURL);
- }
- if (factoryURLPkgs != null) {
+ }
+ if ((factoryURLPkgs != null) {
System.setProperty(PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, factoryURLPkgs);
}
JNDIRegistration.register();
More information about the jboss-svn-commits
mailing list