You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2008/05/23 01:26:18 UTC
svn commit: r659307 [23/24] - in /ode/trunk:
axis2-war/src/main/webapp/WEB-INF/ axis2-war/src/main/webapp/WEB-INF/classes/
axis2-war/src/test/resources/XSDReferences/
axis2-war/src/test/resources/XSDReferences/BPMN/
axis2-war/src/test/resources/XSDRefe...
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ScopeDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,194 +1,194 @@
-/*
- * 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.dao.jpa;
-
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.evt.BpelEvent;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Query;
-import javax.persistence.Table;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-@Entity
-@Table(name="ODE_SCOPE")
-@NamedQueries({
- @NamedQuery(name="ScopeEvents", query="SELECT se FROM EventDAOImpl as se WHERE se._scopeId = :sid")
- })
-public class ScopeDAOImpl extends OpenJPADAO implements ScopeDAO {
-
- @Id @Column(name="SCOPE_ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- private Long _scopeInstanceId;
-
- @Basic @Column(name="MODEL_ID")
- private int _modelId;
- @Basic @Column(name="SCOPE_NAME")
- private String _name;
- @Basic @Column(name="SCOPE_STATE")
- private String _scopeState;
-
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
- @Column(name="PARENT_SCOPE_ID")
- private ScopeDAOImpl _parentScope;
-
- @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_parentScope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<ScopeDAO> _childScopes = new ArrayList<ScopeDAO>();
- @OneToMany(targetEntity=CorrelationSetDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<CorrelationSetDAO> _correlationSets = new ArrayList<CorrelationSetDAO>();
- @OneToMany(targetEntity=PartnerLinkDAOImpl.class,mappedBy="_scope",fetch= FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<PartnerLinkDAO> _partnerLinks = new ArrayList<PartnerLinkDAO>();
- @OneToMany(targetEntity=XmlDataDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<XmlDataDAO> _variables = new ArrayList<XmlDataDAO>();
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
- private ProcessInstanceDAOImpl _processInstance;
-
- public ScopeDAOImpl() {}
- public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int scopeModelId, ProcessInstanceDAOImpl pi) {
- _parentScope = parentScope;
- _name = name;
- _modelId = scopeModelId;
- _processInstance = pi;
- }
-
- public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
- String myRole, String partnerRole) {
- PartnerLinkDAOImpl pl = new PartnerLinkDAOImpl(plinkModelId, pLinkName, myRole, partnerRole);
- pl.setScope(this);
- _partnerLinks.add(pl);
- return pl;
- }
-
- public Collection<ScopeDAO> getChildScopes() {
- return _childScopes;
- }
-
- public CorrelationSetDAO getCorrelationSet(String corrSetName) {
- CorrelationSetDAO ret = null;
- for (CorrelationSetDAO csElement : _correlationSets) {
- if ( csElement.getName().equals(corrSetName)) ret = csElement;
- }
-
- if ( ret == null ) {
- // Apparently the caller knows there should be a correlation set
- // in here. Create a new set if one does not exist.
- // Not sure I understand this implied object creation and why
- // an explicit create pattern isn't used ( i.e. similar to
- // PartnerLink creation )
- ret = new CorrelationSetDAOImpl(this,corrSetName);
- // Persist the new correlation set to generate an ID
- getEM().persist(ret);
- _correlationSets.add(ret);
- }
-
- return ret;
- }
-
- public Collection<CorrelationSetDAO> getCorrelationSets() {
- return _correlationSets;
- }
-
- public int getModelId() {
- return _modelId;
- }
-
- public String getName() {
- return _name;
- }
-
- public ScopeDAO getParentScope() {
- return _parentScope;
- }
-
- public PartnerLinkDAO getPartnerLink(int plinkModelId) {
- for (PartnerLinkDAO pLink : getPartnerLinks()) {
- if (pLink.getPartnerLinkModelId() == plinkModelId) {
- return pLink;
- }
- }
- return null;
- }
-
- public Collection<PartnerLinkDAO> getPartnerLinks() {
- return _partnerLinks;
- }
-
- public ProcessInstanceDAO getProcessInstance() {
- return _processInstance;
- }
-
- public Long getScopeInstanceId() {
- return _scopeInstanceId;
- }
-
- public ScopeStateEnum getState() {
- return new ScopeStateEnum(_scopeState);
- }
-
- public XmlDataDAO getVariable(String varName) {
- XmlDataDAO ret = null;
-
- for (XmlDataDAO xmlElement : _variables) {
- if ( xmlElement.getName().equals(varName)) return xmlElement;
- }
-
- ret = new XmlDataDAOImpl(this,varName);
- _variables.add(ret);
-
- return ret;
- }
-
- public Collection<XmlDataDAO> getVariables() {
- return _variables;
- }
-
- public List<BpelEvent> listEvents() {
- List<BpelEvent> result = new ArrayList<BpelEvent>();
- Query qry = getEM().createNamedQuery("ScopeEvents");
- qry.setParameter("sid", _scopeInstanceId);
- for (Object eventDao : qry.getResultList()) {
- result.add(((EventDAOImpl)eventDao).getEvent());
- }
- return result;
- }
-
- public void setState(ScopeStateEnum state) {
- _scopeState = state.toString();
- }
-
-}
+/*
+ * 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.dao.jpa;
+
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ScopeStateEnum;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@Entity
+@Table(name="ODE_SCOPE")
+@NamedQueries({
+ @NamedQuery(name="ScopeEvents", query="SELECT se FROM EventDAOImpl as se WHERE se._scopeId = :sid")
+ })
+public class ScopeDAOImpl extends OpenJPADAO implements ScopeDAO {
+
+ @Id @Column(name="SCOPE_ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _scopeInstanceId;
+
+ @Basic @Column(name="MODEL_ID")
+ private int _modelId;
+ @Basic @Column(name="SCOPE_NAME")
+ private String _name;
+ @Basic @Column(name="SCOPE_STATE")
+ private String _scopeState;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @Column(name="PARENT_SCOPE_ID")
+ private ScopeDAOImpl _parentScope;
+
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_parentScope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ScopeDAO> _childScopes = new ArrayList<ScopeDAO>();
+ @OneToMany(targetEntity=CorrelationSetDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<CorrelationSetDAO> _correlationSets = new ArrayList<CorrelationSetDAO>();
+ @OneToMany(targetEntity=PartnerLinkDAOImpl.class,mappedBy="_scope",fetch= FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<PartnerLinkDAO> _partnerLinks = new ArrayList<PartnerLinkDAO>();
+ @OneToMany(targetEntity=XmlDataDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<XmlDataDAO> _variables = new ArrayList<XmlDataDAO>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInstance;
+
+ public ScopeDAOImpl() {}
+ public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int scopeModelId, ProcessInstanceDAOImpl pi) {
+ _parentScope = parentScope;
+ _name = name;
+ _modelId = scopeModelId;
+ _processInstance = pi;
+ }
+
+ public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
+ String myRole, String partnerRole) {
+ PartnerLinkDAOImpl pl = new PartnerLinkDAOImpl(plinkModelId, pLinkName, myRole, partnerRole);
+ pl.setScope(this);
+ _partnerLinks.add(pl);
+ return pl;
+ }
+
+ public Collection<ScopeDAO> getChildScopes() {
+ return _childScopes;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ CorrelationSetDAO ret = null;
+ for (CorrelationSetDAO csElement : _correlationSets) {
+ if ( csElement.getName().equals(corrSetName)) ret = csElement;
+ }
+
+ if ( ret == null ) {
+ // Apparently the caller knows there should be a correlation set
+ // in here. Create a new set if one does not exist.
+ // Not sure I understand this implied object creation and why
+ // an explicit create pattern isn't used ( i.e. similar to
+ // PartnerLink creation )
+ ret = new CorrelationSetDAOImpl(this,corrSetName);
+ // Persist the new correlation set to generate an ID
+ getEM().persist(ret);
+ _correlationSets.add(ret);
+ }
+
+ return ret;
+ }
+
+ public Collection<CorrelationSetDAO> getCorrelationSets() {
+ return _correlationSets;
+ }
+
+ public int getModelId() {
+ return _modelId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public ScopeDAO getParentScope() {
+ return _parentScope;
+ }
+
+ public PartnerLinkDAO getPartnerLink(int plinkModelId) {
+ for (PartnerLinkDAO pLink : getPartnerLinks()) {
+ if (pLink.getPartnerLinkModelId() == plinkModelId) {
+ return pLink;
+ }
+ }
+ return null;
+ }
+
+ public Collection<PartnerLinkDAO> getPartnerLinks() {
+ return _partnerLinks;
+ }
+
+ public ProcessInstanceDAO getProcessInstance() {
+ return _processInstance;
+ }
+
+ public Long getScopeInstanceId() {
+ return _scopeInstanceId;
+ }
+
+ public ScopeStateEnum getState() {
+ return new ScopeStateEnum(_scopeState);
+ }
+
+ public XmlDataDAO getVariable(String varName) {
+ XmlDataDAO ret = null;
+
+ for (XmlDataDAO xmlElement : _variables) {
+ if ( xmlElement.getName().equals(varName)) return xmlElement;
+ }
+
+ ret = new XmlDataDAOImpl(this,varName);
+ _variables.add(ret);
+
+ return ret;
+ }
+
+ public Collection<XmlDataDAO> getVariables() {
+ return _variables;
+ }
+
+ public List<BpelEvent> listEvents() {
+ List<BpelEvent> result = new ArrayList<BpelEvent>();
+ Query qry = getEM().createNamedQuery("ScopeEvents");
+ qry.setParameter("sid", _scopeInstanceId);
+ for (Object eventDao : qry.getResultList()) {
+ result.add(((EventDAOImpl)eventDao).getEvent());
+ }
+ return result;
+ }
+
+ public void setState(ScopeStateEnum state) {
+ _scopeState = state.toString();
+ }
+
+}
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,139 +1,139 @@
-/*
- * 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.dao.jpa;
-
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_XML_DATA")
-public class XmlDataDAOImpl implements XmlDataDAO {
-
- @Id @Column(name="XML_DATA_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- private Long _id;
- @Lob @Column(name="DATA")
- private String _data;
- @Transient
- private Node _node;
- @Basic @Column(name="IS_SIMPLE_TYPE")
- private boolean _isSimpleType;
- @Basic @Column(name="NAME")
- private String _name;
-
- @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
- private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
-
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
- private ScopeDAOImpl _scope;
-
- public XmlDataDAOImpl() {}
- public XmlDataDAOImpl(ScopeDAOImpl scope, String name){
- _scope = scope;
- _name = name;
- }
-
- public Node get() {
- if ( _node == null && _data != null ) {
- if(_isSimpleType){
- Document d = DOMUtils.newDocument();
- // we create a dummy wrapper element
- // prevents some apps from complaining
- // when text node is not actual child of document
- Element e = d.createElement("text-node-wrapper");
- Text tnode = d.createTextNode(_data);
- d.appendChild(e);
- e.appendChild(tnode);
- _node = tnode;
- }else{
- try{
- _node = DOMUtils.stringToDOM(_data);
- }catch(Exception e){
- throw new RuntimeException(e);
- }
- }
- }
-
- return _node;
- }
-
- public String getName() {
- return _name;
- }
-
- public String getProperty(String propertyName) {
- for (XmlDataProperty prop : _props) {
- if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
- }
- return null;
- }
-
- public ScopeDAO getScopeDAO() {
- return _scope;
- }
-
- public boolean isNull() {
- return _data == null;
- }
-
- public void remove() {
-
- }
-
- public void set(Node val) {
- _node = val;
- if ( val instanceof Element ) {
- _isSimpleType = false;
- _data = DOMUtils.domToString(val);
- } else {
- _isSimpleType = true;
- _data = _node.getNodeValue();
- }
- }
-
- public void setProperty(String pname, String pvalue) {
- _props.add(new XmlDataProperty(pname, pvalue, this));
- }
-
-}
+/*
+ * 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.dao.jpa;
+
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA")
+public class XmlDataDAOImpl implements XmlDataDAO {
+
+ @Id @Column(name="XML_DATA_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _id;
+ @Lob @Column(name="DATA")
+ private String _data;
+ @Transient
+ private Node _node;
+ @Basic @Column(name="IS_SIMPLE_TYPE")
+ private boolean _isSimpleType;
+ @Basic @Column(name="NAME")
+ private String _name;
+
+ @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
+ private ScopeDAOImpl _scope;
+
+ public XmlDataDAOImpl() {}
+ public XmlDataDAOImpl(ScopeDAOImpl scope, String name){
+ _scope = scope;
+ _name = name;
+ }
+
+ public Node get() {
+ if ( _node == null && _data != null ) {
+ if(_isSimpleType){
+ Document d = DOMUtils.newDocument();
+ // we create a dummy wrapper element
+ // prevents some apps from complaining
+ // when text node is not actual child of document
+ Element e = d.createElement("text-node-wrapper");
+ Text tnode = d.createTextNode(_data);
+ d.appendChild(e);
+ e.appendChild(tnode);
+ _node = tnode;
+ }else{
+ try{
+ _node = DOMUtils.stringToDOM(_data);
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ return _node;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getProperty(String propertyName) {
+ for (XmlDataProperty prop : _props) {
+ if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
+ }
+ return null;
+ }
+
+ public ScopeDAO getScopeDAO() {
+ return _scope;
+ }
+
+ public boolean isNull() {
+ return _data == null;
+ }
+
+ public void remove() {
+
+ }
+
+ public void set(Node val) {
+ _node = val;
+ if ( val instanceof Element ) {
+ _isSimpleType = false;
+ _data = DOMUtils.domToString(val);
+ } else {
+ _isSimpleType = true;
+ _data = _node.getNodeValue();
+ }
+ }
+
+ public void setProperty(String pname, String pvalue) {
+ _props.add(new XmlDataProperty(pname, pvalue, this));
+ }
+
+}
Modified: ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.bpel?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.bpel (original)
+++ ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.bpel Thu May 22 16:25:57 2008
@@ -18,7 +18,7 @@
-->
<process name="HelloWorld2"
targetNamespace="http://ode/bpel/unit-test"
- xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:tns="http://ode/bpel/unit-test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://ode/bpel/unit-test.wsdl"
Modified: ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.wsdl?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.wsdl (original)
+++ ode/trunk/distro/src/examples-war/HelloWorld2/HelloWorld2.wsdl Thu May 22 16:25:57 2008
@@ -25,7 +25,7 @@
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
<wsdl:message name="HelloMessage">
<wsdl:part name="TestPart" type="xsd:string"/>
Modified: ode/trunk/extensions/README.extensions
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/README.extensions?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/README.extensions (original)
+++ ode/trunk/extensions/README.extensions Thu May 22 16:25:57 2008
@@ -1,22 +1,22 @@
-=============================================
- Apache ODE - Extension Installation Guide
-=============================================
-
-BPEL 2.0 introduces extensibility mechanisms, which allow you to extend
-the set of activities and/or variable assignment mechanisms.
-With BPEL 2.0 it is possible to extend the language by user-defined
-activities and custom assignment logic.
-
-Since version 1.2 Apache ODE supports these extensibility mechanismns
-and provides a plug-in architecture that allows for registering
-third-party extensions.
-
-1.) Installation of extensions (WAR)
- 1) Copy the extension
- TBC
-
-2.) Installation of extensions (JBI)
- TBW
-
-3.) Writing ODE extensions
+=============================================
+ Apache ODE - Extension Installation Guide
+=============================================
+
+BPEL 2.0 introduces extensibility mechanisms, which allow you to extend
+the set of activities and/or variable assignment mechanisms.
+With BPEL 2.0 it is possible to extend the language by user-defined
+activities and custom assignment logic.
+
+Since version 1.2 Apache ODE supports these extensibility mechanismns
+and provides a plug-in architecture that allows for registering
+third-party extensions.
+
+1.) Installation of extensions (WAR)
+ 1) Copy the extension
+ TBC
+
+2.) Installation of extensions (JBI)
+ TBW
+
+3.) Writing ODE extensions
TBW
\ No newline at end of file
Modified: ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/ExtensionContextWrapper.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/ExtensionContextWrapper.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/ExtensionContextWrapper.java (original)
+++ ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/ExtensionContextWrapper.java Thu May 22 16:25:57 2008
@@ -1,114 +1,114 @@
-/*
- * 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.extension.e4x;
-
-import java.io.StringWriter;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apche.ode.bpel.evar.ExternalVariableModuleException;
-import org.apache.ode.bpel.common.FaultException;
-import org.apache.ode.bpel.runtime.extension.ExtensionContext;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Function;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.xml.XMLObject;
-import org.mozilla.javascript.xmlimpl.XMLLibImpl;
-import org.w3c.dom.Node;
-
-/**
- * Scriptable wrapper for the <code>ExtensionContext</code>. This
- * is needed for a transparent transformation between org.w3c.dom.Node
- * and Rhino's XML implementation.
- *
- * Currently only
- * <pre>Node readVariable(String)</pre> and <pre>void writeVariable(String, Node)</pre>
- * are implemented.
- *
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class ExtensionContextWrapper extends ScriptableObject {
- private static final long serialVersionUID = 1L;
-
- private ExtensionContext _ectx;
- private Context _sctx;
-
- public ExtensionContextWrapper() {
- super();
- }
-
- public ExtensionContextWrapper(ExtensionContext ectx, Context sctx) {
- super();
- _ectx = ectx;
- _sctx = sctx;
- }
-
- public String getClassName() {
- return "ExtensionContext";
- }
-
- public static Scriptable jsConstructor(Context cx, Object[] args,
- Function ctorObj,
- boolean inNewExpr)
- {
- if (args.length == 2 && (args[0] instanceof ExtensionContext) && (args[1] instanceof Context)) {
- return new ExtensionContextWrapper((ExtensionContext)args[0], (Context)args[1]);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- public void jsFunction_writeVariable(String varName, XMLObject node) throws FaultException, ExternalVariableModuleException {
- Node n = js2node(node);
- _ectx.writeVariable(varName, n);
- }
-
- public XMLObject jsFunction_readVariable(String varName) throws FaultException, TransformerException {
- Node n = _ectx.readVariable(varName);
- return node2js(n);
- }
-
- private Node js2node(final XMLObject xml) {
- return XMLLibImpl.toDomNode(xml);
- }
-
- public XMLObject node2js(Node n) throws TransformerException {
- Scriptable parentScope = getParentScope();
- return (XMLObject) _sctx.newObject(parentScope, "XML", new Object[] {Context.javaToJS(domToString(n), parentScope)});
- }
-
- public static String domToString(Node n) throws TransformerException {
- TransformerFactory xformFactory = TransformerFactory.newInstance();
- Transformer idTransform = xformFactory.newTransformer();
- idTransform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- Source input = new DOMSource(n);
- StringWriter sw = new StringWriter();
- Result output = new StreamResult(sw);
- idTransform.transform(input, output);
- return sw.toString();
- }
-}
+/*
+ * 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.extension.e4x;
+
+import java.io.StringWriter;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apche.ode.bpel.evar.ExternalVariableModuleException;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.runtime.extension.ExtensionContext;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.xml.XMLObject;
+import org.mozilla.javascript.xmlimpl.XMLLibImpl;
+import org.w3c.dom.Node;
+
+/**
+ * Scriptable wrapper for the <code>ExtensionContext</code>. This
+ * is needed for a transparent transformation between org.w3c.dom.Node
+ * and Rhino's XML implementation.
+ *
+ * Currently only
+ * <pre>Node readVariable(String)</pre> and <pre>void writeVariable(String, Node)</pre>
+ * are implemented.
+ *
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class ExtensionContextWrapper extends ScriptableObject {
+ private static final long serialVersionUID = 1L;
+
+ private ExtensionContext _ectx;
+ private Context _sctx;
+
+ public ExtensionContextWrapper() {
+ super();
+ }
+
+ public ExtensionContextWrapper(ExtensionContext ectx, Context sctx) {
+ super();
+ _ectx = ectx;
+ _sctx = sctx;
+ }
+
+ public String getClassName() {
+ return "ExtensionContext";
+ }
+
+ public static Scriptable jsConstructor(Context cx, Object[] args,
+ Function ctorObj,
+ boolean inNewExpr)
+ {
+ if (args.length == 2 && (args[0] instanceof ExtensionContext) && (args[1] instanceof Context)) {
+ return new ExtensionContextWrapper((ExtensionContext)args[0], (Context)args[1]);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public void jsFunction_writeVariable(String varName, XMLObject node) throws FaultException, ExternalVariableModuleException {
+ Node n = js2node(node);
+ _ectx.writeVariable(varName, n);
+ }
+
+ public XMLObject jsFunction_readVariable(String varName) throws FaultException, TransformerException {
+ Node n = _ectx.readVariable(varName);
+ return node2js(n);
+ }
+
+ private Node js2node(final XMLObject xml) {
+ return XMLLibImpl.toDomNode(xml);
+ }
+
+ public XMLObject node2js(Node n) throws TransformerException {
+ Scriptable parentScope = getParentScope();
+ return (XMLObject) _sctx.newObject(parentScope, "XML", new Object[] {Context.javaToJS(domToString(n), parentScope)});
+ }
+
+ public static String domToString(Node n) throws TransformerException {
+ TransformerFactory xformFactory = TransformerFactory.newInstance();
+ Transformer idTransform = xformFactory.newTransformer();
+ idTransform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ Source input = new DOMSource(n);
+ StringWriter sw = new StringWriter();
+ Result output = new StreamResult(sw);
+ idTransform.transform(input, output);
+ return sw.toString();
+ }
+}
Modified: ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionBundle.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionBundle.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionBundle.java (original)
+++ ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionBundle.java Thu May 22 16:25:57 2008
@@ -1,41 +1,41 @@
-/*
- * 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.extension.e4x;
-
-import org.apache.ode.bpel.runtime.extension.AbstractExtensionBundle;
-
-/**
- * Implementation of a Javascript extension bundle.
- *
- * It currently provides only one extension operation to be used either as
- * extensionActivity or as extensionAssignOperation.
- *
- * @author Tammo van Lessen
- */
-public class JSExtensionBundle extends AbstractExtensionBundle {
- public static final String NS = "http://ode.apache.org/extensions/e4x";
- public String getNamespaceURI() {
- return NS;
- }
-
- public void registerExtensionActivities() {
- registerExtensionOperation("snippet", JSExtensionOperation.class);
- }
-
-}
+/*
+ * 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.extension.e4x;
+
+import org.apache.ode.bpel.runtime.extension.AbstractExtensionBundle;
+
+/**
+ * Implementation of a Javascript extension bundle.
+ *
+ * It currently provides only one extension operation to be used either as
+ * extensionActivity or as extensionAssignOperation.
+ *
+ * @author Tammo van Lessen
+ */
+public class JSExtensionBundle extends AbstractExtensionBundle {
+ public static final String NS = "http://ode.apache.org/extensions/e4x";
+ public String getNamespaceURI() {
+ return NS;
+ }
+
+ public void registerExtensionActivities() {
+ registerExtensionOperation("snippet", JSExtensionOperation.class);
+ }
+
+}
Modified: ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionOperation.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionOperation.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionOperation.java (original)
+++ ode/trunk/extensions/e4x/src/main/java/org/apache/ode/extension/e4x/JSExtensionOperation.java Thu May 22 16:25:57 2008
@@ -1,72 +1,72 @@
-/*
- * 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.extension.e4x;
-
-import javax.xml.namespace.QName;
-
-import org.apache.ode.bpel.common.FaultException;
-import org.apache.ode.bpel.runtime.extension.AbstractSyncExtensionOperation;
-import org.apache.ode.bpel.runtime.extension.ExtensionContext;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.ContextFactory;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.xml.XMLLib;
-import org.mozilla.javascript.xml.XMLLib.Factory;
-import org.w3c.dom.Element;
-
-/**
- * Implementation of a Javascript extension assign operation.
- *
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class JSExtensionOperation extends AbstractSyncExtensionOperation {
-
- public void runSync(ExtensionContext context, Element element) throws FaultException {
-
- CustomContextFactory.init();
- Context ctx = Context.enter();
- try {
- Scriptable scope = ctx.initStandardObjects();
- ScriptableObject.defineClass(scope, ExtensionContextWrapper.class);
- Scriptable wrappedContext = ctx.newObject(scope, "ExtensionContext", new Object[] {context, ctx});
- ScriptableObject.putProperty(scope, "context", wrappedContext);
- String source = element.getTextContent();
- ctx.evaluateString(scope, source, context.getActivityName(), 1, null);
- } catch (Exception e) {
- throw new FaultException(new QName("ExtensionEvaluationFault", JSExtensionBundle.NS), e.getMessage());
- } finally {
- Context.exit();
- }
- }
-
- private static class CustomContextFactory extends ContextFactory {
- //Enforce usage of plain DOM
- protected Factory getE4xImplementationFactory() {
- return XMLLib.Factory.create("org.mozilla.javascript.xmlimpl.XMLLibImpl");
- }
-
- static void init() {
- if (!ContextFactory.hasExplicitGlobal()) {
- ContextFactory.initGlobal(new CustomContextFactory());
- }
- }
-
- }
-}
+/*
+ * 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.extension.e4x;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.runtime.extension.AbstractSyncExtensionOperation;
+import org.apache.ode.bpel.runtime.extension.ExtensionContext;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.xml.XMLLib;
+import org.mozilla.javascript.xml.XMLLib.Factory;
+import org.w3c.dom.Element;
+
+/**
+ * Implementation of a Javascript extension assign operation.
+ *
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class JSExtensionOperation extends AbstractSyncExtensionOperation {
+
+ public void runSync(ExtensionContext context, Element element) throws FaultException {
+
+ CustomContextFactory.init();
+ Context ctx = Context.enter();
+ try {
+ Scriptable scope = ctx.initStandardObjects();
+ ScriptableObject.defineClass(scope, ExtensionContextWrapper.class);
+ Scriptable wrappedContext = ctx.newObject(scope, "ExtensionContext", new Object[] {context, ctx});
+ ScriptableObject.putProperty(scope, "context", wrappedContext);
+ String source = element.getTextContent();
+ ctx.evaluateString(scope, source, context.getActivityName(), 1, null);
+ } catch (Exception e) {
+ throw new FaultException(new QName("ExtensionEvaluationFault", JSExtensionBundle.NS), e.getMessage());
+ } finally {
+ Context.exit();
+ }
+ }
+
+ private static class CustomContextFactory extends ContextFactory {
+ //Enforce usage of plain DOM
+ protected Factory getE4xImplementationFactory() {
+ return XMLLib.Factory.create("org.mozilla.javascript.xmlimpl.XMLLibImpl");
+ }
+
+ static void init() {
+ if (!ContextFactory.hasExplicitGlobal()) {
+ ContextFactory.initGlobal(new CustomContextFactory());
+ }
+ }
+
+ }
+}
Modified: ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSBPELTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSBPELTest.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSBPELTest.java (original)
+++ ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSBPELTest.java Thu May 22 16:25:57 2008
@@ -1,35 +1,35 @@
-/*
- * 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.extension.e4x;
-
-import org.apache.ode.test.BPELTestAbstract;
-import org.junit.Test;
-
-/**
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class JSBPELTest extends BPELTestAbstract {
-
- @Test public void testE4XAssign() throws Throwable {
- // Test E4X
- registerExtensionBundle(new JSExtensionBundle());
- go("/bpel/TestE4X");
- }
-
-}
+/*
+ * 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.extension.e4x;
+
+import org.apache.ode.test.BPELTestAbstract;
+import org.junit.Test;
+
+/**
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class JSBPELTest extends BPELTestAbstract {
+
+ @Test public void testE4XAssign() throws Throwable {
+ // Test E4X
+ registerExtensionBundle(new JSExtensionBundle());
+ go("/bpel/TestE4X");
+ }
+
+}
Modified: ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSOperationTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSOperationTest.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSOperationTest.java (original)
+++ ode/trunk/extensions/e4x/src/test/java/org/apache/ode/extension/e4x/JSOperationTest.java Thu May 22 16:25:57 2008
@@ -1,70 +1,70 @@
-/*
- * 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.extension.e4x;
-
-
-import org.apache.ode.test.MockExtensionContext;
-import org.apache.ode.utils.DOMUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.w3c.dom.Element;
-
-/**
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class JSOperationTest {
-
- @Test public void testHelloWorld() throws Exception {
- StringBuffer s = new StringBuffer();
- s.append("var request = context.readVariable('request');\n");
- s.append("request.TestPart += ' World';\n");
- s.append("context.writeVariable('request', request);\n");
-
- MockExtensionContext c = new MockExtensionContext();
- c.getVariables().put("request", DOMUtils.stringToDOM("<message><TestPart>Hello</TestPart></message>"));
- JSExtensionOperation jso = new JSExtensionOperation();
- Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
- jso.run(c, e);
- String res = DOMUtils.domToString(c.getVariables().get("request"));
- Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart>Hello World</TestPart></message>", res);
- Assert.assertTrue(c.completed);
- Assert.assertFalse(c.faulted);
- }
-
- @Test public void testArrayCopy() throws Exception {
- StringBuffer s = new StringBuffer();
- s.append("var item = context.readVariable('item');\n");
- s.append("var items = context.readVariable('items');\n");
- s.append("items.TestPart.items.item += item.TestPart.item;\n");
- s.append("items.TestPart.items.item.(@hyped=='true').price *= 2;");
- s.append("context.writeVariable('items', items);\n");
-
- MockExtensionContext c = new MockExtensionContext();
- c.getVariables().put("item", DOMUtils.stringToDOM("<message><TestPart><item hyped=\"true\"><name>BPEL consulting</name><price>3000</price></item></TestPart></message>"));
- c.getVariables().put("items", DOMUtils.stringToDOM("<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item></items></TestPart></message>"));
- JSExtensionOperation jso = new JSExtensionOperation();
- Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
- jso.run(c, e);
- String res = DOMUtils.domToString(c.getVariables().get("items"));
- Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item><item hyped=\"true\"><name>BPEL consulting</name><price>6000</price></item></items></TestPart></message>", res);
- Assert.assertTrue(c.completed);
- Assert.assertFalse(c.faulted);
- }
-
-}
+/*
+ * 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.extension.e4x;
+
+
+import org.apache.ode.test.MockExtensionContext;
+import org.apache.ode.utils.DOMUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class JSOperationTest {
+
+ @Test public void testHelloWorld() throws Exception {
+ StringBuffer s = new StringBuffer();
+ s.append("var request = context.readVariable('request');\n");
+ s.append("request.TestPart += ' World';\n");
+ s.append("context.writeVariable('request', request);\n");
+
+ MockExtensionContext c = new MockExtensionContext();
+ c.getVariables().put("request", DOMUtils.stringToDOM("<message><TestPart>Hello</TestPart></message>"));
+ JSExtensionOperation jso = new JSExtensionOperation();
+ Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
+ jso.run(c, e);
+ String res = DOMUtils.domToString(c.getVariables().get("request"));
+ Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart>Hello World</TestPart></message>", res);
+ Assert.assertTrue(c.completed);
+ Assert.assertFalse(c.faulted);
+ }
+
+ @Test public void testArrayCopy() throws Exception {
+ StringBuffer s = new StringBuffer();
+ s.append("var item = context.readVariable('item');\n");
+ s.append("var items = context.readVariable('items');\n");
+ s.append("items.TestPart.items.item += item.TestPart.item;\n");
+ s.append("items.TestPart.items.item.(@hyped=='true').price *= 2;");
+ s.append("context.writeVariable('items', items);\n");
+
+ MockExtensionContext c = new MockExtensionContext();
+ c.getVariables().put("item", DOMUtils.stringToDOM("<message><TestPart><item hyped=\"true\"><name>BPEL consulting</name><price>3000</price></item></TestPart></message>"));
+ c.getVariables().put("items", DOMUtils.stringToDOM("<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item></items></TestPart></message>"));
+ JSExtensionOperation jso = new JSExtensionOperation();
+ Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
+ jso.run(c, e);
+ String res = DOMUtils.domToString(c.getVariables().get("items"));
+ Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item><item hyped=\"true\"><name>BPEL consulting</name><price>6000</price></item></items></TestPart></message>", res);
+ Assert.assertTrue(c.completed);
+ Assert.assertFalse(c.faulted);
+ }
+
+}
Modified: ode/trunk/extensions/e4x/src/test/resources/bpel/TestE4X/TestE4X.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/e4x/src/test/resources/bpel/TestE4X/TestE4X.bpel?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/e4x/src/test/resources/bpel/TestE4X/TestE4X.bpel (original)
+++ ode/trunk/extensions/e4x/src/test/resources/bpel/TestE4X/TestE4X.bpel Thu May 22 16:25:57 2008
@@ -26,7 +26,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://ode/bpel/unit-testAssign1.wsdl"
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
- expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
xmlns:js="http://ode.apache.org/extensions/e4x">
<import location="TestE4X.wsdl"
@@ -36,10 +36,10 @@
<partnerLinks>
<partnerLink name="TestAssignPartnerLink" partnerLinkType="test:TestAssignPartnerLinkType" myRole="me" />
</partnerLinks>
-
- <extensions>
- <extension namespace="http://ode.apache.org/extensions/e4x" mustUnderstand="yes"/>
- </extensions>
+
+ <extensions>
+ <extension namespace="http://ode.apache.org/extensions/e4x" mustUnderstand="yes"/>
+ </extensions>
<variables>
<variable name="myVar" messageType="test:TestAssignMessage"/>
@@ -55,12 +55,12 @@
operation="testAssign" variable="myVar" createInstance="yes"/>
<assign name="assign1">
- <extensionAssignOperation>
- <js:snippet>
- var request = context.readVariable('myVar');
- request.TestPart += ' World';
- context.writeVariable('otherMsgVar', request);
- </js:snippet>
+ <extensionAssignOperation>
+ <js:snippet>
+ var request = context.readVariable('myVar');
+ request.TestPart += ' World';
+ context.writeVariable('otherMsgVar', request);
+ </js:snippet>
</extensionAssignOperation>
</assign>
<reply name="end" partnerLink="TestAssignPartnerLink" portType="test:TestAssignPortType"
Modified: ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java (original)
+++ ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/JmsBpelEventListener.java Thu May 22 16:25:57 2008
@@ -1,250 +1,250 @@
-/*
- * 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.extension.jmseventlistener;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.evt.ActivityEvent;
-import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.evt.CorrelationEvent;
-import org.apache.ode.bpel.evt.CorrelationMatchEvent;
-import org.apache.ode.bpel.evt.CorrelationSetEvent;
-import org.apache.ode.bpel.evt.CorrelationSetWriteEvent;
-import org.apache.ode.bpel.evt.ExpressionEvaluationEvent;
-import org.apache.ode.bpel.evt.ExpressionEvaluationFailedEvent;
-import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
-import org.apache.ode.bpel.evt.PartnerLinkEvent;
-import org.apache.ode.bpel.evt.ProcessCompletionEvent;
-import org.apache.ode.bpel.evt.ProcessEvent;
-import org.apache.ode.bpel.evt.ProcessInstanceEvent;
-import org.apache.ode.bpel.evt.ProcessInstanceStartedEvent;
-import org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent;
-import org.apache.ode.bpel.evt.ProcessMessageExchangeEvent;
-import org.apache.ode.bpel.evt.ScopeCompletionEvent;
-import org.apache.ode.bpel.evt.ScopeEvent;
-import org.apache.ode.bpel.evt.ScopeFaultEvent;
-import org.apache.ode.bpel.evt.VariableEvent;
-import org.apache.ode.bpel.iapi.BpelEventListener;
-import org.apache.ode.bpel.pmapi.TEventInfo;
-
-/**
- * Example for a BPEL Event Listener:
- * Publishes BPEL events to an ActiveMQ JMS topic
- *
- * This listener can be configured by adding the following keys to
- * ODE's config file:
- * <ul>
- * <li><code>jel.topicname</code> - identifies the name of the target topic.</li>
- * <li><code>jel.mqurl</code> - the URL to the ActiveMQ broker.</li>
- * </ul>
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class JmsBpelEventListener implements BpelEventListener {
- protected static final Log logger = LogFactory.getLog(JmsBpelEventListener.class);
-
- public static final String TOPIC_NAME_KEY = "jel.topicname";
- public static final String MQ_URL_KEY = "jel.mqurl";
- private String topicName;
- private String url;
-
- private ConnectionFactory factory;
- private Connection connection;
- private Session session;
- private Topic topic;
- private MessageProducer publisher;
-
- boolean initialized = false;
- protected Calendar _calendar = Calendar.getInstance();
-
- public void onEvent(BpelEvent bpelEvent) {
- if (!initialized)
- return;
- try {
- String msg = serializeEvent(bpelEvent);
- if (msg != null) {
- TextMessage om = session.createTextMessage(serializeEvent(bpelEvent));
- publisher.send(om);
- }
- } catch (JMSException e) {
- logger.warn("Event " + bpelEvent + "could not be sent", e);
- }
- }
-
- public void shutdown() {
- if (connection == null) {
- return;
- }
- try {
- connection.stop();
- connection.close();
- connection = null;
- initialized = false;
- } catch (JMSException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- factory = null;
- logger.info("JMS BPEL event has been shutdown.");
- }
-
- public void startup(Properties configProperties) {
- if (configProperties == null) {
- logger.info("No configuration properties given. Initialization aborted.");
- return;
- }
- topicName = configProperties.getProperty(TOPIC_NAME_KEY, "org.apache.ode.events");
- url = configProperties.getProperty(MQ_URL_KEY, "tcp://localhost:61616");
-
- try {
- factory = new ActiveMQConnectionFactory(url);
- connection = factory.createConnection();
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- topic = session.createTopic(topicName);
- publisher = session.createProducer(topic);
- publisher.setDeliveryMode(DeliveryMode.PERSISTENT);
- initialized = true;
- } catch (JMSException e) {
- logger.error("Initialization failed.", e);
- }
- logger.info("JMS BPEL event has been started.");
- }
-
- protected String serializeEvent(BpelEvent evt) {
- TEventInfo ei = TEventInfo.Factory.newInstance();
- fillEventInfo(ei, evt);
- String xml = ei.toString();
- logger.debug(xml);
- return xml;
- }
-
- //TODO: This code should be reused
- private void fillEventInfo(TEventInfo info, BpelEvent event) {
- info.setName(BpelEvent.eventName(event));
- info.setType(event.getType().toString());
- info.setLineNumber(event.getLineNo());
- info.setTimestamp(toCalendar(event.getTimestamp()));
- if (event instanceof ActivityEvent) {
- info.setActivityName(((ActivityEvent) event).getActivityName());
- info.setActivityId(((ActivityEvent) event).getActivityId());
- info.setActivityType(((ActivityEvent) event).getActivityType());
- info.setActivityDefinitionId(((ActivityEvent) event).getActivityDeclarationId());
- }
- if (event instanceof CorrelationEvent) {
- info.setPortType(((CorrelationEvent) event).getPortType());
- info.setOperation(((CorrelationEvent) event).getOperation());
- info.setMexId(((CorrelationEvent) event).getMessageExchangeId());
- }
- if (event instanceof CorrelationMatchEvent) {
- info.setPortType(((CorrelationMatchEvent) event).getPortType());
- }
- if (event instanceof CorrelationSetEvent) {
- info.setCorrelationSet(((CorrelationSetEvent) event).getCorrelationSetName());
- }
- if (event instanceof CorrelationSetWriteEvent) {
- info.setCorrelationKey(((CorrelationSetWriteEvent) event).getCorrelationSetName());
- }
- if (event instanceof ExpressionEvaluationEvent) {
- info.setExpression(((ExpressionEvaluationEvent) event).getExpression());
- }
- if (event instanceof ExpressionEvaluationFailedEvent) {
- info.setFault(((ExpressionEvaluationFailedEvent) event).getFault());
- }
- if (event instanceof NewProcessInstanceEvent) {
- if ((((NewProcessInstanceEvent) event).getRootScopeId()) != null)
- info.setRootScopeId(((NewProcessInstanceEvent) event).getRootScopeId());
- info.setScopeDefinitionId(((NewProcessInstanceEvent) event).getScopeDeclarationId());
- }
- if (event instanceof PartnerLinkEvent) {
- info.setPartnerLinkName(((PartnerLinkEvent) event).getpLinkName());
- }
- if (event instanceof ProcessCompletionEvent) {
- info.setFault(((ProcessCompletionEvent) event).getFault());
- }
- if (event instanceof ProcessEvent) {
- info.setProcessId(((ProcessEvent) event).getProcessId());
- info.setProcessType(((ProcessEvent) event).getProcessName());
- }
- if (event instanceof ProcessInstanceEvent) {
- info.setInstanceId(((ProcessInstanceEvent) event).getProcessInstanceId());
- }
- if (event instanceof ProcessInstanceStartedEvent) {
- info.setRootScopeId(((ProcessInstanceStartedEvent) event).getRootScopeId());
- info.setRootScopeDeclarationId(((ProcessInstanceStartedEvent) event).getScopeDeclarationId());
- }
- if (event instanceof ProcessInstanceStateChangeEvent) {
- info.setOldState(((ProcessInstanceStateChangeEvent) event).getOldState());
- info.setNewState(((ProcessInstanceStateChangeEvent) event).getNewState());
- }
- if (event instanceof ProcessMessageExchangeEvent) {
- info.setPortType(((ProcessMessageExchangeEvent) event).getPortType());
- info.setOperation(((ProcessMessageExchangeEvent) event).getOperation());
- info.setMexId(((ProcessMessageExchangeEvent) event).getMessageExchangeId());
- }
- if (event instanceof ScopeCompletionEvent) {
- info.setSuccess(((ScopeCompletionEvent) event).isSuccess());
- info.setFault(((ScopeCompletionEvent) event).getFault());
- }
- if (event instanceof ScopeEvent) {
- info.setScopeId(((ScopeEvent) event).getScopeId());
- if (((ScopeEvent) event).getParentScopeId() != null)
- info.setParentScopeId(((ScopeEvent) event).getParentScopeId());
- if (((ScopeEvent) event).getScopeName() != null)
- info.setScopeName(((ScopeEvent) event).getScopeName());
- info.setScopeDefinitionId(((ScopeEvent) event).getScopeDeclarationId());
- }
- if (event instanceof ScopeFaultEvent) {
- info.setFault(((ScopeFaultEvent) event).getFaultType());
- info.setFaultLineNumber(((ScopeFaultEvent) event).getFaultLineNo());
- info.setExplanation(((ScopeFaultEvent) event).getExplanation());
- }
- if (event instanceof VariableEvent) {
- info.setVariableName(((VariableEvent) event).getVarName());
- }
- }
-
- /**
- * Convert a {@link Date} to a {@link Calendar}.
- *
- * @param dtime
- * a {@link Date}
- * @return a {@link Calendar}
- */
- private Calendar toCalendar(Date dtime) {
- if (dtime == null)
- return null;
-
- Calendar c = (Calendar) _calendar.clone();
- c.setTime(dtime);
- return c;
- }
-}
+/*
+ * 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.extension.jmseventlistener;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.evt.ActivityEvent;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.CorrelationEvent;
+import org.apache.ode.bpel.evt.CorrelationMatchEvent;
+import org.apache.ode.bpel.evt.CorrelationSetEvent;
+import org.apache.ode.bpel.evt.CorrelationSetWriteEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationFailedEvent;
+import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
+import org.apache.ode.bpel.evt.PartnerLinkEvent;
+import org.apache.ode.bpel.evt.ProcessCompletionEvent;
+import org.apache.ode.bpel.evt.ProcessEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStartedEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent;
+import org.apache.ode.bpel.evt.ProcessMessageExchangeEvent;
+import org.apache.ode.bpel.evt.ScopeCompletionEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.bpel.evt.ScopeFaultEvent;
+import org.apache.ode.bpel.evt.VariableEvent;
+import org.apache.ode.bpel.iapi.BpelEventListener;
+import org.apache.ode.bpel.pmapi.TEventInfo;
+
+/**
+ * Example for a BPEL Event Listener:
+ * Publishes BPEL events to an ActiveMQ JMS topic
+ *
+ * This listener can be configured by adding the following keys to
+ * ODE's config file:
+ * <ul>
+ * <li><code>jel.topicname</code> - identifies the name of the target topic.</li>
+ * <li><code>jel.mqurl</code> - the URL to the ActiveMQ broker.</li>
+ * </ul>
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class JmsBpelEventListener implements BpelEventListener {
+ protected static final Log logger = LogFactory.getLog(JmsBpelEventListener.class);
+
+ public static final String TOPIC_NAME_KEY = "jel.topicname";
+ public static final String MQ_URL_KEY = "jel.mqurl";
+ private String topicName;
+ private String url;
+
+ private ConnectionFactory factory;
+ private Connection connection;
+ private Session session;
+ private Topic topic;
+ private MessageProducer publisher;
+
+ boolean initialized = false;
+ protected Calendar _calendar = Calendar.getInstance();
+
+ public void onEvent(BpelEvent bpelEvent) {
+ if (!initialized)
+ return;
+ try {
+ String msg = serializeEvent(bpelEvent);
+ if (msg != null) {
+ TextMessage om = session.createTextMessage(serializeEvent(bpelEvent));
+ publisher.send(om);
+ }
+ } catch (JMSException e) {
+ logger.warn("Event " + bpelEvent + "could not be sent", e);
+ }
+ }
+
+ public void shutdown() {
+ if (connection == null) {
+ return;
+ }
+ try {
+ connection.stop();
+ connection.close();
+ connection = null;
+ initialized = false;
+ } catch (JMSException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ factory = null;
+ logger.info("JMS BPEL event has been shutdown.");
+ }
+
+ public void startup(Properties configProperties) {
+ if (configProperties == null) {
+ logger.info("No configuration properties given. Initialization aborted.");
+ return;
+ }
+ topicName = configProperties.getProperty(TOPIC_NAME_KEY, "org.apache.ode.events");
+ url = configProperties.getProperty(MQ_URL_KEY, "tcp://localhost:61616");
+
+ try {
+ factory = new ActiveMQConnectionFactory(url);
+ connection = factory.createConnection();
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ topic = session.createTopic(topicName);
+ publisher = session.createProducer(topic);
+ publisher.setDeliveryMode(DeliveryMode.PERSISTENT);
+ initialized = true;
+ } catch (JMSException e) {
+ logger.error("Initialization failed.", e);
+ }
+ logger.info("JMS BPEL event has been started.");
+ }
+
+ protected String serializeEvent(BpelEvent evt) {
+ TEventInfo ei = TEventInfo.Factory.newInstance();
+ fillEventInfo(ei, evt);
+ String xml = ei.toString();
+ logger.debug(xml);
+ return xml;
+ }
+
+ //TODO: This code should be reused
+ private void fillEventInfo(TEventInfo info, BpelEvent event) {
+ info.setName(BpelEvent.eventName(event));
+ info.setType(event.getType().toString());
+ info.setLineNumber(event.getLineNo());
+ info.setTimestamp(toCalendar(event.getTimestamp()));
+ if (event instanceof ActivityEvent) {
+ info.setActivityName(((ActivityEvent) event).getActivityName());
+ info.setActivityId(((ActivityEvent) event).getActivityId());
+ info.setActivityType(((ActivityEvent) event).getActivityType());
+ info.setActivityDefinitionId(((ActivityEvent) event).getActivityDeclarationId());
+ }
+ if (event instanceof CorrelationEvent) {
+ info.setPortType(((CorrelationEvent) event).getPortType());
+ info.setOperation(((CorrelationEvent) event).getOperation());
+ info.setMexId(((CorrelationEvent) event).getMessageExchangeId());
+ }
+ if (event instanceof CorrelationMatchEvent) {
+ info.setPortType(((CorrelationMatchEvent) event).getPortType());
+ }
+ if (event instanceof CorrelationSetEvent) {
+ info.setCorrelationSet(((CorrelationSetEvent) event).getCorrelationSetName());
+ }
+ if (event instanceof CorrelationSetWriteEvent) {
+ info.setCorrelationKey(((CorrelationSetWriteEvent) event).getCorrelationSetName());
+ }
+ if (event instanceof ExpressionEvaluationEvent) {
+ info.setExpression(((ExpressionEvaluationEvent) event).getExpression());
+ }
+ if (event instanceof ExpressionEvaluationFailedEvent) {
+ info.setFault(((ExpressionEvaluationFailedEvent) event).getFault());
+ }
+ if (event instanceof NewProcessInstanceEvent) {
+ if ((((NewProcessInstanceEvent) event).getRootScopeId()) != null)
+ info.setRootScopeId(((NewProcessInstanceEvent) event).getRootScopeId());
+ info.setScopeDefinitionId(((NewProcessInstanceEvent) event).getScopeDeclarationId());
+ }
+ if (event instanceof PartnerLinkEvent) {
+ info.setPartnerLinkName(((PartnerLinkEvent) event).getpLinkName());
+ }
+ if (event instanceof ProcessCompletionEvent) {
+ info.setFault(((ProcessCompletionEvent) event).getFault());
+ }
+ if (event instanceof ProcessEvent) {
+ info.setProcessId(((ProcessEvent) event).getProcessId());
+ info.setProcessType(((ProcessEvent) event).getProcessName());
+ }
+ if (event instanceof ProcessInstanceEvent) {
+ info.setInstanceId(((ProcessInstanceEvent) event).getProcessInstanceId());
+ }
+ if (event instanceof ProcessInstanceStartedEvent) {
+ info.setRootScopeId(((ProcessInstanceStartedEvent) event).getRootScopeId());
+ info.setRootScopeDeclarationId(((ProcessInstanceStartedEvent) event).getScopeDeclarationId());
+ }
+ if (event instanceof ProcessInstanceStateChangeEvent) {
+ info.setOldState(((ProcessInstanceStateChangeEvent) event).getOldState());
+ info.setNewState(((ProcessInstanceStateChangeEvent) event).getNewState());
+ }
+ if (event instanceof ProcessMessageExchangeEvent) {
+ info.setPortType(((ProcessMessageExchangeEvent) event).getPortType());
+ info.setOperation(((ProcessMessageExchangeEvent) event).getOperation());
+ info.setMexId(((ProcessMessageExchangeEvent) event).getMessageExchangeId());
+ }
+ if (event instanceof ScopeCompletionEvent) {
+ info.setSuccess(((ScopeCompletionEvent) event).isSuccess());
+ info.setFault(((ScopeCompletionEvent) event).getFault());
+ }
+ if (event instanceof ScopeEvent) {
+ info.setScopeId(((ScopeEvent) event).getScopeId());
+ if (((ScopeEvent) event).getParentScopeId() != null)
+ info.setParentScopeId(((ScopeEvent) event).getParentScopeId());
+ if (((ScopeEvent) event).getScopeName() != null)
+ info.setScopeName(((ScopeEvent) event).getScopeName());
+ info.setScopeDefinitionId(((ScopeEvent) event).getScopeDeclarationId());
+ }
+ if (event instanceof ScopeFaultEvent) {
+ info.setFault(((ScopeFaultEvent) event).getFaultType());
+ info.setFaultLineNumber(((ScopeFaultEvent) event).getFaultLineNo());
+ info.setExplanation(((ScopeFaultEvent) event).getExplanation());
+ }
+ if (event instanceof VariableEvent) {
+ info.setVariableName(((VariableEvent) event).getVarName());
+ }
+ }
+
+ /**
+ * Convert a {@link Date} to a {@link Calendar}.
+ *
+ * @param dtime
+ * a {@link Date}
+ * @return a {@link Calendar}
+ */
+ private Calendar toCalendar(Date dtime) {
+ if (dtime == null)
+ return null;
+
+ Calendar c = (Calendar) _calendar.clone();
+ c.setTime(dtime);
+ return c;
+ }
+}
Modified: ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java
URL: http://svn.apache.org/viewvc/ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java (original)
+++ ode/trunk/extensions/jms-eventpublisher/src/main/java/org/apache/ode/extension/jmseventlistener/TestConsumer.java Thu May 22 16:25:57 2008
@@ -1,73 +1,73 @@
-/*
- * 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.extension.jmseventlistener;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-
-/**
- * Basic Consumer that dumps Ode's BPEL events to the console.
- *
- * @author Tammo van Lessen (University of Stuttgart)
- */
-public class TestConsumer implements MessageListener {
- private Connection connection;
- private Session session;
- private Topic topic;
-
- public static void main(String[] argv) throws Exception {
- TestConsumer c = new TestConsumer();
- c.run();
- }
-
- public void run() throws JMSException {
- ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
- connection = factory.createConnection();
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- topic = session.createTopic("org.apache.ode.events");
-
- MessageConsumer consumer = session.createConsumer(topic);
- consumer.setMessageListener(this);
-
- connection.start();
-
- System.out.println("Waiting for messages...");
- }
-
- public void onMessage(Message msg) {
- TextMessage t = (TextMessage)msg;
- try {
- System.err.println("--");
- System.out.println(t.getText());
- } catch (JMSException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-}
+/*
+ * 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.extension.jmseventlistener;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * Basic Consumer that dumps Ode's BPEL events to the console.
+ *
+ * @author Tammo van Lessen (University of Stuttgart)
+ */
+public class TestConsumer implements MessageListener {
+ private Connection connection;
+ private Session session;
+ private Topic topic;
+
+ public static void main(String[] argv) throws Exception {
+ TestConsumer c = new TestConsumer();
+ c.run();
+ }
+
+ public void run() throws JMSException {
+ ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
+ connection = factory.createConnection();
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ topic = session.createTopic("org.apache.ode.events");
+
+ MessageConsumer consumer = session.createConsumer(topic);
+ consumer.setMessageListener(this);
+
+ connection.start();
+
+ System.out.println("Waiting for messages...");
+ }
+
+ public void onMessage(Message msg) {
+ TextMessage t = (TextMessage)msg;
+ try {
+ System.err.println("--");
+ System.out.println(t.getText());
+ } catch (JMSException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
Modified: ode/trunk/tools/src/main/java/org/apache/ode/tools/ToolMessages.java
URL: http://svn.apache.org/viewvc/ode/trunk/tools/src/main/java/org/apache/ode/tools/ToolMessages.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/tools/src/main/java/org/apache/ode/tools/ToolMessages.java (original)
+++ ode/trunk/tools/src/main/java/org/apache/ode/tools/ToolMessages.java Thu May 22 16:25:57 2008
@@ -1,38 +1,38 @@
-/*
- * 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.tools;
-
-import org.apache.ode.utils.msg.MessageBundle;
-
-public class ToolMessages extends MessageBundle {
-
- public String msgBadUrl(String url, String message) {
- return this.format("{0} does not appear to be a valid URL: {1}", url, message);
- }
-
- public String msgSoapErrorOnSend(String msg) {
- return this.format("Unable to send message due to SOAP-related error: {0}", msg);
- }
-
- public String msgIoErrorOnSend(String msg) {
- return this.format("Unable to send message due to I/O-related error: {0}", msg);
- }
-
-}
+/*
+ * 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.tools;
+
+import org.apache.ode.utils.msg.MessageBundle;
+
+public class ToolMessages extends MessageBundle {
+
+ public String msgBadUrl(String url, String message) {
+ return this.format("{0} does not appear to be a valid URL: {1}", url, message);
+ }
+
+ public String msgSoapErrorOnSend(String msg) {
+ return this.format("Unable to send message due to SOAP-related error: {0}", msg);
+ }
+
+ public String msgIoErrorOnSend(String msg) {
+ return this.format("Unable to send message due to I/O-related error: {0}", msg);
+ }
+
+}