From 027e08ca2bc8411d313a36f881f56bd5d578c71d Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 27 Jun 2008 09:59:34 +0000 Subject: Remove as not required in release git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@672208 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/corba/CorbaBinding.java | 40 --- .../sca/binding/corba/CorbaBindingFactory.java | 31 -- .../binding/corba/exceptions/CorbaException.java | 34 -- .../exceptions/RequestConfigurationException.java | 39 -- .../corba/impl/CorbaBindingFactoryImpl.java | 37 -- .../sca/binding/corba/impl/CorbaBindingImpl.java | 118 ------ .../binding/corba/impl/CorbaBindingProcessor.java | 125 ------- .../corba/impl/CorbaBindingProviderFactory.java | 60 ---- .../sca/binding/corba/impl/CorbaInvoker.java | 81 ----- .../corba/impl/CorbaReferenceBindingProvider.java | 72 ---- .../corba/impl/CorbaServiceBindingProvider.java | 126 ------- .../binding/corba/impl/CorbaServiceLocator.java | 395 --------------------- .../sca/binding/corba/impl/TuscanyServant.java | 46 --- .../corba/impl/reference/DynaCorbaRequest.java | 166 --------- .../corba/impl/reference/DynaCorbaResponse.java | 39 -- .../impl/reference/InterfaceInstanceCreator.java | 72 ---- .../impl/reference/InterfaceMethodInterceptor.java | 61 ---- .../tuscany/sca/binding/corba/types/NodeType.java | 28 -- .../tuscany/sca/binding/corba/types/TypeTree.java | 76 ---- .../sca/binding/corba/types/TypeTreeCreator.java | 224 ------------ .../sca/binding/corba/types/TypeTreeNode.java | 66 ---- .../binding/corba/types/util/ArrayTypeHelper.java | 46 --- .../corba/types/util/BooleanTypeHelper.java | 45 --- .../binding/corba/types/util/ByteTypeHelper.java | 45 --- .../binding/corba/types/util/CharTypeHelper.java | 45 --- .../binding/corba/types/util/DoubleTypeHelper.java | 45 --- .../binding/corba/types/util/FloatTypeHelper.java | 45 --- .../binding/corba/types/util/IntTypeHelper.java | 45 --- .../binding/corba/types/util/LongTypeHelper.java | 46 --- .../corba/types/util/ReferenceTypeHelper.java | 48 --- .../corba/types/util/SequenceTypeHelper.java | 83 ----- .../binding/corba/types/util/ShortTypeHelper.java | 46 --- .../binding/corba/types/util/StringTypeHelper.java | 46 --- .../binding/corba/types/util/StructTypeHelper.java | 90 ----- .../sca/binding/corba/types/util/TypeHelper.java | 55 --- .../binding/corba/types/util/TypeHelpersProxy.java | 132 ------- 36 files changed, 2798 deletions(-) delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/CorbaException.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/RequestConfigurationException.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceLocator.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/TuscanyServant.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaResponse.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceInstanceCreator.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceMethodInterceptor.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/NodeType.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTree.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeCreator.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeNode.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ArrayTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/BooleanTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ByteTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/CharTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/DoubleTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/FloatTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/IntTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/LongTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ReferenceTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/SequenceTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ShortTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StringTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StructTypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelper.java delete mode 100644 branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelpersProxy.java (limited to 'branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca') diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java deleted file mode 100644 index 3fcff6b0d8..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.binding.corba; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.xml.Constants; - -/** - * @version $Rev$ $Date$ - */ -public interface CorbaBinding extends Binding { - QName BINDING_CORBA_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "binding.corba"); - - String getHost(); - - void setHost(String host); - - int getPort(); - - void setPort(int port); -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java deleted file mode 100644 index 67e3bdcf74..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.binding.corba; - -/** - * @version $Rev$ $Date$ - */ -public interface CorbaBindingFactory { - /** - * Create a CorbaBinding model - * @return The CorbaBinding model - */ - CorbaBinding createCorbaBinding(); -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/CorbaException.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/CorbaException.java deleted file mode 100644 index 35d9799bd9..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/CorbaException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.binding.corba.exceptions; - -/** - * @version $Rev$ $Date$ - * Represents CORBA SystemException - */ -public class CorbaException extends Exception { - - private static final long serialVersionUID = 1L; - - public CorbaException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/RequestConfigurationException.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/RequestConfigurationException.java deleted file mode 100644 index f143215196..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/exceptions/RequestConfigurationException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.binding.corba.exceptions; - -/** - * @version $Rev$ $Date$ - */ -public class RequestConfigurationException extends Exception { - - private static final long serialVersionUID = 1L; - private String objectId; - - public RequestConfigurationException(String message, String objectId) { - super(message + ", object id was: " + objectId); - this.objectId = objectId; - } - - public String getType() { - return objectId; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java deleted file mode 100644 index cecb4fb567..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.binding.corba.CorbaBindingFactory; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaBindingFactoryImpl implements CorbaBindingFactory { - - /** - * @see org.apache.tuscany.sca.binding.corba.CorbaBindingFactory#createCorbaBinding() - */ - public CorbaBinding createCorbaBinding() { - return new CorbaBindingImpl(); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java deleted file mode 100644 index 8d54cd4936..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.binding.corba.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaBindingImpl implements CorbaBinding, PolicySetAttachPoint { - private String name; - private String uri; - private String host; - private int port; - - private List requiredIntents = new ArrayList(); - private List policySets = new ArrayList(); - private IntentAttachPointType intentAttachPointType; - private List applicablePolicySets = new ArrayList(); - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getName() { - return name; - } - - public String getURI() { - return uri; - } - - public void setName(String name) { - this.name = name; - - } - - public void setURI(String uri) { - this.uri = uri; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - public List getPolicySets() { - return policySets; - } - - public List getRequiredIntents() { - return requiredIntents; - } - - public IntentAttachPointType getType() { - return intentAttachPointType; - } - - public void setType(IntentAttachPointType intentAttachPointType) { - this.intentAttachPointType = intentAttachPointType; - } - - public void setPolicySets(List policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List intents) { - this.requiredIntents = intents; - } - - public List getApplicablePolicySets() { - return applicablePolicySets; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java deleted file mode 100644 index ce227bed1c..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.binding.corba.impl; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaBindingProcessor implements StAXArtifactProcessor { - private PolicyFactory policyFactory; - private PolicyAttachPointProcessor policyProcessor; - - public CorbaBindingProcessor(ModelFactoryExtensionPoint modelFactories) { - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - } - - /** - * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#getArtifactType() - */ - public QName getArtifactType() { - return CorbaBinding.BINDING_CORBA_QNAME; - } - - /** - * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader) - */ - public CorbaBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - CorbaBinding binding = new CorbaBindingImpl(); - - // Read the policies - policyProcessor.readPolicies(binding, reader); - - binding.setHost(reader.getAttributeValue(null, "host")); - String port = reader.getAttributeValue(null, "port"); - if (port != null) { - binding.setPort(Integer.parseInt(port)); - } - - // Read the name - String name = reader.getAttributeValue(null, "name"); - if (name != null) { - binding.setName(name); - } - - // Read binding URI - String uri = reader.getAttributeValue(null, "uri"); - if (uri != null) { - binding.setURI(uri); - } - return binding; - } - - /** - * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#write(java.lang.Object, javax.xml.stream.XMLStreamWriter) - */ - public void write(CorbaBinding model, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - // Write a - writer.writeStartElement(Constants.SCA10_TUSCANY_NS, "binding.corba"); - - if (model.getName() != null) { - writer.writeAttribute("name", model.getName()); - } - - if (model.getURI() != null) { - writer.writeAttribute("uri", model.getURI()); - } - - if (model.getHost() != null) { - writer.writeAttribute("host", model.getHost()); - } - - if (model.getPort() != -1) { - writer.writeAttribute("port", String.valueOf(model.getPort())); - } - - writer.writeEndElement(); - } - - /** - * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#getModelType() - */ - public Class getModelType() { - return CorbaBinding.class; - } - - /** - * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#resolve(java.lang.Object, org.apache.tuscany.sca.contribution.resolver.ModelResolver) - */ - public void resolve(CorbaBinding model, ModelResolver resolver) throws ContributionResolveException { - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java deleted file mode 100644 index fe70b22953..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaBindingProviderFactory implements BindingProviderFactory { - - /** - * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createReferenceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) - */ - public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - CorbaBinding binding) { - return null; - } - - /** - * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createServiceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) - */ - public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, - CorbaBinding binding) { - return null; - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class getModelType() { - return CorbaBinding.class; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java deleted file mode 100644 index 87fd6ce00c..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.omg.CORBA.Any; -import org.omg.CORBA.Request; -import org.omg.CosNaming.NamingContextExt; -import org.omg.CosNaming.NamingContextExtHelper; -import org.osoa.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaInvoker implements Invoker { - private Operation operation; - private CorbaBinding binding; - - public CorbaInvoker(CorbaBinding binding, Operation operation) { - super(); - this.binding = binding; - this.operation = operation; - } - - /** - * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message) - */ - public Message invoke(Message msg) { - try { - org.omg.CORBA.ORB orb = initORB(binding.getHost(), String.valueOf(binding.getPort())); - - org.omg.CORBA.Object service = orb.string_to_object(binding.getURI()); - - // get the root naming context - org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); - - // Use NamingContextExt instead of NamingContext. This is - // part of the Interoperable Naming Service. - NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); - - // resolve the Object Reference in Naming - org.omg.CORBA.Object impl = ncRef.resolve_str(binding.getURI()); - - String op = operation.getName(); - Request req = impl._request(op); - Any any = req.add_in_arg(); - return null; - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - private org.omg.CORBA.ORB initORB(String host, String port) { - java.util.Properties props = new java.util.Properties(); - props.put("org.omg.CORBA.ORBInitialHost", host); - props.put("org.omg.CORBA.ORBInitialPort", port); - org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props); - return orb; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java deleted file mode 100644 index a79abd94a5..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaReferenceBindingProvider implements ReferenceBindingProvider { - private CorbaBinding binding; - - /** - * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#createInvoker(org.apache.tuscany.sca.interfacedef.Operation) - */ - public Invoker createInvoker(Operation operation) { - return new CorbaInvoker(binding, operation); - } - - /** - * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#getBindingInterfaceContract() - */ - public InterfaceContract getBindingInterfaceContract() { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#start() - */ - public void start() { - // TODO Auto-generated method stub - - } - - /** - * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#stop() - */ - public void stop() { - // TODO Auto-generated method stub - - } - - /** - * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#supportsOneWayInvocation() - */ - public boolean supportsOneWayInvocation() { - return false; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java deleted file mode 100644 index 5292b3e452..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.apache.tuscany.sca.binding.corba.CorbaBinding; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.omg.CosNaming.NameComponent; -import org.omg.CosNaming.NamingContextExt; -import org.omg.CosNaming.NamingContextExtHelper; -import org.omg.PortableServer.POA; -import org.omg.PortableServer.POAHelper; -import org.omg.PortableServer.Servant; -import org.osoa.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaServiceBindingProvider implements ServiceBindingProvider { - private CorbaBinding binding; - - /** - * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#getBindingInterfaceContract() - */ - public InterfaceContract getBindingInterfaceContract() { - // TODO Auto-generated method stub - return null; - } - - protected Servant createServant() { - return null; - } - - private NameComponent[] nameComponents; - - /** - * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#start() - */ - public void start() { - try { - java.util.Properties props = new java.util.Properties(); - props.put("org.omg.CORBA.ORBInitialHost", binding.getHost()); - props.put("org.omg.CORBA.ORBInitialPort", String.valueOf(binding.getPort())); - org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props); - - Servant servant = createServant(); - - // get reference to rootpoa & activate the POAManager - POA rootpoa = POAHelper.narrow( - orb.resolve_initial_references("RootPOA")); - rootpoa.the_POAManager().activate(); - - // get object reference from the servant - org.omg.CORBA.Object ref = - rootpoa.servant_to_reference(servant); - - org.omg.CORBA.Object href = null; // AddHelper.narrow(ref); - - // get the root naming context - // NameService invokes the name service - org.omg.CORBA.Object objRef = - orb.resolve_initial_references("NameService"); - // Use NamingContextExt which is part of the Interoperable - // Naming Service (INS) specification. - NamingContextExt ncRef = - NamingContextExtHelper.narrow(objRef); - - // bind the Object Reference in Naming - NameComponent path[] = ncRef.to_name( binding.getURI() ); - ncRef.rebind(path, href); - - // wait for invocations from clients - orb.run(); - - - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - - } - - /** - * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#stop() - */ - public void stop() { - try { - java.util.Properties props = new java.util.Properties(); - props.put("org.omg.CORBA.ORBInitialHost", binding.getHost()); - props.put("org.omg.CORBA.ORBInitialPort", String.valueOf(binding.getPort())); - org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props); - - org.omg.CORBA.Object object = orb.resolve_initial_references("NameService"); - org.omg.CosNaming.NamingContextExt root = org.omg.CosNaming.NamingContextExtHelper.narrow(object); - root.unbind(nameComponents); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - - } - - /** - * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#supportsOneWayInvocation() - */ - public boolean supportsOneWayInvocation() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceLocator.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceLocator.java deleted file mode 100644 index 867cfd5717..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceLocator.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * 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.binding.corba.impl; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - -import javax.naming.NamingException; - -import org.omg.CORBA.ORB; -import org.omg.CosNaming.NamingContextExt; - -/** - * CosNaming utility - */ -public class CorbaServiceLocator { - - /* - * Root Context Initial Reference Key ------------ - * ----------------------------------- Server Root NameServiceServerRoot - * Cell Persistent Root NameServiceCellPersistentRoot Cell Root - * NameServiceCellRoot, NameService Node Root NameServiceNodeRoot - */ - public static final String SERVER_ROOT = "NameServiceServerRoot"; - public static final String CELL_PERSISTENT_ROOT = "NameServiceCellPersistentRoot"; - public static final String CELL_ROOT = "NameServiceCellRoot"; - public static final String NODE_ROOT = "NameServiceNodeRoot"; - public static final String DEFAULT_ROOT = "NameService"; // Same as - // CELL_ROOT - - public static final String DEFAULT_HOST = "127.0.0.1"; // Default host name - // or IP address for - // WebSphere - public static final int DEFAULT_NAMING_PORT = 2809; // Default port - public static final String NAMING_SERVICE = "NameService"; // The name of - // the naming - // service - private static final Set ROOTS = - new HashSet(Arrays.asList(new String[] {SERVER_ROOT, CELL_PERSISTENT_ROOT, CELL_ROOT, DEFAULT_ROOT, - NODE_ROOT})); - - // private static final String CHARS_TO_ESCAPE = "\\/."; - private static final String RFC2396 = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;/:?@&=+$,-_.!~*'()"; - private static final String HEX = "0123456789ABCDEF"; - - private String hostName = DEFAULT_HOST; - private int port = DEFAULT_NAMING_PORT; - private String root = SERVER_ROOT; - - private ORB orb = null; - private CosNamingLocator locator = null; - - public CorbaServiceLocator(String hostName, int port) { - this.hostName = (hostName == null) ? DEFAULT_HOST : hostName; - this.port = port > 0 ? port : DEFAULT_NAMING_PORT; - this.root = SERVER_ROOT; - } - - public CorbaServiceLocator(String hostName, int port, String root) { - this(hostName, port); - if (ROOTS.contains(root)) { - this.root = root; - } else { - throw new IllegalArgumentException(root + " is not a legal root"); - } - } - - public CorbaServiceLocator(String corbaName) { - if (corbaName.startsWith("corbaname:iiop:")) { - processCorbaURL(corbaName); - } else { - throw new IllegalArgumentException(corbaName + " is not a legal corbaname"); - } - } - - private void processCorbaURL(String url) { - if (url != null && (url.startsWith("corbaname:iiop:") || url.startsWith("corbaloc:iiop:"))) { - /** - * corbaname:iiop::/#name corbaloc:iiop::/ - * For example, - * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome"; - * or "corbaloc:iiop:myhost:2809/NameServiceServerRoot" - */ - String[] parts = url.split("(:|/|#)"); - if (parts.length > 2 && parts[2].length() > 0) { - hostName = parts[2]; // The host name - int index = hostName.lastIndexOf('@'); // version@hostname - if (index != -1) { - hostName = hostName.substring(index + 1); - } - } - if (parts.length > 3 && parts[3].length() > 0) { - port = Integer.parseInt(parts[3]); // The port number - } - if (parts.length > 4 && parts[4].length() > 0) { - root = parts[4]; // The root of naming - } - } - } - - /** - * The corbaloc and corbaname formats enable you to provide a URL to access - * CORBA objects. Use the corbaloc format for resolving to a particular - * CORBAservice without going through a naming service. Use the corbaname - * format to resolve a stringified name from a specific naming context. - */ - - /** - * corbaname Syntax The full corbaname BNF is: <corbaname> = - * "corbaname:"<corbaloc_obj>["#"<string_name>] - * <corbaloc_obj> = <obj_addr_list> ["/"<key_string>] - * <obj_addr_list> = as defined in a corbaloc URL <key_string> = - * as defined in a corbaloc URL <string_name>= stringified Name - * empty_string Where: - *
    - *
  • corbaloc_obj: portion of a corbaname URL that identifies the naming - * context. The syntax is identical to its use in a corbaloc URL. - *
  • obj_addr_list: as defined in a corbaloc URL - *
  • key_string: as defined in a corbaloc URL. - *
  • string_name: a stringified Name with URL escapes as defined below. - *
- * - * @param hostName The host name or IP address of the naming server - * @param port The port number of the naming service - * @param root The root of the namespace - * @param name The JNDI name - */ - private static String getCorbaname(String hostName, int port, String root, String name) { - if (name == null) { - return "corbaname:iiop:" + hostName + ":" + port + "/" + root; - } else { - return "corbaname:iiop:" + hostName + ":" + port + "/" + root + "#" + toCorbaname(name); - } - } - - String getCorbaname(String name) { - return getCorbaname(hostName, port, root, name); - } - - /** - * Connect to the ORB. - */ - - // FIXME. May need to change the IBM classes if this binding is contributed - // to Tuscany - public ORB connect() { - if (orb == null) { - Properties props = new Properties(); - /* - * This code is for IBM JVM props.put("org.omg.CORBA.ORBClass", - * "com.ibm.CORBA.iiop.ORB"); - * props.put("com.ibm.CORBA.ORBInitRef.NameService", - * getCorbaloc(NAMING_SERVICE)); - * props.put("com.ibm.CORBA.ORBInitRef.NameServiceServerRoot", - * getCorbaloc("NameServiceServerRoot")); - */ - orb = ORB.init((String[])null, props); - } - return orb; - } - - /** - * Replace substrings - * - * @param source The source string. - * @param match The string to search for within the source string. - * @param replace The replacement for any matching components. - * @return - */ - private static String replace(String source, String match, String replace) { - int index = source.indexOf(match, 0); - if (index >= 0) { - - // We have at least one match, so got to do the - // work... - - StringBuffer result = new StringBuffer(source.length() + 16); - int matchLength = match.length(); - int startIndex = 0; - - while (index >= 0) { - result.append(source.substring(startIndex, index)); - result.append(replace); - startIndex = index + matchLength; - index = source.indexOf(match, startIndex); - } - - // Grab the last piece, if any... - if (startIndex < source.length()) { - result.append(source.substring(startIndex)); - } - - return result.toString(); - - } else { - // No matches, just return the source... - return source; - } - } - - /** - * Resolved the JNDI name from the initial CosNaming context - * - * @param jndiName - * @return resolved CORBA object - * @throws NamingException - */ - private static org.omg.CORBA.Object resovleString(NamingContextExt initCtx, String jndiName) throws NamingException { - try { - String name = stringify(jndiName); - return initCtx.resolve_str(name); - } catch (Exception e) { - NamingException ne = new NamingException(e.getMessage()); - ne.setRootCause(e); - throw ne; - } - } - - /** - * Look up a CORBA object by its JNDI name - * - * @param jndiName - * @return - * @throws NamingException - */ - org.omg.CORBA.Object stringToObject(String jndiName) throws NamingException { - /* - * Using an existing ORB and invoking string_to_object with a CORBA - * object URL with multiple name server addresses to get an initial - * context CORBA object URLs can contain more than one bootstrap server - * address. Use this feature when attempting to obtain an initial - * context from a server cluster. You can specify the bootstrap server - * addresses for all servers in the cluster in the URL. The operation - * will succeed if at least one of the servers is running, eliminating a - * single point of failure. There is no guarantee of any particular - * order in which the address list will be processed. For example, the - * second bootstrap server address may be used to obtain the initial - * context even though the first bootstrap server in the list is - * available. An example of a corbaloc URL with multiple addresses - * follows. obj = - * orb.string_to_object("corbaloc::myhost1:9810,:myhost1:9811,:myhost2:9810/NameService"); - */ - String corbaName = null; - if (jndiName.startsWith("corbaloc:") || jndiName.startsWith("corbaname:")) { - // Keep the qualified URL - corbaName = jndiName; - } else { - // Create a corbaname URL - corbaName = getCorbaname(jndiName); - } - - connect(); - org.omg.CORBA.Object obj = orb.string_to_object(corbaName); - return obj; - } - - /** - * The character escape rules for the stringified name portion of an - * corbaname are: US-ASCII alphanumeric characters are not escaped. - * Characters outside this range are escaped, except for the following: ; / : ? @ & = + $ , - _ . ! ~ * ' ( ) - * corbaname Escape Mechanism The percent '%' character is used as an - * escape. If a character that requires escaping is present in a name - * component it is encoded as two hexadecimal digits following a "%" - * character to represent the octet. (The first hexadecimal character - * represent the highorder nibble of the octet, the second hexadecimal - * character represents the low-order nibble.) If a '%' is not followed by - * two hex digits, the stringified name is syntactically invalid. - * @param s - * @return RFC2396-encoded stringified name - */ - static String encode2396(String s) { - if (s == null) { - return null; - } - StringBuffer encoded = new StringBuffer(s); - for (int i = 0; i < encoded.length(); i++) { - char c = encoded.charAt(i); - if (RFC2396.indexOf(c) == -1) { - encoded.setCharAt(i, '%'); - char[] ac = Integer.toHexString(c).toCharArray(); - if (ac.length == 2) { - encoded.insert(i + 1, ac); - } else if (ac.length == 1) { - encoded.insert(i + 1, '0'); - encoded.insert(i + 2, ac[0]); - } else { - throw new IllegalArgumentException("Invalid character '" + c + "' in \"" + s + "\""); - } - i += 2; // NOPMD - } - } - return encoded.toString(); - } - - /** - * Decode an RFC2396-encoded string - * - * @param s - * @return Plain string - */ - static String decode2396(String s) { - if (s == null) { - return null; - } - StringBuffer decoded = new StringBuffer(s); - for (int i = 0; i < decoded.length(); i++) { - char c = decoded.charAt(i); - if (c == '%') { - if (i + 2 >= decoded.length()) { - throw new IllegalArgumentException("Incomplete key_string escape sequence"); - } - int j; - j = HEX.indexOf(decoded.charAt(i + 1)) * 16 + HEX.indexOf(decoded.charAt(i + 2)); - decoded.setCharAt(i, (char)j); - decoded.delete(i + 1, i + 3); - } else if (RFC2396.indexOf(c) == -1) { - throw new IllegalArgumentException("Invalid key_string character '" + c + "'"); - } - } - return decoded.toString(); - } - - /** - * The backslash '\' character escapes the reserved meaning of '/', '.', and - * '\' in a stringified name. - * - * @param jndiName - * @return Escaped stringified name for CosNaming - */ - private static String stringify(String jndiName) { - // Escape . into \. since it's an INS naming delimiter - return replace(encode2396(jndiName), ".", "\\."); - } - - /** - * Escape the "." into "%5C%2E" - * - * @param jndiName - * @return corbaname treating "." as a literal - */ - private static String toCorbaname(String jndiName) { - // Escape . into %5C%2E (\.) since it's an INS naming delimiter - // For example, sca.sample.StockQuote ---> - // sca%5C%2Esample%5C%2EStockQuote/StockQuote - return replace(encode2396(jndiName), ".", "%5C%2E"); - } - - private CosNamingLocator getObjectLocator() throws NamingException { - if (locator != null) { - return locator; - } - locator = new CosNamingLocator(); - return locator; - } - - public Object locate(String jndiName) throws NamingException { - - Object result = getObjectLocator().locate(jndiName); - return result; - } - - private final class CosNamingLocator { - private NamingContextExt context; - - private CosNamingLocator() { - } - - public Object locate(String name) throws NamingException { - if (context != null) { - return resovleString(context, name); - } else { - return stringToObject(name); - } - } - } -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/TuscanyServant.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/TuscanyServant.java deleted file mode 100644 index e6733a8c71..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/TuscanyServant.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.binding.corba.impl; - -import org.omg.CORBA.ORB; -import org.omg.CORBA.ServerRequest; -import org.omg.PortableServer.DynamicImplementation; -import org.omg.PortableServer.POA; - - -/** - * This is the CORBA DSI servant that dispatches CORBA requests to SCA components - * - * @version $Rev$ $Date$ - */ -public class TuscanyServant extends DynamicImplementation { - private ORB orb; - - @Override - public void invoke(ServerRequest request) { - } - - @Override - public String[] _all_interfaces(POA poa, byte[] objectId) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java deleted file mode 100644 index efa06296cc..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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.binding.corba.impl.reference; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.binding.corba.exceptions.CorbaException; -import org.apache.tuscany.sca.binding.corba.exceptions.RequestConfigurationException; -import org.apache.tuscany.sca.binding.corba.types.TypeTree; -import org.apache.tuscany.sca.binding.corba.types.TypeTreeCreator; -import org.apache.tuscany.sca.binding.corba.types.util.TypeHelpersProxy; -import org.omg.CORBA.BAD_OPERATION; -import org.omg.CORBA.Object; -import org.omg.CORBA.SystemException; -import org.omg.CORBA.portable.ApplicationException; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.ObjectImpl; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ Represents single CORBA request - */ -public class DynaCorbaRequest { - - private TypeTree returnTree; - private List arguments = new ArrayList(); - private List exceptions = new ArrayList(); - private OutputStream outputStream; - private ObjectImpl remoteObject; - private String operation; - - /** - * Creates request. - * - * @param ObjectremoteObject - * remote object reference - * @param operation - * operation to invoke - */ - public DynaCorbaRequest(Object remoteObject, String operation) { - outputStream = ((ObjectImpl) remoteObject)._request(operation, true); - this.remoteObject = (ObjectImpl) remoteObject; - this.operation = operation; - - } - - /** - * Adds operation argument - * - * @param argument - */ - public void addArgument(java.lang.Object argument) { - TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass()); - TypeHelpersProxy.write(tree.getRootNode(), outputStream, argument); - } - - /** - * Sets return type for operation - * - * @param forClass - */ - public void setOutputType(Class forClass) { - returnTree = TypeTreeCreator.createTypeTree(forClass); - } - - /** - * Configures possible exceptions - * - * @param forClass - */ - public void addExceptionType(Class forClass) { - TypeTree tree = TypeTreeCreator.createTypeTree(forClass); - exceptions.add(tree); - } - - /** - * Handles application excpeition. - * - * @param ae - * occured exception - * @throws Exception - */ - private void handleApplicationException(ApplicationException ae) - throws Exception { - try { - if (exceptions.size() == 0) { - RequestConfigurationException exception = new RequestConfigurationException( - "ApplicationException occured, but no exception type was specified.", - ae.getId()); - throw exception; - } else if (exceptions.size() == 1) { - InputStream is = ae.getInputStream(); - is.read_string(); - TypeTree tree = exceptions.get(0); - Exception userExc = (Exception) TypeHelpersProxy.read(tree - .getRootNode(), is); - //TODO: handle errors during blind exception creation - throw userExc; - } else if (exceptions.size() > 1) { - RequestConfigurationException exception = new RequestConfigurationException( - "ApplicationException occured, but user specified more than one exception type. Cannot distinguish type of occured exception.", - ae.getId()); - throw exception; - } - } catch (Exception e) { - throw e; - } - } - - /** - * Handles exceptions generated by CORBA API - * - * @param se - */ - private void handleSystemException(SystemException se) throws Exception { - if (se instanceof BAD_OPERATION) { - throw new CorbaException("Bad operation name: " + operation, se); - } else { - //TODO: handle more system exception types - throw new CorbaException(se.getMessage(), se); - } - } - - /** - * Invokes previously configured request - * - * @return - */ - public DynaCorbaResponse invoke() throws Exception { - DynaCorbaResponse response = new DynaCorbaResponse(); - InputStream is = null; - try { - is = remoteObject._invoke(outputStream); - if (is != null && returnTree != null) { - response.setContent(TypeHelpersProxy.read(returnTree - .getRootNode(), is)); - } - } catch (ApplicationException ae) { - handleApplicationException(ae); - } catch (SystemException se) { - handleSystemException(se); - } catch (Exception e) { - throw e; - } - return response; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaResponse.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaResponse.java deleted file mode 100644 index 8d25f229de..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.binding.corba.impl.reference; - -/** - * @version $Rev$ $Date$ - * Holder for content returned from DynaCorbaRequest - * - */ -public class DynaCorbaResponse { - - private Object content; - - public Object getContent() { - return content; - } - - public void setContent(Object content) { - this.content = content; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceInstanceCreator.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceInstanceCreator.java deleted file mode 100644 index 5c24e035de..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceInstanceCreator.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.binding.corba.impl.reference; - -import java.lang.reflect.Method; - -import net.sf.cglib.proxy.Callback; -import net.sf.cglib.proxy.CallbackFilter; -import net.sf.cglib.proxy.Enhancer; -import net.sf.cglib.proxy.MethodInterceptor; -import net.sf.cglib.proxy.NoOp; - -import org.omg.CORBA.Object; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceInstanceCreator { - - private static final CallbackFilter FILTER = new CallbackFilter() { - public int accept(Method method) { - return 1; - } - }; - - /** - * Dynamically creates instance of user defined interface. Instance is - * enhanced by RemoteMethodInterceptor - * - * @param reference - * CORBA reference - * @param forClass - * user defined interface - * @return dynamic implementation instance - */ - public static java.lang.Object createInstance(Object reference, - Class forClass) { - java.lang.Object result = null; - try { - Enhancer enhancer = new Enhancer(); - enhancer.setInterfaces(new Class[] { forClass }); - enhancer.setCallbackFilter(FILTER); - enhancer.setCallbackTypes(new Class[] { NoOp.class, - MethodInterceptor.class }); - Class newClass = enhancer.createClass(); - Enhancer.registerStaticCallbacks(newClass, new Callback[] { - NoOp.INSTANCE, new InterfaceMethodInterceptor(reference) }); - result = newClass.newInstance(); - } catch (Exception e) { - e.printStackTrace(); - } - return result; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceMethodInterceptor.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceMethodInterceptor.java deleted file mode 100644 index f8af8a8d6a..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/InterfaceMethodInterceptor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.binding.corba.impl.reference; - -import java.lang.reflect.Method; - -import net.sf.cglib.proxy.MethodInterceptor; -import net.sf.cglib.proxy.MethodProxy; - -import org.omg.CORBA.Object; - -/** - * @version $Rev$ $Date$ - * Interceptor for CORBA reference methods - */ -public class InterfaceMethodInterceptor implements MethodInterceptor { - - private Object reference; - - public InterfaceMethodInterceptor(Object reference) { - this.reference = reference; - } - - /** - * Create and execute DynaCorbaRequest instance, basing on intercepted - * method arguments, return types, exceptions - */ - public java.lang.Object intercept(java.lang.Object object, Method method, - java.lang.Object[] arguments, MethodProxy arg3) throws Throwable { - DynaCorbaRequest request = new DynaCorbaRequest(reference, method - .getName()); - for (int i = 0; i < arguments.length; i++) { - request.addArgument(arguments[i]); - } - request.setOutputType(method.getReturnType()); - Class[] exceptions = method.getExceptionTypes(); - for (int i = 0; i < exceptions.length; i++) { - request.addExceptionType(exceptions[i]); - } - DynaCorbaResponse response = request.invoke(); - return response.getContent(); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/NodeType.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/NodeType.java deleted file mode 100644 index 85fc2c9f78..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/NodeType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.binding.corba.types; - -/** - * @version $Rev$ $Date$ - * Types of CORBA objects. - */ -public enum NodeType { - primitive, struct, union, array, sequence, reference -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTree.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTree.java deleted file mode 100644 index b15c1cd98e..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTree.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.binding.corba.types; - -import java.util.HashMap; -import java.util.Map; - -/** - * @version $Rev$ $Date$ - * Helper tree for Java object hierarchy. It's closer to CORBA types structure - * than plain Java hierarchy - it helps reading and writing complex structures. - */ -public class TypeTree { - - private Map, TypeTreeNode> typesUsed = new HashMap, TypeTreeNode>(); - private TypeTreeNode rootNode; - - /** - * Intent was to cache previously computed type trees. In practice it caused - * a bug, and it's not being used right now. TODO: enable type trees caching - * - * @param forClass - * @param node - */ - public void addUsedType(Class forClass, TypeTreeNode node) { - typesUsed.put(forClass, node); - } - - /** - * Returns node for previously created tree, it's getter for nodes added by - * addUsedType method. Not in use right now. TODO: enable type trees caching - * - * @param forClass - * @return - */ - public TypeTreeNode getNodeForType(Class forClass) { - return typesUsed.get(forClass); - } - - /** - * Returns root node. - * - * @return root of type tree - */ - public TypeTreeNode getRootNode() { - return rootNode; - } - - /** - * Sets root of the type tree. - * - * @param rootNode - * root node. - */ - public void setRootNode(TypeTreeNode rootNode) { - this.rootNode = rootNode; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeCreator.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeCreator.java deleted file mode 100644 index 4f79719ed4..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeCreator.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.binding.corba.types; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - -/** - * @version $Rev$ $Date$ - * Creator of types tree. - * - */ -public class TypeTreeCreator { - - /** - * Helps to determine if type is a primitive. - */ - private static List> primitives = new ArrayList>(); - - static { - primitives.add(boolean.class); - primitives.add(byte.class); - primitives.add(short.class); - primitives.add(int.class); - primitives.add(long.class); - primitives.add(double.class); - primitives.add(float.class); - primitives.add(char.class); - primitives.add(String.class); - primitives.add(Boolean.class); - primitives.add(Byte.class); - primitives.add(Short.class); - primitives.add(Integer.class); - primitives.add(Long.class); - primitives.add(Double.class); - primitives.add(Float.class); - primitives.add(Character.class); - } - - /** - * Creates class for given string argument. - * - * @param name - * name of type - * @return type - */ - private static Class createClassFromString(String name) { - Class result = null; - try { - if (name.length() == 1) { - // primitives - switch (name.charAt(0)) { - case 'Z': - result = boolean.class; - break; - case 'C': - result = char.class; - break; - case 'B': - result = byte.class; - break; - case 'S': - result = short.class; - break; - case 'I': - result = int.class; - break; - case 'J': - result = long.class; - break; - case 'F': - result = float.class; - break; - case 'D': - result = double.class; - break; - } - } else { - // class - name = name.substring(1, name.length() - 1); - result = Class.forName(name); - } - } catch (Exception e) { - e.printStackTrace(); - } - return result; - } - - /** - * Reduces dimension of array. - * - * @param forClass - * array class - * @return reduced array - */ - private static Class reduceArrayDimension(Class forClass) { - String name = forClass.getName(); - try { - String reduced = name.substring(1, name.length()); - if (reduced.startsWith("[")) { - // reduced class is still an array - return Class.forName(reduced); - } else { - // reduced class may be primitive or class - return createClassFromString(reduced); - } - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - return null; - } - - /** - * Creates tree for given type. - * - * @param forClass - * @return type tree - */ - public static TypeTree createTypeTree(Class forClass) { - TypeTree tree = new TypeTree(); - TypeTreeNode rootNode = null; - rootNode = inspectClassHierarchy(forClass, tree); - tree.setRootNode(rootNode); - return tree; - - } - - /** - * Recurrent method which builds type tree. - * - * @param forClass - * @param tree - * @return - */ - private static TypeTreeNode inspectClassHierarchy(Class forClass, - TypeTree tree) { - // //remains of type tree caching - // TypeTreeNode existingNode = tree.getNodeForType(forClass); - // if (existingNode != null) { - // return existingNode; - // } - - TypeTreeNode node = createTypeNode(forClass); - NodeType nodeType = node.getNodeType(); - TypeTreeNode[] children = null; - - // //remains of type tree caching - // tree.addUsedType(forClass, node); - - if (nodeType.equals(NodeType.primitive)) { - // stop condition for recurrent method - } else if (nodeType.equals(NodeType.array)) { - // similar to sequence, but with fixed array length - // TODO: determine how array length will be declared - } else if (nodeType.equals(NodeType.sequence)) { - // reducing sequence dimension - Class reduced = reduceArrayDimension(node.getJavaClass()); - children = new TypeTreeNode[1]; - children[0] = inspectClassHierarchy(reduced, tree); - } else if (nodeType.equals(NodeType.struct)) { - // inspect types for every structure member - Field[] fields = node.getJavaClass().getFields(); - children = new TypeTreeNode[fields.length]; - for (int i = 0; i < fields.length; i++) { - Class field = fields[i].getType(); - TypeTreeNode child = inspectClassHierarchy(field, tree); - child.setName(fields[i].getName()); - children[i] = child; - } - } else if (nodeType.equals(NodeType.union)) { - // TODO: unions - } else if (nodeType.equals(NodeType.reference)) { - // TODO: CORBA references - } - - node.setChildren(children); - return node; - } - - /** - * Creating and configuring TypeTreeNode for given class. - * - * @param forClass - * class - * @return node - */ - private static TypeTreeNode createTypeNode(Class forClass) { - TypeTreeNode node = new TypeTreeNode(); - if (forClass.isArray()) { - node.setNodeType(NodeType.sequence); - node.setJavaClass(forClass); - } else if (primitives.contains(forClass)) { - node.setNodeType(NodeType.primitive); - node.setJavaClass(forClass); - node.setChildren(null); - } else if (forClass.isInterface()) { - node.setNodeType(NodeType.reference); - node.setJavaClass(forClass); - node.setChildren(null); - } else { - node.setNodeType(NodeType.struct); - node.setJavaClass(forClass); - } - return node; - } -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeNode.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeNode.java deleted file mode 100644 index c8509ff2e4..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/TypeTreeNode.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.binding.corba.types; - -/** - * @version $Rev$ $Date$ - * Represents single tree node. - * - */ -public class TypeTreeNode { - - private NodeType nodeType; - private TypeTreeNode[] children; - private Class javaClass; - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public NodeType getNodeType() { - return nodeType; - } - - public void setNodeType(NodeType nodeType) { - this.nodeType = nodeType; - } - - public TypeTreeNode[] getChildren() { - return children; - } - - public void setChildren(TypeTreeNode[] children) { - this.children = children; - } - - public Class getJavaClass() { - return javaClass; - } - - public void setJavaClass(Class javaClass) { - this.javaClass = javaClass; - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ArrayTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ArrayTypeHelper.java deleted file mode 100644 index e1d047b543..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ArrayTypeHelper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; -/** - * @version $Rev$ $Date$ - */ -public class ArrayTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - // TODO Auto-generated method stub - return null; - } - - public Object read(TypeTreeNode node, InputStream is) { - // TODO Auto-generated method stub - return null; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - // TODO Auto-generated method stub - - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/BooleanTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/BooleanTypeHelper.java deleted file mode 100644 index 681d46342b..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/BooleanTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class BooleanTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(8)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_boolean(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_boolean((Boolean) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ByteTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ByteTypeHelper.java deleted file mode 100644 index f9d58bdf9a..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ByteTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ByteTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(10)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_octet(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_octet((Byte) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/CharTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/CharTypeHelper.java deleted file mode 100644 index 393493c925..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/CharTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class CharTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(9)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_char(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_char((Character) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/DoubleTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/DoubleTypeHelper.java deleted file mode 100644 index fb4e319939..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/DoubleTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class DoubleTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(7)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_double(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_double((Double) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/FloatTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/FloatTypeHelper.java deleted file mode 100644 index ffccf94f4a..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/FloatTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class FloatTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(6)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_float(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_float((Float) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/IntTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/IntTypeHelper.java deleted file mode 100644 index ecb886333a..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/IntTypeHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class IntTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(3)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_long(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_long((Integer) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/LongTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/LongTypeHelper.java deleted file mode 100644 index bbcdc6a07a..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/LongTypeHelper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class LongTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(23)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_longlong(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_longlong((Long) data); - } - - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ReferenceTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ReferenceTypeHelper.java deleted file mode 100644 index c34e38b76d..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ReferenceTypeHelper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.impl.reference.InterfaceInstanceCreator; -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.Object; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - // TODO Auto-generated method stub - return null; - } - - public java.lang.Object read(TypeTreeNode node, InputStream is) { - Object reference = is.read_Object(); - return (java.lang.Object) InterfaceInstanceCreator.createInstance(reference, node.getJavaClass()); - } - - public void write(TypeTreeNode node, OutputStream os, java.lang.Object data) { - os.write_Object((Object) data); - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/SequenceTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/SequenceTypeHelper.java deleted file mode 100644 index b14aa6f972..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/SequenceTypeHelper.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class SequenceTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - TypeCode typeCode = - org.omg.CORBA.ORB.init().create_alias_tc( - node.getJavaClass().getSimpleName(), - node.getJavaClass().getSimpleName(), - org.omg.CORBA.ORB.init().create_sequence_tc(0, - TypeHelpersProxy.getType(node.getChildren()[0]))); - return typeCode; - } - - public Object read(TypeTreeNode node, InputStream is) { - Object sequence = null; - try { - int size = is.read_long(); - sequence = Array.newInstance(node.getChildren()[0].getJavaClass(), - size); - for (int i = 0; i < size; i++) { - Array.set(sequence, i, TypeHelpersProxy.read( - node.getChildren()[0], is)); - } - } catch (Exception e) { - e.printStackTrace(); - } - return sequence; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - int sum = 0; - // determine length of array - List array = new ArrayList(); - while (true) { - try { - array.add(Array.get(data, sum)); - sum++; - } catch (ArrayIndexOutOfBoundsException e) { - break; - } - } - os.write_long(sum); - Iterator iter = array.iterator(); - while (iter.hasNext()) { - Object elem = iter.next(); - TypeHelpersProxy.write(node.getChildren()[0], os, elem); - } - - } -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ShortTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ShortTypeHelper.java deleted file mode 100644 index 36c89984c7..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/ShortTypeHelper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class ShortTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.from_int(2)); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_short(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_short((Short) data); - } - - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StringTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StringTypeHelper.java deleted file mode 100644 index b3f22c6737..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StringTypeHelper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class StringTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - return ORB.init().create_string_tc(0); - } - - public Object read(TypeTreeNode node, InputStream is) { - return is.read_string(); - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - os.write_string((String) data); - } - - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StructTypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StructTypeHelper.java deleted file mode 100644 index 50e28cbd85..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/StructTypeHelper.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import java.lang.reflect.Field; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.StructMember; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public class StructTypeHelper implements TypeHelper { - - public TypeCode getType(TypeTreeNode node) { - TypeTreeNode[] children = node.getChildren(); - if (children != null) { - StructMember[] members = new StructMember[children.length]; - for (int i = 0; i < children.length; i++) { - members[i] = new StructMember(children[i].getJavaClass() - .getSimpleName(), - TypeHelpersProxy.getType(children[i]), null); - } - TypeCode result = org.omg.CORBA.ORB.init().create_struct_tc( - node.getJavaClass().getSimpleName(), - node.getJavaClass().getSimpleName(), members); - return result; - } else { - return null; - } - } - - public Object read(TypeTreeNode node, InputStream is) { - TypeTreeNode[] children = node.getChildren(); - Object result = null; - if (children != null) { - try { - result = node.getJavaClass().newInstance(); - for (int i = 0; i < children.length; i++) { - Object childResult = TypeHelpersProxy.read(children[i], is); - Field childField = result.getClass().getField( - children[i].getName()); - childField.set(result, childResult); - } - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - } - } - return result; - } - - public void write(TypeTreeNode node, OutputStream os, Object data) { - TypeTreeNode[] children = node.getChildren(); - if (children != null) { - try { - for (int i = 0; i < children.length; i++) { - Field childField = node.getJavaClass().getField( - children[i].getName()); - TypeHelpersProxy.write(children[i], os, childField - .get(data)); - } - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - } - } - } - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelper.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelper.java deleted file mode 100644 index c94fa79d83..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - */ -public interface TypeHelper { - - /** - * Gets type definition for CORBA API. - * @param node - * @return - */ - TypeCode getType(TypeTreeNode node); - - /** - * Reads CORBA object - * @param node - * @param is - * @return - */ - Object read(TypeTreeNode node, InputStream is); - - /** - * Writes CORBA object - * @param node - * @param os - * @param data - */ - void write(TypeTreeNode node, OutputStream os, Object data); - -} diff --git a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelpersProxy.java b/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelpersProxy.java deleted file mode 100644 index c81f101a7e..0000000000 --- a/branches/sca-java-1.3/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/types/util/TypeHelpersProxy.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.binding.corba.types.util; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.binding.corba.types.NodeType; -import org.apache.tuscany.sca.binding.corba.types.TypeTreeNode; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.OutputStream; - -/** - * @version $Rev$ $Date$ - * Proxies getType(), write(), read() methods to appropriate TypeHelper implementation. - */ -public class TypeHelpersProxy { - - /** - * Maps primitive types to its TypeHelper implementations - */ - private static Map, TypeHelper> primitiveTypes = null; - - /** - * Maps other types to its TypeHelper implementations - */ - private static Map complexTypes = null; - - static { - // initiate type helpers - primitiveTypes = new HashMap, TypeHelper>(); - complexTypes = new HashMap(); - - primitiveTypes.put(boolean.class, new BooleanTypeHelper()); - primitiveTypes.put(char.class, new CharTypeHelper()); - primitiveTypes.put(byte.class, new ByteTypeHelper()); - primitiveTypes.put(short.class, new ShortTypeHelper()); - primitiveTypes.put(int.class, new IntTypeHelper()); - primitiveTypes.put(long.class, new LongTypeHelper()); - primitiveTypes.put(float.class, new FloatTypeHelper()); - primitiveTypes.put(double.class, new DoubleTypeHelper()); - primitiveTypes.put(String.class, new StringTypeHelper()); - primitiveTypes.put(Boolean.class, primitiveTypes.get(boolean.class)); - primitiveTypes.put(Character.class, primitiveTypes.get(char.class)); - primitiveTypes.put(Byte.class, primitiveTypes.get(byte.class)); - primitiveTypes.put(Short.class, primitiveTypes.get(short.class)); - primitiveTypes.put(Integer.class, primitiveTypes.get(int.class)); - primitiveTypes.put(Long.class, primitiveTypes.get(long.class)); - primitiveTypes.put(Float.class, primitiveTypes.get(float.class)); - primitiveTypes.put(Double.class, primitiveTypes.get(double.class)); - primitiveTypes.put(String.class, primitiveTypes.get(String.class)); - complexTypes.put(NodeType.array, new ArrayTypeHelper()); - complexTypes.put(NodeType.struct, new StructTypeHelper()); - complexTypes.put(NodeType.reference, new ReferenceTypeHelper()); - complexTypes.put(NodeType.sequence, new SequenceTypeHelper()); - } - - /** - * Gets type helper basing on given type - * - * @param node - * @return - */ - private static TypeHelper getTypeHelper(TypeTreeNode node) { - TypeHelper typeHelper = null; - NodeType type = node.getNodeType(); - if (type.equals(NodeType.primitive)) { - typeHelper = primitiveTypes.get(node.getJavaClass()); - } else { - typeHelper = complexTypes.get(type); - } - return typeHelper; - } - - /** - * Proxies getType method invocation to appropriate TypeHelper - * implementation. It's not being used since I've changed method for passing - * arguments. May be useful while implementing CORBA service bindings. - * - * @param node - * @return - */ - public static final TypeCode getType(TypeTreeNode node) { - TypeHelper typeHelper = getTypeHelper(node); - TypeCode typeCode = typeHelper.getType(node); - return typeCode; - } - - /** - * Proxies read method invocation to appropriate TypeHelper implementation. - * - * @param node - * @param is - * @return - */ - public static final Object read(TypeTreeNode node, InputStream is) { - TypeHelper helper = getTypeHelper(node); - return helper.read(node, is); - } - - /** - * Proxies write method invocation to appropriate TypeHelper implementation. - * - * @param node - * @param os - * @param data - */ - public static final void write(TypeTreeNode node, OutputStream os, - Object data) { - TypeHelper helper = getTypeHelper(node); - helper.write(node, os, data); - } - -} -- cgit v1.2.3