You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2007/09/04 14:39:45 UTC
svn commit: r572651 [5/6] - in /webservices/axis2/trunk/java: ./
modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ modules/corba/
modules/corba/src/ modules/corba/src/org/ modules/corba/src/org/apache/
modules/corba/src/org/apache/axis2/ module...
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractCollectionValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractCollectionValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractCollectionValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractCollectionValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.CompositeDataType;
+import org.apache.axis2.corba.idl.types.AbstractCollectionType;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+public abstract class AbstractCollectionValue extends AbstractValue {
+ protected Object[] values = null;
+
+ public AbstractCollectionValue(CompositeDataType dataType) {
+ super(dataType);
+ }
+
+ public AbstractCollectionValue(AbstractCollectionType dataType) {
+ super(dataType);
+ }
+
+ public Object[] getValues() {
+ return values;
+ }
+
+ public void setValues(Object[] values) {
+ this.values = values;
+ }
+
+ public abstract void read(InputStream inputStream);
+
+ public abstract void write(OutputStream outputStream);
+
+ public String toString() {
+ AbstractCollectionType collectionType = (AbstractCollectionType) dataType;
+ String type = null;
+ if (collectionType.isArray())
+ type = "Array: ";
+ else if (collectionType.isSequence())
+ type = "Sequence: ";
+ return type + collection2String(values);
+ }
+
+ private String collection2String(Object[] collectionValues) {
+ StringBuffer str = new StringBuffer();
+ for (int i = 0; i < collectionValues.length; i++) {
+ Object value = collectionValues[i];
+ String elem;
+ if (value instanceof Object[]) {
+ elem = collection2String((Object[]) value);
+ } else {
+ if (value != null) {
+ elem = value.toString();
+ } else {
+ elem = "null";
+ }
+ }
+ str.append(", ");
+ str.append(elem);
+ }
+ return "{" + str.substring(2) + "}";
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AbstractValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,161 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+import java.io.Serializable;
+
+public abstract class AbstractValue {
+ protected Object[] memberValues;
+ protected CompositeDataType dataType;
+ private static final Log log = LogFactory.getLog(AbstractValue.class);
+
+ protected AbstractValue (CompositeDataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public Member[] getMembers() {
+ return dataType.getMembers();
+ }
+
+ public void setMemberValues(Object[] memberValues) {
+ this.memberValues = memberValues;
+ }
+
+ public Object[] getMemberValues() {
+ return memberValues;
+ }
+
+ public TypeCode getTypeCode() {
+ return dataType.getTypeCode();
+ }
+
+ protected void write(Object value, DataType dataType, OutputStream outputStream) {
+ TCKind kind = dataType.getTypeCode().kind();
+ switch(kind.value()) {
+ case TCKind._tk_long : outputStream.write_long(((Integer) value).intValue()); break;
+ case TCKind._tk_ulong : outputStream.write_ulong(((Integer) value).intValue()); break;
+ case TCKind._tk_longlong : outputStream.write_longlong(((Long) value).longValue()); break;
+ case TCKind._tk_ulonglong : outputStream.write_ulonglong(((Long) value).longValue()); break;
+ case TCKind._tk_short : outputStream.write_short(((Short) value).shortValue()); break;
+ case TCKind._tk_ushort : outputStream.write_ushort(((Short) value).shortValue()); break;
+ case TCKind._tk_float : outputStream.write_float(((Float) value).floatValue()); break;
+ case TCKind._tk_double : outputStream.write_double(((Double) value).floatValue()); break;
+ case TCKind._tk_char : outputStream.write_char(((Character) value).charValue()); break;
+ case TCKind._tk_wchar : outputStream.write_wchar(((Character) value).charValue()); break;
+ case TCKind._tk_boolean : outputStream.write_boolean(((Boolean) value).booleanValue()); break;
+ case TCKind._tk_octet : outputStream.write_octet(((Byte) value).byteValue()); break;
+ case TCKind._tk_string : outputStream.write_string((String) value); break;
+ case TCKind._tk_wstring : outputStream.write_wstring((String) value); break;
+ case TCKind._tk_any : outputStream.write_any((Any) value); break;
+ case TCKind._tk_value : outputStream.write_value((Serializable) value); break;
+ case TCKind._tk_struct : ((StructValue) value).write(outputStream); break;
+ case TCKind._tk_enum : ((EnumValue) value).write(outputStream); break;
+ case TCKind._tk_union: ((UnionValue) value).write(outputStream); break;
+ case TCKind._tk_alias: ((AliasValue) value).write(outputStream); break;
+ case TCKind._tk_sequence: ((SequenceValue) value).write(outputStream); break;
+ case TCKind._tk_array: ((ArrayValue) value).write(outputStream); break;
+ default:
+ log.error("ERROR! Invalid dataType");
+ break;
+ }
+ }
+
+ protected Object read(DataType dataType, InputStream inputStream) {
+ TCKind kind = dataType.getTypeCode().kind();
+ Object ret = null;
+ switch(kind.value()) {
+ case TCKind._tk_long: ret = new Integer(inputStream.read_long()); break;
+ case TCKind._tk_ulong: ret = new Integer(inputStream.read_ulong()); break;
+ case TCKind._tk_longlong: ret = new Long(inputStream.read_longlong()); break;
+ case TCKind._tk_ulonglong: ret = new Long(inputStream.read_ulonglong()); break;
+ case TCKind._tk_short: ret = new Short(inputStream.read_short()); break;
+ case TCKind._tk_ushort: ret = new Short(inputStream.read_ushort()); break;
+ case TCKind._tk_float: ret = new Float(inputStream.read_float()); break;
+ case TCKind._tk_double: ret = new Double(inputStream.read_double()); break;
+ case TCKind._tk_char: ret = new Character(inputStream.read_char()); break;
+ case TCKind._tk_wchar: ret = new Character(inputStream.read_wchar()); break;
+ case TCKind._tk_boolean: ret = Boolean.valueOf(inputStream.read_boolean()); break;
+ case TCKind._tk_octet: ret = new Byte(inputStream.read_octet()); break;
+ case TCKind._tk_string: ret = inputStream.read_string(); break;
+ case TCKind._tk_wstring: ret = inputStream.read_wstring(); break;
+ case TCKind._tk_any: ret = inputStream.read_any(); break;
+ case TCKind._tk_value: ret = inputStream.read_value(); break;
+ //case TCKind._tk_longdouble :
+ case TCKind._tk_struct:
+ StructValue structValue = new StructValue((Struct) dataType);
+ structValue.read(inputStream);
+ ret = structValue;
+ break;
+ case TCKind._tk_enum:
+ EnumValue enumValue = new EnumValue((EnumType) dataType);
+ enumValue.read(inputStream);
+ ret = enumValue;
+ break;
+ case TCKind._tk_union:
+ UnionValue unionValue = new UnionValue((UnionType) dataType);
+ unionValue.read(inputStream);
+ ret = unionValue;
+ break;
+ case TCKind._tk_alias:
+ AliasValue aliasValue = new AliasValue((Typedef) dataType);
+ aliasValue.read(inputStream);
+ ret = aliasValue;
+ break;
+ case TCKind._tk_sequence:
+ SequenceValue sequenceValue = new SequenceValue((SequenceType) dataType);
+ sequenceValue.read(inputStream);
+ ret = sequenceValue;
+ break;
+ case TCKind._tk_array:
+ ArrayValue arrayValue = new ArrayValue((ArrayType) dataType);
+ arrayValue.read(inputStream);
+ ret = arrayValue;
+ break;
+ case TCKind._tk_except:
+ ExceptionValue exValue = new ExceptionValue((ExceptionType) dataType);
+ exValue.read(inputStream);
+ ret = exValue;
+ break;
+ default:
+ log.error("ERROR! Invalid dataType");
+ break;
+ }
+ return ret;
+ }
+
+ public String toString() {
+ Member[] members = getMembers();
+ String ret = "CompositeDataType name: " + dataType.getModule() + dataType.getName() + '\n';
+ for (int i = 0; i < members.length; i++) {
+ Object value = memberValues[i];
+ ret += '\t' + members[i].getName() + ": " + value + '\n';
+ }
+ return ret;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AliasValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AliasValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AliasValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/AliasValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.Typedef;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+public class AliasValue extends AbstractValue {
+ private Object value;
+ public AliasValue(Typedef dataType) {
+ super(dataType);
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public void read(InputStream inputStream) {
+ value = read(((Typedef) dataType).getDataType(), inputStream);
+ }
+
+ public void write(OutputStream outputStream) {
+ write(value, ((Typedef) dataType).getDataType(), outputStream);
+ }
+
+ public String toString() {
+ return (value == null)? " NULL value" : "Alias of: " + value.toString();
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ArrayValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ArrayValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ArrayValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ArrayValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.ArrayType;
+import org.apache.axis2.corba.idl.types.DataType;
+import org.apache.axis2.corba.idl.types.AbstractCollectionType;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+public class ArrayValue extends AbstractCollectionValue {
+ public ArrayValue(ArrayType arrayType) {
+ super(arrayType);
+ }
+
+ public void read(InputStream inputStream) {
+ AbstractCollectionType collectionType = (AbstractCollectionType) dataType;
+ DataType memberType = collectionType.getDataType();
+ int length = collectionType.getElementCount();
+ values = new Object[length];
+ for (int i = 0; i < length; i++) {
+ values[i] = read(memberType, inputStream);
+ }
+ }
+
+ public void write(OutputStream outputStream) {
+ AbstractCollectionType collectionType = (AbstractCollectionType) dataType;
+ DataType memberType = collectionType.getDataType();
+ int length = collectionType.getElementCount();
+ for (int i = 0; i < length; i++) {
+ write(values[i], memberType, outputStream);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/EnumValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/EnumValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/EnumValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/EnumValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.EnumType;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+public class EnumValue extends AbstractValue {
+ private int index;
+
+ public EnumValue(EnumType enumType) {
+ super(enumType);
+ }
+
+ public void setValue(int index) {
+ this.index = index;
+ }
+
+ public int getValue() {
+ return index;
+ }
+
+ public String getValueAsString() {
+ return (String) ((EnumType) dataType).getEnumMembers().get(index);
+ }
+
+ public String toString() {
+ return dataType.getModule() + dataType.getName() + " : " + index;
+ }
+
+ public void read(InputStream inputStream) {
+ index = inputStream.read_long();
+ }
+
+ public void write(OutputStream outputStream) {
+ outputStream.write_long(index);
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof EnumValue) {
+ if (getValueAsString().equals(((EnumValue) o).getValueAsString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ExceptionValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ExceptionValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ExceptionValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ExceptionValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.ExceptionType;
+import org.apache.axis2.corba.idl.types.Member;
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+
+public class ExceptionValue extends AbstractValue {
+
+ public ExceptionValue(ExceptionType exceptionType) {
+ super(exceptionType);
+ }
+
+ public void read(InputStream inputStream) {
+ Member[] members = getMembers();
+ Object[] memberValues = new Object[members.length];
+ if (!dataType.getId().equals(inputStream.read_string()))
+ throw new RuntimeException("Mismaching IDs");
+ for (int i = 0; i < members.length; i++) {
+ memberValues[i] = read(members[i].getDataType(), inputStream);
+ }
+ setMemberValues(memberValues);
+ }
+
+ public CorbaInvocationException getException() {
+ return new CorbaInvocationException(toString());
+ }
+
+ public String toString() {
+ Member[] members = getMembers();
+ String ret = "Exception name: " + dataType.getModule() + dataType.getName() + '\n';
+ for (int i = 0; i < members.length; i++) {
+ Object value = memberValues[i];
+ ret += '\t' + members[i].getName() + ": " + value + '\n';
+ }
+ return ret;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ObjectByValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ObjectByValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ObjectByValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/ObjectByValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,69 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.TypeCode;
+
+import org.apache.axis2.corba.idl.types.ValueType;
+import org.apache.axis2.corba.idl.types.Member;
+
+public class ObjectByValue extends AbstractValue implements org.omg.CORBA.portable.StreamableValue {
+
+ public ObjectByValue(ValueType valueType) {
+ super(valueType);
+ }
+
+ public void _read(InputStream is) {
+ read(is);
+ }
+
+ public void _write(OutputStream os) {
+ write(os);
+ }
+
+ public TypeCode _type() {
+ return dataType.getTypeCode();
+ }
+
+ public String[] _truncatable_ids() {
+ return new String[] {dataType.getId()};
+ }
+
+ private void read(InputStream is) {
+ org.omg.CORBA_2_3.portable.InputStream inputStream
+ = (org.omg.CORBA_2_3.portable.InputStream) is;
+ Member[] members = dataType.getMembers();
+ memberValues = new Object[members.length];
+ for (int i = 0; i < members.length; i++) {
+ memberValues[i] = read(members[i].getDataType(), inputStream);
+ }
+ }
+
+ private void write(OutputStream os) {
+ org.omg.CORBA_2_3.portable.OutputStream outputStream
+ = (org.omg.CORBA_2_3.portable.OutputStream) os;
+ Member[] members = dataType.getMembers();
+ for (int i = 0; i < members.length; i++) {
+ write(memberValues[i], members[i].getDataType(), outputStream);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/SequenceValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/SequenceValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/SequenceValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/SequenceValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.SequenceType;
+import org.apache.axis2.corba.idl.types.DataType;
+import org.apache.axis2.corba.idl.types.AbstractCollectionType;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+public class SequenceValue extends AbstractCollectionValue {
+ public SequenceValue(SequenceType sequenceType) {
+ super(sequenceType);
+ }
+
+ public void read(InputStream inputStream) {
+ AbstractCollectionType collectionType = (AbstractCollectionType) dataType;
+ DataType memberType = collectionType.getDataType();
+ int length = inputStream.read_long();
+ values = new Object[length];
+ for (int i = 0; i < length; i++) {
+ values[i] = read(memberType, inputStream);
+ }
+ }
+
+ public void write(OutputStream outputStream) {
+ AbstractCollectionType collectionType = (AbstractCollectionType) dataType;
+ DataType memberType = collectionType.getDataType();
+ int length = values.length;
+ outputStream.write_long(length);
+ for (int i = 0; i < length; i++) {
+ write(values[i], memberType, outputStream);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StreamableValueFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StreamableValueFactory.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StreamableValueFactory.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StreamableValueFactory.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.omg.CORBA.portable.ValueFactory;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.ORB;
+
+import java.io.Serializable;
+
+import org.apache.axis2.corba.idl.types.ValueType;
+
+public class StreamableValueFactory implements ValueFactory {
+ private ValueType valueType;
+
+ private StreamableValueFactory(ValueType valueType) {
+ this.valueType = valueType;
+ }
+
+ public Serializable read_value(InputStream inputStream) {
+ return inputStream.read_value(new ObjectByValue(valueType));
+ }
+
+ public static void register(ORB orb, ValueType valueType) {
+ orb.register_value_factory(valueType.getId(), new StreamableValueFactory(valueType));
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StructValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StructValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StructValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/StructValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.Struct;
+import org.apache.axis2.corba.idl.types.Member;
+
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+public class StructValue extends AbstractValue {
+
+ public StructValue (Struct struct) {
+ super(struct);
+ }
+
+ public void write(OutputStream outputStream) {
+ Member[] members = getMembers();
+ for (int i = 0; i < members.length; i++) {
+ write(memberValues[i], members[i].getDataType(), outputStream);
+ }
+ }
+
+ public void read(InputStream inputStream) {
+ Member[] members = getMembers();
+ memberValues = new Object[members.length];
+ for (int i = 0; i < members.length; i++) {
+ memberValues[i] = read(members[i].getDataType(), inputStream);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/UnionValue.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/UnionValue.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/UnionValue.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/idl/values/UnionValue.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,140 @@
+/*
+ * 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.axis2.corba.idl.values;
+
+import org.apache.axis2.corba.idl.types.*;
+import org.apache.axis2.corba.receivers.CorbaUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.omg.CORBA.TCKind;
+
+public class UnionValue extends AbstractValue {
+ private static final Log log = LogFactory.getLog(UnionValue.class);
+ private Object discriminator;
+ private String memberName;
+ private Object memberValue;
+ private DataType memberType;
+
+
+ public UnionValue(UnionType unionType) {
+ super(unionType);
+ }
+
+ public void read(InputStream inputStream) {
+ UnionType unionType = (UnionType) dataType;
+ discriminator = read(unionType.getDiscriminatorType(), inputStream);
+ populateValue();
+ memberValue = read(getMemberType(), inputStream);
+ }
+
+ private void populateValue() {
+ Member[] members = getMembers();
+ UnionMember unionMember = null;
+
+ String discriminatorStr;
+ if (discriminator instanceof EnumValue) {
+ discriminatorStr = ((EnumValue) discriminator).getValueAsString();
+ } else {
+ discriminatorStr = discriminator.toString();
+ }
+
+ for (int i = 0; i < members.length; i++) {
+ unionMember = (UnionMember) members[i];
+ if (discriminatorStr.equals(unionMember.getDiscriminatorValue()))
+ break;
+ }
+ if (unionMember != null) {
+ memberName = unionMember.getName();
+ setMemberType(unionMember.getDataType());
+ } else {
+ log.error("Union must have atleast one members");
+ }
+ }
+
+ private void populateDiscriminator() {
+ Member[] members = getMembers();
+ UnionMember unionMember = null;
+ for (int i = 0; i < members.length; i++) {
+ unionMember = (UnionMember) members[i];
+ if (unionMember.getName().equals(memberName))
+ break;
+ }
+ if (unionMember != null) {
+ setMemberType(unionMember.getDataType());
+ if (!unionMember.isDefault()) {
+ discriminator = CorbaUtil.parseValue(((UnionType)dataType).getDiscriminatorType(), unionMember.getDiscriminatorValue());
+ } else if (unionMember.isDefault()) {
+ DataType discriminatorType = ((UnionType)dataType).getDiscriminatorType();
+ int kindVal = discriminatorType.getTypeCode().kind().value();
+ switch (kindVal) {
+ case TCKind._tk_long:
+ discriminator = Integer.valueOf(-2147483648);
+ break;
+ case TCKind._tk_char:
+ case TCKind._tk_wchar:
+ discriminator = Character.valueOf('\u0000');
+ break;
+ case TCKind._tk_enum:
+ EnumType enumType = (EnumType) discriminatorType;
+ EnumValue enumValue = new EnumValue(enumType);
+ enumValue.setValue(0);
+ discriminator = enumValue;
+ break;
+ default:
+ log.error("Unsupported union member type");
+ }
+ } else {
+ discriminator = null;
+ }
+ }
+ }
+
+ public void write(OutputStream outputStream) {
+ populateDiscriminator();
+ write(discriminator, ((UnionType) dataType).getDiscriminatorType(), outputStream);
+ write(memberValue, getMemberType(), outputStream);
+ }
+
+ public String getMemberName() {
+ return memberName;
+ }
+
+ public void setMemberName(String memberName) {
+ this.memberName = memberName;
+ }
+
+ public Object getMemberValue() {
+ return memberValue;
+ }
+
+ public void setMemberValue(Object memberValue) {
+ this.memberValue = memberValue;
+ }
+
+ public DataType getMemberType() {
+ return memberType;
+ }
+
+ public void setMemberType(DataType memberType) {
+ this.memberType = memberType;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOnlyMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOnlyMessageReceiver.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOnlyMessageReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOnlyMessageReceiver.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,132 @@
+/*
+ * 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.axis2.corba.receivers;
+
+import org.apache.axis2.corba.deployer.CorbaConstants;
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+import org.apache.axis2.corba.idl.types.IDL;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA_2_3.ORB;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CorbaInOnlyMessageReceiver extends AbstractInMessageReceiver implements CorbaConstants {
+
+ private static Log log = LogFactory.getLog(CorbaInOnlyMessageReceiver.class);
+ private ORB orb = null;
+ private Map invokerCache = new HashMap();
+
+ public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+ try{
+ invoke(inMessage);
+ log.info("org.omg.CORBA.TRANSIENT exception thrown.");
+ } catch (org.omg.CORBA.TRANSIENT e) {
+ /*
+ * If cannot connect to the corba server
+ * try again after clearing the cache
+ * (eg. if the Corba server is restarted)
+ */
+ invokerCache.clear();
+ invoke(inMessage);
+ }
+ }
+
+ private void invoke(MessageContext inMessage) throws AxisFault {
+ String methodName = null;
+ try {
+ AxisOperation op = inMessage.getOperationContext().getAxisOperation();
+ AxisService service = inMessage.getAxisService();
+ OMElement methodElement = inMessage.getEnvelope().getBody().getFirstElement();
+
+ AxisMessage inAxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ String messageNameSpace;
+ QName elementQName;
+ methodName = op.getName().getLocalPart();
+
+ Invoker invoker = (Invoker) invokerCache.get(methodName);
+ if (invoker==null) {
+ if (orb==null) {
+ Parameter orbParam = service.getParameter(ORB_LITERAL);
+ orb = orbParam != null ? (ORB) orbParam.getValue() : CorbaUtil.getORB(service);
+ }
+ org.omg.CORBA.Object obj = CorbaUtil.resolveObject(service, orb);
+ Parameter idlParameter = service.getParameter(IDL_LITERAL);
+ if (idlParameter==null)
+ throw new CorbaInvocationException("No IDL found");
+ IDL idl = (IDL) idlParameter.getValue();
+ invoker = CorbaUtil.getInvoker(service, obj, idl, methodName);
+ invokerCache.put(methodName, invoker);
+ }
+
+ if (inAxisMessage != null) {
+ if (inAxisMessage.getElementQName()!=null) {
+ elementQName = inAxisMessage.getElementQName();
+ messageNameSpace = elementQName.getNamespaceURI();
+ OMNamespace namespace = methodElement.getNamespace();
+ if (messageNameSpace != null) {
+ if (namespace == null ||
+ !messageNameSpace.equals(namespace.getNamespaceURI())) {
+ throw new AxisFault("namespace mismatch require " +
+ messageNameSpace +
+ " found " +
+ methodElement.getNamespace().getNamespaceURI());
+ }
+ } else if (namespace != null) {
+ throw new AxisFault("namespace mismatch. Axis Oepration expects non-namespace " +
+ "qualified element. But received a namespace qualified element");
+ }
+
+ Object[] objectArray = CorbaUtil.extractParameters(methodElement, invoker.getParameterMembers());
+ invoker.setParameters(objectArray);
+ }
+ invoker.invoke();
+ }
+ } catch (CorbaInvocationException e) {
+ String msg;
+ Throwable cause = e.getCause();
+ if (cause != null) {
+ msg = cause.getMessage();
+ if (msg == null) {
+ msg = "Exception occurred while trying to invoke service method " + methodName;
+ }
+ //log.error(msg, e);
+ if (cause instanceof AxisFault) {
+ throw (AxisFault) cause;
+ }
+ } else {
+ msg = e.getMessage();
+ }
+ throw new AxisFault(msg);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInOutAsyncMessageReceiver.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,149 @@
+/*
+ * 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.axis2.corba.receivers;
+
+import org.apache.axis2.corba.deployer.CorbaConstants;
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+import org.apache.axis2.corba.idl.types.IDL;
+import org.apache.axis2.corba.idl.types.Member;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA_2_3.ORB;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CorbaInOutAsyncMessageReceiver extends AbstractInOutAsyncMessageReceiver implements CorbaConstants {
+
+ private static Log log = LogFactory.getLog(CorbaInOutAsyncMessageReceiver.class);
+ private ORB orb = null;
+ private Map invokerCache = new HashMap();
+
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ try{
+ invoke(inMessage, outMessage);
+ } catch (org.omg.CORBA.TRANSIENT e) {
+ log.info("org.omg.CORBA.TRANSIENT exception thrown.");
+ /*
+ * If cannot connect to the corba server
+ * try again after clearing the cache
+ * (eg. if the Corba server is restarted)
+ */
+ invokerCache.clear();
+ invoke(inMessage, outMessage);
+ }
+ }
+
+ private void invoke(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ String methodName = null;
+ try {
+ AxisOperation op = inMessage.getOperationContext().getAxisOperation();
+ AxisService service = inMessage.getAxisService();
+ OMElement methodElement = inMessage.getEnvelope().getBody().getFirstElement();
+
+ AxisMessage inAxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ String messageNameSpace = null;
+ QName elementQName;
+ methodName = op.getName().getLocalPart();
+
+ Invoker invoker = (Invoker) invokerCache.get(methodName);
+ if (invoker==null) {
+ if (orb==null) {
+ Parameter orbParam = service.getParameter(ORB_LITERAL);
+ orb = orbParam != null ? (ORB) orbParam.getValue() : CorbaUtil.getORB(service);
+ }
+ org.omg.CORBA.Object obj = CorbaUtil.resolveObject(service, orb);
+ Parameter idlParameter = service.getParameter(IDL_LITERAL);
+ if (idlParameter==null)
+ throw new CorbaInvocationException("IDL not found");
+ IDL idl = (IDL) idlParameter.getValue();
+ invoker = CorbaUtil.getInvoker(service, obj, idl, methodName);
+ invokerCache.put(methodName, invoker);
+ }
+
+ Object resObject = null;
+ Member[] params = null;
+ Object[] outParamValues = null;
+ if (inAxisMessage != null) {
+ if (inAxisMessage.getElementQName()!=null) {
+ elementQName = inAxisMessage.getElementQName();
+ messageNameSpace = elementQName.getNamespaceURI();
+ OMNamespace namespace = methodElement.getNamespace();
+ if (messageNameSpace != null) {
+ if (namespace == null || !messageNameSpace.equals(namespace.getNamespaceURI())) {
+ throw new AxisFault("namespace mismatch require " +
+ messageNameSpace +
+ " found " + methodElement.getNamespace().getNamespaceURI());
+ }
+ } else if (namespace != null) {
+ throw new AxisFault("namespace mismatch. Axis Oepration expects non-namespace " +
+ "qualified element. But received a namespace qualified element");
+ }
+
+ Object[] objectArray = CorbaUtil.extractParameters(methodElement, invoker.getParameterMembers());
+ invoker.setParameters(objectArray);
+ params = invoker.getParameterMembers();
+ outParamValues = invoker.getOutParameterValuess();
+ }
+ resObject = invoker.invoke();
+ }
+ SOAPFactory fac = getSOAPFactory(inMessage);
+
+ AxisMessage outaxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ if (messageNameSpace == null) {
+ QName qname = outaxisMessage.getElementQName();
+ if (qname != null) {
+ messageNameSpace = qname.getNamespaceURI();
+ }
+ }
+ // Handling the response
+ CorbaUtil.processResponse(resObject, params, outParamValues, invoker.getReturnType(), service, methodName, fac,
+ messageNameSpace, outMessage);
+ } catch (CorbaInvocationException e) {
+ String msg;
+ Throwable cause = e.getCause();
+ if (cause != null) {
+ msg = cause.getMessage();
+ if (msg == null) {
+ msg = "Exception occurred while trying to invoke service method " + methodName;
+ }
+ //log.error(msg, e);
+ if (cause instanceof AxisFault) {
+ throw (AxisFault) cause;
+ }
+ } else {
+ msg = e.getMessage();
+ }
+ throw new AxisFault(msg);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvoker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvoker.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvoker.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvoker.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,182 @@
+/*
+ * 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.axis2.corba.receivers;
+
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+import org.apache.axis2.corba.idl.types.*;
+import org.apache.axis2.corba.idl.values.ExceptionValue;
+import org.omg.CORBA.*;
+
+import java.lang.Object;
+import java.util.*;
+
+public class CorbaInvoker implements Invoker {
+ private Operation operation;
+ private Interface intf;
+ //private Map compositeDataTypes;
+ private org.omg.CORBA.Object object;
+ private Object[] parameters;
+ private List parameterTypeList = new ArrayList();
+ private List returnedParams;
+
+ protected CorbaInvoker(Operation operation, Interface intf, org.omg.CORBA.Object object) {
+ this.operation = operation;
+ this.intf = intf;
+ this.object = object;
+
+ List params = operation.getParams();
+ if (params!=null) {
+ for (int i = 0; i < params.size(); i++) {
+ Member member = (Member) params.get(i);
+ parameterTypeList.add(member);
+ }
+ }
+ }
+
+ public Object invoke() throws CorbaInvocationException {
+ // Create request
+ Request request = object._request(operation.getName());
+
+ // Set parameters
+ Any arg = null;
+ List memArgs = new ArrayList();
+ if (parameters!=null) {
+ List patamList = new LinkedList(Arrays.asList(parameters));
+ Iterator paramsIter = patamList.iterator();
+ for (int i = 0; i < parameterTypeList.size(); i++) {
+ Member member = (Member) parameterTypeList.get(i);
+ DataType type = member.getDataType();
+ Object value = null;
+ String mode = member.getMode();
+ if (mode.equals(Member.MODE_IN)) {
+ arg = request.add_in_arg();
+ value = paramsIter.next();
+ }else if (mode.equals(Member.MODE_INOUT)) {
+ arg = request.add_inout_arg();
+ value = paramsIter.next();
+ } else if (mode.equals(Member.MODE_OUT)) {
+ arg = request.add_out_arg();
+ value = CorbaUtil.getEmptyValue(type);
+ }
+
+ memArgs.add(arg);
+ CorbaUtil.insertValue(arg, type, value);
+ }
+ }
+
+ // Set return type
+ DataType returnType = operation.getReturnType();
+ if (returnType!=null) {
+ TypeCode typeCode = returnType.getTypeCode();
+ request.set_return_type(typeCode);
+ }
+
+ // Set exceptions
+ List exceptions = operation.getRaises();
+ if (exceptions!=null && !exceptions.isEmpty()) {
+ ExceptionList exceptionList = request.exceptions();
+ for (int i = 0; i < exceptions.size(); i++) {
+ ExceptionType exType = (ExceptionType) exceptions.get(i);
+ exceptionList.add(exType.getTypeCode());
+ }
+ }
+
+ // Invoke
+ request.invoke();
+
+ // Get exception
+ Object returnValue = null;
+ Exception exception = request.env().exception();
+ if (exception == null) {
+ // Extract the return value
+ if (returnType != null) {
+ Any returned = request.return_value();
+ returnValue = CorbaUtil.extractValue(returnType, returned);
+ }
+
+ // Extract the values of inout and out parameters
+ returnedParams = new ArrayList();
+ for (int i = 0; i < parameterTypeList.size(); i++) {
+ Member member = (Member) parameterTypeList.get(i);
+ String mode = member.getMode();
+ if (mode.equals(Member.MODE_INOUT) || mode.equals(Member.MODE_OUT)) {
+ returnedParams.add(CorbaUtil.extractValue(member.getDataType(), (Any) memArgs.get(i)));
+ }
+ }
+ } else {
+ if(exception instanceof UnknownUserException) {
+ UnknownUserException userException = (UnknownUserException) exception;
+ TypeCode exTypeCode = userException.except.type();
+ ExceptionType exceptionType = null;
+ if (exceptions!=null && !exceptions.isEmpty()) {
+ for (int i = 0; i < exceptions.size(); i++) {
+ ExceptionType exType = (ExceptionType) exceptions.get(i);
+ if (exTypeCode.equal(exType.getTypeCode())) {
+ exceptionType = exType;
+ break;
+ }
+ }
+ }
+ if (exceptionType==null) {
+ throw new CorbaInvocationException(exception);
+ } else {
+ ExceptionValue exceptionValue = (ExceptionValue) CorbaUtil.extractValue(exceptionType, userException.except);
+ if (exceptionValue!=null)
+ throw exceptionValue.getException();
+ }
+ } else {
+ throw new CorbaInvocationException(exception);
+ }
+ }
+
+ return returnValue;
+ }
+
+ public void setParameters(Object[] parameters){
+ this.parameters = parameters;
+ }
+
+ public String getInterfaceName(){
+ return intf.getName();
+ }
+
+ public String getOperationName(){
+ return operation.getName();
+ }
+
+ public DataType getReturnType() {
+ return operation.getReturnType();
+ }
+
+ public Object[] getOutParameterValuess() {
+ if (returnedParams == null)
+ return null;
+ else
+ return returnedParams.toArray();
+ }
+
+ public Member[] getParameterMembers() {
+ Member[] membersArray = new Member[parameterTypeList.size()];
+ for (int i = 0; i < parameterTypeList.size(); i++) {
+ membersArray[i] = (Member) parameterTypeList.get(i);
+ }
+ return membersArray;
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvokerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvokerFactory.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvokerFactory.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaInvokerFactory.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,56 @@
+/*
+ * 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.axis2.corba.receivers;
+
+import org.apache.axis2.corba.idl.types.IDL;
+import org.apache.axis2.corba.idl.types.Interface;
+import org.apache.axis2.corba.idl.types.Operation;
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+
+import java.util.Map;
+
+public class CorbaInvokerFactory implements InvokerFactory {
+ //private Map compositeDataTypes;
+ private Map interfaces;
+
+ public CorbaInvokerFactory(IDL idl){
+ //this.compositeDataTypes = idl.getCompositeDataTypes();
+ this.interfaces = idl.getInterfaces();
+ }
+
+ public Invoker newInvoker(String interfaceName, String operationName, org.omg.CORBA.Object object) throws CorbaInvocationException {
+ Interface intf = (Interface) interfaces.get(interfaceName);
+
+ if (intf==null)
+ throw new CorbaInvocationException("Interface " + interfaceName + " not found");
+
+ Map operations = intf.getOperationsMap();
+
+ if (operations==null || operations.isEmpty())
+ throw new CorbaInvocationException("Interface " + interfaceName + " does not have operations");
+
+ Operation operation = (Operation) operations.get(operationName);
+
+ if (operation==null)
+ throw new CorbaInvocationException("Operation " + operationName + " not found in interface " + interfaceName);
+
+ return new CorbaInvoker(operation, intf, /*compositeDataTypes,*/ object);
+ }
+}
Added: webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaMessageReceiver.java?rev=572651&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaMessageReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/corba/src/org/apache/axis2/corba/receivers/CorbaMessageReceiver.java Tue Sep 4 05:39:42 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.axis2.corba.receivers;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.corba.deployer.CorbaConstants;
+import org.apache.axis2.corba.exceptions.CorbaInvocationException;
+import org.apache.axis2.corba.idl.types.IDL;
+import org.apache.axis2.corba.idl.types.Member;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA_2_3.ORB;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CorbaMessageReceiver extends AbstractInOutMessageReceiver implements CorbaConstants {
+ private static Log log = LogFactory.getLog(CorbaMessageReceiver.class);
+ private ORB orb = null;
+ private Map invokerCache = new HashMap(); // Hashmap to cache invoker objects to increase preformance
+
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ try{
+ invoke(inMessage, outMessage);
+ } catch (org.omg.CORBA.TRANSIENT e) {
+ log.info("org.omg.CORBA.TRANSIENT exception thrown.");
+ /*
+ * If cannot connect to the corba server
+ * try again after clearing the cache
+ * (eg. if the Corba server is restarted)
+ */
+ invokerCache.clear();
+ invoke(inMessage, outMessage);
+ }
+ }
+
+ private void invoke(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ String methodName = null;
+ try {
+ AxisOperation op = inMessage.getOperationContext().getAxisOperation();
+ AxisService service = inMessage.getAxisService();
+ OMElement methodElement = inMessage.getEnvelope().getBody().getFirstElement();
+ AxisMessage inAxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ String messageNameSpace = null;
+ QName elementQName;
+ methodName = op.getName().getLocalPart();
+
+ Invoker invoker = (Invoker) invokerCache.get(methodName);
+ if (invoker==null) {
+ if (orb==null) {
+ Parameter orbParam = service.getParameter(ORB_LITERAL);
+ orb = orbParam != null ? (ORB) orbParam.getValue() : CorbaUtil.getORB(service);
+ }
+ org.omg.CORBA.Object obj = CorbaUtil.resolveObject(service, orb);
+ Parameter idlParameter = service.getParameter(IDL_LITERAL);
+ if (idlParameter==null)
+ throw new CorbaInvocationException("IDL not found");
+ IDL idl = (IDL) idlParameter.getValue();
+ invoker = CorbaUtil.getInvoker(service, obj, idl, methodName);
+ invokerCache.put(methodName, invoker);
+ }
+
+ Object resObject = null;
+ Member[] params = null;
+ Object[] outParamValues = null;
+ if (inAxisMessage != null) {
+ if (inAxisMessage.getElementQName() != null) {
+ elementQName = inAxisMessage.getElementQName();
+ messageNameSpace = elementQName.getNamespaceURI();
+ OMNamespace namespace = methodElement.getNamespace();
+ if (messageNameSpace != null) {
+ if (namespace == null) {
+ throw new AxisFault("namespace mismatch require " +
+ messageNameSpace +
+ " found none");
+ }
+ if (!messageNameSpace.equals(namespace.getNamespaceURI())) {
+ throw new AxisFault("namespace mismatch require " +
+ messageNameSpace +
+ " found " + methodElement.getNamespace().getNamespaceURI());
+ }
+ } else if (namespace != null) {
+ throw new AxisFault("namespace mismatch. Axis Oepration expects non-namespace " +
+ "qualified element. But received a namespace qualified element");
+ }
+ Object[] objectArray = CorbaUtil.extractParameters(methodElement, invoker.getParameterMembers());
+ invoker.setParameters(objectArray);
+ }
+ resObject = invoker.invoke();
+ params = invoker.getParameterMembers();
+ outParamValues = invoker.getOutParameterValuess();
+ }
+
+ if (messageNameSpace == null) {
+ AxisMessage outaxisMessage = op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ QName qname = outaxisMessage.getElementQName();
+ if (qname != null) {
+ messageNameSpace = qname.getNamespaceURI();
+ }
+ }
+
+ // Handling the response
+ SOAPFactory fac = getSOAPFactory(inMessage);
+ CorbaUtil.processResponse(resObject, params, outParamValues, invoker.getReturnType(), service,
+ methodName, fac, messageNameSpace, outMessage);
+ } catch (CorbaInvocationException e) {
+ String msg;
+ Throwable cause = e.getCause();
+ if (cause != null) {
+ msg = cause.getMessage();
+ if (msg == null) {
+ msg = "Exception occurred while trying to invoke service method " + methodName;
+ }
+ //log.error(msg, e);
+ if (cause instanceof AxisFault) {
+ throw (AxisFault) cause;
+ }
+ } else {
+ msg = e.getMessage();
+ }
+ throw new AxisFault(msg);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org