You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/06/07 09:15:40 UTC
svn commit: r664294 [7/10] - in
/incubator/tuscany/sandbox/sebastien/java/sca-test2: ./ demos/
demos/bigbank/ demos/bigbank/src/main/java/bigbank/account/feed/
demos/secure-bigbank/ demos/secure-bigbank/secure-bigbank-account/
demos/secure-bigbank/secu...
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,159 @@
+/*
+ * 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.tuscany.sca.data.collection;
+
+import java.util.Date;
+
+
+/**
+ * Represents a data item.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Item {
+
+ private String title;
+ private String contents;
+ private String link;
+ private String related;
+ private String alternate;
+ private Date date;
+
+ /**
+ * Constructs a new item.
+ */
+ public Item() {
+ }
+
+ /**
+ * Constructs a new item.
+ * @param title the item title
+ * @param contents the item contents
+ * @param link the item link to a web resource
+ * @param related the item link to a related web resource
+ * @param date the item date
+ */
+ public Item(String title, String contents, String link, String related, Date date) {
+ this.title = title;
+ this.contents = contents;
+ this.link = link;
+ this.related = related;
+ this.date = date;
+ }
+
+ /**
+ * Returns the item title.
+ * @return the item title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the item title.
+ * @param title the item title
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the item contents
+ * @return the item contents
+ */
+ public String getContents() {
+ return contents;
+ }
+
+ /**
+ * Sets the item contents
+ * @param contents the item contents
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Returns the item link to a web resource
+ * @return the item link to a web resource
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * Sets the item link to a web resource
+ * @param link the item link to a web resource
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ /**
+ * Returns the item link to a related web resource
+ * @return the item link to a related web resource
+ */
+ public String getRelated() {
+ return related;
+ }
+
+ /**
+ * Sets the item link to a related web resource.
+ *
+ * @param related the item link to a related web resource
+ */
+ public void setRelated(String related) {
+ this.related = related;
+ }
+
+ /**
+ * Returns the item link to an alternate web resource
+ * @return the item link to an alternate web resource
+ */
+ public String getAlternate() {
+ return alternate;
+ }
+
+ /**
+ * Sets the item link to an alternate web resource.
+ *
+ * @param alternate the item link to an alternate web resource
+ */
+ public void setAlternate(String alternate) {
+ this.alternate = alternate;
+ }
+
+ /**
+ * Returns the item date
+ * @return the item date
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Sets the item date
+ * @param date the item date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.tuscany.sca.data.collection;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface ItemCollection extends Collection<String, Item> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.tuscany.sca.data.collection;
+
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LocalItemCollection extends Collection<String, Item> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.tuscany.sca.data.collection;
+
+/**
+ * Indicates that an item could not be found in a collection.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = 6792367409396084646L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Collection.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Collection.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Collection.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Collection.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@Deprecated
+public interface Collection <K, D> extends org.apache.tuscany.sca.data.collection.Collection<K, D> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Entry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Entry.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Entry.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Entry.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,29 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+
+/**
+ * Represents a key/data pair in a data collection.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class Entry <K, D> extends org.apache.tuscany.sca.data.collection.Entry<K, D> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Item.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Item.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Item.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/Item.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+
+
+/**
+ * Represents a data item.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class Item extends org.apache.tuscany.sca.data.collection.Item {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/ItemCollection.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/ItemCollection.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/ItemCollection.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/ItemCollection.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@Deprecated
+public interface ItemCollection extends Collection<String, Item> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/LocalItemCollection.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/LocalItemCollection.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/LocalItemCollection.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/LocalItemCollection.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,29 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public interface LocalItemCollection extends Collection<String, Item> {
+}
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/NotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/NotFoundException.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/NotFoundException.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/data-api/src/main/java/org/apache/tuscany/sca/implementation/data/collection/NotFoundException.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.tuscany.sca.implementation.data.collection;
+
+/**
+ * Indicates that an item could not be found in a collection.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class NotFoundException extends org.apache.tuscany.sca.data.collection.NotFoundException {
+ private static final long serialVersionUID = 2812975065056330240L;
+}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java Sat Jun 7 00:15:29 2008
@@ -34,9 +34,11 @@
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.WrapperHandler;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
/**
@@ -109,11 +111,12 @@
}
/**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(org.apache.tuscany.sca.interfacedef.util.ElementInfo, Class, org.apache.tuscany.sca.databinding.TransformationContext)
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
*/
- public DataType getWrapperType(ElementInfo element,
- Class<? extends OMElement> wrapperClass,
- TransformationContext context) {
+ public DataType getWrapperType(Operation operation,
+ boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ ElementInfo element = input? wrapper.getInputWrapperElement(): wrapper.getOutputWrapperElement();
DataType<XMLType> wrapperType =
new DataTypeImpl<XMLType>(AxiomDataBinding.NAME, OMElement.class, new XMLType(element));
return wrapperType;
Added: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java?rev=664294&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java Sat Jun 7 00:15:29 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.tuscany.databinding.jaxb.axiom;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Test;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OMElement2JAXBTestCase {
+ private static final String XML =
+ "<ns1:root xmlns:ns1=\"http://ns1\" xmlns:ns2=\"http://www.example.com/IPO\">" + "<ns2:purchaseOrder>"
+ + "<shipTo xsi:type=\"ns2:USAddress\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ + "<street>ABC St.</street><city>San Jose</city><state>CA</state></shipTo>"
+ + "<ns2:comment>123</ns2:comment><items/>"
+ + "</ns2:purchaseOrder>"
+ + "</ns1:root>";
+
+ @Test
+ public void testTransform() throws Exception {
+ DataType<?> sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, XMLType.UNKNOWN);
+ QName qname = new QName("http://www.example.com/IPO", "purchaseOrder");
+ DataType<?> targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(qname, null));
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setSourceDataType(sourceDataType);
+ tContext.setTargetDataType(targetDataType);
+
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(XML.getBytes("UTF-8")));
+ OMElement root = builder.getDocumentElement();
+ OMElement po = (OMElement)root.getChildElements().next();
+ Object jaxb = new OMElement2JAXB().transform(po, tContext);
+ Assert.assertTrue(jaxb instanceof PurchaseOrderType);
+ }
+}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java Sat Jun 7 00:15:29 2008
@@ -53,6 +53,8 @@
* @version $Rev$ $Date$
*/
public class JAXBContextCache {
+ private static final int CACHE_SIZE = 128;
+
private static HashMap<String, Class<?>> loadClassMap = new HashMap<String, Class<?>>();
static {
@@ -89,7 +91,7 @@
protected JAXBContext commonContext;
public JAXBContextCache() {
- this(64, 64, 64);
+ this(CACHE_SIZE, CACHE_SIZE, CACHE_SIZE);
}
public JAXBContextCache(int contextSize, int marshallerSize, int unmarshallerSize) {
@@ -197,6 +199,10 @@
}
}
+ public LRUCache<Object, JAXBContext> getCache() {
+ return cache;
+ }
+
public JAXBContext getJAXBContext(Class<?> cls) throws JAXBException {
if (COMMON_CLASSES_SET.contains(cls)) {
return commonContext;
@@ -226,6 +232,29 @@
}
}
+ public JAXBContext getJAXBContext(Class<?>[] classes) throws JAXBException {
+ Set<Class<?>> classSet = new HashSet<Class<?>>(Arrays.asList(classes));
+ return getJAXBContext(classSet);
+ }
+
+ public JAXBContext getJAXBContext(Set<Class<?>> classes) throws JAXBException {
+ if (COMMON_CLASSES_SET.containsAll(classes)) {
+ return commonContext;
+ }
+ if (classes.size() == 1) {
+ return getJAXBContext(classes.iterator().next());
+ }
+ synchronized (cache) {
+ JAXBContext context = cache.get(classes);
+ if (context != null) {
+ return context;
+ }
+ context = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()]));
+ cache.put(classes, context);
+ return context;
+ }
+ }
+
public void clear() {
synchronized (cache) {
cache.clear();
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java Sat Jun 7 00:15:29 2008
@@ -20,6 +20,10 @@
import java.beans.Introspector;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@@ -39,7 +43,13 @@
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.TransformationException;
import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextCache.LRUCache;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.w3c.dom.Node;
@@ -59,6 +69,12 @@
private JAXBContextHelper() {
}
+ /**
+ * Create a JAXBContext for a given class
+ * @param cls
+ * @return
+ * @throws JAXBException
+ */
public static JAXBContext createJAXBContext(Class<?> cls) throws JAXBException {
return cache.getJAXBContext(cls);
}
@@ -147,6 +163,95 @@
}
}
+ /**
+ * Create a JAXContext for an array of classes
+ * @param classes
+ * @return
+ * @throws JAXBException
+ */
+ public static JAXBContext createJAXBContext(Class<?>[] classes) throws JAXBException {
+ return cache.getJAXBContext(classes);
+ }
+
+ /**
+ * Create a JAXBContext for a given java interface
+ * @param intf
+ * @return
+ * @throws JAXBException
+ */
+ public static JAXBContext createJAXBContext(Interface intf, boolean useWrapper) throws JAXBException {
+ synchronized (cache) {
+ LRUCache<Object, JAXBContext> map = cache.getCache();
+ Integer key = new Integer(System.identityHashCode(intf));
+ JAXBContext context = map.get(key);
+ if (context != null) {
+ return context;
+ }
+ List<DataType> dataTypes = getDataTypes(intf, useWrapper);
+ context = createJAXBContext(dataTypes);
+ map.put(key, context);
+ return context;
+ }
+ }
+
+ public static JAXBContext createJAXBContext(List<DataType> dataTypes) throws JAXBException {
+ JAXBContext context;
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ for (DataType d : dataTypes) {
+ if (JAXBDataBinding.NAME.equals(d.getDataBinding()) || JavaBeansDataBinding.NAME.equals(d
+ .getDataBinding())
+ || SimpleJavaDataBinding.NAME.equals(d.getDataBinding())) {
+ if (!d.getPhysical().isInterface()) {
+ classes.add(d.getPhysical());
+ }
+ }
+ }
+
+ context = createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
+ return context;
+ }
+
+ public static JAXBContext createJAXBContext(Interface intf) throws JAXBException {
+ return createJAXBContext(intf, true);
+ }
+
+ /**
+ * @param intf
+ * @param useWrapper Use wrapper classes?
+ * @return
+ */
+ private static List<DataType> getDataTypes(Interface intf, boolean useWrapper) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ for (Operation op : intf.getOperations()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (useWrapper && wrapper != null) {
+ DataType dt1 = wrapper.getInputWrapperType();
+ if (dt1 != null) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = wrapper.getOutputWrapperType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ } else {
+ for (DataType dt1 : op.getInputType().getLogical()) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = op.getOutputType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ }
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ if (dt4 != null) {
+ dataTypes.add(dt4);
+ }
+ }
+ }
+ return dataTypes;
+ }
+
public static Class<?> getJavaType(DataType<?> dataType) {
if (dataType == null) {
return null;
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java Sat Jun 7 00:15:29 2008
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.databinding.jaxb;
-import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -32,6 +31,7 @@
import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
import org.apache.tuscany.sca.databinding.impl.DOMHelper;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.w3c.dom.Document;
@@ -57,7 +57,7 @@
}
@Override
- public boolean introspect(DataType dataType, Annotation[] annotations) {
+ public boolean introspect(DataType dataType, Operation operation) {
Class javaType = dataType.getPhysical();
if (JAXBElement.class.isAssignableFrom(javaType)) {
Type type = javaType.getGenericSuperclass();
@@ -102,7 +102,7 @@
} else {
arg = new JAXBElement(ROOT_ELEMENT, Object.class, arg);
}
- JAXBContext context = JAXBContext.newInstance(cls);
+ JAXBContext context = JAXBContextHelper.createJAXBContext(cls);
Document doc = DOMHelper.newDocument();
context.createMarshaller().marshal(arg, doc);
JAXBElement<?> element = context.createUnmarshaller().unmarshal(doc, cls);
@@ -119,7 +119,8 @@
@Override
public XMLTypeHelper getXMLTypeHelper() {
- return xmlTypeHelper;
+ return new JAXBTypeHelper();
+ // return xmlTypeHelper;
}
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java Sat Jun 7 00:15:29 2008
@@ -37,13 +37,15 @@
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.apache.tuscany.sca.xsd.XSDFactory;
import org.apache.tuscany.sca.xsd.XSDefinition;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.osoa.sca.ServiceRuntimeException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -52,7 +54,7 @@
private static final String ANYTYPE_NAME = "anyType";
private static final QName ANYTYPE_QNAME = new QName(SCHEMA_NS, ANYTYPE_NAME);
- private List<Class<?>> types = new ArrayList<Class<?>>();
+ // private List<Class<?>> types = new ArrayList<Class<?>>();
public JAXBTypeHelper() {
super();
@@ -65,7 +67,7 @@
} else if (javaType.isInterface()) {
return new TypeInfo(ANYTYPE_QNAME, true, null);
} else {
- types.add(javaType);
+ // types.add(javaType);
if (logical instanceof XMLType) {
xmlType = ((XMLType)logical).getTypeName();
}
@@ -77,11 +79,13 @@
}
}
+ /*
public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver) {
List<XSDefinition> definitions = new ArrayList<XSDefinition>();
generateJAXBSchemas(definitions, factory);
return definitions;
}
+ */
public static Map<String, String> generateSchema(JAXBContext context) throws IOException {
StringResolverImpl resolver = new StringResolverImpl();
@@ -113,21 +117,22 @@
}
+ /*
private void generateJAXBSchemas1(List<XSDefinition> definitions, XSDFactory factory) {
if (types.size() > 0) {
try {
XmlSchemaCollection collection = new XmlSchemaCollection();
Class[] typesArray = new Class[types.size()];
typesArray = types.toArray(typesArray);
- JAXBContext context = JAXBContext.newInstance(typesArray);
+ JAXBContext context = JAXBContextHelper.createJAXBContext(typesArray);
Map<String, String> results = generateSchema(context);
collection.setSchemaResolver(new XSDResolver(results));
-
+
for (Map.Entry<String, String> entry : results.entrySet()) {
XSDefinition definition = factory.createXSDefinition();
int index = entry.getKey().lastIndexOf('#');
String ns = entry.getKey().substring(0, index);
- String file = entry.getKey().substring(index+1);
+ String file = entry.getKey().substring(index + 1);
definition.setUnresolved(true);
definition.setNamespace(ns);
definition.setSchema(collection.read(new StringReader(entry.getValue()), null));
@@ -140,6 +145,7 @@
}
}
}
+ */
private static class DOMResolverImpl extends SchemaOutputResolver {
private Map<String, DOMResult> results = new HashMap<String, DOMResult>();
@@ -156,28 +162,35 @@
return results;
}
}
-
+
+ /*
private void generateJAXBSchemas(List<XSDefinition> definitions, XSDFactory factory) {
if (types.size() > 0) {
try {
Class<?>[] typesArray = new Class<?>[types.size()];
typesArray = types.toArray(typesArray);
JAXBContext context = JAXBContext.newInstance(typesArray);
- DOMResolverImpl resolver = new DOMResolverImpl();
- context.generateSchema(resolver);
- Map<String, DOMResult> results = resolver.getResults();
- for (Map.Entry<String, DOMResult> entry: results.entrySet()) {
- XSDefinition definition = factory.createXSDefinition();
- definition.setUnresolved(true);
- definition.setDocument((Document)entry.getValue().getNode());
- definition.setNamespace(entry.getKey());
- definitions.add(definition);
- }
+ generateSchemas(definitions, factory, context);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
+ */
+
+ private void generateSchemas(List<XSDefinition> definitions, XSDFactory factory, JAXBContext context)
+ throws IOException {
+ DOMResolverImpl resolver = new DOMResolverImpl();
+ context.generateSchema(resolver);
+ Map<String, DOMResult> results = resolver.getResults();
+ for (Map.Entry<String, DOMResult> entry : results.entrySet()) {
+ XSDefinition definition = factory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setDocument((Document)entry.getValue().getNode());
+ definition.setNamespace(entry.getKey());
+ definitions.add(definition);
+ }
+ }
private static class StringResolverImpl extends SchemaOutputResolver {
private Map<String, StreamResult> results = new HashMap<String, StreamResult>();
@@ -197,4 +210,27 @@
}
}
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf) {
+ try {
+ JAXBContext context = JAXBContextHelper.createJAXBContext(intf, false);
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSchemas(definitions, factory, context);
+ return definitions;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes) {
+ try {
+
+ JAXBContext context = JAXBContextHelper.createJAXBContext(dataTypes);
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSchemas(definitions, factory, context);
+ return definitions;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java Sat Jun 7 00:15:29 2008
@@ -34,9 +34,9 @@
import org.apache.tuscany.sca.databinding.TransformationException;
import org.apache.tuscany.sca.databinding.WrapperHandler;
import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
/**
* JAXB WrapperHandler implementation
@@ -128,16 +128,12 @@
}
/**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(org.apache.tuscany.sca.interfacedef.util.ElementInfo, Class, org.apache.tuscany.sca.databinding.TransformationContext)
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
*/
- public DataType getWrapperType(ElementInfo element,
- Class<? extends Object> wrapperClass,
- TransformationContext context) {
- if (wrapperClass == null) {
- return null;
- } else {
- return new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, wrapperClass, new XMLType(element));
- }
+ public DataType getWrapperType(Operation operation, boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ DataType dt = input ? wrapper.getInputWrapperType() : wrapper.getOutputWrapperType();
+ return dt;
}
/**
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java Sat Jun 7 00:15:29 2008
@@ -26,6 +26,7 @@
import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
@@ -52,28 +53,29 @@
/**
* Test method for
- * {@link org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding#introspect(java.lang.Class, java.lang.annotation.Annotation)}.
+ * {@link org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding#introspect(java.lang.Class, Operation)}.
*/
public final void testIntrospect() {
DataType dataType = new DataTypeImpl<Class>(JAXBElement.class, null);
- boolean yes = binding.introspect(dataType, null);
+ Operation op = null;
+ boolean yes = binding.introspect(dataType, op);
assertTrue(yes);
assertTrue(dataType.getDataBinding().equals(binding.getName()));
assertTrue(dataType.getPhysical() == JAXBElement.class && dataType.getLogical() == XMLType.UNKNOWN);
dataType = new DataTypeImpl<Class>(MockJAXBElement.class, null);
- yes = binding.introspect(dataType, null);
+ yes = binding.introspect(dataType, op);
assertTrue(yes);
assertEquals(MockJAXBElement.class, dataType.getPhysical());
assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), ((XMLType)dataType.getLogical())
.getTypeName());
dataType = new DataTypeImpl<Class>(USAddress.class, null);
- yes = binding.introspect(dataType, null);
+ yes = binding.introspect(dataType, op);
assertTrue(yes);
assertEquals(USAddress.class, dataType.getPhysical());
assertEquals(new QName("http://www.example.com/IPO", "USAddress"), ((XMLType)dataType.getLogical())
.getTypeName());
dataType = new DataTypeImpl<Class>(USState.class, null);
- yes = binding.introspect(dataType, null);
+ yes = binding.introspect(dataType, op);
assertTrue(yes);
assertTrue(dataType.getDataBinding().equals(binding.getName()));
assertEquals(USState.class, dataType.getPhysical());
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java Sat Jun 7 00:15:29 2008
@@ -19,12 +19,12 @@
package org.apache.tuscany.sca.databinding.json;
-import java.lang.annotation.Annotation;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.codehaus.jettison.json.JSONObject;
@@ -44,7 +44,7 @@
super(NAME, ALIASES, org.json.JSONObject.class);
}
- public boolean introspect(DataType type, Annotation[] annotations) {
+ public boolean introspect(DataType type, Operation operation) {
assert type != null;
Class cls = type.getPhysical();
if (JSONObject.class.isAssignableFrom(cls) || org.json.JSONObject.class.isAssignableFrom(cls)) {
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonNodeDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonNodeDataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonNodeDataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonNodeDataBinding.java Sat Jun 7 00:15:29 2008
@@ -18,12 +18,12 @@
*/
package org.apache.tuscany.sca.databinding.saxon;
-import java.lang.annotation.Annotation;
import net.sf.saxon.om.NodeInfo;
import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
/**
* Represents data binding for parameters of type NodeInfo.
@@ -43,8 +43,8 @@
}
@Override
- public boolean introspect(DataType type, Annotation[] annotations) {
- if (super.introspect(type, annotations)) {
+ public boolean introspect(DataType type, Operation operation) {
+ if (super.introspect(type, operation)) {
// type.setLogical(XMLType.UNKNOWN);
return true;
} else {
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonValueDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonValueDataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonValueDataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-saxon/src/main/java/org/apache/tuscany/sca/databinding/saxon/SaxonValueDataBinding.java Sat Jun 7 00:15:29 2008
@@ -18,12 +18,12 @@
*/
package org.apache.tuscany.sca.databinding.saxon;
-import java.lang.annotation.Annotation;
import net.sf.saxon.value.Value;
import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
/**
* Represents data binding for parameters of type Value.
@@ -42,8 +42,8 @@
}
@Override
- public boolean introspect(DataType type, Annotation[] annotations) {
- if (super.introspect(type, annotations)) {
+ public boolean introspect(DataType type, Operation operation) {
+ if (super.introspect(type, operation)) {
// type.setLogical(XMLType.UNKNOWN);
return true;
} else {
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java Sat Jun 7 00:15:29 2008
@@ -94,6 +94,32 @@
return helperContext;
}
+
+ public static HelperContext getHelperContext(Operation op) {
+ if (op == null) {
+ return getDefaultHelperContext();
+ }
+
+ HelperContext helperContext = SDOUtil.createHelperContext();
+
+ boolean found = false;
+ if (op != null) {
+ found = register(helperContext, op.getInputType()) || found;
+ found = register(helperContext, op.getOutputType()) || found;
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ found = register(helperContext, wrapper.getInputWrapperClass()) || found;
+ found = register(helperContext, wrapper.getOutputWrapperClass()) || found;
+ }
+ }
+ if (!found) {
+ helperContext = getDefaultHelperContext();
+ }
+
+ return helperContext;
+
+ }
+
/**
* @param helperContext
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java Sat Jun 7 00:15:29 2008
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.databinding.sdo;
-import java.lang.annotation.Annotation;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -30,6 +29,7 @@
import org.apache.tuscany.sca.databinding.XMLTypeHelper;
import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import commonj.sdo.DataObject;
@@ -61,7 +61,7 @@
}
@Override
- public boolean introspect(DataType dataType, Annotation[] annotations) {
+ public boolean introspect(DataType dataType, Operation operation) {
Class javaType = dataType.getPhysical();
// Allow privileged access to read system properties. Requires PropertyPermission
// java.specification.version read in security policy.
@@ -113,7 +113,8 @@
@Override
public XMLTypeHelper getXMLTypeHelper() {
- return xmlTypeHelper;
+ return new SDOTypeHelper();
+ // return xmlTypeHelper;
}
@Override
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java Sat Jun 7 00:15:29 2008
@@ -23,39 +23,42 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import javax.xml.namespace.QName;
-import commonj.sdo.Type;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XSDHelper;
+import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.apache.tuscany.sca.xsd.XSDefinition;
import org.apache.tuscany.sca.xsd.XSDFactory;
-
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.osoa.sca.ServiceRuntimeException;
+import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.DOMImplementation;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSParser;
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
public class SDOTypeHelper implements XMLTypeHelper {
private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
private TypeHelper typeHelper;
private XSDHelper xsdHelper;
- private Map<String, List<Type>> xsdTypesMap = new HashMap<String, List<Type>>();
- private Map<String, List<Type>> typesMap = new HashMap<String, List<Type>>();
-
+ // private Map<String, List<Type>> xsdTypesMap = new HashMap<String, List<Type>>();
+ // private Map<String, List<Type>> typesMap = new HashMap<String, List<Type>>();
+
public SDOTypeHelper() {
super();
typeHelper = SDOContextHelper.getDefaultHelperContext().getTypeHelper();
@@ -67,69 +70,84 @@
if (xmlType != null) {
return new TypeInfo(xmlType, true, null);
} else {
- Type type = typeHelper.getType(javaType);
- if (xsdHelper.isXSD(type)) {
- List<Type> xsdTypes = xsdTypesMap.get(type.getURI());
- if (xsdTypes == null) {
- xsdTypes = new ArrayList<Type>();
- xsdTypesMap.put(type.getURI(), xsdTypes);
- }
- if (!xsdTypes.contains(type)) {
- xsdTypes.add(type);
- }
- } else {
- List<Type> types = typesMap.get(type.getURI());
- if (types == null) {
- types = new ArrayList<Type>();
- typesMap.put(type.getURI(), types);
- }
- if (!types.contains(type)) {
- types.add(type);
- }
- }
+ // introspect(javaType, xsdTypesMap, typesMap);
if (logical instanceof XMLType) {
xmlType = ((XMLType)logical).getTypeName();
}
if (xmlType == null) {
- xmlType = new QName(JavaXMLMapper.getNamespace(javaType),
- Introspector.decapitalize(javaType.getSimpleName()));
+ xmlType =
+ new QName(JavaXMLMapper.getNamespace(javaType), Introspector.decapitalize(javaType.getSimpleName()));
}
return new TypeInfo(xmlType, false, null);
}
}
+ private void introspect(Class javaType, Map<String, List<Type>> xsdTypesMap, Map<String, List<Type>> typesMap) {
+ Type type = typeHelper.getType(javaType);
+ if (type == null) {
+ return;
+ }
+ if (xsdHelper.isXSD(type)) {
+ addToMap(xsdTypesMap, type);
+ } else {
+ addToMap(typesMap, type);
+ }
+ }
+
+ private void addToMap(Map<String, List<Type>> map, Type type) {
+ List<Type> types = map.get(type.getURI());
+ if (types == null) {
+ types = new ArrayList<Type>();
+ map.put(type.getURI(), types);
+ }
+ if (!types.contains(type)) {
+ types.add(type);
+ }
+ }
+
+ /*
public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver) {
List<XSDefinition> definitions = new ArrayList<XSDefinition>();
- generateSDOSchemas(definitions, factory);
- addResolvedXSDs(definitions, factory, resolver);
+ generateSDOSchemas(definitions, factory, typesMap);
+ addResolvedXSDs(definitions, factory, resolver, xsdTypesMap);
return definitions;
}
+ */
- private void generateSDOSchemas(List<XSDefinition> definitions, XSDFactory factory) {
- for (Map.Entry<String, List<Type>> entry: typesMap.entrySet()) {
- String schema = xsdHelper.generate(entry.getValue());
- DOMImplementationRegistry registry = null;
- try {
- registry = DOMImplementationRegistry.newInstance();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
- DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
- LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
- LSInput input = ls.createLSInput();
- input.setCharacterStream(new StringReader(schema));
- Document document = parser.parse(input);
- XSDefinition definition = factory.createXSDefinition();
- definition.setUnresolved(true);
- definition.setDocument(document);
- definition.setNamespace(entry.getKey());
- definitions.add(definition);
+ private void generateSDOSchemas(List<XSDefinition> definitions, XSDFactory factory, Map<String, List<Type>> map) {
+ for (Map.Entry<String, List<Type>> entry : map.entrySet()) {
+ List<Type> types = entry.getValue();
+ String ns = entry.getKey();
+ generateSchema(definitions, factory, types, ns);
}
}
- private void addResolvedXSDs(List<XSDefinition> definitions, XSDFactory factory, ModelResolver resolver) {
- for (Map.Entry<String, List<Type>> entry: xsdTypesMap.entrySet()) {
+ private void generateSchema(List<XSDefinition> definitions, XSDFactory factory, List<Type> types, String ns) {
+ String schema = xsdHelper.generate(types);
+ DOMImplementationRegistry registry = null;
+ try {
+ registry = DOMImplementationRegistry.newInstance();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
+ LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
+ LSInput input = ls.createLSInput();
+ input.setCharacterStream(new StringReader(schema));
+ Document document = parser.parse(input);
+ XSDefinition definition = factory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setDocument(document);
+ definition.setNamespace(ns);
+ definitions.add(definition);
+ }
+
+ private void addResolvedXSDs(List<XSDefinition> definitions,
+ XSDFactory factory,
+ ModelResolver resolver,
+ Map<String, List<Type>> map) {
+ for (Map.Entry<String, List<Type>> entry : map.entrySet()) {
XSDefinition definition = factory.createXSDefinition();
definition.setUnresolved(true);
definition.setNamespace(entry.getKey());
@@ -140,7 +158,7 @@
throw new RuntimeException("No XSD found for namespace " + entry.getKey());
}
// make sure all the required types are defined in the resolved schema
- for (Type type: entry.getValue()) {
+ for (Type type : entry.getValue()) {
QName typeName = new QName(type.getURI(), type.getName());
if (resolved.getXmlSchemaType(typeName) == null) {
//FIXME: create a checked exception and propagate it back up to the activator
@@ -151,4 +169,54 @@
}
}
+ private static List<DataType> getDataTypes(Interface intf) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ for (Operation op : intf.getOperations()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ DataType dt1 = wrapper.getInputWrapperType();
+ if (dt1 != null) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = wrapper.getOutputWrapperType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ } else {
+ for (DataType dt1 : op.getInputType().getLogical()) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = op.getOutputType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ if (dt4 != null) {
+ dataTypes.add(dt4);
+ }
+ }
+ }
+ }
+ return dataTypes;
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf) {
+ return getSchemaDefinitions(factory, resolver, getDataTypes(intf));
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes) {
+ Map<String, List<Type>> xsdTypesMap = new HashMap<String, List<Type>>();
+ Map<String, List<Type>> typesMap = new HashMap<String, List<Type>>();
+ for (DataType d : dataTypes) {
+ if (SDODataBinding.NAME.equals(d.getDataBinding())) {
+ introspect(d.getPhysical(), xsdTypesMap, typesMap);
+ }
+ }
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSDOSchemas(definitions, factory, typesMap);
+ addResolvedXSDs(definitions, factory, resolver, xsdTypesMap);
+ return definitions;
+ }
+
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java Sat Jun 7 00:15:29 2008
@@ -28,9 +28,11 @@
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.WrapperHandler;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import commonj.sdo.DataObject;
@@ -53,7 +55,6 @@
* @see org.apache.tuscany.sca.databinding.WrapperHandler#create(ElementInfo, Class, TransformationContext)
*/
public Object create(ElementInfo element, Class<? extends Object> wrapperClass, TransformationContext context) {
- DataObject wrapper = null;
HelperContext helperContext = SDOContextHelper.getHelperContext(context);
Type sdoType = getSDOType(helperContext, element);
if (sdoType != null) {
@@ -121,12 +122,13 @@
}
/**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(org.apache.tuscany.sca.interfacedef.util.ElementInfo, Class, org.apache.tuscany.sca.databinding.TransformationContext)
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
*/
- public DataType getWrapperType(ElementInfo element,
- Class<? extends Object> wrapperClass,
- TransformationContext context) {
- HelperContext helperContext = SDOContextHelper.getHelperContext(context);
+ public DataType getWrapperType(Operation operation,
+ boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ ElementInfo element = input? wrapper.getInputWrapperElement(): wrapper.getOutputWrapperElement();
+ HelperContext helperContext = SDOContextHelper.getHelperContext(operation);
Type sdoType = getSDOType(helperContext, element);
if (sdoType != null) {
// Check if child elements matches
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java Sat Jun 7 00:15:29 2008
@@ -24,6 +24,7 @@
import junit.framework.TestCase;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
@@ -56,19 +57,20 @@
}
public final void testIntrospect() {
+ Operation op = null;
DataType dataType = new DataTypeImpl<Class>(DataObject.class, null);
- boolean yes = binding.introspect(dataType, null);
+ boolean yes = binding.introspect(dataType, op);
assertTrue(yes);
assertTrue(dataType.getDataBinding().equals(binding.getName()));
assertTrue(dataType.getPhysical() == DataObject.class && dataType.getLogical() == XMLType.UNKNOWN);
dataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
- yes = binding.introspect(dataType, null);
+ yes = binding.introspect(dataType, op);
assertTrue(yes);
assertEquals(PurchaseOrderType.class, dataType.getPhysical());
assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), ((XMLType)dataType.getLogical())
.getTypeName());
dataType = new DataTypeImpl<Class>(USAddress.class, null);
- yes = binding.introspect(dataType, null);
+ yes = binding.introspect(dataType, op);
assertTrue(yes);
assertEquals(USAddress.class, dataType.getPhysical());
assertEquals(new QName("http://www.example.com/IPO", "USAddress"), ((XMLType)dataType.getLogical())
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java Sat Jun 7 00:15:29 2008
@@ -19,9 +19,9 @@
package org.apache.tuscany.sca.databinding;
-import java.lang.annotation.Annotation;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
/**
* DataBinding represents a data representation, for example, SDO, JAXB and AXIOM
@@ -59,10 +59,10 @@
* Introspect and populate information to a DataType model
*
* @param dataType The data type to be introspected
- * @param annotations The java annotations
+ * @param operation The operation
* @return true if the databinding has recognized the given data type
*/
- boolean introspect(DataType dataType, Annotation[] annotations);
+ boolean introspect(DataType dataType, Operation operation);
/**
* Introspect the data to figure out the corresponding data type
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java Sat Jun 7 00:15:29 2008
@@ -18,9 +18,9 @@
*/
package org.apache.tuscany.sca.databinding;
-import java.lang.annotation.Annotation;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
/**
* An extension point for data binding extensions.
@@ -56,29 +56,19 @@
* Introspect the java class to figure out what DataType supports it.
*
* @param dataType The initial data type
- * @param annotations The java annotations
+ * @param operation TODO
* @return A DataType representing the java type or null if no databinding
* recognizes the java type
*/
- boolean introspectType(DataType dataType, Annotation[] annotations);
-
- /**
- * Introspect the java class to figure out what DataType supports it.
- *
- * @param dataType The initial data type
- * @param annotations The java annotations
- * @param isFaultType Should be set to true if DataType parameter represents an Exception
- * @return A DataType representing the java type or null if no databinding
- * recognizes the java type
- */
- boolean introspectType(DataType dataType, Annotation[] annotations, boolean isFaultType);
+ boolean introspectType(DataType dataType, Operation operation);
/**
* Introspect the value to figure out the corresponding DataType
*
* @param value The object value
+ * @param operation TODO
* @return A DataType representing the value or null if no databinding
* recognizes the value
*/
- DataType introspectType(Object value);
+ DataType introspectType(Object value, Operation operation);
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java Sat Jun 7 00:15:29 2008
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.databinding;
import java.io.IOException;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,6 +33,7 @@
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
/**
@@ -191,8 +191,8 @@
return getDataBinding().getWrapperHandler();
}
- public boolean introspect(DataType dataType, Annotation[] annotations) {
- return getDataBinding().introspect(dataType, annotations);
+ public boolean introspect(DataType dataType, Operation operation) {
+ return getDataBinding().introspect(dataType, operation);
}
public DataType introspect(Object value) {
@@ -202,27 +202,7 @@
//FIXME The following methods should not be on the extension point
// they should be on a separate class
- public boolean introspectType(DataType dataType, Annotation[] annotations) {
- return introspectType(dataType, annotations, false);
- }
-
- private boolean introspectArray(DataType dataType, Annotation[] annotations) {
- Class physical = dataType.getPhysical();
- if (!physical.isArray() || physical == byte[].class) {
- return false;
- }
- Class componentType = physical.getComponentType();
- DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
- introspectType(logical, annotations);
- dataType.setDataBinding("java:array");
- dataType.setLogical(logical);
- return true;
- }
-
- //
- // Leverage the DataBinding ExceptionHandler to calculate the DataType of an exception DataType
- //
- public boolean introspectType(DataType dataType, Annotation[] annotations, boolean isException) {
+ public boolean introspectType(DataType dataType, Operation operation) {
loadDataBindings();
for (DataBinding binding : databindings) {
// don't introspect for JavaBeansDatabinding as all javatypes will
@@ -230,26 +210,8 @@
// which is java.lang.Object. Default to this only if no databinding
// results
if (!binding.getName().equals(JavaBeansDataBinding.NAME)) {
- /*
- if (isException) {
- // Next look to see if the DB's exceptionHandler handles this exception
- ExceptionHandler excHandler = binding.getExceptionHandler();
- if (excHandler != null) {
- // Asymmetric to have the introspect() methods set the DataBindings themselves
- // whereas we're setting it ourselves here.
- DataType faultType = excHandler.getFaultType(dataType);
- if (faultType != null) {
- dataType.setDataBinding(binding.getName());
- dataType.setLogical(faultType);
- return true;
- }
- }
- } else
- */
- {
- if (binding.introspect(dataType, annotations)) {
- return true;
- }
+ if (binding.introspect(dataType, operation)) {
+ return true;
}
}
}
@@ -260,18 +222,30 @@
return false;
}
if (dataType.getPhysical().isArray()) {
- introspectArray(dataType, annotations);
+ introspectArray(dataType, operation);
return true;
- } else if (isException) {
+ } else if (Throwable.class.isAssignableFrom(physical)) {
dataType.setDataBinding(JavaExceptionDataBinding.NAME);
return true;
} else {
dataType.setDataBinding(JavaBeansDataBinding.NAME);
return false;
+ } }
+
+ private boolean introspectArray(DataType dataType, Operation operation) {
+ Class physical = dataType.getPhysical();
+ if (!physical.isArray() || physical == byte[].class) {
+ return false;
}
+ Class componentType = physical.getComponentType();
+ DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
+ introspectType(logical, operation);
+ dataType.setDataBinding("java:array");
+ dataType.setLogical(logical);
+ return true;
}
- public DataType introspectType(Object value) {
+ public DataType introspectType(Object value, Operation operation) {
loadDataBindings();
DataType dataType = null;
for (DataBinding binding : databindings) {
Modified: incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java?rev=664294&r1=664293&r2=664294&view=diff
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca-test2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java Sat Jun 7 00:15:29 2008
@@ -22,6 +22,7 @@
import java.util.List;
import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
/**
@@ -41,12 +42,11 @@
/**
* Get the data type for the wrapper
- * @param element The wrapper element
- * @param wrapperClass Wrapper class
- * @param context The transformation context
+ * @param operation The operation
+ * @param input Is it for input or output?
* @return The data type of the wrapper, null if it's not a wrapper type
*/
- DataType getWrapperType(ElementInfo element, Class<? extends T> wrapperClass, TransformationContext context);
+ DataType getWrapperType(Operation operation, boolean input);
/**
* Check if the given data is an instance of the wrapper