Author: jeff.yuchang
Date: 2012-04-20 03:32:46 -0400 (Fri, 20 Apr 2012)
New Revision: 1546
Added:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
Modified:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
Log:
RIFTSAW-489 reading properties from BPEL Process.
Modified:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
===================================================================
---
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java 2012-04-20
07:30:59 UTC (rev 1545)
+++
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java 2012-04-20
07:32:46 UTC (rev 1546)
@@ -1050,6 +1050,10 @@
}
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:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
===================================================================
---
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java 2012-04-20
07:30:59 UTC (rev 1545)
+++
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java 2012-04-20
07:32:46 UTC (rev 1546)
@@ -62,4 +62,6 @@
/** 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:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
===================================================================
---
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java
(rev 0)
+++
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/CustomProcessProperties.java 2012-04-20
07:32:46 UTC (rev 1546)
@@ -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:
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
===================================================================
---
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java
(rev 0)
+++
branches/ODE/RiftSaw-ODE-trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/CustomProcessPropertiesTest.java 2012-04-20
07:32:46 UTC (rev 1546)
@@ -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")));
+ }
+}
\ No newline at end of file