You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2007/10/31 12:49:37 UTC
Re: svn commit: r590532 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
All I can say is "wow, what a hack". Nice job getting it to work.
Dan
On Tuesday 30 October 2007, bimargulies@apache.org wrote:
> Author: bimargulies
> Date: Tue Oct 30 18:41:40 2007
> New Revision: 590532
>
> URL: http://svn.apache.org/viewvc?rev=590532&view=rev
> Log:
> Arrange for schemas created by the ReflectionServiceFactoryBean to be
> added to the XmlSchemaCollection for the ServiceInfo.
>
> FINE a common log message instead of INFO.
>
>
>
> Modified:
>
> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
>injection/ResourceInjector.java
> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
>rvice/factory/ReflectionServiceFactoryBean.java
>
> Modified:
> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
>injection/ResourceInjector.java URL:
> http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/mai
>n/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=590532
>&r1=590531&r2=590532&view=diff
> ======================================================================
>======== ---
> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
>injection/ResourceInjector.java (original) +++
> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
>injection/ResourceInjector.java Tue Oct 30 18:41:40 2007 @@ -189,7
> +189,7 @@
> } else {
> resource = resolveResource(resourceName, clz);
>
> - LOG.log(Level.INFO, "RESOURCE_RESOLVE_FAILED", new
> Object[] {resourceName, clz}); + LOG.log(Level.FINE,
> "RESOURCE_RESOLVE_FAILED", new Object[] {resourceName, clz}); }
> }
>
>
> Modified:
> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
>rvice/factory/ReflectionServiceFactoryBean.java URL:
> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/sr
>c/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean
>.java?rev=590532&r1=590531&r2=590532&view=diff
> ======================================================================
>======== ---
> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
>rvice/factory/ReflectionServiceFactoryBean.java (original) +++
> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
>rvice/factory/ReflectionServiceFactoryBean.java Tue Oct 30 18:41:40
> 2007 @@ -19,6 +19,7 @@
>
> package org.apache.cxf.service.factory;
>
> +import java.io.StringReader;
> import java.lang.annotation.Annotation;
> import java.lang.reflect.Array;
> import java.lang.reflect.Field;
> @@ -80,6 +81,7 @@
> import org.apache.cxf.service.model.UnwrappedOperationInfo;
> import org.apache.cxf.wsdl.WSDLConstants;
> import org.apache.cxf.wsdl11.WSDLServiceFactory;
> +import org.apache.ws.commons.schema.ValidationEventHandler;
> import org.apache.ws.commons.schema.XmlSchema;
> import org.apache.ws.commons.schema.XmlSchemaCollection;
> import org.apache.ws.commons.schema.XmlSchemaComplexType;
> @@ -909,6 +911,22 @@
> }
> }
>
> +
> + /**
> + * This is a really ugly trick to get around a bug or oversight
> in XmlSchema, which is that + * there is no way to
> programmatically construct an XmlSchema instance that ends up
> cataloged + * in a collection. If there is a fix to WSCOMMONS-272,
> this can go away. + * @param collection collection to contain new
> schema
> + * @return new schema
> + */
> + private XmlSchema newXmlSchemaInCollection(XmlSchemaCollection
> collection, String namespaceURI) { + StringBuffer
> tinyXmlSchemaDocument = new StringBuffer(); +
> tinyXmlSchemaDocument.append("<xsd:schema
> xmlns:xsd='http://www.w3.org/2001/XMLSchema' "); +
> tinyXmlSchemaDocument.append("targetNamespace='" + namespaceURI +
> "'/>"); + StringReader reader = new
> StringReader(tinyXmlSchemaDocument.toString()); + return
> collection.read(reader, new ValidationEventHandler() { }); + }
> +
> private SchemaInfo getOrCreateSchema(ServiceInfo serviceInfo,
> String namespaceURI,
> boolean qualified) {
> @@ -921,7 +939,7 @@
> SchemaInfo schemaInfo = new SchemaInfo(serviceInfo,
> namespaceURI); XmlSchemaCollection col =
> serviceInfo.getXmlSchemaCollection();
>
> - XmlSchema schema = new XmlSchema(namespaceURI, col);
> + XmlSchema schema = newXmlSchemaInCollection(col,
> namespaceURI); if (qualified) {
> schema.setElementFormDefault(new
> XmlSchemaForm(XmlSchemaForm.QUALIFIED)); }
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
RE: svn commit: r590532 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Posted by Benson Margulies <bi...@basistech.com>.
Thanks.
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Wednesday, October 31, 2007 7:50 AM
> To: cxf-dev@incubator.apache.org
> Subject: Re: svn commit: r590532 - in /incubator/cxf/trunk:
>
common/common/src/main/java/org/apache/cxf/common/injection/ResourceInje
ct
> or.java
>
rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/Reflecti
on
> ServiceFactoryBean.java
>
>
> All I can say is "wow, what a hack". Nice job getting it to work.
>
> Dan
>
> On Tuesday 30 October 2007, bimargulies@apache.org wrote:
> > Author: bimargulies
> > Date: Tue Oct 30 18:41:40 2007
> > New Revision: 590532
> >
> > URL: http://svn.apache.org/viewvc?rev=590532&view=rev
> > Log:
> > Arrange for schemas created by the ReflectionServiceFactoryBean to
be
> > added to the XmlSchemaCollection for the ServiceInfo.
> >
> > FINE a common log message instead of INFO.
> >
> >
> >
> > Modified:
> >
> >
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
> >injection/ResourceInjector.java
> >
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
> >rvice/factory/ReflectionServiceFactoryBean.java
> >
> > Modified:
> >
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
> >injection/ResourceInjector.java URL:
> >
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/mai
>
>n/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=590532
> >&r1=590531&r2=590532&view=diff
> >
======================================================================
> >======== ---
> >
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
> >injection/ResourceInjector.java (original) +++
> >
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/
> >injection/ResourceInjector.java Tue Oct 30 18:41:40 2007 @@ -189,7
> > +189,7 @@
> > } else {
> > resource = resolveResource(resourceName, clz);
> >
> > - LOG.log(Level.INFO, "RESOURCE_RESOLVE_FAILED", new
> > Object[] {resourceName, clz}); + LOG.log(Level.FINE,
> > "RESOURCE_RESOLVE_FAILED", new Object[] {resourceName, clz}); }
> > }
> >
> >
> > Modified:
> >
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
> >rvice/factory/ReflectionServiceFactoryBean.java URL:
> >
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/sr
>
>c/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean
> >.java?rev=590532&r1=590531&r2=590532&view=diff
> >
======================================================================
> >======== ---
> >
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
> >rvice/factory/ReflectionServiceFactoryBean.java (original) +++
> >
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/se
> >rvice/factory/ReflectionServiceFactoryBean.java Tue Oct 30 18:41:40
> > 2007 @@ -19,6 +19,7 @@
> >
> > package org.apache.cxf.service.factory;
> >
> > +import java.io.StringReader;
> > import java.lang.annotation.Annotation;
> > import java.lang.reflect.Array;
> > import java.lang.reflect.Field;
> > @@ -80,6 +81,7 @@
> > import org.apache.cxf.service.model.UnwrappedOperationInfo;
> > import org.apache.cxf.wsdl.WSDLConstants;
> > import org.apache.cxf.wsdl11.WSDLServiceFactory;
> > +import org.apache.ws.commons.schema.ValidationEventHandler;
> > import org.apache.ws.commons.schema.XmlSchema;
> > import org.apache.ws.commons.schema.XmlSchemaCollection;
> > import org.apache.ws.commons.schema.XmlSchemaComplexType;
> > @@ -909,6 +911,22 @@
> > }
> > }
> >
> > +
> > + /**
> > + * This is a really ugly trick to get around a bug or oversight
> > in XmlSchema, which is that + * there is no way to
> > programmatically construct an XmlSchema instance that ends up
> > cataloged + * in a collection. If there is a fix to
WSCOMMONS-272,
> > this can go away. + * @param collection collection to contain
new
> > schema
> > + * @return new schema
> > + */
> > + private XmlSchema newXmlSchemaInCollection(XmlSchemaCollection
> > collection, String namespaceURI) { + StringBuffer
> > tinyXmlSchemaDocument = new StringBuffer(); +
> > tinyXmlSchemaDocument.append("<xsd:schema
> > xmlns:xsd='http://www.w3.org/2001/XMLSchema' "); +
> > tinyXmlSchemaDocument.append("targetNamespace='" + namespaceURI +
> > "'/>"); + StringReader reader = new
> > StringReader(tinyXmlSchemaDocument.toString()); + return
> > collection.read(reader, new ValidationEventHandler() { }); + }
> > +
> > private SchemaInfo getOrCreateSchema(ServiceInfo serviceInfo,
> > String namespaceURI,
> > boolean qualified) {
> > @@ -921,7 +939,7 @@
> > SchemaInfo schemaInfo = new SchemaInfo(serviceInfo,
> > namespaceURI); XmlSchemaCollection col =
> > serviceInfo.getXmlSchemaCollection();
> >
> > - XmlSchema schema = new XmlSchema(namespaceURI, col);
> > + XmlSchema schema = newXmlSchemaInCollection(col,
> > namespaceURI); if (qualified) {
> > schema.setElementFormDefault(new
> > XmlSchemaForm(XmlSchemaForm.QUALIFIED)); }
>
>
>
> --
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727 C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog