You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/06/12 01:31:30 UTC
svn commit: r666899 - in /servicemix/sandbox/lhein/validation: ./
servicemix-validation/ servicemix-validation/src/
servicemix-validation/src/main/ servicemix-validation/src/main/java/
servicemix-validation/src/main/java/org/ servicemix-validation/src/...
Author: lhein
Date: Wed Jun 11 16:31:29 2008
New Revision: 666899
URL: http://svn.apache.org/viewvc?rev=666899&view=rev
Log:
- added first shot of a lw validate component replacement
Added:
servicemix/sandbox/lhein/validation/
servicemix/sandbox/lhein/validation/servicemix-validation/
servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/main/resources/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd (with props)
servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml (with props)
Added: servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+
+ 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.
+-->
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>serviceengines</artifactId>
+ <version>3.3-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-validation</artifactId>
+ <packaging>jbi-component</packaging>
+ <name>ServiceMix :: Validation</name>
+ <description>Validation Service Engine</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>jbi-maven-plugin</artifactId>
+ <version>${servicemix-version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <type>service-engine</type>
+ <component>org.apache.servicemix.validation.ValidationComponent</component>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>${xbean-version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ <configuration>
+ <namespace>http://servicemix.apache.org/validation/1.0</namespace>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,47 @@
+/*
+ * 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.servicemix.validation;
+
+import java.util.List;
+
+import org.apache.servicemix.common.DefaultComponent;
+
+/**
+ * @org.apache.xbean.XBean element="component"
+ * description="Validation Component"
+ */
+public class ValidationComponent extends DefaultComponent {
+
+ private ValidationEndpointType[] endpoints;
+
+ public ValidationEndpointType[] getEndpoints() {
+ return endpoints;
+ }
+
+ public void setEndpoints(ValidationEndpointType[] endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ protected List getConfiguredEndpoints() {
+ return asList(endpoints);
+ }
+
+ protected Class[] getEndpointClasses() {
+ return new Class[] { ValidationEndpoint.class };
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationComponent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,320 @@
+/*
+ * 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.servicemix.validation;
+
+import java.io.IOException;
+
+import javax.jbi.JBIException;
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.apache.servicemix.common.endpoints.ProviderEndpoint;
+import org.apache.servicemix.jbi.FaultException;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.util.MessageUtil;
+import org.apache.servicemix.validation.handler.CountingErrorHandlerFactory;
+import org.apache.servicemix.validation.handler.MessageAwareErrorHandler;
+import org.apache.servicemix.validation.handler.MessageAwareErrorHandlerFactory;
+import org.springframework.core.io.Resource;
+import org.xml.sax.SAXException;
+
+/**
+ * @org.apache.xbean.XBean element="endpoint"
+ */
+public class ValidationEndpoint extends ProviderEndpoint implements ValidationEndpointType {
+
+ public static final String FAULT_FLOW = "FAULT_FLOW";
+ public static final String FAULT_JBI = "FAULT_JBI";
+
+ private String handlingErrorMethod = "FAULT_JBI";
+ private Schema schema;
+ private String schemaLanguage = "http://www.w3.org/2001/XMLSchema";
+ private Source schemaSource;
+ private Resource schemaResource;
+ private MessageAwareErrorHandlerFactory errorHandlerFactory = new CountingErrorHandlerFactory();
+ private SourceTransformer sourceTransformer = new SourceTransformer();
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#start()
+ */
+ @Override
+ public void start() throws Exception {
+ super.start();
+
+ try {
+ if (schema == null) {
+ SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
+
+ if (schemaSource == null) {
+ if (schemaResource == null) {
+ throw new JBIException("You must specify a schema, schemaSource or schemaResource property");
+ }
+ if (schemaResource.getURL() == null) {
+ schemaSource = new StreamSource(schemaResource.getInputStream());
+ } else {
+ schemaSource = new StreamSource(schemaResource.getInputStream(), schemaResource.getURL().toExternalForm());
+ }
+ }
+ schema = factory.newSchema(schemaSource);
+ }
+ }
+ catch (IOException e) {
+ throw new JBIException("Failed to load schema: " + e, e);
+ }
+ catch (SAXException e) {
+ throw new JBIException("Failed to load schema: " + e, e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#stop()
+ */
+ @Override
+ public void stop() throws Exception {
+ super.stop();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#processInOnly(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage)
+ */
+ @Override
+ protected void processInOnly(MessageExchange exchange, NormalizedMessage in)
+ throws Exception {
+ NormalizedMessage out = exchange.createMessage();
+ Fault fault = null;
+ this.startValidation(exchange, in, out, fault);
+
+ if (fault != null) {
+ throw new RuntimeException(sourceTransformer.contentToString(fault));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#processInOut(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage, javax.jbi.messaging.NormalizedMessage)
+ */
+ @Override
+ protected void processInOut(MessageExchange exchange, NormalizedMessage in,
+ NormalizedMessage out) throws Exception {
+ Fault fault = null;
+ this.startValidation(exchange, in, out, fault);
+ if (fault != null) {
+ exchange.setFault(fault);
+ }
+ }
+
+ /**
+ * does the validation
+ *
+ * @param exchange
+ * @param in
+ * @param out
+ * @param fault
+ * @throws Exception
+ */
+ public void startValidation(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out, Fault fault) throws Exception {
+ Validator validator = schema.newValidator();
+
+ // create a new errorHandler and set it on the validator
+ MessageAwareErrorHandler errorHandler = errorHandlerFactory.createMessageAwareErrorHandler();
+ validator.setErrorHandler(errorHandler);
+ DOMResult result = new DOMResult();
+
+ try {
+ // Only DOMSource and SAXSource are allowed for validating
+ // See http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source,%20javax.xml.transform.Result)
+ // As we expect a DOMResult as output, we must ensure that the input is a
+ // DOMSource
+ DOMSource src = sourceTransformer.toDOMSource(in.getContent());
+ doValidation(validator, src, result);
+
+ if (errorHandler.hasErrors()) {
+ fault = exchange.createFault();
+
+ // Dont set the schema and source document as properties on the fault
+ // because they are not serializable
+ //fault.setProperty("org.apache.servicemix.xml", src);
+ // Dont set the schema because it contains an instance of
+ // com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaImpl that
+ // is not serializable
+ //fault.setProperty("org.apache.servicemix.schema", schema);
+
+ /*
+ * check if this error handler supports the capturing of
+ * error messages.
+ */
+ if (errorHandler.capturesMessages()) {
+
+ /*
+ * In descending order of preference select a format to use. If
+ * neither DOMSource, StringSource or String are supported throw
+ * a messaging exception.
+ */
+ if (errorHandler.supportsMessageFormat(DOMSource.class)) {
+ fault.setContent(
+ (DOMSource)errorHandler.getMessagesAs(DOMSource.class));
+ } else if (errorHandler.supportsMessageFormat(StringSource.class)) {
+ fault.setContent(sourceTransformer.toDOMSource(
+ (StringSource)errorHandler.getMessagesAs(StringSource.class)));
+ } else if (errorHandler.supportsMessageFormat(String.class)) {
+ fault.setContent(
+ sourceTransformer.toDOMSource(
+ new StringSource(
+ (String)errorHandler.getMessagesAs(String.class))));
+ } else {
+ throw new MessagingException("MessageAwareErrorHandler implementation " +
+ errorHandler.getClass().getName() +
+ " does not support a compatible error message format.");
+ }
+ } else {
+ /*
+ * we can't do much here if the ErrorHandler implementation does
+ * not support capturing messages
+ */
+ fault.setContent(new DOMSource(result.getNode(), result.getSystemId()));
+ }
+ if (!handlingErrorMethod.equalsIgnoreCase(FAULT_FLOW)) {
+ // HANDLE AS JBI FAULT
+ throw new FaultException("Failed to validate against schema: " + schema, exchange, fault);
+ } else {
+ MessageUtil.transfer(fault, out);
+ }
+ }
+ else {
+ // Retrieve the ouput of the validation
+ // as it may have been changed by the validator
+ out.setContent(new DOMSource(result.getNode(), result.getSystemId()));
+ }
+ }
+ catch (SAXException e) {
+ throw new MessagingException(e);
+ }
+ catch (IOException e) {
+ throw new MessagingException(e);
+ }
+ catch (ParserConfigurationException e) {
+ throw new MessagingException(e);
+ }
+ catch (TransformerException e) {
+ throw new MessagingException(e);
+ }
+ }
+
+ /**
+ * does the validation
+ *
+ * @param validator
+ * @param src
+ * @param result
+ * @throws SAXException
+ * @throws IOException
+ */
+ protected void doValidation(Validator validator, DOMSource src, DOMResult result) throws SAXException, IOException {
+ validator.validate(src, result);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.SimpleEndpoint#fail(javax.jbi.messaging.MessageExchange, java.lang.Exception)
+ */
+ protected void fail(MessageExchange messageExchange, Exception e) throws MessagingException {
+ super.fail(messageExchange, e);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.SimpleEndpoint#send(javax.jbi.messaging.MessageExchange)
+ */
+ protected void send(MessageExchange messageExchange) throws MessagingException {
+ super.send(messageExchange);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.SimpleEndpoint#sendSync(javax.jbi.messaging.MessageExchange)
+ */
+ protected void sendSync(MessageExchange messageExchange) throws MessagingException {
+ super.sendSync(messageExchange);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.servicemix.common.endpoints.SimpleEndpoint#done(javax.jbi.messaging.MessageExchange)
+ */
+ protected void done(MessageExchange messageExchange) throws MessagingException {
+ super.done(messageExchange);
+ }
+
+ public String getHandlingErrorMethod() {
+ return handlingErrorMethod;
+ }
+
+ public void setHandlingErrorMethod(String handlingErrorMethod) {
+ this.handlingErrorMethod = handlingErrorMethod;
+ }
+
+ public Schema getSchema() {
+ return schema;
+ }
+
+ public void setSchema(Schema schema) {
+ this.schema = schema;
+ }
+
+ public String getSchemaLanguage() {
+ return schemaLanguage;
+ }
+
+ public void setSchemaLanguage(String schemaLanguage) {
+ this.schemaLanguage = schemaLanguage;
+ }
+
+ public Source getSchemaSource() {
+ return schemaSource;
+ }
+
+ public void setSchemaSource(Source schemaSource) {
+ this.schemaSource = schemaSource;
+ }
+
+ public Resource getSchemaResource() {
+ return schemaResource;
+ }
+
+ public void setSchemaResource(Resource schemaResource) {
+ this.schemaResource = schemaResource;
+ }
+
+ public MessageAwareErrorHandlerFactory getErrorHandlerFactory() {
+ return errorHandlerFactory;
+ }
+
+ public void setErrorHandlerFactory(MessageAwareErrorHandlerFactory errorHandlerFactory) {
+ this.errorHandlerFactory = errorHandlerFactory;
+ }
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpoint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,26 @@
+/*
+ * 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.servicemix.validation;
+
+/**
+ * grouping interface
+ * @author lhein
+ */
+public interface ValidationEndpointType {
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/ValidationEndpointType.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,105 @@
+/*
+ * 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.servicemix.validation.handler;
+
+import javax.jbi.messaging.MessagingException;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+/**
+ * A simple implementation of {@link ErrorHandler} which just counts the number of warnings, errors and fatal errors.
+ *
+ * @version $Revision: 430194 $
+ */
+public class CountingErrorHandler implements MessageAwareErrorHandler {
+ private int warningCount;
+ private int errorCount;
+ private int fatalErrorCount;
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#hasErrors()
+ */
+ public boolean hasErrors() {
+ return getErrorCount() > 0 || getFatalErrorCount() > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getWarningCount()
+ */
+ public int getWarningCount() {
+ return warningCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getErrorCount()
+ */
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getFatalErrorCount()
+ */
+ public int getFatalErrorCount() {
+ return fatalErrorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
+ */
+ public void warning(SAXParseException e) throws SAXException {
+ ++warningCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
+ */
+ public void error(SAXParseException e) throws SAXException {
+ ++errorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ public void fatalError(SAXParseException e) throws SAXException {
+ ++fatalErrorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#capturesMessages()
+ */
+ public boolean capturesMessages() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getMessagesAs(java.lang.Class)
+ */
+ public Object getMessagesAs(Class format) throws MessagingException {
+ throw new MessagingException("Unsupported message format: " + format.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#supportsMessageFormat(java.lang.Class)
+ */
+ public boolean supportsMessageFormat(Class format) {
+ return false;
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.servicemix.validation.handler;
+
+/**
+ * @author gmcdonald
+ *
+ */
+public class CountingErrorHandlerFactory implements
+ MessageAwareErrorHandlerFactory {
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandlerFactory#createMessageAwareErrorHandler()
+ */
+ public MessageAwareErrorHandler createMessageAwareErrorHandler() {
+ return new CountingErrorHandler();
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/CountingErrorHandlerFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,314 @@
+/*
+ * 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.servicemix.validation.handler;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.jbi.messaging.MessagingException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+/**
+ * An implementation of {@link ErrorHandler} which aggregates all warnings and
+ * error messages into a StringBuffer.
+ *
+ * @version $Revision: 359186 $
+ */
+public class MessageAggregatingErrorHandler implements MessageAwareErrorHandler {
+
+ private static final String openCDATA = "<![CDATA[";
+ private static final String closeCDATA = "]]>";
+ private static final String openError = "<error>";
+ private static final String closeError = "</error>";
+ private static final String openFatalError = "<fatalError>";
+ private static final String closeFatalError = "</fataError>";
+ private static final String openWarning = "<warning>";
+ private static final String closeWarning = "</warning>";
+
+ private String openRootElement;
+ private String closeRootElement;
+
+ /**
+ * Number of warnings.
+ */
+ private int warningCount;
+
+ /**
+ * Number of errors.
+ */
+ private int errorCount;
+
+ /**
+ * Number of fatal errors.
+ */
+ private int fatalErrorCount;
+
+ /**
+ * The root element name for the fault xml message
+ */
+ private String rootPath;
+
+ /**
+ * The namespace for the fault xml message
+ */
+ private String namespace;
+
+ /**
+ * Determines whether or not to include stacktraces in the fault xml message
+ */
+ private boolean includeStackTraces;
+
+ /**
+ * Variable to hold the warning/error messages from the validator
+ */
+ private StringBuffer messages = new StringBuffer();
+
+ private SourceTransformer sourceTransformer = new SourceTransformer();
+
+ /**
+ * Constructor.
+ *
+ * @param rootElement
+ * The root element name of the fault xml message
+ * @param namespace
+ * The namespace for the fault xml message
+ * @param includeStackTraces
+ * Include stracktraces in the final output
+ */
+ public MessageAggregatingErrorHandler(String rootPath, String namespace, boolean includeStackTraces) throws IllegalArgumentException {
+ if (rootPath == null || rootPath.trim().length() == 0) {
+ throw new IllegalArgumentException("rootPath must not be null or an empty string");
+ }
+ this.rootPath = rootPath;
+ this.namespace = namespace;
+ this.includeStackTraces = includeStackTraces;
+ createRootElementTags();
+ }
+
+ /**
+ * Creates the root element tags for later use down to n depth.
+ * Note: the rootPath here is of the form:
+ *
+ * <code>rootElementName/elementName-1/../elementName-n</code>
+ *
+ * The namespace will be appended to the root element if it is not
+ * null or empty.
+ */
+ private void createRootElementTags() {
+ /*
+ * since the rootPath is constrained to be not null or empty
+ * then we have at least one path element.
+ */
+ String[] pathElements = rootPath.split("/");
+
+ StringBuffer openRootElementSB = new StringBuffer().append("<").append(pathElements[0]);
+ StringBuffer closeRootElementSB = new StringBuffer();
+
+ if (namespace != null && namespace.trim().length() > 0) {
+ openRootElementSB.append(" xmlns=\"").append(namespace).append("\">");
+ } else {
+ openRootElementSB.append(">");
+ }
+
+ if (pathElements.length > 0) {
+ for (int i = 1, j = pathElements.length - 1; i < pathElements.length; i++, j--) {
+ openRootElementSB.append("<").append(pathElements[i]).append(">");
+ closeRootElementSB.append("</").append(pathElements[j]).append(">");
+ }
+ }
+
+ // create the closing root element tag
+ closeRootElementSB.append("</").append(pathElements[0]).append(">");
+
+ openRootElement = openRootElementSB.toString();
+ closeRootElement = closeRootElementSB.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#hasErrors()
+ */
+ public boolean hasErrors() {
+ return getErrorCount() > 0 || getFatalErrorCount() > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getWarningCount()
+ */
+ public int getWarningCount() {
+ return warningCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getErrorCount()
+ */
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getFatalErrorCount()
+ */
+ public int getFatalErrorCount() {
+ return fatalErrorCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
+ */
+ public void warning(SAXParseException e) throws SAXException {
+ ++warningCount;
+
+ // open warning and CDATA tags
+ messages.append(openWarning).append(openCDATA);
+
+ // append the fatal error message
+ appendErrorMessage(e);
+
+ // close CDATA and warning tags
+ messages.append(closeCDATA).append(closeWarning);
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
+ */
+ public void error(SAXParseException e) throws SAXException {
+ ++errorCount;
+
+ // open fatal error and CDATA tags
+ messages.append(openError).append(openCDATA);
+
+ // append the error message
+ appendErrorMessage(e);
+
+ // close CDATA and error tags
+ messages.append(closeCDATA).append(closeError);
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ public void fatalError(SAXParseException e) throws SAXException {
+ ++fatalErrorCount;
+
+ // open fatal error and CDATA tags
+ messages.append(openFatalError).append(openCDATA);
+
+ // append the fatal error message
+ appendErrorMessage(e);
+
+ // close CDATA and fatal error tags
+ messages.append(closeCDATA).append(closeFatalError);
+ }
+
+ /**
+ * Append the error message or stacktrace to the messages attribute.
+ *
+ * @param e
+ */
+ private void appendErrorMessage(SAXParseException e) {
+ if (includeStackTraces) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ messages.append(sw.toString());
+ } else {
+ messages.append(e.getLocalizedMessage());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#capturesMessages()
+ */
+ public boolean capturesMessages() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#getMessagesAs(java.lang.Class)
+ */
+ public Object getMessagesAs(Class format) throws MessagingException {
+ if (format == DOMSource.class) {
+ return getDOMSource();
+ } else if (format == StringSource.class) {
+ return getStringSource();
+ } else if (format == String.class) {
+ return getMessagesWithRootElement();
+ }
+ throw new MessagingException("Unsupported message format: " + format.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandler#supportsMessageFormat(java.lang.Class)
+ */
+ public boolean supportsMessageFormat(Class format) {
+ if (format == DOMSource.class) {
+ return true;
+ } else if (format == StringSource.class) {
+ return true;
+ } else if (format == String.class) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return the messages encapsulated with the root element.
+ *
+ * @return
+ */
+ private String getMessagesWithRootElement() {
+ return new StringBuffer().append(openRootElement).append(messages).append(closeRootElement).toString();
+ }
+
+ /**
+ * Get the error messages as a String Source.
+ *
+ * @return
+ */
+ private StringSource getStringSource() {
+ return new StringSource(getMessagesWithRootElement());
+ }
+
+ /**
+ * Get the error messages as a DOMSource.
+ *
+ * @return
+ * @throws MessagingException
+ */
+ private DOMSource getDOMSource() throws MessagingException {
+ try {
+ return sourceTransformer.toDOMSource(getStringSource());
+ } catch (ParserConfigurationException e) {
+ throw new MessagingException("Failed to create DOMSource for Schema validation messages: " + e, e);
+ } catch (IOException e) {
+ throw new MessagingException("Failed to create DOMSource for Schema validation messages: " + e, e);
+ } catch (SAXException e) {
+ throw new MessagingException("Failed to create DOMSource for Schema validation messages: " + e, e);
+ } catch (TransformerException e) {
+ throw new MessagingException("Failed to create DOMSource for Schema validation messages: " + e, e);
+ }
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.servicemix.validation.handler;
+
+/**
+ * @author gmcdonald
+ *
+ */
+public class MessageAggregatingErrorHandlerFactory implements
+ MessageAwareErrorHandlerFactory {
+
+ /**
+ * The root element name for the fault xml message
+ */
+ private String rootPath;
+
+ /**
+ * The namespace for the fault xml message
+ */
+ private String namespace;
+
+ /**
+ * Determines whether or not to include stacktraces in the fault xml message
+ */
+ private boolean includeStackTraces;
+
+ /**
+ * @return Returns the includeStackTraces.
+ */
+ public boolean isIncludeStackTraces() {
+ return includeStackTraces;
+ }
+
+ /**
+ * @param includeStackTraces The includeStackTraces to set.
+ */
+ public void setIncludeStackTraces(boolean includeStackTraces) {
+ this.includeStackTraces = includeStackTraces;
+ }
+
+ /**
+ * @return Returns the namespace.
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * @param namespace The namespace to set.
+ */
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * @return Returns the rootPath.
+ */
+ public String getRootPath() {
+ return rootPath;
+ }
+
+ /**
+ * @param rootPath The rootPath to set.
+ */
+ public void setRootPath(String rootPath) {
+ this.rootPath = rootPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.components.validation.MessageAwareErrorHandlerFactory#createMessageAwareErrorHandler()
+ */
+ public MessageAwareErrorHandler createMessageAwareErrorHandler() {
+ return new MessageAggregatingErrorHandler(rootPath, namespace, includeStackTraces);
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAggregatingErrorHandlerFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,76 @@
+/*
+ * 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.servicemix.validation.handler;
+
+import javax.jbi.messaging.MessagingException;
+
+import org.xml.sax.ErrorHandler;
+
+public interface MessageAwareErrorHandler extends ErrorHandler {
+
+ /**
+ * Does the error handler contain any error messages?
+ *
+ * @return
+ */
+ public boolean hasErrors();
+
+ /**
+ * Return the number of warnings.
+ *
+ * @return
+ */
+ public int getWarningCount();
+
+ /**
+ * Return the number of errors.
+ *
+ * @return
+ */
+ public int getErrorCount();
+
+ /**
+ * Return the number of fatal errors.
+ *
+ * @return
+ */
+ public int getFatalErrorCount();
+
+ /**
+ * Does this ErrorHandler implementation capture error messages?
+ *
+ * @return
+ */
+ public boolean capturesMessages();
+
+ /**
+ * Get the messages from this ErrorHandler in a particular format.
+ *
+ * @return
+ */
+ public Object getMessagesAs(Class format) throws MessagingException;
+
+ /**
+ * Does the message support a given format?
+ *
+ * @param clazz
+ * The Class of the format for which support is required.
+ * @return
+ */
+ public boolean supportsMessageFormat(Class format);
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.servicemix.validation.handler;
+
+/**
+ * Simple factory interface to a MessageAwareErrorHandler implementation
+ *
+ * @author gmcdonald
+ *
+ */
+public interface MessageAwareErrorHandlerFactory {
+
+ /**
+ * Create and return a concrete MessageAwareErrorHandler implementation
+ *
+ * @return
+ */
+ public MessageAwareErrorHandler createMessageAwareErrorHandler();
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/java/org/apache/servicemix/validation/handler/MessageAwareErrorHandlerFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The J2EE application client deployer service
+ -->
+<server>
+ <depends>org.servicemix:service=Deployer</depends>
+</server>
+
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/main/jbi/jboss-service.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java Wed Jun 11 16:31:29 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.servicemix.validation;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class ValidationComponentTest extends SpringTestSupport {
+ private static transient Log log = LogFactory.getLog(ValidationComponentTest.class);
+
+ public void testValidation() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "service"));
+ me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else if (me.getFault() != null) {
+ fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+ }
+ log.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
+ client.done(me);
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("spring.xml");
+ }
+
+}
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/java/org/apache/servicemix/validation/ValidationComponentTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd Wed Jun 11 16:31:29 2008
@@ -0,0 +1,33 @@
+<?xml version="1.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.
+
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="USAddress">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="street" type="xsd:string"/>
+ <xsd:element name="city" type="xsd:string"/>
+ <xsd:element name="state" type="xsd:string"/>
+ <xsd:element name="zip" type="xsd:decimal"/>
+ </xsd:sequence>
+ <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
+ </xsd:complexType>
+
+</xsd:schema>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/address/address.xsd
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:foo="http://servicemix.org/cheese/">
+
+ <!-- the JBI container -->
+ <sm:container id="jbi" embedded="true">
+ <sm:activationSpecs>
+
+ <!-- START SNIPPET: example -->
+ <sm:activationSpec componentName="myDefaultErrorHandlerService" service="foo:myDefaultErrorHandlerService" endpoint="myDefaultErrorHandlerService" destinationService="foo:myServiceImpl">
+ <sm:component><bean class="org.apache.servicemix.components.validation.ValidateComponent">
+ <property name="schemaResource" value="classpath:org/apache/servicemix/components/validation/schema.xsd"/>
+ </bean></sm:component>
+ </sm:activationSpec>
+
+ <sm:activationSpec componentName="myMessageAwareErrorHandlerService" service="foo:myMessageAwareErrorHandlerService" endpoint="myMessageAwareErrorHandlerService" destinationService="foo:myServiceImpl">
+ <sm:component>
+ <bean class="org.apache.servicemix.components.validation.ValidateComponent">
+ <property name="schemaResource" value="classpath:org/apache/servicemix/components/validation/schema.xsd"/>
+ <property name="errorHandlerFactory" ref="messageAggregatingErrorHandlerFactory"/>
+ </bean>
+ </sm:component>
+ </sm:activationSpec>
+
+ <!-- END SNIPPET: example -->
+
+ <!-- START SNIPPET: groovy -->
+ <sm:activationSpec componentName="myServiceImpl" service="foo:myServiceImpl" endpoint="myService">
+ <sm:component><bean class="org.apache.servicemix.components.groovy.GroovyComponent">
+ <property name="scriptText">
+ <value>
+ <![CDATA[
+if (bindings.counter == null) {
+ bindings.counter = 1
+}
+else {
+ ++bindings.counter
+}
+
+def date = new Date()
+
+outMessage.bodyText = "<response counter='$bindings.counter' date='$date'></response>"
+ ]]>
+ </value>
+ </property>
+ </bean></sm:component>
+ </sm:activationSpec>
+ <!-- END SNIPPET: groovy -->
+
+ </sm:activationSpecs>
+ </sm:container>
+
+ <bean id="messageAggregatingErrorHandlerFactory" class="org.apache.servicemix.components.validation.MessageAggregatingErrorHandlerFactory">
+ <property name="rootPath" value="Fault/payload/messages"/>
+ <property name="namespace" value="http://www.servicemix.org/fault"/>
+ </bean>
+
+ <bean id="defaultErrorHandlerClient" class="org.apache.servicemix.client.DefaultServiceMixClient">
+ <constructor-arg ref="jbi"/>
+ <constructor-arg>
+ <!-- lets hardwire this client to talk to instances of a service by default -->
+ <sm:activationSpec destinationService="foo:myDefaultErrorHandlerService"/>
+ </constructor-arg>
+ </bean>
+
+ <bean id="messageAwareErrorHandlerClient" class="org.apache.servicemix.client.DefaultServiceMixClient">
+ <constructor-arg ref="jbi"/>
+ <constructor-arg>
+ <!-- lets hardwire this client to talk to instances of a service by default -->
+ <sm:activationSpec destinationService="foo:myMessageAwareErrorHandlerService"/>
+ </constructor-arg>
+ </bean>
+
+</beans>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/example.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties Wed Jun 11 16:31:29 2008
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j-tests.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties Wed Jun 11 16:31:29 2008
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+
+# CONSOLE appender
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<wrongElement orderDate="1999-10-20">
+ <shipTo country="US">
+ <name>Alice Smith</name>
+ <street>123 Maple Street</street>
+ <city>Mill Valley</city>
+ <state>CA</state>
+ <zip>90952</zip>
+ </shipTo>
+ <billTo country="US">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+ <comment>Hurry, my lawn is going wild</comment>
+ <items>
+ <item partNum="872-AA">
+ <productName>Lawnmower</productName>
+ <quantity>1</quantity>
+ <USPrice>148.95</USPrice>
+ <comment>Confirm this is electric</comment>
+ </item>
+ <item partNum="926-AA">
+ <productName>Baby Monitor</productName>
+ <quantity>1</quantity>
+ <USPrice>39.98</USPrice>
+ <shipDate>1999-05-21</shipDate>
+ </item>
+ </items>
+</wrongElement>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestInvalid.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<purchaseOrder orderDate="1999-10-20">
+ <shipTo country="US">
+ <name>Alice Smith</name>
+ <street>123 Maple Street</street>
+ <city>Mill Valley</city>
+ <state>CA</state>
+ <zip>90952</zip>
+ </shipTo>
+ <billTo country="US">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+ <comment>Hurry, my lawn is going wild</comment>
+ <items>
+ <item partNum="872-AA">
+ <productName>Lawnmower</productName>
+ <quantity>1</quantity>
+ <USPrice>148.95</USPrice>
+ <comment>Confirm this is electric</comment>
+ </item>
+ <item partNum="926-AA">
+ <productName>Baby Monitor</productName>
+ <quantity>1</quantity>
+ <USPrice>39.98</USPrice>
+ <shipDate>1999-05-21</shipDate>
+ </item>
+ </items>
+</purchaseOrder>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/requestValid.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd Wed Jun 11 16:31:29 2008
@@ -0,0 +1,75 @@
+<?xml version="1.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.
+
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ Purchase order schema for Example.com.
+ Copyright 2000 Example.com. All rights reserved.
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:include schemaLocation="address/address.xsd"/>
+
+ <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
+
+ <xsd:element name="comment" type="xsd:string"/>
+
+ <xsd:complexType name="PurchaseOrderType">
+ <xsd:sequence>
+ <xsd:element name="shipTo" type="USAddress"/>
+ <xsd:element name="billTo" type="USAddress"/>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="items" type="Items"/>
+ </xsd:sequence>
+ <xsd:attribute name="orderDate" type="xsd:date"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="Items">
+ <xsd:sequence>
+ <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="productName" type="xsd:string"/>
+ <xsd:element name="quantity">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:positiveInteger">
+ <xsd:maxExclusive value="100"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element name="USPrice" type="xsd:decimal"/>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute name="partNum" type="SKU" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- Stock Keeping Unit, a code for identifying products -->
+ <xsd:simpleType name="SKU">
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="\d{3}-[A-Z]{2}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/schema.xsd
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml?rev=666899&view=auto
==============================================================================
--- servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml (added)
+++ servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml Wed Jun 11 16:31:29 2008
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:validation="http://servicemix.apache.org/validation/1.0"
+ xmlns:test="urn:test">
+
+ <sm:container id="jbi" embedded="true" createMBeanServer="false">
+
+ <sm:activationSpecs>
+
+ <sm:activationSpec>
+ <sm:component>
+ <validation:component>
+ <validation:endpoints>
+ <validation:endpoint service="test:service" endpoint="endpoint" />
+ </validation:endpoints>
+ </validation:component>
+ </sm:component>
+ </sm:activationSpec>
+
+ </sm:activationSpecs>
+ </sm:container>
+
+</beans>
Propchange: servicemix/sandbox/lhein/validation/servicemix-validation/src/test/resources/spring.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain