You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by dm...@apache.org on 2006/06/13 19:40:52 UTC
svn commit: r413964 [1/3] - in /incubator/yoko/trunk/bindings: ./
src/main/java/org/apache/yoko/bindings/corba/
src/main/java/org/apache/yoko/bindings/corba/extensions/
Author: dmiddlem
Date: Tue Jun 13 12:40:51 2006
New Revision: 413964
URL: http://svn.apache.org/viewvc?rev=413964&view=rev
Log:
Adding support for primitive types to binding runtime (YOKO-40)
Added:
incubator/yoko/trunk/bindings/checkstyle.xml
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConstants.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectHolder.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectWriter.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStreamable.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaTypeMap.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/Messages.properties
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/CorbaAddressExtensionHelper.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/CorbaBindingExtensionHelper.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/CorbaOperationExtensionHelper.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/extensions/CorbaTypesExtensionHelper.java
Modified:
incubator/yoko/trunk/bindings/pom.xml
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerBinding.java
Added: incubator/yoko/trunk/bindings/checkstyle.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/checkstyle.xml?rev=413964&view=auto
==============================================================================
--- incubator/yoko/trunk/bindings/checkstyle.xml (added)
+++ incubator/yoko/trunk/bindings/checkstyle.xml Tue Jun 13 12:40:51 2006
@@ -0,0 +1,263 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<!--
+Checks to make sure the code meets the Yoko coding guidelines
+http://java.sun.com/docs/codeconv/index.html
+
+It also enforces aa bunch of other "BestPractices like method
+lengths, if/try depths, etc...
+
+-->
+
+<module name="Checker">
+ <!-- Checks whether files end with a new line. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <!--
+ <module name="NewlineAtEndOfFile"/>
+ -->
+
+ <!-- Checks that property files contain the same keys. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+ <module name="Translation"/>
+
+ <!--<module name="StrictDuplicateCode"/>-->
+
+ <module name="TreeWalker">
+
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!--
+ <module name="PackageHtml"/>
+ <module name="JavadocMethod"/>
+ <module name="JavadocType"/>
+ <module name="JavadocVariable"/>
+ <module name="JavadocStyle"/>
+ -->
+
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="AbstractClassName">
+ <property name="format" value="^Abstract.*$|^.*Factory$|^.*Bus$|^.*ConfigurationRepository$|^.*Base$|^Exception$|^.*Builder$"/>
+ </module>
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <!-- Have to turn this off because CORBA method names
+ can begin with the '_' character -->
+ <!-- <module name="MethodName"/> -->
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <!-- <module name="StaticVariableName"/> -->
+ <module name="TypeName"/>
+
+ <!-- Header checks -->
+ <!-- <module name="Header"/> -->
+ <!-- <module name="RegexpHeader"/> -->
+
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport">
+ <property name="excludes" value="java.io,java.util,java.net,java.nio,java.nio.channels,java.lang.reflect,org.w3c.dom,org.xml.sax,java.awt,javax.swing,junit.framework"/>
+ </module>
+ <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="ImportOrder">
+ <property name="groups" value="java,javax,org.w3c,org.xml,w3c"/>
+ <property name="ordered" value="true"/>
+ </module>
+ <!--
+ <module name="ImportControl">
+ <property name="file" value="etc/import-control.xml"/>
+ </module>
+ -->
+
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="AnonInnerLength">
+ <property name="max" value="40"/>
+ </module>
+ <module name="ExecutableStatementCount">
+ <property name="max" value="50"/>
+ </module>
+ <module name="FileLength"/>
+ <module name="LineLength">
+ <property name="max" value="110"/>
+ </module>
+ <module name="MethodLength">
+ <property name="max" value="150"/>
+ <property name="countEmpty" value="false"/>
+ </module>
+ <module name="ParameterNumber">
+ <property name="max" value="7"/>
+ </module>
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad"/>
+ <module name="EmptyForInitializerPad"/>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <module name="TabCharacter"/>
+ <module name="WhitespaceAfter">
+ <property name="tokens" value="COMMA, SEMI"/>
+ </module>
+ <module name="WhitespaceAround">
+ <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>
+ </module>
+
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks">
+ <property name="allowInSwitchCase" value="true"/>
+ </module>
+ <module name="EmptyBlock">
+ <property name="option" value="text"/>
+ </module>
+ <module name="LeftCurly"/>
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!--<module name="ArrayTrailingComma"/>-->
+ <!--<module name="AvoidInlineConditionals"/>-->
+ <module name="CovariantEquals"/>
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <!--<module name="FinalLocalVariable"/>-->
+ <module name="HiddenField"/>
+ <module name="IllegalInstantiation"/>
+ <!--<module name="IllegalToken"/>-->
+ <!--<module name="IllegalTokenText"/>-->
+ <!--<module name="InnerAssignment"/>-->
+ <!--<module name="MagicNumber"/>-->
+ <module name="MissingSwitchDefault"/>
+ <module name="ModifiedControlVariable"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+ <module name="StringLiteralEquality"/>
+ <module name="NestedIfDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="NestedTryDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="SuperClone"/>
+ <module name="SuperFinalize"/>
+ <!--<module name="IllegalCatch"/>-->
+ <module name="IllegalThrows">
+ <property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException"/>
+ </module>
+ <!--<module name="RedundantThrows"/>-->
+ <module name="PackageDeclaration"/>
+ <module name="JUnitTestCase"/>
+ <module name="ReturnCount">
+ <property name="max" value="6"/>
+ </module>
+
+ <module name="IllegalType">
+ <property name="format" value="^xxx$"/>
+ </module>
+ <module name="DeclarationOrder"/>
+ <!--<module name="ParameterAssignment"/>-->
+ <module name="ExplicitInitialization"/>
+ <module name="DefaultComesLast"/>
+ <!--<module name="MissingCtor"/>-->
+ <module name="FallThrough"/>
+ <!--<module name="MultipleStringLiterals"/>-->
+ <module name="MultipleVariableDeclarations"/>
+ <!--<module name="RequireThis"/>-->
+ <module name="UnnecessaryParentheses"/>
+
+
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--<module name="DesignForExtension"/>-->
+ <module name="FinalClass"/>
+ <!--<module name="HideUtilityClassConstructor"/> -->
+ <module name="InterfaceIsType"/>
+ <module name="MutableException"/>
+ <module name="ThrowsCount">
+ <property name="max" value="5"/>
+ </module>
+ <module name="VisibilityModifier">
+ <property name="protectedAllowed" value="true"/>
+ <property name="packageAllowed" value="true"/>
+ <!-- this is needed for the resource injection unit tests. It will removed
+ when private member inject is supported.
+ -->
+ <property name="publicMemberPattern" value="resource[12].*"/>
+ </module>
+
+
+
+ <!-- Metrics checks. -->
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <module name="BooleanExpressionComplexity">
+ <property name="max" value="6"/>
+ </module>
+ <!--<module name="ClassDataAbstractionCoupling"/>-->
+ <!--<module name="ClassFanOutComplexity"/>-->
+ <!--<module name="CyclomaticComplexity"/>-->
+ <!--<module name="NPathComplexity"/>-->
+ <module name="JavaNCSS">
+ <property name="methodMaximum" value="75"/>
+ </module>
+
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!--
+ <module name="ArrayTypeStyle"/>
+ <module name="FinalParameters"/>
+ -->
+ <!--
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ -->
+ <module name="TodoComment">
+ <property name="format" value="WARNING"/>
+ </module>
+
+ <module name="UpperEll"/>
+
+ <!--Assert statement may have side effects:-->
+ <module name="DescendantToken">
+ <property name="tokens" value="LITERAL_ASSERT"/>
+ <property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN"/>
+ <property name="maximumNumber" value="0"/>
+ </module>
+
+ <!--<module name="UncommentedMain"/>-->
+ <module name="TrailingComment"/>
+ <module name="Indentation">
+ <property name="caseIndent" value="0"/>
+ </module>
+ <!--<module name="RequiredRegexp">-->
+ </module>
+
+</module>
Modified: incubator/yoko/trunk/bindings/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/pom.xml?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/pom.xml (original)
+++ incubator/yoko/trunk/bindings/pom.xml Tue Jun 13 12:40:51 2006
@@ -24,13 +24,6 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
-
- <!-- <dependency>
- <groupId>easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.0-20050821.154600</version>
- <scope>test</scope>
- </dependency> -->
<dependency>
<groupId>org.objectweb.celtix</groupId>
@@ -49,13 +42,12 @@
<artifactId>celtix-api</artifactId>
<version>${celtix.version}</version>
</dependency>
-
</dependencies>
<build>
<plugins>
- <plugin>
+<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.version}</version>
@@ -75,8 +67,11 @@
<header>YOKO API</header>
<footer>YOKO API</footer>
</configuration>
+ </plugin> -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
-
</plugins>
</build>
Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java?rev=413964&view=auto
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingException.java Tue Jun 13 12:40:51 2006
@@ -0,0 +1,46 @@
+/**
+ * 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.yoko.bindings.corba;
+
+import javax.xml.ws.ProtocolException;
+
+// NOTE: This exception provides basic functionality for throwing exceptions within the binding.
+// At the momemnt, we just want to support the ability to throw a message (and accompanying
+// exception) but it may be necessary to break up this functionality into separate exceptions
+// or make this exception a bit more complex.
+public class CorbaBindingException extends ProtocolException {
+
+ public static final long serialVersionUID = 8493263228127324876L;
+
+ public CorbaBindingException() {
+ super();
+ }
+
+ public CorbaBindingException(String msg) {
+ super(msg);
+ }
+
+ public CorbaBindingException(String msg, Throwable t) {
+ super(msg, t);
+ }
+
+ public CorbaBindingException(Throwable t) {
+ super(t);
+ }
+}
\ No newline at end of file
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingFactory.java Tue Jun 13 12:40:51 2006
@@ -1,8 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.yoko.bindings.corba;
import java.io.IOException;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
import javax.wsdl.WSDLException;
+import org.apache.yoko.bindings.corba.extensions.CorbaAddressExtensionHelper;
+import org.apache.yoko.bindings.corba.extensions.CorbaBindingExtensionHelper;
+import org.apache.yoko.bindings.corba.extensions.CorbaOperationExtensionHelper;
+import org.apache.yoko.bindings.corba.extensions.CorbaTypesExtensionHelper;
+
import org.objectweb.celtix.Bus;
import org.objectweb.celtix.bindings.BindingFactory;
import org.objectweb.celtix.bindings.ClientBinding;
@@ -11,24 +38,33 @@
import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
public class CorbaBindingFactory implements BindingFactory {
-
+
private Bus bus;
-
+
public CorbaBindingFactory() {
}
-
+
public void init(Bus b) {
bus = b;
+
+ CorbaAddressExtensionHelper.addExtension(
+ bus.getWSDLManager().getExtenstionRegistry(), Port.class, "address");
+ CorbaBindingExtensionHelper.addExtension(
+ bus.getWSDLManager().getExtenstionRegistry(), Binding.class, "binding");
+ CorbaOperationExtensionHelper.addExtension(
+ bus.getWSDLManager().getExtenstionRegistry(), BindingOperation.class, "operation");
+ CorbaTypesExtensionHelper.addExtension(
+ bus.getWSDLManager().getExtenstionRegistry(), Definition.class, "typeMapping");
}
-
- public ClientBinding createClientBinding(EndpointReferenceType reference)
- throws WSDLException, IOException {
+
+ public ClientBinding createClientBinding(EndpointReferenceType reference)
+ throws WSDLException, IOException {
return new CorbaClientBinding(bus, reference);
}
public ServerBinding createServerBinding(EndpointReferenceType reference,
- ServerBindingEndpointCallback cbFactory)
- throws WSDLException, IOException {
+ ServerBindingEndpointCallback cbFactory) throws WSDLException,
+ IOException {
return new CorbaServerBinding(bus, reference, cbFactory);
}
}
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java Tue Jun 13 12:40:51 2006
@@ -1,39 +1,124 @@
+/**
+ * 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.yoko.bindings.corba;
-import java.io.*;
-import java.util.*;
-//import java.util.logging.Level;
-//import java.util.logging.Logger;
-
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jws.WebParam;
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
+import org.apache.schemas.yoko.bindings.corba.ArgType;
+import org.apache.schemas.yoko.bindings.corba.Array;
+import org.apache.schemas.yoko.bindings.corba.CorbaType;
+import org.apache.schemas.yoko.bindings.corba.Exception;
+import org.apache.schemas.yoko.bindings.corba.ModeType;
+import org.apache.schemas.yoko.bindings.corba.NamedType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.ParamType;
+import org.apache.schemas.yoko.bindings.corba.Sequence;
+import org.apache.schemas.yoko.bindings.corba.Struct;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.schemas.yoko.bindings.corba.Union;
+
import org.objectweb.celtix.Bus;
import org.objectweb.celtix.bindings.AbstractBindingImpl;
import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bindings.DataReader;
+import org.objectweb.celtix.bindings.DataWriter;
import org.objectweb.celtix.bus.handlers.HandlerChainInvoker;
-//import org.objectweb.celtix.common.logging.LogUtils;
+import org.objectweb.celtix.common.logging.LogUtils;
import org.objectweb.celtix.context.InputStreamMessageContext;
import org.objectweb.celtix.context.ObjectMessageContext;
import org.objectweb.celtix.context.OutputStreamMessageContext;
import org.objectweb.celtix.handlers.HandlerInvoker;
import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
public class CorbaBindingImpl extends AbstractBindingImpl {
-// private static final Logger LOG = LogUtils.getL7dLogger(CorbaBindingImpl.class);
- protected final boolean isServer;
+ private static final Logger LOG = LogUtils.getL7dLogger(CorbaBindingImpl.class);
+ protected final boolean isServer;
private Bus bus;
private EndpointReferenceType endpointRef;
-
+ private ORB orb;
+ private List<CorbaTypeMap> typeMaps;
+
public CorbaBindingImpl(boolean server) {
isServer = server;
}
- public CorbaBindingImpl(Bus b, EndpointReferenceType ert, boolean server) {
+ public CorbaBindingImpl(Bus b, EndpointReferenceType endpointRefType, ORB theOrb, boolean server) {
this(server);
this.bus = b;
- this.endpointRef = ert;
+ this.endpointRef = endpointRefType;
+ this.orb = theOrb;
+
+ // initialize the type maps for the binding
+ try {
+ typeMaps = new ArrayList<CorbaTypeMap>();
+ Definition wsdlDef = EndpointReferenceUtils.getWSDLDefinition(bus.getWSDLManager(),
+ endpointRef);
+ List extElements = wsdlDef.getExtensibilityElements();
+
+ for (int i = 0; i < extElements.size(); ++i) {
+ Object e = extElements.get(i);
+ if (e instanceof TypeMappingType) {
+ TypeMappingType tmType = (TypeMappingType) e;
+ CorbaTypeMap map = new CorbaTypeMap(tmType.getTargetNamespace());
+ map.setPrefix(wsdlDef.getPrefix(tmType.getTargetNamespace()));
+
+ List types = tmType.getStructOrExceptionOrUnion();
+ for (int j = 0; j < types.size(); ++j) {
+ CorbaType corbaType = (CorbaType) types.get(j);
+ map.addType(corbaType.getName(), corbaType);
+ }
+ typeMaps.add(map);
+ }
+ }
+ } catch (java.lang.Exception ex) {
+ // Proceed without the type maps.
+ }
}
public Bus getBus() {
@@ -43,9 +128,12 @@
public EndpointReferenceType getEndpointReference() {
return this.endpointRef;
}
-
- // --- AbstractBindingImpl interface ---
+ public List<CorbaTypeMap> getCorbaTypeMaps() {
+ return typeMaps;
+ }
+
+ // --- AbstractBindingImpl interface ---
public MessageContext createBindingMessageContext(MessageContext srcCtx) {
return new CorbaMessageContextImpl(srcCtx);
}
@@ -55,44 +143,325 @@
}
public void marshal(ObjectMessageContext objContext, MessageContext mc, DataBindingCallback callback) {
- // TODO - provide implementation. This could be tricky since we are using the ORB
- // for a transport and it does not use Message Contexts.
+ CorbaMessageContext corbaCtx = (CorbaMessageContext) mc;
+ corbaCtx.setMessage(new CorbaMessage());
+
+ try {
+ DataWriter<XMLEventWriter> writer = callback.createWriter(XMLEventWriter.class);
+ if (writer == null) {
+ throw new CorbaBindingException("Unable to create data writer");
+ }
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ // Get information about the operation being invoked from the WSDL
+ // definition.
+ // We need this to marshal data correctly
+ OperationType opElement =
+ CorbaUtils.getCorbaOperationType(callback.getOperationName(), bus, endpointRef);
+ if (opElement == null) {
+ throw new CorbaBindingException("Unable to find operation definition");
+ }
+
+ // Handle the parameters that are given for the operation
+ int numParams = callback.getParamsLength();
+ Object[] args = objContext.getMessageObjects();
+ List<ParamType> paramTypes = opElement.getParam();
+ for (int i = 0; i < numParams; ++i) {
+ WebParam param = callback.getWebParam(i);
+ Object partValue = args[i];
+ if (param.mode() != WebParam.Mode.IN) {
+ partValue = ((Holder) args[i]).value;
+ }
+
+ QName elName = new QName(param.targetNamespace(), param.name());
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+ writer.write(partValue, elName, evtWriter);
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+ CorbaObjectHolder obj = readCorbaObject(evtReader, paramTypes.get(i));
+
+ CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+ ModeType paramMode = paramTypes.get(i).getMode();
+ if (paramMode.value().equals("in")) {
+ streamable.setMode(org.omg.CORBA.ARG_IN.value);
+ } else if (paramMode.value().equals("inout")) {
+ streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
+ } else if (paramMode.value().equals("out")) {
+ streamable.setMode(org.omg.CORBA.ARG_OUT.value);
+ }
+ corbaCtx.getMessage().addStreamableArgument(streamable);
+ }
+
+ // Check to see if we have an input or output message and handle the
+ // return type
+ // appropriately
+ boolean isInputMessage = (Boolean) mc.get(ObjectMessageContext.MESSAGE_INPUT);
+ if (!isInputMessage && callback.getWebResult() != null) {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+ writer.write(objContext.getReturn(), callback.getWebResultQName(), evtWriter);
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+ CorbaObjectHolder obj = readCorbaObject(evtReader, opElement.getReturn());
+
+ CorbaStreamable streamable = new CorbaStreamable(obj, callback.getWebResultQName());
+ corbaCtx.getMessage().setStreamableReturn(streamable);
+ } else if (isInputMessage && callback.getWebResult() != null) {
+ QName retName = callback.getWebResultQName();
+ QName retIdlType = opElement.getReturn().getIdltype();
+ TypeCode retTC = CorbaUtils.getTypeCode(orb, retIdlType, typeMaps);
+
+ CorbaObjectHolder obj = new CorbaObjectHolder(retName, retIdlType, retTC, null);
+ CorbaStreamable streamable = new CorbaStreamable(obj, retName);
+ corbaCtx.getMessage().setStreamableReturn(streamable);
+ }
+ } catch (java.lang.Exception ex) {
+ LOG.log(Level.SEVERE, "CORBA marshal exception", ex);
+ throw new CorbaBindingException("CORBA Marshal Exception", ex);
+ }
}
-
- public void marshalFault(ObjectMessageContext objContext,
+
+ public void marshalFault(ObjectMessageContext objContext,
MessageContext mc,
DataBindingCallback callback) {
- // TODO - provide implementation. This could be tricky since we are using the ORB
- // for a transport and it does not use Message Contexts.
+ try {
+ DataWriter<XMLEventWriter> writer = callback.createWriter(XMLEventWriter.class);
+ if (writer == null) {
+ throw new WebServiceException("Unable to create data writer");
+ }
+
+ // TODO: Implement once we have support for exceptions
+ throw new CorbaBindingException("Method unmarshalFault not implemented");
+ } catch (java.lang.Exception ex) {
+ LOG.log(Level.SEVERE, "CORBA marshalFault exception", ex);
+ // TODO: Throw a exception proper exception once implemented
+ throw new CorbaBindingException("Method unmarshalFault not implemented");
+ }
}
public void unmarshal(MessageContext mc, ObjectMessageContext objContext, DataBindingCallback callback) {
- // TODO - provide implementation. This could be tricky since we are using the ORB
- // for a transport and it does not use Message Contexts.
- }
-
- public void unmarshalFault(MessageContext context, ObjectMessageContext objContext,
- DataBindingCallback callback) {
- // TODO - provide implementation. This could be tricky since we are using the ORB
- // for a transport and it does not use Message Contexts.
+ CorbaMessageContext corbaCtx = (CorbaMessageContext) mc;
+
+ try {
+ DataReader<XMLEventReader> reader = callback.createReader(XMLEventReader.class);
+ if (reader == null) {
+ throw new WebServiceException("Unable to create data reader");
+ }
+
+ // Handle the parameters that are given for the operation
+ int numParams = callback.getParamsLength();
+ Object[] args = objContext.getMessageObjects();
+ CorbaStreamable[] streamables = corbaCtx.getMessage().getStreamableArguments();
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ for (int i = 0; i < numParams; ++i) {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+ writeCorbaObject(streamables[i].getObject(), evtWriter, null);
+ evtWriter.flush();
+
+ WebParam param = callback.getWebParam(i);
+ QName elName = new QName(param.targetNamespace(), param.name());
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+ Object obj = reader.read(elName, i, evtReader);
+
+ if (param.mode() != WebParam.Mode.IN) {
+ args[i].getClass().getField("value").set(args[i], obj);
+ } else {
+ args[i] = obj;
+ }
+ }
+
+ // Check to see if we have an input or output message and handle the
+ // return type
+ // appropriately
+ boolean isInputMessage = (Boolean) mc.get(ObjectMessageContext.MESSAGE_INPUT);
+ if (!isInputMessage && callback.getWebResult() != null) {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+ writeCorbaObject(corbaCtx.getMessage().getStreamableReturn().getObject(), evtWriter, null);
+ evtWriter.flush();
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+ Object returnValue = reader.read(callback.getWebResultQName(), -1, evtReader);
+
+ objContext.setReturn(returnValue);
+ }
+ } catch (java.lang.Exception ex) {
+ LOG.log(Level.SEVERE, "CORBA unmarshal exception", ex);
+ throw new CorbaBindingException("CORBA Unmarshal Exception", ex);
+ }
+ }
+
+ public void unmarshalFault(MessageContext mc, ObjectMessageContext objContext,
+ DataBindingCallback callback) {
+ try {
+ DataReader<XMLEventReader> reader = callback.createReader(XMLEventReader.class);
+ if (reader == null) {
+ throw new CorbaBindingException("Unable to create data reader");
+ }
+
+ // TODO: Implement once we have support for exceptions
+ throw new CorbaBindingException("Method unmarshalFault not implemented");
+ } catch (java.lang.Exception ex) {
+ LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
+ // TODO: Throw a exception proper exception once implemented
+ throw new CorbaBindingException("Method unmarshalFault not implemented");
+ }
}
public void write(MessageContext msgContext, OutputStreamMessageContext outContext) throws IOException {
- // TODO - provide implementation. This will likely not be needed for this binding.
+ // Complete. This will not be needed for this binding as we are not
+ // using Celtix transports
+ // which require StreamMessageContexts.
}
-
+
public void read(InputStreamMessageContext inContext, MessageContext context) throws IOException {
- // TODO - provide implementation. This will likely not be needed for this binding.
+ // Complete. This will not be needed for this binding as we are not
+ // using Celtix transports
+ // which require StreamMessageContexts.
}
public boolean hasFault(MessageContext msgContext) {
- // TODO - this may not be the final way that we are going to handle this.
- CorbaMessage msg = ((CorbaMessageContext)msgContext).getMessage();
+ CorbaMessage msg = ((CorbaMessageContext) msgContext).getMessage();
assert msg != null;
- return msg.hasFault();
+ return msg.getException() != null;
}
public void updateMessageContext(MessageContext msgContext) {
// TODO - provide implementation.
}
-}
+
+ public CorbaObjectHolder readCorbaObject(XMLEventReader reader, ArgType argType)
+ throws CorbaBindingException {
+ CorbaObjectHolder obj = null;
+ Stack<CorbaObjectHolder> objStack = new Stack<CorbaObjectHolder>();
+
+ NamedType currentType = null;
+ QName currentIdlType = null;
+
+ try {
+ XMLEvent evt = reader.nextEvent();
+
+ // Find the start of the document. Anything before this we can
+ // ignore.
+ while (!evt.isStartDocument()) {
+ evt = reader.nextEvent();
+ }
+
+ // Build the object until we get an end of document tag
+ while (!evt.isEndDocument()) {
+ switch (evt.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+
+ StartElement startEl = evt.asStartElement();
+
+ if (obj == null) {
+ currentIdlType = argType.getIdltype();
+
+ if (!CorbaUtils.isPrimitiveIdlType(currentIdlType)) {
+ currentType = CorbaUtils.getCorbaType(currentIdlType, typeMaps);
+ if (currentType == null) {
+ throw new CorbaBindingException("Unable to locate type definition");
+ }
+ }
+ } else {
+ // TODO: This is a special case if we have an exception, struct, or union
+ }
+
+ TypeCode tc = CorbaUtils.getTypeCode(orb, currentIdlType, typeMaps);
+ obj = new CorbaObjectHolder(startEl.getName(), currentIdlType, tc, currentType);
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (!objStack.isEmpty()) {
+ CorbaObjectHolder temp = objStack.pop();
+ temp.addMember(obj);
+ obj = temp;
+
+ currentIdlType = obj.getIdlType();
+ currentType = obj.getTypeDefintion();
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ Characters charEl = evt.asCharacters();
+ String data = charEl.getData();
+
+ // An array and sequence are special cases. Store the
+ // elements of the array into
+ // the members of the current object holder.
+ if (currentType instanceof Array || currentType instanceof Sequence) {
+ // TODO: these are special types that will need to be handled differently
+ } else {
+ obj.setValue(data);
+ }
+ break;
+ default:
+ // We can ignore the other cases for now
+ }
+
+ // get the next event
+ evt = reader.nextEvent();
+ }
+ } catch (java.lang.Exception ex) {
+ throw new CorbaBindingException("readCorbaObject exception", ex);
+ }
+
+ return obj;
+ }
+
+ public void writeCorbaObject(CorbaObjectHolder obj, XMLEventWriter writer, XMLEventFactory factory) {
+ try {
+ // If the factory is null, then this should be the beginning of the
+ // object. Create an event factory
+ // and the appropriate start and end document events. The end
+ // document event will be used as a marker
+ // later to indicate when we have found the end of the object data.
+ // TODO: REVISIT. This is no longer needed since we don't apply
+ // start and end document elements.
+ if (factory == null) {
+ factory = XMLEventFactory.newInstance();
+ }
+
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ writer.add(startEl);
+
+ // There are a few special cases we have to watch out for. These can
+ // not simply write character data to the event writer. Instead, they need
+ // to structure the data in the form of additional XML events and
+ // character data.
+ NamedType objType = obj.getTypeDefintion();
+ if (objType instanceof Struct
+ || objType instanceof Exception
+ || objType instanceof Union
+ || objType instanceof Array
+ || objType instanceof Sequence) {
+
+ List<CorbaObjectHolder> structMembers = obj.getMembers();
+ for (int i = 0; i < structMembers.size(); ++i) {
+ writeCorbaObject(structMembers.get(i), writer, factory);
+ }
+ } else {
+ Characters charEvt = factory.createCharacters(obj.getValueData());
+ writer.add(charEvt);
+ }
+
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ writer.add(endEl);
+ } catch (java.lang.Exception ex) {
+ throw new CorbaBindingException("writeCorbaObject exception", ex);
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java Tue Jun 13 12:40:51 2006
@@ -1,57 +1,310 @@
+/**
+ * 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.yoko.bindings.corba;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.wsdl.Port;
import javax.wsdl.WSDLException;
-// TODO imports needed for the DII functionality of the ORB
-//import org.apache.yoko.core.OB.ORB;
+import org.apache.schemas.yoko.bindings.corba.AddressType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.AbstractBindingBase;
import org.objectweb.celtix.bindings.AbstractBindingImpl;
-import org.objectweb.celtix.bindings.AbstractClientBinding;
+import org.objectweb.celtix.bindings.ClientBinding;
import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bindings.ResponseCallback;
+import org.objectweb.celtix.common.logging.LogUtils;
import org.objectweb.celtix.context.ObjectMessageContext;
import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
-public class CorbaClientBinding extends AbstractClientBinding {
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.TypeCode;
+
+public class CorbaClientBinding extends AbstractBindingBase implements
+ ClientBinding {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(CorbaClientBinding.class);
protected final CorbaBindingImpl corbaBinding;
-
- public CorbaClientBinding(Bus b, EndpointReferenceType ref) throws WSDLException, IOException {
+ protected EndpointReferenceType endpointRef;
+ protected ORB orb;
+ protected org.omg.CORBA.Object target;
+
+ public CorbaClientBinding(Bus b, EndpointReferenceType ref)
+ throws WSDLException, IOException {
super(b, ref);
- corbaBinding = new CorbaBindingImpl(b, ref, false);
+ endpointRef = ref;
+
+ // TODO: Set any additional properties needed to initialize the ORB before
+ // we initialize it. We will get this information from the Celtix configuration
+ // that is used with the current application.
+ java.util.Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass",
+ "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "Yoko-Client-Binding");
+
+ orb = ORB.init(new String[0], props);
+ if (orb == null) {
+ LOG.severe("Could not create instance of the ORB");
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Could not create instance of the ORB");
+ }
+
+ try {
+ // obtain a reference to the target object
+ Port wsdlPort = EndpointReferenceUtils.getPort(b.getWSDLManager(),
+ this.endpointRef);
+
+ List extElements = wsdlPort.getExtensibilityElements();
+ AddressType address = null;
+ for (int i = 0; i < extElements.size(); ++i) {
+ Object e = extElements.get(i);
+ if (e instanceof AddressType) {
+ address = (AddressType) e;
+ break;
+ }
+ }
+
+ if (address == null || !isBindingCompatible(address.getLocation())) {
+ LOG.log(Level.SEVERE, "Address not a valid CORBA address");
+ throw new CorbaBindingException("Address not a valid CORBA address");
+ }
+ target = orb.string_to_object(address.getLocation());
+ } catch (Exception ex) {
+ LOG.log(Level.SEVERE, "Could not resolve target object");
+ throw new WSDLException(WSDLException.OTHER_ERROR, "Could not resolve target object", ex);
+ }
+
+ corbaBinding = new CorbaBindingImpl(b, ref, orb, false);
}
-
+
+ // -- from BindingBase interface --
public AbstractBindingImpl getBindingImpl() {
return corbaBinding;
}
+ // -- from ClientBinding interface --
public boolean isBindingCompatible(String address) {
// TODO - add support for file that contain IORs
- return address.startsWith("IOR:") || address.startsWith("corbaloc:");
+ return address.startsWith("IOR:")
+ || address.startsWith("corbaloc:")
+ || address.startsWith("relfile");
}
- // --- Override the default invoke* methods to use the ORB instead of a celtix transport ---
-
- public ObjectMessageContext invoke(ObjectMessageContext objectCtx, DataBindingCallback callback)
- throws IOException {
+ public ResponseCallback createResponseCallback() {
// TODO - provide implementation
return null;
}
- public void invokeOneWay(ObjectMessageContext objectCtx, DataBindingCallback callback)
- throws IOException {
- // TODO - provide implementation
+ public ObjectMessageContext invoke(ObjectMessageContext objectCtx,
+ DataBindingCallback callback) throws IOException {
+ CorbaMessageContext mc = (CorbaMessageContext) corbaBinding.createBindingMessageContext(objectCtx);
+ mc.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);
+
+ corbaBinding.marshal(objectCtx, mc, callback);
+ CorbaMessage message = mc.getMessage();
+
+ try {
+ objectCtx.put(ObjectMessageContext.WSDL_OPERATION, callback.getOperationName());
+
+ // Build the list of DII arguments, contexts, returns, and exceptions
+ CorbaStreamable[] arguments = message.getStreamableArguments();
+ NVList list = orb.create_list(arguments.length);
+
+ for (int i = 0; i < arguments.length; ++i) {
+ Any value = orb.create_any();
+ value.insert_Streamable(arguments[i]);
+ list.add_value(arguments[i].getName(), value, arguments[i].getMode());
+ }
+
+ ContextList ctxList = orb.create_context_list();
+ Context ctx = orb.get_default_context();
+
+ CorbaStreamable retVal = mc.getMessage().getStreamableReturn();
+ NamedValue ret = null;
+ if (retVal != null) {
+ Any returnAny = orb.create_any();
+ returnAny.insert_Streamable(retVal);
+ ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
+ } else {
+ // TODO: REVISIT: for some reason, the yoko ORB does not like to have a null NamedValue
+ // return value. Create this 'empty' one if a void return type is used.
+ ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
+ }
+
+ // Get the typecodes for the exceptions this operation can throw. These are defined in the
+ // operation definition from WSDL.
+ ExceptionList exList = orb.create_exception_list();
+ OperationType operation = CorbaUtils.getCorbaOperationType(callback.getOperationName(),
+ bus,
+ endpointRef);
+
+ if (operation == null) {
+ throw new CorbaBindingException("Unable to obtain operation definition");
+ }
+
+ Map<TypeCode, RaisesType> exceptions = getOperationExceptions(operation);
+ Object[] tcs = exceptions.keySet().toArray();
+ for (int i = 0; i < exceptions.size(); ++i) {
+ exList.add((TypeCode) tcs[i]);
+ }
+
+ Request request =
+ target._create_request(ctx,
+ (String)objectCtx.get(ObjectMessageContext.WSDL_OPERATION),
+ list,
+ ret,
+ exList,
+ ctxList);
+ request.invoke();
+
+ mc.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.FALSE);
+ Exception ex = request.env().exception();
+ if (ex == null) {
+ if (retVal != null) {
+ message.setStreamableReturnValue(retVal.getObject());
+ }
+
+ for (int i = 0; i < list.count(); ++i) {
+ NamedValue arg = (NamedValue) list.item(i);
+ if (arg.flags() != org.omg.CORBA.ARG_IN.value) {
+ CorbaStreamable streamable = (CorbaStreamable)arg.value().extract_Streamable();
+ message.setStreamableArgumentValue(streamable.getObject(), i);
+ }
+ }
+
+ corbaBinding.unmarshal(mc, objectCtx, callback);
+ } else {
+ // TODO: Do we need to check for any particular type of exception? This path
+ // is not complete until we have support for exceptions.
+ message.setException(ex);
+ corbaBinding.unmarshalFault(mc, objectCtx, callback);
+ }
+ } catch (Exception ex) {
+ throw new CorbaBindingException("Exception during invoke", ex);
+ }
+
+ return objectCtx;
}
- public Future<ObjectMessageContext> invokeAsync(ObjectMessageContext objectCtx,
- DataBindingCallback callback,
- Executor executor)
- throws IOException {
- // TODO - provide implementation
- return null;
+ public void invokeOneWay(ObjectMessageContext objectCtx,
+ DataBindingCallback callback) throws IOException {
+ CorbaMessageContext mc = (CorbaMessageContext)corbaBinding.createBindingMessageContext(objectCtx);
+ mc.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);
+
+ corbaBinding.marshal(objectCtx, mc, callback);
+ CorbaMessage message = mc.getMessage();
+
+ try {
+ CorbaStreamable[] arguments = message.getStreamableArguments();
+ NVList list = orb.create_list(arguments.length);
+
+ for (int i = 0; i < arguments.length; ++i) {
+ Any value = orb.create_any();
+ value.insert_Streamable(arguments[i]);
+ list.add_value(arguments[i].getName(), value, arguments[i].getMode());
+ }
+
+ ContextList ctxList = orb.create_context_list();
+ Context ctx = orb.get_default_context();
+
+ // TODO: This doen't really apply to a oneway since we are not expecting a return.
+ CorbaStreamable retVal = mc.getMessage().getStreamableReturn();
+ NamedValue ret = null;
+ if (retVal != null) {
+ Any returnAny = orb.create_any();
+ returnAny.insert_Streamable(retVal);
+ ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
+ } else {
+ // TODO: REVISIT: for some reason, the yoko ORB does not like to have a null NamedValue
+ // return value. Create this 'empty' one if a void return type is used.
+ ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
+ }
+
+ // Get the typecodes for the exceptions this operation can throw. These are defined in the
+ // operation definition from WSDL.
+ ExceptionList exList = orb.create_exception_list();
+ OperationType operation = CorbaUtils.getCorbaOperationType(callback.getOperationName(),
+ bus,
+ endpointRef);
+
+ if (operation == null) {
+ throw new CorbaBindingException("Unable to obtain operation definition");
+ }
+
+ Map<TypeCode, RaisesType> exceptions = getOperationExceptions(operation);
+ Object[] tcs = exceptions.keySet().toArray();
+ for (int i = 0; i < exceptions.size(); ++i) {
+ exList.add((TypeCode) tcs[i]);
+ }
+
+ Request request =
+ target._create_request(ctx,
+ (String)objectCtx.get(ObjectMessageContext.WSDL_OPERATION),
+ list,
+ ret,
+ exList,
+ ctxList);
+ request.send_oneway();
+ } catch (java.lang.Exception ex) {
+ throw new CorbaBindingException("Exception during invokeOneWay", ex);
+ }
+ }
+
+ public Future<ObjectMessageContext> invokeAsync(
+ ObjectMessageContext objectCtx, DataBindingCallback callback,
+ Executor executor) throws IOException {
+ throw new CorbaBindingException("invokeAsync not yet implemented");
+ }
+
+ public Map<TypeCode, RaisesType> getOperationExceptions(
+ OperationType operation) {
+
+ Map<TypeCode, RaisesType> exceptions = new HashMap<TypeCode, RaisesType>();
+ List<RaisesType> exList = operation.getRaises();
+
+ for (int i = 0; i < exList.size(); ++i) {
+ RaisesType ex = exList.get(i);
+ TypeCode tc = CorbaUtils.getTypeCode(orb, ex.getException(), corbaBinding.getCorbaTypeMaps());
+ exceptions.put(tc, ex);
+ }
+
+ return exceptions;
}
-}
+}
\ No newline at end of file
Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConstants.java?rev=413964&view=auto
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConstants.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConstants.java Tue Jun 13 12:40:51 2006
@@ -0,0 +1,86 @@
+/**
+ * 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.yoko.bindings.corba;
+
+import javax.xml.namespace.QName;
+
+// NOTE: This currently contains duplicates of the class in tools. It would
+// probably be better
+// somewhere more common (e.g. api) so that both the tools and bindings can make
+// used of the
+// definitions contained here.
+public interface CorbaConstants {
+
+ String NP_WSDL_CORBA = "corba";
+ String NU_WSDL_CORBA = "http://schemas.apache.org/yoko/bindings/corba";
+
+ // CORBA Binding Extensibility Elements
+ QName NE_CORBA_ADDRESS = new QName(NU_WSDL_CORBA, "address", NP_WSDL_CORBA);
+ QName NE_CORBA_POLICY = new QName(NU_WSDL_CORBA, "policy", NP_WSDL_CORBA);
+ QName NE_CORBA_BINDING = new QName(NU_WSDL_CORBA, "binding", NP_WSDL_CORBA);
+ QName NE_CORBA_OPERATION = new QName(NU_WSDL_CORBA, "operation", NP_WSDL_CORBA);
+ QName NE_CORBA_PARAM = new QName(NU_WSDL_CORBA, "param", NP_WSDL_CORBA);
+ QName NE_CORBA_RETURN = new QName(NU_WSDL_CORBA, "return", NP_WSDL_CORBA);
+ QName NE_CORBA_RAISES = new QName(NU_WSDL_CORBA, "raises", NP_WSDL_CORBA);
+
+ // CORBA Type Mapping Extensiblity Elements
+ QName NE_CORBA_TYPEMAPPING = new QName(NU_WSDL_CORBA, "typeMapping", NP_WSDL_CORBA);
+ QName NE_CORBA_STRUCT = new QName(NU_WSDL_CORBA, "struct", NP_WSDL_CORBA);
+ QName NE_CORBA_STRUCT_MEM = new QName(NU_WSDL_CORBA, "member", NP_WSDL_CORBA);
+ QName NE_CORBA_UNION = new QName(NU_WSDL_CORBA, "union", NP_WSDL_CORBA);
+ QName NE_CORBA_UNION_BRANCH = new QName(NU_WSDL_CORBA, "unionbranch", NP_WSDL_CORBA);
+ QName NE_CORBA_UNION_CASE = new QName(NU_WSDL_CORBA, "case", NP_WSDL_CORBA);
+ QName NE_CORBA_ALIAS = new QName(NU_WSDL_CORBA, "alias", NP_WSDL_CORBA);
+ QName NE_CORBA_FIXED = new QName(NU_WSDL_CORBA, "fixed", NP_WSDL_CORBA);
+ QName NE_CORBA_ANONFIXED = new QName(NU_WSDL_CORBA, "anonfixed", NP_WSDL_CORBA);
+ QName NE_CORBA_CONST = new QName(NU_WSDL_CORBA, "const", NP_WSDL_CORBA);
+ QName NE_CORBA_ENUM = new QName(NU_WSDL_CORBA, "enum", NP_WSDL_CORBA);
+ QName NE_CORBA_ENUMERATOR = new QName(NU_WSDL_CORBA, "enumerator", NP_WSDL_CORBA);
+ QName NE_CORBA_SEQUENCE = new QName(NU_WSDL_CORBA, "sequence", NP_WSDL_CORBA);
+ QName NE_CORBA_ANONSEQUENCE = new QName(NU_WSDL_CORBA, "anonsequence", NP_WSDL_CORBA);
+ QName NE_CORBA_ARRAY = new QName(NU_WSDL_CORBA, "array", NP_WSDL_CORBA);
+ QName NE_CORBA_ANONARRAY = new QName(NU_WSDL_CORBA, "anonarray", NP_WSDL_CORBA);
+ QName NE_CORBA_ANONSTRING = new QName(NU_WSDL_CORBA, "anonstring", NP_WSDL_CORBA);
+ QName NE_CORBA_ANONWSTRING = new QName(NU_WSDL_CORBA, "anonwstring", NP_WSDL_CORBA);
+ QName NE_CORBA_EXCEPTION = new QName(NU_WSDL_CORBA, "exception", NP_WSDL_CORBA);
+ QName NE_CORBA_INTERFACE = new QName(NU_WSDL_CORBA, "object", NP_WSDL_CORBA);
+
+ // CORBA Primitive Types
+ QName NT_CORBA_LONG = new QName(NU_WSDL_CORBA, "long", NP_WSDL_CORBA);
+ QName NT_CORBA_ULONG = new QName(NU_WSDL_CORBA, "ulong", NP_WSDL_CORBA);
+ QName NT_CORBA_LONGLONG = new QName(NU_WSDL_CORBA, "longlong", NP_WSDL_CORBA);
+ QName NT_CORBA_ULONGLONG = new QName(NU_WSDL_CORBA, "ulonglong", NP_WSDL_CORBA);
+ QName NT_CORBA_SHORT = new QName(NU_WSDL_CORBA, "short", NP_WSDL_CORBA);
+ QName NT_CORBA_USHORT = new QName(NU_WSDL_CORBA, "ushort", NP_WSDL_CORBA);
+ QName NT_CORBA_FLOAT = new QName(NU_WSDL_CORBA, "float", NP_WSDL_CORBA);
+ QName NT_CORBA_DOUBLE = new QName(NU_WSDL_CORBA, "double", NP_WSDL_CORBA);
+ QName NT_CORBA_CHAR = new QName(NU_WSDL_CORBA, "char", NP_WSDL_CORBA);
+ QName NT_CORBA_WCHAR = new QName(NU_WSDL_CORBA, "wchar", NP_WSDL_CORBA);
+ QName NT_CORBA_BOOLEAN = new QName(NU_WSDL_CORBA, "boolean", NP_WSDL_CORBA);
+ QName NT_CORBA_OCTET = new QName(NU_WSDL_CORBA, "octet", NP_WSDL_CORBA);
+ QName NT_CORBA_STRING = new QName(NU_WSDL_CORBA, "string", NP_WSDL_CORBA);
+ QName NT_CORBA_WSTRING = new QName(NU_WSDL_CORBA, "wstring", NP_WSDL_CORBA);
+ QName NT_CORBA_ANY = new QName(NU_WSDL_CORBA, "any", NP_WSDL_CORBA);
+ QName NT_CORBA_DATETIME = new QName(NU_WSDL_CORBA, "dateTime", NP_WSDL_CORBA);
+ QName NT_CORBA_LONGDOUBLE = new QName(NU_WSDL_CORBA, "double", NP_WSDL_CORBA);
+ QName NT_CORBA_DATE = new QName(NU_WSDL_CORBA, "date", NP_WSDL_CORBA);
+ QName NT_CORBA_TIME = new QName(NU_WSDL_CORBA, "time", NP_WSDL_CORBA);
+
+ String getValue(String value);
+}
Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java?rev=413964&view=auto
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java (added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java Tue Jun 13 12:40:51 2006
@@ -0,0 +1,267 @@
+/**
+ * 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.yoko.bindings.corba;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.schemas.yoko.bindings.corba.Array;
+import org.apache.schemas.yoko.bindings.corba.BindingType;
+import org.apache.schemas.yoko.bindings.corba.Exception;
+import org.apache.schemas.yoko.bindings.corba.MemberType;
+import org.apache.schemas.yoko.bindings.corba.ModeType;
+import org.apache.schemas.yoko.bindings.corba.NamedType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.ParamType;
+import org.apache.schemas.yoko.bindings.corba.Sequence;
+import org.apache.schemas.yoko.bindings.corba.Struct;
+// import org.apache.schemas.yoko.bindings.corba.Union;
+
+import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.context.GenericMessageContext;
+import org.objectweb.celtix.context.ObjectMessageContext;
+import org.objectweb.celtix.context.WebServiceContextImpl;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ServerRequest;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.PortableServer.DynamicImplementation;
+import org.omg.PortableServer.POA;
+
+public class CorbaDSIServant extends DynamicImplementation {
+
+ private final ORB orb;
+ private final POA servantPOA;
+ private final CorbaServerBinding serverBinding;
+ private ServerBindingEndpointCallback sbeCallback;
+ private List<String> interfaces;
+
+ public CorbaDSIServant(ORB theOrb, POA poa, CorbaServerBinding binding,
+ ServerBindingEndpointCallback epCallback) {
+ orb = theOrb;
+ servantPOA = poa;
+ serverBinding = binding;
+ sbeCallback = epCallback;
+
+ // Get the list of interfaces that this servant will support
+ try {
+ BindingType bindType = CorbaUtils.getCorbaBindingType(binding.getBus(),
+ binding.getEndpointReference());
+ if (bindType == null) {
+ throw new CorbaBindingException("Unable to determine binding information");
+ }
+
+ List<String> bases = bindType.getBases();
+ interfaces = new ArrayList<String>();
+ interfaces.add(bindType.getRepositoryID());
+ for (int i = 0; i < bases.size(); ++i) {
+ interfaces.add(bases.get(i));
+ }
+ } catch (java.lang.Exception ex) {
+ // TODO: For now, this exception is consumed. Revisit this to see if
+ // it is the best way to handle this.
+ }
+ }
+
+ public void invoke(ServerRequest request) throws CorbaBindingException {
+ try {
+ CorbaMessageContext corbaCtx =
+ (CorbaMessageContext)serverBinding.getBindingImpl().
+ createBindingMessageContext(new GenericMessageContext());
+ corbaCtx.setMessage(new CorbaMessage());
+ corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.TRUE);
+
+ QName operationName = new QName(request.operation());
+ corbaCtx.put(MessageContext.WSDL_OPERATION, operationName);
+
+ ObjectMessageContext objectCtx = serverBinding.createObjectContext();
+ DataBindingCallback.Mode mode = sbeCallback.getServiceMode();
+ DataBindingCallback callback =
+ sbeCallback.getDataBindingCallback((QName)corbaCtx.get(MessageContext.WSDL_OPERATION),
+ objectCtx,
+ mode);
+ callback.initObjectContext(objectCtx);
+ objectCtx.putAll(corbaCtx);
+
+ // Get the WSDL definition for the operation being invoked
+ // TODO: Verify that two operations can't be overloaded.
+ OperationType opElement = CorbaUtils.getCorbaOperationType(operationName.getLocalPart(),
+ serverBinding.getBus(),
+ serverBinding.getEndpointReference());
+ if (opElement == null) {
+ throw new CorbaBindingException("Unable to locate operation type definition");
+ }
+
+ List<ParamType> paramTypes = opElement.getParam();
+ List<CorbaTypeMap> typeMaps =
+ ((CorbaBindingImpl)serverBinding.getBindingImpl()).getCorbaTypeMaps();
+
+ // Build a list of streamables that correspond to the values that should be contained in the
+ // argument list of the ServerRequest, build the correct NVList and retreive the arguments
+ CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
+ NVList list = orb.create_list(arguments.length);
+ for (int i = 0; i < paramTypes.size(); ++i) {
+ ParamType pType = paramTypes.get(i);
+ QName paramName = new QName(pType.getName());
+ QName paramIdlType = pType.getIdltype();
+ ModeType paramMode = pType.getMode();
+
+ CorbaObjectHolder obj = createCorbaObjectHolder(paramName, paramIdlType, typeMaps);
+
+ arguments[i] = new CorbaStreamable(obj, paramName);
+ if (paramMode.value().equals("in")) {
+ arguments[i].setMode(org.omg.CORBA.ARG_IN.value);
+ } else if (paramMode.value().equals("out")) {
+ arguments[i].setMode(org.omg.CORBA.ARG_OUT.value);
+ } else {
+ arguments[i].setMode(org.omg.CORBA.ARG_INOUT.value);
+ }
+
+ Any value = orb.create_any();
+ value.insert_Streamable(arguments[i]);
+ list.add_value(arguments[i].getName(), value, arguments[i].getMode());
+ corbaCtx.getMessage().addStreamableArgument(arguments[i]);
+ }
+ request.arguments(list);
+
+ serverBinding.getBindingImpl().unmarshal(corbaCtx, objectCtx, callback);
+
+ // TODO: Set if the request is one way or not. This needs to be determined
+ boolean isOneWay = false;
+
+ ServerDataBindingCallback method = (ServerDataBindingCallback) callback;
+ new WebServiceContextImpl(objectCtx);
+ method.invoke(objectCtx);
+
+ corbaCtx.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.FALSE);
+ if (!isOneWay) {
+ serverBinding.getBindingImpl().marshal(objectCtx, corbaCtx, callback);
+
+ arguments = corbaCtx.getMessage().getStreamableArguments();
+ for (int i = 0; i < arguments.length; ++i) {
+ if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
+ list.item(i).value().insert_Streamable(arguments[i]);
+ }
+ }
+
+ CorbaStreamable resultValue = corbaCtx.getMessage().getStreamableReturn();
+ if (resultValue != null) {
+ Any resultAny = orb.create_any();
+ resultAny.insert_Streamable(resultValue);
+ request.set_result(resultAny);
+ }
+ }
+
+ } catch (java.lang.Exception ex) {
+ throw new CorbaBindingException("Exception during invoke", ex);
+ }
+ }
+
+ public String[] _all_interfaces(POA poa, byte[] objectId) {
+ return interfaces.toArray(new String[interfaces.size()]);
+ }
+
+ public CorbaObjectHolder createCorbaObjectHolder(QName name,
+ QName idlType,
+ List<CorbaTypeMap> typeMaps) {
+ CorbaObjectHolder obj = null;
+ TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMaps);
+
+ if (!CorbaUtils.isPrimitiveIdlType(idlType)) {
+ NamedType typeDef = CorbaUtils.getCorbaType(idlType, typeMaps);
+
+ if (typeDef == null) {
+ throw new CorbaBindingException("Unable to locate type definition");
+ }
+
+ obj = new CorbaObjectHolder(name, idlType, tc, typeDef);
+
+ TCKind typeKind = tc.kind();
+ switch (typeKind.value()) {
+ case TCKind._tk_array:
+ Array arrayType = (Array) typeDef;
+ QName arrayElementType = arrayType.getElemtype();
+ for (int i = 0; i < arrayType.getBound(); ++i) {
+ QName elementName = new QName(arrayType.getName() + "[" + i + "]");
+ CorbaObjectHolder elementObj =
+ createCorbaObjectHolder(elementName, arrayElementType, typeMaps);
+ obj.addMember(elementObj);
+ }
+ break;
+ case TCKind._tk_except:
+ Exception exceptType = (Exception) typeDef;
+ List<MemberType> exceptMembers = exceptType.getMember();
+
+ for (int i = 0; i < exceptMembers.size(); ++i) {
+ MemberType member = exceptMembers.get(i);
+ QName memberName = new QName(member.getName());
+ QName memberType = member.getIdltype();
+ CorbaObjectHolder memberObj = createCorbaObjectHolder(memberName, memberType, typeMaps);
+ obj.addMember(memberObj);
+ }
+ break;
+ case TCKind._tk_sequence:
+ Sequence seqType = (Sequence) typeDef;
+ QName seqElementType = seqType.getElemtype();
+ for (int i = 0; i < seqType.getBound(); ++i) {
+ QName elementName = new QName(seqType.getName() + "[" + i + "]");
+ CorbaObjectHolder elementObj =
+ createCorbaObjectHolder(elementName, seqElementType, typeMaps);
+ obj.addMember(elementObj);
+ }
+ break;
+ case TCKind._tk_struct:
+ Struct structType = (Struct) typeDef;
+ List<MemberType> structMembers = structType.getMember();
+
+ for (int i = 0; i < structMembers.size(); ++i) {
+ MemberType member = structMembers.get(i);
+ QName memberName = new QName(member.getName());
+ QName memberType = member.getIdltype();
+ CorbaObjectHolder memberObj = createCorbaObjectHolder(memberName, memberType, typeMaps);
+ obj.addMember(memberObj);
+ }
+ break;
+ case TCKind._tk_union:
+ // Union unionType = (Union)typeDef;
+ // TODO: provide implementation
+ break;
+ default:
+ // TODO: Should we raise an exception or log?
+ }
+
+ } else {
+ obj = new CorbaObjectHolder(name, idlType, tc, null);
+ }
+
+ return obj;
+ }
+
+ public POA _default_POA() {
+ return servantPOA;
+ }
+}
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessage.java Tue Jun 13 12:40:51 2006
@@ -1,21 +1,106 @@
+/**
+ * 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.yoko.bindings.corba;
-import java.io.*;
-import org.w3c.dom.*;
+import java.util.ArrayList;
+import java.util.List;
public class CorbaMessage {
+ private String operation;
+ private List<CorbaStreamable> arguments;
+ private CorbaStreamable returnParam;
+ private Exception exception;
+
public CorbaMessage() {
- // TODO - provide implementation
+ operation = null;
+ arguments = new ArrayList<CorbaStreamable>();
+ returnParam = null;
+ exception = null;
+ }
+
+ public String getOperationName() {
+ return operation;
+ }
+
+ public void setOperationName(String opName) {
+ operation = opName;
+ }
+
+ public void setException(Exception ex) {
+ exception = ex;
}
-
- public boolean hasFault() {
- // TODO - provide implementation
- return false;
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public CorbaStreamable[] getStreamableArguments() {
+ return arguments.toArray(new CorbaStreamable[0]);
+ }
+
+ public CorbaStreamable getStreamableReturn() {
+ return returnParam;
+ }
+
+ public void addStreamableArgument(CorbaStreamable arg) {
+ if (arguments == null) {
+ arguments = new ArrayList<CorbaStreamable>(1);
+ }
+
+ arguments.add(arg);
+ }
+
+ public void setStreamableArguments(CorbaStreamable[] data) {
+ if (arguments == null) {
+ arguments = new ArrayList<CorbaStreamable>(data.length);
+ }
+
+ for (int i = 0; i < data.length; ++i) {
+ arguments.set(i, data[i]);
+ }
+ }
+
+ public void setStreamableArgumentValue(CorbaObjectHolder data, int idx) {
+ if (idx >= arguments.size()) {
+ throw new CorbaBindingException("setStreamableArgumentValue: Index out of range");
+ }
+
+ arguments.get(idx).setObject(data);
+ }
+
+ public void setStreamableArgumentValues(CorbaObjectHolder[] data) {
+ for (int i = 0; i < data.length; ++i) {
+ arguments.get(i).setObject(data[i]);
+ }
+ }
+
+ public void setStreamableReturn(CorbaStreamable data) {
+ returnParam = data;
+ }
+
+ public void setStreamableReturnValue(CorbaObjectHolder data) {
+ returnParam.setObject(data);
}
public String toString() {
- // TODO - provide implementation
- return "CorbaMessage";
+ // TODO: Add a more complete toString
+ return operation;
}
-}
+}
\ No newline at end of file
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContext.java Tue Jun 13 12:40:51 2006
@@ -1,9 +1,27 @@
+/**
+ * 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.yoko.bindings.corba;
import javax.xml.ws.handler.MessageContext;
interface CorbaMessageContext extends MessageContext {
CorbaMessage getMessage();
+
void setMessage(CorbaMessage message);
}
-
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java?rev=413964&r1=413963&r2=413964&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaMessageContextImpl.java Tue Jun 13 12:40:51 2006
@@ -1,23 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.yoko.bindings.corba;
-import java.util.*;
-
import javax.xml.ws.handler.MessageContext;
import org.objectweb.celtix.context.MessageContextWrapper;
-class CorbaMessageContextImpl extends MessageContextWrapper implements CorbaMessageContext {
+class CorbaMessageContextImpl extends MessageContextWrapper implements
+ CorbaMessageContext {
private static final long serialVersionUID = 1L;
+
private static final String CORBA_MESSAGE = "org.apache.yoko.core.binding.message";
public CorbaMessageContextImpl(MessageContext ctx) {
super(ctx);
}
-
+
public CorbaMessage getMessage() {
- return (CorbaMessage)get(CORBA_MESSAGE);
+ return (CorbaMessage) get(CORBA_MESSAGE);
}
-
+
public void setMessage(CorbaMessage corbaMsg) {
put(CORBA_MESSAGE, corbaMsg);
setScope(CORBA_MESSAGE, MessageContext.Scope.HANDLER);