Author: rr
Date: Thu Jul 1 13:33:07 2010
New Revision: 959650
URL: http://svn.apache.org/viewvc?rev=959650&view=rev
Log:
ODE-863: Add hostname and ip address properties to be readable from bpel process
Added:
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
Modified:
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
Modified:
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?rev=959650&r1=959649&r2=959650&view=diff
==============================================================================
---
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
(original)
+++
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
Thu Jul 1 13:33:07 2010
@@ -1030,6 +1030,10 @@ public class BpelProcess {
}
public Node getProcessProperty(QName propertyName) {
+ Node value =
getEngine()._contexts.customProcessProperties.getProperty(propertyName);
+ if (value != null) {
+ return value;
+ }
Map<QName, Node> properties = _pconf.getProcessProperties();
if (properties != null) {
return properties.get(propertyName);
Modified:
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java?rev=959650&r1=959649&r2=959650&view=diff
==============================================================================
---
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
(original)
+++
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
Thu Jul 1 13:33:07 2010
@@ -61,5 +61,7 @@ public class Contexts {
/** Mapping from external variable engine identifier to the engine
implementation. */
final HashMap<QName, ExternalVariableModule> externalVariableEngines = new
HashMap<QName, ExternalVariableModule>();
+
+ public CustomProcessProperties customProcessProperties = new
CustomProcessProperties();
}
Added:
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java?rev=959650&view=auto
==============================================================================
---
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
(added)
+++
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
Thu Jul 1 13:33:07 2010
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.bpel.engine;
+
+import java.net.InetAddress;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class CustomProcessProperties {
+ private static final Log __log =
LogFactory.getLog(CustomProcessProperties.class);
+
+ public Node getProperty(QName propertyName) {
+ String name = propertyName.getLocalPart();
+ try {
+ if (name.equals("ode.localhost.name")) {
+ return stringToNode(InetAddress.getLocalHost().getHostName());
+ } else if (name.equals("ode.localhost.address")) {
+ return
stringToNode(InetAddress.getLocalHost().getHostAddress());
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ __log.warn("Can't evaluate property " + propertyName, e);
+ return null;
+ }
+ }
+
+ public static Node stringToNode(String s) {
+ Document d = DOMUtils.newDocument();
+ Element e = d.createElement("value");
+ e.setTextContent(s);
+ d.appendChild(e);
+ return d.getDocumentElement();
+ }
+}
Added:
ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java?rev=959650&view=auto
==============================================================================
---
ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
(added)
+++
ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
Thu Jul 1 13:33:07 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.bpel.engine;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+public class CustomProcessPropertiesTest extends TestCase {
+ public void test() throws Exception {
+ CustomProcessProperties p = new CustomProcessProperties();
+ assertNotNull(p.getProperty(QName.valueOf("ode.localhost.name")));
+ assertNotNull(p.getProperty(QName.valueOf("ode.localhost.address")));
+ assertNull(p.getProperty(QName.valueOf("ode.localhost.address5")));
+ }
+}