http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OAssign.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OAssign.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OAssign.java index b0b5868..5020f08 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OAssign.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OAssign.java @@ -1,20 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.obj; @@ -33,537 +29,538 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; public class OAssign extends OActivity implements Serializable { - public static final long serialVersionUID = -1L; - private static final String OPERATION = "operation"; - - @JsonCreator - public OAssign(){ - } - - public OAssign(OProcess owner, OActivity parent) { - super(owner, parent); - setOperations(new ArrayList<OAssignOperation>()); - } - - @Override - public void dehydrate() { - super.dehydrate(); - for (OAssignOperation operation : getOperations()) { - operation.dehydrate(); - } - } - - @SuppressWarnings("unchecked") - @JsonIgnore - public List<OAssignOperation> getOperations() { - Object o = fieldContainer.get(OPERATION); - return o == null ? null : (List<OAssignOperation>)o; - } - - public void setOperations(List<OAssignOperation> operation) { - if (getOperations() == null){ - fieldContainer.put(OPERATION, operation); - } - } - - public String toString() { - return "{OAssign : " + getName() + ", joinCondition=" - + getJoinCondition() + "}"; - } - - /** + public static final long serialVersionUID = -1L; + private static final String OPERATION = "operation"; + + @JsonCreator + public OAssign() {} + + public OAssign(OProcess owner, OActivity parent) { + super(owner, parent); + setOperations(new ArrayList<OAssignOperation>()); + } + + @Override + public void dehydrate() { + super.dehydrate(); + for (OAssignOperation operation : getOperations()) { + operation.dehydrate(); + } + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public List<OAssignOperation> getOperations() { + Object o = fieldContainer.get(OPERATION); + return o == null ? null : (List<OAssignOperation>) o; + } + + public void setOperations(List<OAssignOperation> operation) { + if (getOperations() == null) { + fieldContainer.put(OPERATION, operation); + } + } + + public String toString() { + return "{OAssign : " + getName() + ", joinCondition=" + getJoinCondition() + "}"; + } + + /** * Base class for assign operations. */ public static abstract class OAssignOperation extends OBase implements Serializable { - private static final long serialVersionUID = -3042873658302758854L; - - public enum Type { Copy, ExtensionOperation } - - @JsonCreator - public OAssignOperation() { - } - - public OAssignOperation(OProcess owner) { - super(owner); - } - - public abstract Type getType(); + private static final long serialVersionUID = -3042873658302758854L; + + public enum Type { + Copy, ExtensionOperation + } + + @JsonCreator + public OAssignOperation() {} + + public OAssignOperation(OProcess owner) { + super(owner); + } + + public abstract Type getType(); } - /** - * Assignment copy entry, i.e. what the assignment consists of. - */ - public static class Copy extends OAssignOperation implements Serializable { - public static final long serialVersionUID = -1L; - private static final String TO = "to"; - private static final String FROM = "from"; - private static final String KEEPSRCELEMENTNAME = "keepSrcElementName"; - private static final String IGNOREMISSINGFROMDATA = "ignoreMissingFromData"; - private static final String IGNOREUNINITIALIZEDFROMVARIABLE = "ignoreUninitializedFromVariable"; - private static final String INSERTMISSINGTODATA = "insertMissingToData"; - - @JsonCreator - public Copy(){ - initPrimitive(); - } - - public Copy(OProcess owner) { - super(owner); - initPrimitive(); - } - - private void initPrimitive(){ - setIgnoreMissingFromData(false); - setIgnoreUninitializedFromVariable(false); - setInsertMissingToData(false); - setKeepSrcElementName(false); - } - - @Override - public void dehydrate() { - super.dehydrate(); - setTo(null); - setFrom(null); - } - - @JsonIgnore - public RValue getFrom() { - Object o = fieldContainer.get(FROM); - return o == null ? null : (RValue)o; - } - - @JsonIgnore - public boolean isIgnoreMissingFromData() { - Object o = fieldContainer.get(IGNOREMISSINGFROMDATA); - return o == null ? false : (Boolean)o; - } - - @JsonIgnore - public boolean isIgnoreUninitializedFromVariable() { - return (Boolean) fieldContainer - .get(IGNOREUNINITIALIZEDFROMVARIABLE); - } - - @JsonIgnore - public boolean isInsertMissingToData() { - Object o = fieldContainer.get(INSERTMISSINGTODATA); - return o == null ? false : (Boolean)o; - } - - @JsonIgnore - public boolean isKeepSrcElementName() { - Object o = fieldContainer.get(KEEPSRCELEMENTNAME); - return o == null ? false : (Boolean)o; - } - - @JsonIgnore - public LValue getTo() { - Object o = fieldContainer.get(TO); - return o == null ? null : (LValue)o; - } - - public void setFrom(RValue from) { - fieldContainer.put(FROM, from); - } - - public void setIgnoreMissingFromData(boolean ignoreMissingFromData) { - fieldContainer.put(IGNOREMISSINGFROMDATA, ignoreMissingFromData); - } - - public void setIgnoreUninitializedFromVariable( - boolean ignoreUninitializedFromVariable) { - fieldContainer.put(IGNOREUNINITIALIZEDFROMVARIABLE, - ignoreUninitializedFromVariable); - } - - public void setInsertMissingToData(boolean insertMissingToData) { - fieldContainer.put(INSERTMISSINGTODATA, insertMissingToData); - } - - public void setKeepSrcElementName(boolean keepSrcElementName) { - fieldContainer.put(KEEPSRCELEMENTNAME, keepSrcElementName); - } - - public void setTo(LValue to) { - fieldContainer.put(TO, to); - } - - public String toString() { - return "{OCopy " + getTo() + "=" + getFrom() + "}"; - } - - @JsonIgnore - public Type getType() { - return Type.Copy; - } - } - - /** + /** + * Assignment copy entry, i.e. what the assignment consists of. + */ + public static class Copy extends OAssignOperation implements Serializable { + public static final long serialVersionUID = -1L; + private static final String TO = "to"; + private static final String FROM = "from"; + private static final String KEEPSRCELEMENTNAME = "keepSrcElementName"; + private static final String IGNOREMISSINGFROMDATA = "ignoreMissingFromData"; + private static final String IGNOREUNINITIALIZEDFROMVARIABLE = + "ignoreUninitializedFromVariable"; + private static final String INSERTMISSINGTODATA = "insertMissingToData"; + + @JsonCreator + public Copy() { + initPrimitive(); + } + + public Copy(OProcess owner) { + super(owner); + initPrimitive(); + } + + private void initPrimitive() { + setIgnoreMissingFromData(false); + setIgnoreUninitializedFromVariable(false); + setInsertMissingToData(false); + setKeepSrcElementName(false); + } + + @Override + public void dehydrate() { + super.dehydrate(); + setTo(null); + setFrom(null); + } + + @JsonIgnore + public RValue getFrom() { + Object o = fieldContainer.get(FROM); + return o == null ? null : (RValue) o; + } + + @JsonIgnore + public boolean isIgnoreMissingFromData() { + Object o = fieldContainer.get(IGNOREMISSINGFROMDATA); + return o == null ? false : (Boolean) o; + } + + @JsonIgnore + public boolean isIgnoreUninitializedFromVariable() { + return (Boolean) fieldContainer.get(IGNOREUNINITIALIZEDFROMVARIABLE); + } + + @JsonIgnore + public boolean isInsertMissingToData() { + Object o = fieldContainer.get(INSERTMISSINGTODATA); + return o == null ? false : (Boolean) o; + } + + @JsonIgnore + public boolean isKeepSrcElementName() { + Object o = fieldContainer.get(KEEPSRCELEMENTNAME); + return o == null ? false : (Boolean) o; + } + + @JsonIgnore + public LValue getTo() { + Object o = fieldContainer.get(TO); + return o == null ? null : (LValue) o; + } + + public void setFrom(RValue from) { + fieldContainer.put(FROM, from); + } + + public void setIgnoreMissingFromData(boolean ignoreMissingFromData) { + fieldContainer.put(IGNOREMISSINGFROMDATA, ignoreMissingFromData); + } + + public void setIgnoreUninitializedFromVariable(boolean ignoreUninitializedFromVariable) { + fieldContainer.put(IGNOREUNINITIALIZEDFROMVARIABLE, ignoreUninitializedFromVariable); + } + + public void setInsertMissingToData(boolean insertMissingToData) { + fieldContainer.put(INSERTMISSINGTODATA, insertMissingToData); + } + + public void setKeepSrcElementName(boolean keepSrcElementName) { + fieldContainer.put(KEEPSRCELEMENTNAME, keepSrcElementName); + } + + public void setTo(LValue to) { + fieldContainer.put(TO, to); + } + + public String toString() { + return "{OCopy " + getTo() + "=" + getFrom() + "}"; + } + + @JsonIgnore + public Type getType() { + return Type.Copy; + } + } + + /** * Assignment extension operation entry, i.e. what the assignment consists of. */ public static class ExtensionAssignOperation extends OAssignOperation { private static final long serialVersionUID = 1L; - + private static final String EXTENSIONNAME = "extensionName"; - private static final String NESTEDELEMENT = "nestedElement"; - - @JsonCreator - public ExtensionAssignOperation(){ - } + private static final String NESTEDELEMENT = "nestedElement"; + + @JsonCreator + public ExtensionAssignOperation() {} public ExtensionAssignOperation(OProcess owner) { super(owner); } @JsonIgnore - public QName getExtensionName() { - Object o = fieldContainer.get(EXTENSIONNAME); - return o == null ? null : (QName) o; - } - + public QName getExtensionName() { + Object o = fieldContainer.get(EXTENSIONNAME); + return o == null ? null : (QName) o; + } + @JsonIgnore - public String getNestedElement() { - Object o = fieldContainer.get(NESTEDELEMENT); - return o == null ? null : (String)o; - } - + public String getNestedElement() { + Object o = fieldContainer.get(NESTEDELEMENT); + return o == null ? null : (String) o; + } + public void setExtensionName(QName extensionName) { - fieldContainer.put(EXTENSIONNAME, extensionName); - } - + fieldContainer.put(EXTENSIONNAME, extensionName); + } + public void setNestedElement(String nestedElement) { - fieldContainer.put(NESTEDELEMENT, nestedElement); - } + fieldContainer.put(NESTEDELEMENT, nestedElement); + } public String toString() { return "{OExtensionAssignOperation; " + getExtensionName() + "}"; } - + @Override - public void dehydrate() { - super.dehydrate(); - setExtensionName(null); - setNestedElement(null); - } + public void dehydrate() { + super.dehydrate(); + setExtensionName(null); + setNestedElement(null); + } public Type getType() { - return Type.ExtensionOperation; - } + return Type.ExtensionOperation; + } + } + + /** + * Direct reference: selects named child of the message document element. This is used for + * access to extensions (SOAP headers for example). + * + * @author mszefler + */ + public static class DirectRef extends OBase implements RValue, LValue, Serializable { + public static final long serialVersionUID = -1L; + /** Referenced Variable */ + private static final String VARIABLE = "variable"; + + /** Name of the element referenced. */ + private static final String ELNAME = "elName"; + + @JsonCreator + public DirectRef() {} + + public DirectRef(OProcess owner) { + super(owner); + } + + @JsonIgnore + public QName getElName() { + Object o = fieldContainer.get(ELNAME); + return o == null ? null : (QName) o; + } + + @JsonIgnore + public OScope.Variable getVariable() { + Object o = fieldContainer.get(VARIABLE); + return o == null ? null : (OScope.Variable) o; + } + + public void setElName(QName elName) { + fieldContainer.put(ELNAME, elName); + } + + public void setVariable(Variable variable) { + fieldContainer.put(VARIABLE, variable); + } + } + + public static class Expression extends OBase implements RValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String EXPRESSION = "expression"; + + @JsonCreator + public Expression() {} + + public Expression(OProcess owner, OExpression compiledExpression) { + super(owner); + setExpression(compiledExpression); + } + + @JsonIgnore + public OExpression getExpression() { + Object o = fieldContainer.get(EXPRESSION); + return o == null ? null : (OExpression) o; + } + + public void setExpression(OExpression expression) { + fieldContainer.put(EXPRESSION, expression); + } + + public String toString() { + return getExpression().toString(); + } + } + + public static class Literal extends OBase implements RValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String XMLLITERAL = "xmlLiteral"; + + @JsonCreator + public Literal() {} + + public Literal(OProcess owner, Document xmlLiteral) { + super(owner); + if (xmlLiteral == null) + throw new IllegalArgumentException("null xmlLiteral!"); + setXmlLiteral(org.apache.ode.utils.DOMUtils.domToString(xmlLiteral)); + } + + @JsonIgnore + public String getXmlLiteral() { + Object o = fieldContainer.get(XMLLITERAL); + return o == null ? null : (String) o; + } + + public void setXmlLiteral(String xmlLiteral) { + fieldContainer.put(XMLLITERAL, xmlLiteral); + } + + public String toString() { + return "{Literal " + getXmlLiteral() + "}"; + } } - /** - * Direct reference: selects named child of the message document element. - * This is used for access to extensions (SOAP headers for example). - * @author mszefler - */ - public static class DirectRef extends OBase implements RValue, LValue, Serializable{ - public static final long serialVersionUID = -1L; - /** Referenced Variable */ - private static final String VARIABLE = "variable"; - - /** Name of the element referenced. */ - private static final String ELNAME = "elName"; - - @JsonCreator - public DirectRef(){} - - public DirectRef(OProcess owner) { - super(owner); - } - - @JsonIgnore - public QName getElName() { - Object o = fieldContainer.get(ELNAME); - return o == null ? null : (QName)o; - } - - @JsonIgnore - public OScope.Variable getVariable() { - Object o = fieldContainer.get(VARIABLE); - return o == null ? null : (OScope.Variable)o; - } - - public void setElName(QName elName) { - fieldContainer.put(ELNAME, elName); - } - - public void setVariable(Variable variable) { - fieldContainer.put(VARIABLE, variable); - } - } - - public static class Expression extends OBase implements RValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String EXPRESSION = "expression"; - - @JsonCreator - public Expression(){} - public Expression(OProcess owner, OExpression compiledExpression) { - super(owner); - setExpression(compiledExpression); - } - - @JsonIgnore - public OExpression getExpression() { - Object o = fieldContainer.get(EXPRESSION); - return o == null ? null : (OExpression)o; - } - - public void setExpression(OExpression expression) { - fieldContainer.put(EXPRESSION, expression); - } - - public String toString() { - return getExpression().toString(); - } - } - - public static class Literal extends OBase implements RValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String XMLLITERAL = "xmlLiteral"; - - @JsonCreator - public Literal(){} - - public Literal(OProcess owner, Document xmlLiteral) { - super(owner); - if (xmlLiteral == null) - throw new IllegalArgumentException("null xmlLiteral!"); - setXmlLiteral(org.apache.ode.utils.DOMUtils.domToString(xmlLiteral)); - } - - @JsonIgnore - public String getXmlLiteral() { - Object o = fieldContainer.get(XMLLITERAL); - return o == null ? null : (String)o; - } - - public void setXmlLiteral(String xmlLiteral) { - fieldContainer.put(XMLLITERAL, xmlLiteral); - } - - public String toString() { - return "{Literal " + getXmlLiteral() + "}"; - } - } - - public interface LValue { - OScope.Variable getVariable(); - } - - public static class LValueExpression extends OBase implements LValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String EXPRESSION = "expression"; - - @JsonCreator - public LValueExpression(){} - - public LValueExpression(OProcess owner, - OLValueExpression compiledExpression) { - super(owner); - setExpression(compiledExpression); - } - - @JsonIgnore - public OLValueExpression getExpression() { - Object o = fieldContainer.get(EXPRESSION); - return o == null ? null : (OLValueExpression)o; - } - - /** - * @see org.apache.ode.bpel.obj.OAssign.LValue#getVariable() - */ - @JsonIgnore - public Variable getVariable() { - return getExpression().getVariable(); - } - - @JsonIgnore - public boolean isInsertMissingToData() { + public interface LValue { + OScope.Variable getVariable(); + } + + public static class LValueExpression extends OBase implements LValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String EXPRESSION = "expression"; + + @JsonCreator + public LValueExpression() {} + + public LValueExpression(OProcess owner, OLValueExpression compiledExpression) { + super(owner); + setExpression(compiledExpression); + } + + @JsonIgnore + public OLValueExpression getExpression() { + Object o = fieldContainer.get(EXPRESSION); + return o == null ? null : (OLValueExpression) o; + } + + /** + * @see org.apache.ode.bpel.obj.OAssign.LValue#getVariable() + */ + @JsonIgnore + public Variable getVariable() { + return getExpression().getVariable(); + } + + @JsonIgnore + public boolean isInsertMissingToData() { return getExpression().isInsertMissingData(); - } - - public void setExpression(OLValueExpression expression) { - fieldContainer.put(EXPRESSION, expression); - } - - public void setInsertMissingToData(boolean insertMissingToData) { - getExpression().setInsertMissingData(insertMissingToData); - } - - public String toString() { - return getExpression().toString(); - } - - } - - public static class PartnerLinkRef extends OBase implements RValue, LValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String PARTNERLINK = "partnerLink"; - private static final String ISMYENDPOINTREFERENCE = "isMyEndpointReference"; - - @JsonCreator - public PartnerLinkRef(){ - setIsMyEndpointReference(false); - } - public PartnerLinkRef(OProcess owner) { - super(owner); - setIsMyEndpointReference(false); - } - - @JsonIgnore - public boolean isIsMyEndpointReference() { - Object o = fieldContainer.get(ISMYENDPOINTREFERENCE); - return o == null ? false : (Boolean)o; - } - - @JsonIgnore - public OPartnerLink getPartnerLink() { - Object o = fieldContainer.get(PARTNERLINK); - return o == null ? null : (OPartnerLink)o; - } - - // Must fit in a LValue even if it's not variable based - @JsonIgnore - public Variable getVariable() { - return null; - } - - public void setIsMyEndpointReference(boolean isMyEndpointReference) { - fieldContainer.put(ISMYENDPOINTREFERENCE, isMyEndpointReference); - } - - public void setPartnerLink(OPartnerLink partnerLink) { - fieldContainer.put(PARTNERLINK, partnerLink); - } - - public String toString() { - return "{PLinkRef " + getPartnerLink() + "!" - + isIsMyEndpointReference() + "}"; - } - } - - public static class PropertyRef extends OBase implements RValue, LValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String VARIABLE = "variable"; - private static final String PROPERTYALIAS = "propertyAlias"; - - @JsonCreator - public PropertyRef(){} - public PropertyRef(OProcess owner) { - super(owner); - } - - @JsonIgnore - public OPropertyAlias getPropertyAlias() { - Object o = fieldContainer.get(PROPERTYALIAS); - return o == null ? null : (OPropertyAlias)o; - } - - @JsonIgnore - public Variable getVariable() { - Object o = fieldContainer.get(VARIABLE); - return o == null ? null : (Variable)o; - } - - public void setPropertyAlias(OPropertyAlias propertyAlias) { - fieldContainer.put(PROPERTYALIAS, propertyAlias); - } - - public void setVariable(Variable variable) { - fieldContainer.put(VARIABLE, variable); - } - - public String toString() { - return "{PropRef " + getVariable() + "!" + getPropertyAlias() + "}"; - } - } - - public interface RValue { - } - - public static class VariableRef extends OBase implements RValue, LValue, Serializable{ - public static final long serialVersionUID = -1L; - private static final String VARIABLE = "variable"; - private static final String PART = "part"; - private static final String HEADERPART = "headerPart"; - private static final String LOCATION = "location"; - - @JsonCreator - public VariableRef(){} - - public VariableRef(OProcess owner) { - super(owner); - } - - @JsonIgnore - public Part getHeaderPart() { - Object o = fieldContainer.get(HEADERPART); - return o == null ? null : (Part)o; - } - - @JsonIgnore - public OExpression getLocation() { - Object o = fieldContainer.get(LOCATION); - return o == null ? null : (OExpression)o; - } - - @JsonIgnore - public Part getPart() { - Object o = fieldContainer.get(PART); - return o == null ? null : (Part)o; - } - - @JsonIgnore - public Variable getVariable() { - Object o = fieldContainer.get(VARIABLE); - return o == null ? null : (Variable)o; - } - - @JsonIgnore - public boolean isHeaderRef() { - return getVariable().getType() instanceof OMessageVarType && getHeaderPart() != null && getLocation() == null; - } - - /** - * Report whether this is a reference to a whole "message" - * @return <code>true</code> if whole-message reference - */ - @JsonIgnore - public boolean isMessageRef() { - return getVariable().getType() instanceof OMessageVarType && getPart() == null && getHeaderPart() == null && getLocation() == null; - } - - /** - * Report whether this is a reference to a message part. - * @return <code>true</code> if reference to a message part - */ - @JsonIgnore - public boolean isPartRef() { - return getVariable().getType() instanceof OMessageVarType && getPart() != null && getLocation() == null; - } - - public void setHeaderPart(Part headerPart) { - fieldContainer.put(HEADERPART, headerPart); - } - - public void setLocation(OExpression location) { - fieldContainer.put(LOCATION, location); - } - - public void setPart(Part part) { - fieldContainer.put(PART, part); - } - - public void setVariable(Variable variable) { - fieldContainer.put(VARIABLE, variable); - } - - public String toString() { - return "{VarRef " + getVariable() - + (getPart() == null ? "" : "." + getPart().getName()) - + (getLocation() == null ? "" : getLocation().toString()) - + "}"; - } - } + } + + public void setExpression(OLValueExpression expression) { + fieldContainer.put(EXPRESSION, expression); + } + + public void setInsertMissingToData(boolean insertMissingToData) { + getExpression().setInsertMissingData(insertMissingToData); + } + + public String toString() { + return getExpression().toString(); + } + + } + + public static class PartnerLinkRef extends OBase implements RValue, LValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String PARTNERLINK = "partnerLink"; + private static final String ISMYENDPOINTREFERENCE = "isMyEndpointReference"; + + @JsonCreator + public PartnerLinkRef() { + setIsMyEndpointReference(false); + } + + public PartnerLinkRef(OProcess owner) { + super(owner); + setIsMyEndpointReference(false); + } + + @JsonIgnore + public boolean isIsMyEndpointReference() { + Object o = fieldContainer.get(ISMYENDPOINTREFERENCE); + return o == null ? false : (Boolean) o; + } + + @JsonIgnore + public OPartnerLink getPartnerLink() { + Object o = fieldContainer.get(PARTNERLINK); + return o == null ? null : (OPartnerLink) o; + } + + // Must fit in a LValue even if it's not variable based + @JsonIgnore + public Variable getVariable() { + return null; + } + + public void setIsMyEndpointReference(boolean isMyEndpointReference) { + fieldContainer.put(ISMYENDPOINTREFERENCE, isMyEndpointReference); + } + + public void setPartnerLink(OPartnerLink partnerLink) { + fieldContainer.put(PARTNERLINK, partnerLink); + } + + public String toString() { + return "{PLinkRef " + getPartnerLink() + "!" + isIsMyEndpointReference() + "}"; + } + } + + public static class PropertyRef extends OBase implements RValue, LValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String VARIABLE = "variable"; + private static final String PROPERTYALIAS = "propertyAlias"; + + @JsonCreator + public PropertyRef() {} + + public PropertyRef(OProcess owner) { + super(owner); + } + + @JsonIgnore + public OPropertyAlias getPropertyAlias() { + Object o = fieldContainer.get(PROPERTYALIAS); + return o == null ? null : (OPropertyAlias) o; + } + + @JsonIgnore + public Variable getVariable() { + Object o = fieldContainer.get(VARIABLE); + return o == null ? null : (Variable) o; + } + + public void setPropertyAlias(OPropertyAlias propertyAlias) { + fieldContainer.put(PROPERTYALIAS, propertyAlias); + } + + public void setVariable(Variable variable) { + fieldContainer.put(VARIABLE, variable); + } + + public String toString() { + return "{PropRef " + getVariable() + "!" + getPropertyAlias() + "}"; + } + } + + public interface RValue { + } + + public static class VariableRef extends OBase implements RValue, LValue, Serializable { + public static final long serialVersionUID = -1L; + private static final String VARIABLE = "variable"; + private static final String PART = "part"; + private static final String HEADERPART = "headerPart"; + private static final String LOCATION = "location"; + + @JsonCreator + public VariableRef() {} + + public VariableRef(OProcess owner) { + super(owner); + } + + @JsonIgnore + public Part getHeaderPart() { + Object o = fieldContainer.get(HEADERPART); + return o == null ? null : (Part) o; + } + + @JsonIgnore + public OExpression getLocation() { + Object o = fieldContainer.get(LOCATION); + return o == null ? null : (OExpression) o; + } + + @JsonIgnore + public Part getPart() { + Object o = fieldContainer.get(PART); + return o == null ? null : (Part) o; + } + + @JsonIgnore + public Variable getVariable() { + Object o = fieldContainer.get(VARIABLE); + return o == null ? null : (Variable) o; + } + + @JsonIgnore + public boolean isHeaderRef() { + return getVariable().getType() instanceof OMessageVarType && getHeaderPart() != null + && getLocation() == null; + } + + /** + * Report whether this is a reference to a whole "message" + * + * @return <code>true</code> if whole-message reference + */ + @JsonIgnore + public boolean isMessageRef() { + return getVariable().getType() instanceof OMessageVarType && getPart() == null + && getHeaderPart() == null && getLocation() == null; + } + + /** + * Report whether this is a reference to a message part. + * + * @return <code>true</code> if reference to a message part + */ + @JsonIgnore + public boolean isPartRef() { + return getVariable().getType() instanceof OMessageVarType && getPart() != null + && getLocation() == null; + } + + public void setHeaderPart(Part headerPart) { + fieldContainer.put(HEADERPART, headerPart); + } + + public void setLocation(OExpression location) { + fieldContainer.put(LOCATION, location); + } + + public void setPart(Part part) { + fieldContainer.put(PART, part); + } + + public void setVariable(Variable variable) { + fieldContainer.put(VARIABLE, variable); + } + + public String toString() { + return "{VarRef " + getVariable() + (getPart() == null ? "" : "." + getPart().getName()) + + (getLocation() == null ? "" : getLocation().toString()) + "}"; + } + } }
http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OExtensionActivity.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OExtensionActivity.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OExtensionActivity.java index 2c3632a..6efc999 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OExtensionActivity.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OExtensionActivity.java @@ -1,20 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.obj; @@ -28,8 +24,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; /** - * Compiled representation of the BPEL <code><extensionActivity></code> - * activity. + * Compiled representation of the BPEL <code><extensionActivity></code> activity. * <p> * Adapted initial version for compatibility with new ODE object model (bpel-nobj). * @@ -37,15 +32,14 @@ import com.fasterxml.jackson.annotation.JsonIgnore; */ public class OExtensionActivity extends OActivity implements Serializable { - static final long serialVersionUID = -1L; + static final long serialVersionUID = -1L; - private static final String EXTENSIONNAME = "extensionName"; - private static final String NESTEDELEMENT = "nestedElement"; - private static final String CHILDREN = "children"; - - @JsonCreator - public OExtensionActivity(){ - } + private static final String EXTENSIONNAME = "extensionName"; + private static final String NESTEDELEMENT = "nestedElement"; + private static final String CHILDREN = "children"; + + @JsonCreator + public OExtensionActivity() {} public OExtensionActivity(OProcess owner, OActivity parent) { super(owner, parent); @@ -53,50 +47,50 @@ public class OExtensionActivity extends OActivity implements Serializable { } @JsonIgnore - public QName getExtensionName() { - Object o = fieldContainer.get(EXTENSIONNAME); - return o == null ? null : (QName) o; - } - + public QName getExtensionName() { + Object o = fieldContainer.get(EXTENSIONNAME); + return o == null ? null : (QName) o; + } + @JsonIgnore - public String getNestedElement() { - Object o = fieldContainer.get(NESTEDELEMENT); - return o == null ? null : (String)o; - } - + public String getNestedElement() { + Object o = fieldContainer.get(NESTEDELEMENT); + return o == null ? null : (String) o; + } + @SuppressWarnings("unchecked") - @JsonIgnore - public List<OActivity> getChildren() { - Object o = fieldContainer.get(CHILDREN); - return o == null ? null : (List<OActivity>)o; - } - + @JsonIgnore + public List<OActivity> getChildren() { + Object o = fieldContainer.get(CHILDREN); + return o == null ? null : (List<OActivity>) o; + } + public void setExtensionName(QName extensionName) { - fieldContainer.put(EXTENSIONNAME, extensionName); - } - + fieldContainer.put(EXTENSIONNAME, extensionName); + } + public void setNestedElement(String nestedElement) { - fieldContainer.put(NESTEDELEMENT, nestedElement); - } - + fieldContainer.put(NESTEDELEMENT, nestedElement); + } + void setChildren(List<OActivity> children) { - if (getChildren() == null) { - fieldContainer.put(CHILDREN, children); - } - } + if (getChildren() == null) { + fieldContainer.put(CHILDREN, children); + } + } public String toString() { return "{OExtensionActivity; " + getExtensionName() + "}"; } - + @Override - public void dehydrate() { - super.dehydrate(); - setExtensionName(null); - setNestedElement(null); - for (OBase obase : getChildren()) { - obase.dehydrate(); - } - getChildren().clear(); - } + public void dehydrate() { + super.dehydrate(); + setExtensionName(null); + setNestedElement(null); + for (OBase obase : getChildren()) { + obase.dehydrate(); + } + getChildren().clear(); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OProcess.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OProcess.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OProcess.java index b4a3d2a..a01936f 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OProcess.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/OProcess.java @@ -317,14 +317,13 @@ public class OProcess extends OBase implements Serializable{ Object o = fieldContainer.get(XSLSHEETS); return o == null ? null : (HashMap<URI, OXslSheet>)o; } - - @SuppressWarnings("unchecked") - @JsonIgnore - public Set<OExtension> getDeclaredExtensions() { - return (Set<OExtension>) fieldContainer - .get(DECLAREDEXTENSIONS); - } - + + @SuppressWarnings("unchecked") + @JsonIgnore + public Set<OExtension> getDeclaredExtensions() { + return (Set<OExtension>) fieldContainer.get(DECLAREDEXTENSIONS); + } + public void setAllPartnerLinks(Set<OPartnerLink> allPartnerLinks) { if (getAllPartnerLinks() == null) { fieldContainer.put(ALLPARTNERLINKS, allPartnerLinks); @@ -412,11 +411,11 @@ public class OProcess extends OBase implements Serializable{ } } - public void setDeclaredExtensions(Set<OExtension> extensions) { - if (getDeclaredExtensions() == null) { - fieldContainer.put(DECLAREDEXTENSIONS, extensions); - } - } + public void setDeclaredExtensions(Set<OExtension> extensions) { + if (getDeclaredExtensions() == null) { + fieldContainer.put(DECLAREDEXTENSIONS, extensions); + } + } private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException{ ois.defaultReadObject(); @@ -554,40 +553,43 @@ public class OProcess extends OBase implements Serializable{ } } - - public static class OExtension extends OBase implements Serializable { - public static final long serialVersionUID = -1L ; - + + public static class OExtension extends OBase implements Serializable { + public static final long serialVersionUID = -1L; + private static final String NAMESPACE = "namespaceURI"; - private static final String MUSTUNDERSTAND = "mustUnderstand"; - + private static final String MUSTUNDERSTAND = "mustUnderstand"; + @JsonCreator - public OExtension(){} - - public OExtension(OProcess process) { super(process); } - + public OExtension() {} + + public OExtension(OProcess process) { + super(process); + } + @JsonIgnore - public String getNamespace() { - Object o = fieldContainer.get(NAMESPACE); - return o == null ? null : (String)o; - } + public String getNamespace() { + Object o = fieldContainer.get(NAMESPACE); + return o == null ? null : (String) o; + } - @JsonIgnore - public boolean isMustUnderstand() { - Object o = fieldContainer.get(MUSTUNDERSTAND); - return o == null ? false : (Boolean)o; - } - - public void setNamespace(String namespaceURI) { - fieldContainer.put(NAMESPACE, namespaceURI); - } + @JsonIgnore + public boolean isMustUnderstand() { + Object o = fieldContainer.get(MUSTUNDERSTAND); + return o == null ? false : (Boolean) o; + } - public void setMustUnderstand(boolean mustUnderstand) { - fieldContainer.put(MUSTUNDERSTAND, mustUnderstand); - } + public void setNamespace(String namespaceURI) { + fieldContainer.put(NAMESPACE, namespaceURI); + } + + public void setMustUnderstand(boolean mustUnderstand) { + fieldContainer.put(MUSTUNDERSTAND, mustUnderstand); + } public String toString() { - return "{OExtension " + getNamespace() + (isMustUnderstand() ? " mustUnderstand" : "") + "}"; + return "{OExtension " + getNamespace() + (isMustUnderstand() ? " mustUnderstand" : "") + + "}"; } } http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/migrate/OmOld2new.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/migrate/OmOld2new.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/migrate/OmOld2new.java index aeb0050..d8f017e 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/migrate/OmOld2new.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/migrate/OmOld2new.java @@ -25,251 +25,254 @@ import org.apache.ode.bpel.obj.OProcess.OExtension; * @see ObjectTraverser */ public class OmOld2new extends AbstractObjectVisitor { - private static final Logger __log = LoggerFactory.getLogger(OmOld2new.class); + private static final Logger __log = LoggerFactory.getLogger(OmOld2new.class); - private static Map<String, String> beanPkgMap = new HashMap<String, String>(); - static { - beanPkgMap.put("org.apache.ode.bpel.o", "org.apache.ode.bpel.obj"); - beanPkgMap.put("org.apache.ode.bpel.elang.xpath10.o", "org.apache.ode.bpel.elang.xpath10.obj"); - beanPkgMap.put("org.apache.ode.bpel.elang.xpath20.o", "org.apache.ode.bpel.elang.xpath20.obj"); - beanPkgMap.put("org.apache.ode.bpel.elang.xquery10.o", "org.apache.ode.bpel.elang.xquery10.obj"); - } + private static Map<String, String> beanPkgMap = new HashMap<String, String>(); + static { + beanPkgMap.put("org.apache.ode.bpel.o", "org.apache.ode.bpel.obj"); + beanPkgMap.put("org.apache.ode.bpel.elang.xpath10.o", + "org.apache.ode.bpel.elang.xpath10.obj"); + beanPkgMap.put("org.apache.ode.bpel.elang.xpath20.o", + "org.apache.ode.bpel.elang.xpath20.obj"); + beanPkgMap.put("org.apache.ode.bpel.elang.xquery10.o", + "org.apache.ode.bpel.elang.xquery10.obj"); + } - public Object visit(Object obj) { - __log.debug("migrating object: " + obj.getClass() + "@" + System.identityHashCode(obj)); - Object n; - /* - * we use two category of visitXXX methods here. The first visitXXX(Object) - * return corresponding new object instance without fulfilling its contents, - * which avoids recursively call. And then assign the new object. then fill - * contents. other wise, on cyclic reference case, the object re-visited but - * hasn't prepared yet. However, this workaround assumes that the new object is - * mutable, which is true in our case. - */ - if (isMap(obj)) { - n = visitMap(obj); - } else if (isCollection(obj)) { - n = visitCollection(obj); - } else if (isArray(obj)) { - n = visitArray(obj); - } else { - n = visitPojo(obj); - } - rtab.assign(obj, n); + public Object visit(Object obj) { + __log.debug("migrating object: " + obj.getClass() + "@" + System.identityHashCode(obj)); + Object n; + /* + * we use two category of visitXXX methods here. The first visitXXX(Object) return + * corresponding new object instance without fulfilling its contents, which avoids + * recursively call. And then assign the new object. then fill contents. other wise, on + * cyclic reference case, the object re-visited but hasn't prepared yet. However, this + * workaround assumes that the new object is mutable, which is true in our case. + */ + if (isMap(obj)) { + n = visitMap(obj); + } else if (isCollection(obj)) { + n = visitCollection(obj); + } else if (isArray(obj)) { + n = visitArray(obj); + } else { + n = visitPojo(obj); + } + rtab.assign(obj, n); - if (isMap(obj)) { - visitMap(obj, n); - } else if (isCollection(obj)) { - visitCollection(obj, n); - } else if (isArray(obj)) { - visitArray(obj, n); - } else { - visitPojo(obj, n); - } - return n; - } + if (isMap(obj)) { + visitMap(obj, n); + } else if (isCollection(obj)) { + visitCollection(obj, n); + } else if (isArray(obj)) { + visitArray(obj, n); + } else { + visitPojo(obj, n); + } + return n; + } - @Override - protected boolean isCollection(Object old) { - return (old instanceof Collection); - } + @Override + protected boolean isCollection(Object old) { + return (old instanceof Collection); + } - private boolean isOmodelBean(Object old) { - Class<?> cls = old.getClass(); - if (beanPkgMap.containsKey(cls.getPackage().getName()) && !cls.getSimpleName().equals("Serializer")) { - return true; - } - return false; - } + private boolean isOmodelBean(Object old) { + Class<?> cls = old.getClass(); + if (beanPkgMap.containsKey(cls.getPackage().getName()) + && !cls.getSimpleName().equals("Serializer")) { + return true; + } + return false; + } - @Override - public Object visitArray(Object old) { - throw new UnsupportedOperationException("Create new Array is unsupported"); - } + @Override + public Object visitArray(Object old) { + throw new UnsupportedOperationException("Create new Array is unsupported"); + } - private void visitArray(Object obj, Object n) { - throw new UnsupportedOperationException("We don't need the method here"); - } + private void visitArray(Object obj, Object n) { + throw new UnsupportedOperationException("We don't need the method here"); + } - @Override - @SuppressWarnings({ "rawtypes" }) - public Object visitCollection(Object old) { - Collection o = (Collection) old; - try { - Collection n = o.getClass().newInstance(); - return n; - } catch (Exception e) { - // should not get here - e.printStackTrace(); - } - return null; - } + @Override + @SuppressWarnings({"rawtypes"}) + public Object visitCollection(Object old) { + Collection o = (Collection) old; + try { + Collection n = o.getClass().newInstance(); + return n; + } catch (Exception e) { + // should not get here + e.printStackTrace(); + } + return null; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - private void visitCollection(Object old, Object nu) { - Collection o = (Collection) old; - Collection n = (Collection) nu; - for (Object obj : o) { - n.add(traverse.traverseObject(obj)); - } - } + @SuppressWarnings({"rawtypes", "unchecked"}) + private void visitCollection(Object old, Object nu) { + Collection o = (Collection) old; + Collection n = (Collection) nu; + for (Object obj : o) { + n.add(traverse.traverseObject(obj)); + } + } - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public Object visitMap(Object old) { - Map o = (Map) old; - try { - Map n = o.getClass().newInstance(); - return n; - } catch (Exception e) { - // should not get here - e.printStackTrace(); - } - return null; - } + @Override + @SuppressWarnings({"rawtypes", "unchecked"}) + public Object visitMap(Object old) { + Map o = (Map) old; + try { + Map n = o.getClass().newInstance(); + return n; + } catch (Exception e) { + // should not get here + e.printStackTrace(); + } + return null; + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void visitMap(Object obj, Object nu) { - Set<Entry> entries = ((Map) obj).entrySet(); - Map n = (Map) nu; - for (Entry e : entries) { - n.put(traverse.traverseObject(e.getKey()), traverse.traverseObject(e.getValue())); - } - } + @SuppressWarnings({"unchecked", "rawtypes"}) + private void visitMap(Object obj, Object nu) { + Set<Entry> entries = ((Map) obj).entrySet(); + Map n = (Map) nu; + for (Entry e : entries) { + n.put(traverse.traverseObject(e.getKey()), traverse.traverseObject(e.getValue())); + } + } - @Override - public Object visitPojo(Object old) { - if (!isOmodelBean(old)) { - return old; - } else { - return initiateNew(old); - } - } + @Override + public Object visitPojo(Object old) { + if (!isOmodelBean(old)) { + return old; + } else { + return initiateNew(old); + } + } - private void visitPojo(Object old, Object n) { - if (isOmodelBean(old)) { - // @hahnml: We need some special handling for the migration of OAssign model - // elements since the new OModel supports extension assign operations. - if (old.getClass().getSimpleName().equals("OAssign")) { - constructNewOAssign(old, n); - } else { - constructNewOm(old, n); - } - } - } + private void visitPojo(Object old, Object n) { + if (isOmodelBean(old)) { + // @hahnml: We need some special handling for the migration of OAssign model + // elements since the new OModel supports extension assign operations. + if (old.getClass().getSimpleName().equals("OAssign")) { + constructNewOAssign(old, n); + } else { + constructNewOm(old, n); + } + } + } - /** - * construct new omodel instances from old ones. Assume <code>old</code> is an - * old OmodelBean - * - * @param old - * @return - */ - private Object constructNewOm(Object old, Object tn) { - assert tn instanceof ExtensibleImpl; - ExtensibleImpl n = (ExtensibleImpl) tn; - List<Field> fields = getAllFields(old.getClass()); - Map<String, Object> fieldMap = n.getFieldContainer(); - for (Field f : fields) { - if ((f.getModifiers() & Modifier.STATIC) != 0) { - continue; // skip static fields - } - f.setAccessible(true); - try { - String fname = f.getName(); - Object fvalue = f.get(old); - if (fvalue != null) { - fieldMap.put(fname, traverse.traverseObject(fvalue)); - } else { - fieldMap.put(fname, null); - } - } catch (Exception e) { - RuntimeException rte = new RuntimeException( - "Error when try to construct corresponding new Omodel class from old one:" + old.getClass() - + "; Failed on field:" + f.getName()); - rte.initCause(e); - throw rte; - } - } + /** + * construct new omodel instances from old ones. Assume <code>old</code> is an old OmodelBean + * + * @param old + * @return + */ + private Object constructNewOm(Object old, Object tn) { + assert tn instanceof ExtensibleImpl; + ExtensibleImpl n = (ExtensibleImpl) tn; + List<Field> fields = getAllFields(old.getClass()); + Map<String, Object> fieldMap = n.getFieldContainer(); + for (Field f : fields) { + if ((f.getModifiers() & Modifier.STATIC) != 0) { + continue; // skip static fields + } + f.setAccessible(true); + try { + String fname = f.getName(); + Object fvalue = f.get(old); + if (fvalue != null) { + fieldMap.put(fname, traverse.traverseObject(fvalue)); + } else { + fieldMap.put(fname, null); + } + } catch (Exception e) { + RuntimeException rte = new RuntimeException( + "Error when try to construct corresponding new Omodel class from old one:" + + old.getClass() + "; Failed on field:" + f.getName()); + rte.initCause(e); + throw rte; + } + } - // @hahnml: We need to add the new "declaredExtensions" field to the process for - // equality. - if (old.getClass().getSimpleName().equals("OProcess")) { - fieldMap.put("declaredExtensions", new HashSet<OExtension>()); - } + // @hahnml: We need to add the new "declaredExtensions" field to the process for + // equality. + if (old.getClass().getSimpleName().equals("OProcess")) { + fieldMap.put("declaredExtensions", new HashSet<OExtension>()); + } - n.setClassVersion(1); - n.setOriginalVersion(0); - return n; - } + n.setClassVersion(1); + n.setOriginalVersion(0); + return n; + } - private Object constructNewOAssign(Object old, Object tn) { - assert tn instanceof ExtensibleImpl; - ExtensibleImpl n = (ExtensibleImpl) tn; - List<Field> fields = getAllFields(old.getClass()); - Map<String, Object> fieldMap = n.getFieldContainer(); - for (Field f : fields) { - if ((f.getModifiers() & Modifier.STATIC) != 0) { - continue; // skip static fields - } - f.setAccessible(true); - try { - String fname = f.getName(); - Object fvalue = f.get(old); + private Object constructNewOAssign(Object old, Object tn) { + assert tn instanceof ExtensibleImpl; + ExtensibleImpl n = (ExtensibleImpl) tn; + List<Field> fields = getAllFields(old.getClass()); + Map<String, Object> fieldMap = n.getFieldContainer(); + for (Field f : fields) { + if ((f.getModifiers() & Modifier.STATIC) != 0) { + continue; // skip static fields + } + f.setAccessible(true); + try { + String fname = f.getName(); + Object fvalue = f.get(old); - if (fname.equals("copy")) { - fname = "operation"; - } + if (fname.equals("copy")) { + fname = "operation"; + } - if (fvalue != null) { - fieldMap.put(fname, traverse.traverseObject(fvalue)); - } else { - fieldMap.put(fname, null); - } - } catch (Exception e) { - RuntimeException rte = new RuntimeException( - "Error when try to construct corresponding new Omodel class from old one:" + old.getClass() - + "; Failed on field:" + f.getName()); - rte.initCause(e); - throw rte; - } - } + if (fvalue != null) { + fieldMap.put(fname, traverse.traverseObject(fvalue)); + } else { + fieldMap.put(fname, null); + } + } catch (Exception e) { + RuntimeException rte = new RuntimeException( + "Error when try to construct corresponding new Omodel class from old one:" + + old.getClass() + "; Failed on field:" + f.getName()); + rte.initCause(e); + throw rte; + } + } - n.setClassVersion(1); - n.setOriginalVersion(0); - return n; - } + n.setClassVersion(1); + n.setOriginalVersion(0); + return n; + } - private List<Field> getAllFields(Class cls) { - return getAllFieldsRec(cls, new ArrayList<Field>()); - } + private List<Field> getAllFields(Class cls) { + return getAllFieldsRec(cls, new ArrayList<Field>()); + } - private List<Field> getAllFieldsRec(Class cls, ArrayList<Field> fields) { - Class par = cls.getSuperclass(); - if (par != null) { - getAllFieldsRec(par, fields); - } - fields.addAll(Arrays.asList(cls.getDeclaredFields())); - return fields; - } + private List<Field> getAllFieldsRec(Class cls, ArrayList<Field> fields) { + Class par = cls.getSuperclass(); + if (par != null) { + getAllFieldsRec(par, fields); + } + fields.addAll(Arrays.asList(cls.getDeclaredFields())); + return fields; + } - private Object initiateNew(Object old) { - String clsName = old.getClass().getName(); - String qcls = clsName.replace(".o.", ".obj."); - try { - Constructor cons = Class.forName(qcls).getConstructor(); - cons.setAccessible(true); - return cons.newInstance(); - } catch (Exception e) { - RuntimeException rte = new RuntimeException( - "Error when try to initiate corresponding new Omodel class of old one:" + old.getClass()); - rte.initCause(e); - throw rte; - } - } + private Object initiateNew(Object old) { + String clsName = old.getClass().getName(); + String qcls = clsName.replace(".o.", ".obj."); + try { + Constructor cons = Class.forName(qcls).getConstructor(); + cons.setAccessible(true); + return cons.newInstance(); + } catch (Exception e) { + RuntimeException rte = new RuntimeException( + "Error when try to initiate corresponding new Omodel class of old one:" + + old.getClass()); + rte.initCause(e); + throw rte; + } + } - @Override - public Object visitSet(Object obj) { - throw new UnsupportedOperationException("We don't really need this operatiion here"); - } + @Override + public Object visitSet(Object obj) { + throw new UnsupportedOperationException("We don't really need this operatiion here"); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java ---------------------------------------------------------------------- diff --git a/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java b/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java index 7fe5d31..b202928 100644 --- a/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java +++ b/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java @@ -115,7 +115,7 @@ public class OProcess extends OBase { } @SuppressWarnings("rawtypes") - public Collection getExpressionLanguages() { + public Collection getExpressionLanguages() { throw new UnsupportedOperationException(); // TODO: implement me! } http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java ---------------------------------------------------------------------- diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java index 32b5e61..bb8bdfc 100644 --- a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java +++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java @@ -1,20 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.extension.bpel4restlight; @@ -30,21 +26,23 @@ import org.apache.ode.utils.Namespaces; * */ public class Bpel4RestLightExtensionBundle extends AbstractExtensionBundle { - - public static final String NAMESPACE = "http://www.apache.org/ode/bpel/extensions/bpel4restlight"; - - public static final QName FAULT_QNAME = new QName(Namespaces.ODE_EXTENSION_NS, "bpel4RestExtensions"); - - @Override - public String getNamespaceURI() { - return NAMESPACE; - } - - @Override - public void registerExtensionActivities() { - super.registerExtensionOperation("PUT", Bpel4RestLightOperation.class); - super.registerExtensionOperation("GET", Bpel4RestLightOperation.class); - super.registerExtensionOperation("POST", Bpel4RestLightOperation.class); - super.registerExtensionOperation("DELETE", Bpel4RestLightOperation.class); - } + + public static final String NAMESPACE = + "http://www.apache.org/ode/bpel/extensions/bpel4restlight"; + + public static final QName FAULT_QNAME = + new QName(Namespaces.ODE_EXTENSION_NS, "bpel4RestExtensions"); + + @Override + public String getNamespaceURI() { + return NAMESPACE; + } + + @Override + public void registerExtensionActivities() { + super.registerExtensionOperation("PUT", Bpel4RestLightOperation.class); + super.registerExtensionOperation("GET", Bpel4RestLightOperation.class); + super.registerExtensionOperation("POST", Bpel4RestLightOperation.class); + super.registerExtensionOperation("DELETE", Bpel4RestLightOperation.class); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/4b87e5b1/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java ---------------------------------------------------------------------- diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java index 3506435..f2b80df 100644 --- a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java +++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java @@ -1,20 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.extension.bpel4restlight; @@ -28,74 +24,75 @@ import org.w3c.dom.Element; /** * - * This class provides the implementation of the four typical REST operations - * GET, PUT, POST and DELETE through corresponding BPEL extension activities - * ({@link Bpel4RestLightExtensionBundle}). + * This class provides the implementation of the four typical REST operations GET, PUT, POST and + * DELETE through corresponding BPEL extension activities ({@link Bpel4RestLightExtensionBundle}). * * @author Michael Hahn ([email protected]) * */ public class Bpel4RestLightOperation implements ExtensionOperation { - public void run(ExtensionContext context, Element element) throws FaultException { - String httpMethod = element.getLocalName(); + public void run(ExtensionContext context, Element element) throws FaultException { + String httpMethod = element.getLocalName(); - // Extract requestUri - String requestUri = Bpel4RestLightUtil.getMethodAttributeValue(context, element, MethodAttribute.REQUEST_URI); + // Extract requestUri + String requestUri = Bpel4RestLightUtil.getMethodAttributeValue(context, element, + MethodAttribute.REQUEST_URI); - HttpResponseMessage responseMessage = null; + HttpResponseMessage responseMessage = null; - // Execute corresponding HttpMethod via the HighLevelRestApi - switch (HttpMethod.valueOf(httpMethod)) { + // Execute corresponding HttpMethod via the HighLevelRestApi + switch (HttpMethod.valueOf(httpMethod)) { - case PUT: { - String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element); - String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); - responseMessage = HighLevelRestApi.Put(requestUri, requestPayload, acceptHeader); - break; - } + case PUT: { + String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element); + String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); + responseMessage = HighLevelRestApi.Put(requestUri, requestPayload, acceptHeader); + break; + } - case POST: { - String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element); - String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); - responseMessage = HighLevelRestApi.Post(requestUri, requestPayload, acceptHeader); - break; - } + case POST: { + String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element); + String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); + responseMessage = HighLevelRestApi.Post(requestUri, requestPayload, acceptHeader); + break; + } - case GET: { - String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); - responseMessage = HighLevelRestApi.Get(requestUri, acceptHeader); - break; - } + case GET: { + String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); + responseMessage = HighLevelRestApi.Get(requestUri, acceptHeader); + break; + } - case DELETE: { - String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); - responseMessage = HighLevelRestApi.Delete(requestUri, acceptHeader); - break; - } - default: - break; - } + case DELETE: { + String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element); + responseMessage = HighLevelRestApi.Delete(requestUri, acceptHeader); + break; + } + default: + break; + } - processResponseMessage(responseMessage, context, element); - } + processResponseMessage(responseMessage, context, element); + } - private void processResponseMessage(HttpResponseMessage responseMessage, ExtensionContext context, Element element) - throws FaultException { - // Write responsePayload to designated variable - String responsePayloadVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, element, - MethodAttribute.RESPONSE_PAYLOAD_VARIABLE); - String statusCodeVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, element, - MethodAttribute.STATUS_CODE_VARIABLE); + private void processResponseMessage(HttpResponseMessage responseMessage, + ExtensionContext context, Element element) throws FaultException { + // Write responsePayload to designated variable + String responsePayloadVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, + element, MethodAttribute.RESPONSE_PAYLOAD_VARIABLE); + String statusCodeVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, element, + MethodAttribute.STATUS_CODE_VARIABLE); - - if (responsePayloadVariableName != null && !responsePayloadVariableName.isEmpty()) { - Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getResponseBody(), - responsePayloadVariableName); - } - if (statusCodeVariableName != null && !statusCodeVariableName.isEmpty()) { - Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getStatusCode(), statusCodeVariableName); - } - } + if (responsePayloadVariableName != null && !responsePayloadVariableName.isEmpty()) { + Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getResponseBody(), + responsePayloadVariableName); + } + + if (statusCodeVariableName != null && !statusCodeVariableName.isEmpty()) { + Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getStatusCode(), + statusCodeVariableName); + } + } }
