TUSCANY-2519 Fix so "throws exception" doesn't cause a failure in JAXB type generation

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685854 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
slaws 2008-08-14 11:20:30 +00:00
parent a4191dc7ae
commit 836523e74b
7 changed files with 206 additions and 2 deletions

View file

@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.example;
public class BusinessExceptionMinimal extends Exception {
public BusinessExceptionMinimal(String message) {
super(message);
}
}

View file

@ -0,0 +1,54 @@
/*
* 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 com.example;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
//@Service(ExampleClient.class)
@Scope("COMPOSITE")
//public class ExampleClientMinimalImpl implements ExampleClient {
public class ExampleClientMinimalImpl {
@Reference
protected ExampleServiceMinimal myService;
public void runTest() {
try {
//Object result = myService.hello("John");
myService.throwException("John");
//System.out.println("myService returned " + result.getClass().getName());
} catch (BusinessExceptionMinimal e) {
System.out.println("caught exception from hello(): " + e.getMessage() );
}
}
public String hello(String name) throws BusinessExceptionMinimal{
throw new BusinessExceptionMinimal("bad news");
}
public void throwException(String name) throws BusinessExceptionMinimal{
throw new BusinessExceptionMinimal("bad news");
}
public static void main(String[] args) {
}
}

View file

@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.example;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface ExampleServiceMinimal {
public String hello(String name) throws Exception;
public void throwException(String name) throws BusinessExceptionMinimal;
}

View file

@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.example;
public class ExampleServiceMinimalImpl implements ExampleServiceMinimal {
public String hello(String name) throws Exception {
throw new BusinessExceptionMinimal("minimal bad news" + name);
// return "Hello, " + name;
}
public void throwException(String name) throws BusinessExceptionMinimal {
throw new BusinessExceptionMinimal("minimal bad news" + name);
}
}

View file

@ -37,4 +37,20 @@
<binding.ws wsdlElement="http://example.com/#wsdl.port(ExampleService/ExampleServiceSOAP11port_http)" />
</service>
</component>
<component name="ExampleClientMinimalComponent">
<implementation.java class="com.example.ExampleClientMinimalImpl" />
<reference name="myService">
<interface.java interface="com.example.ExampleServiceMinimal"/>
<binding.ws uri="http://localhost:8085/ExampleMinimalComponent" />
</reference>
</component>
<component name="ExampleMinimalComponent">
<implementation.java class="com.example.ExampleServiceMinimalImpl" />
<service name="ExampleServiceMinimal">
<interface.java interface="com.example.ExampleServiceMinimal"/>
<binding.ws uri="http://localhost:8085/ExampleMinimalComponent" />
</service>
</component>
</composite>

View file

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.example;
import junit.framework.TestCase;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class ExampleMinimalTestCase extends TestCase {
private SCADomain scaDomain;
private ExampleClientMinimalImpl client;
@Override
protected void setUp() throws Exception {
scaDomain = SCADomain.newInstance("example.composite");
client = scaDomain.getService(ExampleClientMinimalImpl.class, "ExampleClientMinimalComponent");
}
@Override
protected void tearDown() throws Exception {
scaDomain.close();
}
public void test() throws Exception {
client.runTest();
}
}

View file

@ -36,6 +36,7 @@ import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.FaultExceptionMapper;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.util.FaultException;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.osoa.sca.ServiceRuntimeException;
@ -250,7 +251,7 @@ public class JAXWSFaultExceptionMapper implements FaultExceptionMapper {
}
@SuppressWarnings("unchecked")
public boolean introspectFaultDataType(DataType<DataType> exceptionType, Operation operation, final boolean generatingFaultBean) {
public boolean introspectFaultDataType(DataType<DataType> exceptionType, final Operation operation, final boolean generatingFaultBean) {
QName faultName = null;
boolean result = false;
@ -303,7 +304,10 @@ public class JAXWSFaultExceptionMapper implements FaultExceptionMapper {
} catch (ClassNotFoundException e) {
if (generatingFaultBean) {
Class<? extends Throwable> t = (Class<? extends Throwable>)cls;
GeneratedClassLoader cl = new GeneratedClassLoader(t.getClassLoader());
ClassLoader parent =
operation == null ? t.getClassLoader() : ((JavaInterface)operation.getInterface())
.getJavaClass().getClassLoader();
GeneratedClassLoader cl = new GeneratedClassLoader(parent);
GeneratedDataTypeImpl dt = new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, t, cl);
return dt;
} else {