You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/08 19:26:19 UTC
svn commit: r582899 - in /incubator/cxf/branches/2.0.x-fixes: ./
rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/
rt/databinding/aegis/src/main/resources/META-INF/cxf/
rt/databinding/aegis/src/schema/ rt/databinding/aegis/src/test/java/org...
Author: dkulp
Date: Mon Oct 8 10:26:17 2007
New Revision: 582899
URL: http://svn.apache.org/viewvc?rev=582899&view=rev
Log:
Merged revisions 579391 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r579391 | dandiep | 2007-09-25 17:34:17 -0400 (Tue, 25 Sep 2007) | 1 line
CXF-1054 patch to fix many Aegis bugs thanks to Benson! Also CXF-1062 - properly stop an EndpointImpl.
........
Added:
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/resources/META-INF/cxf/
- copied from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/main/resources/META-INF/cxf/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/resources/META-INF/cxf/aegis.xsd
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/main/resources/META-INF/cxf/aegis.xsd
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceDocLiteral.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceDocLiteral.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceDocLiteralImpl.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceDocLiteralImpl.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/
- copied from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/MapsTest.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/MapsTest.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/
- copied from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTest.aegis.xml
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTest.aegis.xml
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTest.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTest.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTestImpl.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/MapTestImpl.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/ObjectWithAMap.java
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/fortest/ObjectWithAMap.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/package.html
- copied unchanged from r579391, incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/map/package.html
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/schema/mapping.xsd
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/Student.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceImpl.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentTest.java
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java Mon Oct 8 10:26:17 2007
@@ -249,7 +249,7 @@
}
protected Type getOrCreateMapValueType(TypeClassInfo info) {
- return nextCreator.getOrCreateMapKeyType(info);
+ return nextCreator.getOrCreateMapValueType(info);
}
protected Type createMapType(TypeClassInfo info, Type keyType, Type valueType) {
@@ -392,7 +392,8 @@
Object genericType;
Object keyType;
-
+ Object valueType;
+
QName mappedName;
QName typeName;
@@ -500,6 +501,14 @@
@Override
public String toString() {
return "TypeClassInfo " + getDescription();
+ }
+
+ public Object getValueType() {
+ return valueType;
+ }
+
+ public void setValueType(Object valueType) {
+ this.valueType = valueType;
}
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java Mon Oct 8 10:26:17 2007
@@ -19,16 +19,29 @@
package org.apache.cxf.aegis.type;
import java.beans.PropertyDescriptor;
+import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,12 +49,12 @@
import org.apache.cxf.aegis.type.basic.BeanType;
import org.apache.cxf.aegis.type.basic.XMLBeanTypeInfo;
import org.apache.cxf.aegis.util.NamespaceHelper;
-import org.apache.cxf.aegis.util.jdom.StaxBuilder;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
+import org.jdom.input.DOMBuilder;
import org.jdom.xpath.XPath;
/**
@@ -79,7 +92,6 @@
* uniquely identify it. So in the example above, the mapping specifies will
* apply to both method 1 and method 2, since the parameter at index 0 is not
* specified.
- *
*/
public class XMLTypeCreator extends AbstractTypeCreator {
private static final Log LOG = LogFactory.getLog(XMLTypeCreator.class);
@@ -91,9 +103,84 @@
stopClasses.add(Throwable.class);
}
+ private static DocumentBuilderFactory aegisDocumentBuilderFactory;
+ private static Schema aegisSchema;
// cache of classes to documents
private Map<String, Document> documents = new HashMap<String, Document>();
+ static {
+ String path = "/META-INF/cxf/aegis.xsd";
+ InputStream is = XMLTypeCreator.class.getResourceAsStream(path);
+ if (is != null) {
+ try {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ aegisSchema = schemaFactory.newSchema(new StreamSource(is));
+ is.close();
+
+ aegisDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
+ aegisDocumentBuilderFactory.setSchema(aegisSchema);
+ } catch (IOException ie) {
+ LOG.error("Error reading Aegis schema", ie);
+ } catch (FactoryConfigurationError e) {
+ LOG.error("Error reading Aegis schema", e);
+ } catch (SAXException e) {
+ LOG.error("Error reading Aegis schema", e);
+ }
+ }
+ }
+
+ private Document readAegisFile(InputStream is, final String path) throws IOException {
+ DocumentBuilder documentBuilder;
+ try {
+ documentBuilder = aegisDocumentBuilderFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ LOG.error("Unable to create a document builder, e");
+ throw new RuntimeException("Unable to create a document builder, e");
+ }
+ org.w3c.dom.Document doc;
+ documentBuilder.setErrorHandler(new ErrorHandler() {
+
+ private String errorMessage(SAXParseException exception) {
+ return MessageFormat.format("{0} at {1} line {2} column {3}.",
+ new Object[] {exception.getMessage(), path,
+ Integer.valueOf(exception.getLineNumber()),
+ Integer.valueOf(exception.getColumnNumber())});
+ }
+
+ private void throwDatabindingException(String message) {
+ //DatabindingException is quirky. This dance is required to get the full message
+ //to where it belongs.
+ DatabindingException e = new DatabindingException(message);
+ e.setMessage(message);
+ throw e;
+ }
+
+ public void error(SAXParseException exception) throws SAXException {
+ String message = errorMessage(exception);
+ LOG.error(message, exception);
+ throwDatabindingException(message);
+
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException {
+ String message = errorMessage(exception);
+ LOG.error(message, exception);
+ throwDatabindingException(message);
+ }
+ public void warning(SAXParseException exception) throws SAXException {
+ LOG.info(errorMessage(exception), exception);
+ }
+ });
+
+ try {
+ doc = documentBuilder.parse(is);
+ } catch (SAXException e) {
+ LOG.error("Error parsing Aegis file.", e); // can't happen due to
+ // above.
+ return null;
+ }
+ return new DOMBuilder().build(doc);
+ }
protected Document getDocument(Class clazz) {
if (clazz == null) {
@@ -111,13 +198,13 @@
}
LOG.debug("Found mapping file : " + path);
try {
- doc = new StaxBuilder().build(is);
+ doc = readAegisFile(is, path);
documents.put(clazz.getName(), doc);
return doc;
- } catch (XMLStreamException e) {
+ } catch (IOException e) {
LOG.error("Error loading file " + path, e);
+ return null;
}
- return null;
}
@Override
@@ -293,11 +380,19 @@
}
// find the elements that apply to the specified method
- TypeClassInfo info = new TypeClassInfo();
+ TypeClassInfo info = nextCreator.createClassInfo(m, index); // start
+ // with the
+ // java5
+ // (or whatever) version.
+ if (info == null) {
+ info = new TypeClassInfo();
+ }
+
info.setDescription("method " + m.getName() + " parameter " + index);
if (index >= 0) {
if (index >= m.getParameterTypes().length) {
- throw new DatabindingException("Method " + m
+ throw new DatabindingException("Method "
+ + m
+ " does not have a parameter at index "
+ index);
}
@@ -307,14 +402,14 @@
+ "']/parameter[@index='" + index + "']/parent::*");
if (nodes.size() == 0) {
// no mapping for this method
- return nextCreator.createClassInfo(m, index);
+ return info;
}
// pick the best matching node
Element bestMatch = getBestMatch(mapping, m, nodes);
if (bestMatch == null) {
// no mapping for this method
- return nextCreator.createClassInfo(m, index);
+ return info;
}
info.setTypeClass(m.getParameterTypes()[index]);
// info.setAnnotations(m.getParameterAnnotations()[index]);
@@ -324,12 +419,12 @@
List<Element> nodes = getMatches(mapping, "./method[@name='" + m.getName()
+ "']/return-type/parent::*");
if (nodes.size() == 0) {
- return nextCreator.createClassInfo(m, index);
+ return info;
}
Element bestMatch = getBestMatch(mapping, m, nodes);
if (bestMatch == null) {
// no mapping for this method
- return nextCreator.createClassInfo(m, index);
+ return info;
}
info.setTypeClass(m.getReturnType());
// info.setAnnotations(m.getAnnotations());
@@ -345,6 +440,7 @@
info.setMappedName(createQName(parameter, parameter.getAttributeValue("mappedName")));
setComponentType(info, mapping, parameter);
setKeyType(info, mapping, parameter);
+ setValueType(info, mapping, parameter);
setType(info, parameter);
String min = parameter.getAttributeValue("minOccurs");
@@ -405,7 +501,7 @@
protected Type getOrCreateMapValueType(TypeClassInfo info) {
Type type = null;
if (info.getGenericType() != null) {
- type = createTypeFromGeneric(info.getGenericType());
+ type = createTypeFromGeneric(info.getValueType());
}
if (type == null) {
@@ -474,6 +570,13 @@
}
}
+ private void setValueType(TypeClassInfo info, Element mapping, Element parameter) {
+ String componentType = parameter.getAttributeValue("valueType");
+ if (componentType != null) {
+ info.setValueType(loadGeneric(info, mapping, componentType));
+ }
+ }
+
private Element getBestMatch(Element mapping, Method method, List<Element> availableNodes) {
// first find all the matching method names
List<Element> nodes = getMatches(mapping, "./method[@name='" + method.getName() + "']");
@@ -500,13 +603,13 @@
// first we check if the parameter index is specified
Element match = getMatch(element, "parameter[@index='" + i + "']");
if (match != null
- // we check if the type is specified and matches
+ // we check if the type is specified and matches
&& match.getAttributeValue("class") != null
// if it doesn't match, then we can definitely rule out
// this result
&& !match.getAttributeValue("class").equals(parameterType.getName())) {
-
- iterator.remove();
+
+ iterator.remove();
}
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/schema/mapping.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/schema/mapping.xsd?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/schema/mapping.xsd (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/schema/mapping.xsd Mon Oct 8 10:26:17 2007
@@ -18,8 +18,8 @@
under the License.
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://xfire.codehaus.org/aegis/1.0"
- xmlns:tns="http://xfire.codehaus.org/aegis/1.0"
+ targetNamespace="http://cxf.apache.org/aegis/1.1"
+ xmlns:tns="http://cxf.apache.org/aegis/1.1"
elementFormDefault="unqualified"
attributeFormDefault="unqualified" >
@@ -76,10 +76,13 @@
<attribute name="typeName" type="string" />
<attribute name="mappedName" type="string" />
<attribute name="nillable" type="boolean" />
+ <attribute name="flag" type="boolean" />
<attribute name="ignore" type="boolean" />
<attribute name="componentType" type="string" />
<attribute name="keyType" type="string" />
+ <attribute name="valueType" type="string" />
<attribute name="minOccurs" type="int"/>
+ <attribute name="maxOccurs" type="string"/> <!-- takes * -->
<attribute name="style">
<simpleType>
<restriction base="string">
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/Student.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/Student.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/Student.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/Student.java Mon Oct 8 10:26:17 2007
@@ -18,6 +18,38 @@
*/
package org.apache.cxf.aegis.type.java5.map;
+/**
+ * Data object used to test Aegis mapping of maps.
+ */
public class Student {
+ private String name;
+ private long id;
+
+ public Student() {
+ name = "";
+ id = Long.valueOf(0);
+ }
+
+ public Student(String name, long id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceImpl.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceImpl.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentServiceImpl.java Mon Oct 8 10:26:17 2007
@@ -18,29 +18,49 @@
*/
package org.apache.cxf.aegis.type.java5.map;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class StudentServiceImpl implements StudentService {
-
+
+ private Map<Long, Student> studentMap;
+
+ public StudentServiceImpl() {
+ studentMap = new HashMap<Long, Student>();
+ studentMap.put(Long.valueOf(1), new Student("Student1", 1));
+ studentMap.put(Long.valueOf(100), new Student("Student100", 100));
+ studentMap.put(Long.valueOf(-1), new Student("StudentNegative", -1));
+ }
+
public Student findStudent(Long id) {
- // TODO Auto-generated method stub
- return null;
+ return studentMap.get(id);
}
public List<Student> getStudents(Map<String, String> filters) {
- // TODO Auto-generated method stub
- return null;
+ List<Student> returnValue = new LinkedList<Student>();
+ for (Map.Entry<Long, Student> e : studentMap.entrySet()) {
+ if (filters.containsKey(e.getValue())) {
+ returnValue.add(e.getValue());
+ }
+
+ }
+ return returnValue;
}
public List<Student> getStudentsByIds(List<String> ids) {
- // TODO Auto-generated method stub
- return null;
+ List<Student> returnValue = new LinkedList<Student>();
+ for (String id : ids) {
+ Long longId = Long.decode(id);
+ Student s = studentMap.get(longId);
+ returnValue.add(s);
+ }
+ return returnValue;
}
public Map<Long, Student> getStudentsMap() {
- // TODO Auto-generated method stub
- return null;
+ return studentMap;
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentTest.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/map/StudentTest.java Mon Oct 8 10:26:17 2007
@@ -18,14 +18,20 @@
*/
package org.apache.cxf.aegis.type.java5.map;
+import java.util.Map;
+
import org.w3c.dom.Document;
import org.apache.cxf.aegis.AbstractAegisTest;
import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.junit.Test;
public class StudentTest extends AbstractAegisTest {
+
@Test
public void testWSDL() throws Exception {
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
@@ -34,9 +40,65 @@
sf.setAddress("local://StudentService");
setupAegis(sf);
Server server = sf.create();
-
Document wsdl = getWSDLDocument(server);
assertValid("//*[@name='string2stringMap']", wsdl);
+ }
+
+ @Test
+ public void testReturnMap() throws Exception {
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.setServiceClass(StudentService.class);
+ sf.setServiceBean(new StudentServiceImpl());
+ sf.setAddress("local://StudentService");
+ setupAegis(sf);
+ Server server = sf.create();
+ server.start();
+
+ JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+ proxyFac.setAddress("local://StudentService");
+ proxyFac.setServiceClass(StudentService.class);
+ proxyFac.setBus(getBus());
+ setupAegis(proxyFac.getClientFactoryBean());
+
+ StudentService clientInterface = (StudentService)proxyFac.create();
+ Map<Long, Student> fullMap = clientInterface.getStudentsMap();
+ assertNotNull(fullMap);
+ Student one = fullMap.get(Long.valueOf(1));
+ assertNotNull(one);
+ assertEquals("Student1", one.getName());
+
+ }
+
+ @Test
+ public void testReturnMapDocLiteral() throws Exception {
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.setServiceClass(StudentServiceDocLiteral.class);
+ sf.setServiceBean(new StudentServiceDocLiteralImpl());
+ sf.setAddress("local://StudentServiceDocLiteral");
+ setupAegis(sf);
+ Server server = sf.create();
+ server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+ server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+ server.start();
+
+ JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
+ proxyFac.setAddress("local://StudentServiceDocLiteral");
+ proxyFac.setServiceClass(StudentServiceDocLiteral.class);
+ proxyFac.setBus(getBus());
+ setupAegis(proxyFac.getClientFactoryBean());
+
+ proxyFac.getInInterceptors().add(new LoggingInInterceptor());
+ proxyFac.getOutInterceptors().add(new LoggingOutInterceptor());
+
+ StudentServiceDocLiteral clientInterface = (StudentServiceDocLiteral)proxyFac.create();
+ Map<Long, Student> fullMap = clientInterface.getStudentsMap();
+ assertNotNull(fullMap);
+ Student one = fullMap.get(Long.valueOf(1));
+ assertNotNull(one);
+ assertEquals("Student1", one.getName());
+
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Mon Oct 8 10:26:17 2007
@@ -200,6 +200,7 @@
public void stop() {
if (null != server) {
server.stop();
+ server = null;
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?rev=582899&r1=582898&r2=582899&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java Mon Oct 8 10:26:17 2007
@@ -68,6 +68,31 @@
}
+ @Test
+ public void testEndpointStop() throws Exception {
+ GreeterImpl greeter = new GreeterImpl();
+ EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
+
+ WebServiceContext ctx = greeter.getContext();
+ assertNull(ctx);
+ try {
+ String address = "http://localhost:8080/test";
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+ ctx = greeter.getContext();
+
+ assertNotNull(ctx);
+
+ // Test that calling stop on the Endpoint works
+ assertTrue(endpoint.isPublished());
+ endpoint.stop();
+ assertFalse(endpoint.isPublished());
+
+ }
+
@Test
public void testEndpointServiceConstructor() throws Exception {