You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2007/08/07 20:36:08 UTC
svn commit: r563607 [9/12] - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/ main/java/org/apache/camel/builder/
main/java/org/apache/camel/builder/xml/
main/java/org/apache/camel/component/bean/
main/java/org/apache/camel/componen...
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,10 +16,10 @@
*/
package org.apache.camel.processor.loadbalancer;
+import java.util.List;
+
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-
-import java.util.List;
/**
* Implements the round robin load balancing policy
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,14 +16,14 @@
*/
package org.apache.camel.processor.loadbalancer;
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.Processor;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
/**
* Implements a sticky load balancer using an {@link Expression} to calculate
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,15 +16,15 @@
*/
package org.apache.camel.processor.loadbalancer;
+import java.util.List;
+
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.processor.Pipeline;
-
-import java.util.List;
/**
- * A {@link LoadBalancer} implementations which sends to all destinations (rather like JMS Topics)
- *
+ * A {@link LoadBalancer} implementations which sends to all destinations
+ * (rather like JMS Topics)
+ *
* @version $Revision: 1.1 $
*/
public class TopicLoadBalancer extends LoadBalancerSupport {
@@ -38,11 +37,13 @@
}
/**
- * Strategy method to copy the exchange before sending to another endpoint. Derived classes such as the
- * {@link Pipeline} will not clone the exchange
- *
+ * Strategy method to copy the exchange before sending to another endpoint.
+ * Derived classes such as the {@link Pipeline} will not clone the exchange
+ *
* @param processor the processor that will send the exchange
- * @param exchange @return the current exchange if no copying is required such as for a pipeline otherwise a new copy of the exchange is returned.
+ * @param exchange
+ * @return the current exchange if no copying is required such as for a
+ * pipeline otherwise a new copy of the exchange is returned.
*/
protected Exchange copyExchangeStrategy(Processor processor, Exchange exchange) {
return exchange.copy();
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/DefaultValidationErrorHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/DefaultValidationErrorHandler.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/DefaultValidationErrorHandler.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/DefaultValidationErrorHandler.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,15 +16,17 @@
*/
package org.apache.camel.processor.validation;
-import org.apache.camel.Exchange;
-import org.apache.camel.ValidationException;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ValidationException;
/**
* @version $Revision: $
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/NoXmlBodyValidationException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/NoXmlBodyValidationException.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/NoXmlBodyValidationException.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/NoXmlBodyValidationException.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/SchemaValidationException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/SchemaValidationException.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/SchemaValidationException.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/SchemaValidationException.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,24 +16,26 @@
*/
package org.apache.camel.processor.validation;
-import org.apache.camel.Exchange;
-import org.apache.camel.ValidationException;
+import java.util.List;
+
import org.xml.sax.SAXParseException;
-import java.util.List;
+import org.apache.camel.Exchange;
+import org.apache.camel.ValidationException;
/**
* A Schema validation exception occurred
- *
+ *
* @version $Revision: $
*/
public class SchemaValidationException extends ValidationException {
- private Object schema;
- private List<SAXParseException> fatalErrors;
- private List<SAXParseException> errors;
- private List<SAXParseException> warnings;
+ private final Object schema;
+ private final List<SAXParseException> fatalErrors;
+ private final List<SAXParseException> errors;
+ private final List<SAXParseException> warnings;
- public SchemaValidationException(Exchange exchange, Object schema, List<SAXParseException> fatalErrors, List<SAXParseException> errors, List<SAXParseException> warnings) {
+ public SchemaValidationException(Exchange exchange, Object schema, List<SAXParseException> fatalErrors,
+ List<SAXParseException> errors, List<SAXParseException> warnings) {
super(exchange, message(schema, fatalErrors, errors, warnings));
this.schema = schema;
this.fatalErrors = fatalErrors;
@@ -43,7 +45,7 @@
/**
* Returns the schema that failed
- *
+ *
* @return the schema that failed
*/
public Object getSchema() {
@@ -52,7 +54,7 @@
/**
* Returns the validation errors
- *
+ *
* @return the validation errors
*/
public List<SAXParseException> getErrors() {
@@ -61,7 +63,7 @@
/**
* Returns the fatal validation errors
- *
+ *
* @return the fatal validation errors
*/
public List<SAXParseException> getFatalErrors() {
@@ -70,15 +72,15 @@
/**
* Returns the validation warnings
- *
+ *
* @return the validation warnings
*/
public List<SAXParseException> getWarnings() {
return warnings;
}
-
- protected static String message(Object schema, List<SAXParseException> fatalErrors, List<SAXParseException> errors, List<SAXParseException> warnings) {
+ protected static String message(Object schema, List<SAXParseException> fatalErrors,
+ List<SAXParseException> errors, List<SAXParseException> warnings) {
StringBuffer buffer = new StringBuffer("Validation failed for: " + schema);
if (!fatalErrors.isEmpty()) {
buffer.append(" fatal errors: ");
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,9 +16,9 @@
*/
package org.apache.camel.processor.validation;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.xml.sax.SAXException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
@@ -27,15 +27,16 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
+import org.xml.sax.SAXException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
/**
* A processor which validates the XML version of the inbound message body
* against some schema either in XSD or RelaxNG
- *
+ *
* @version $Revision: 453155 $
*/
public class ValidatingProcessor implements Processor {
@@ -49,7 +50,6 @@
private URL schemaUrl;
private File schemaFile;
-
public void process(Exchange exchange) throws Exception {
Schema schema = getSchema();
Validator validator = schema.newValidator();
@@ -67,64 +67,51 @@
validator.validate(source, result);
errorHandler.handleErrors(exchange, schema, result);
- /* Fault fault = exchange.createFault();
- if (errorHandler.hasErrors()) {
-
- // set the schema and source document as properties on the fault
- fault.setProperty("org.apache.servicemix.schema", schema);
- fault.setProperty("org.apache.servicemix.xml", source);
-
- *//*
- * 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()));
- }
- throw new FaultException("Failed to validate against schema: " + schema, exchange, fault);
- }
- else {
- // Retrieve the ouput of the validation
- // as it may have been changed by the validator
- out.setContent(new DOMSource(result.getNode(), result.getSystemId()));
- }
- }
-*/
+ /*
+ * Fault fault = exchange.createFault(); if (errorHandler.hasErrors()) { //
+ * set the schema and source document as properties on the fault
+ * fault.setProperty("org.apache.servicemix.schema", schema);
+ * fault.setProperty("org.apache.servicemix.xml", source);
+ *
+ *//*
+ * 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())); } throw new FaultException("Failed to
+ * validate against schema: " + schema, exchange, fault); } else { //
+ * Retrieve the ouput of the validation // as it may have been
+ * changed by the validator out.setContent(new
+ * DOMSource(result.getNode(), result.getSystemId())); } }
+ */
}
// Properties
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
public Schema getSchema() throws IOException, SAXException {
if (schema == null) {
@@ -133,7 +120,6 @@
return schema;
}
-
public void setSchema(Schema schema) {
this.schema = schema;
}
@@ -193,16 +179,15 @@
}
// Implementation methods
- //-----------------------------------------------------------------------
-
+ // -----------------------------------------------------------------------
protected SchemaFactory createSchemaFactory() {
return SchemaFactory.newInstance(schemaLanguage);
}
-
protected Source createSchemaSource() throws IOException {
- throw new IllegalArgumentException("You must specify a schema, schemaFile, schemaSource or schemaUrl property");
+ throw new IllegalArgumentException("You must specify a schema, "
+ + "schemaFile, schemaSource or schemaUrl property");
}
protected Schema createSchema() throws SAXException, IOException {
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatorErrorHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatorErrorHandler.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatorErrorHandler.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/ValidatorErrorHandler.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,12 +16,13 @@
*/
package org.apache.camel.processor.validation;
-import org.apache.camel.Exchange;
-import org.apache.camel.ValidationException;
-import org.xml.sax.ErrorHandler;
-
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
+
+import org.xml.sax.ErrorHandler;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ValidationException;
/**
* @version $Revision: $
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ComponentResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ComponentResolver.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ComponentResolver.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ComponentResolver.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,10 +16,9 @@
*/
package org.apache.camel.spi;
-import org.apache.camel.Component;
import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultComponentResolver;
/**
* Represents a resolver of components from a URI to be able to auto-load them using some
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExchangeConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExchangeConverter.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExchangeConverter.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExchangeConverter.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Injector.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Injector.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Injector.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Injector.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -19,14 +18,16 @@
/**
* A pluggable strategy for creating and possibly dependency injecting objects
- * which could be implemented using straight forward reflection or using Spring or Guice to perform dependency injection.
- *
+ * which could be implemented using straight forward reflection or using Spring
+ * or Guice to perform dependency injection.
+ *
* @version $Revision$
*/
public interface Injector {
/**
- * Instantiates a new instance of the given type possibly injecting values into the object in the process
- *
+ * Instantiates a new instance of the given type possibly injecting values
+ * into the object in the process
+ *
* @param type the type of object to create
* @return a newly created instance
*/
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Language.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Language.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Language.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Language.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,9 +16,9 @@
*/
package org.apache.camel.spi;
+import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.Exchange;
/**
* Represents a language to be used for {@link Expression} or {@link Predicate} instances
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LanguageResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LanguageResolver.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LanguageResolver.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/LanguageResolver.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Marshaller.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Marshaller.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Marshaller.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Marshaller.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -23,9 +23,9 @@
* @version $Revision: 520124 $
*/
public interface Marshaller {
-
- /**
+
+ /**
* Marshals the object to the given Stream.
*/
- void marshal(Object graph, OutputStream stream) throws IOException;
+ void marshal(Object graph, OutputStream stream) throws IOException;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Provider.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Provider.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Provider.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Provider.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Registry.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Registry.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Registry.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Registry.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterAware.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterAware.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterAware.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterAware.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,7 +16,6 @@
*/
package org.apache.camel.spi;
-import org.apache.camel.impl.converter.DefaultTypeConverter;
import org.apache.camel.TypeConverter;
/**
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Unmarshaller.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Unmarshaller.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Unmarshaller.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Unmarshaller.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -23,8 +23,8 @@
* @version $Revision: 520124 $
*/
public interface Unmarshaller {
-
- /**
+
+ /**
* Unmarshals the given stream into an object.
*/
Object unmarshal(InputStream stream) throws IOException;
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlMarshaller.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlMarshaller.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlMarshaller.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -24,17 +24,17 @@
/**
* Marshallers that marshall to XML should extend this base class.
- *
+ *
* @version $Revision: 520124 $
*/
-public abstract class XmlMarshaller implements Marshaller{
-
- /**
+public abstract class XmlMarshaller implements Marshaller {
+
+ /**
* Marshals the object to the given Stream.
*/
- public void marshal(Object object, OutputStream result) throws IOException {
- marshal(object, new StreamResult(result));
- }
+ public void marshal(Object object, OutputStream result) throws IOException {
+ marshal(object, new StreamResult(result));
+ }
- abstract public void marshal(Object object, Result result);
+ public abstract void marshal(Object object, Result result);
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlUnmarshaller.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlUnmarshaller.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlUnmarshaller.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/XmlUnmarshaller.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -28,17 +28,17 @@
* @version $Revision: 520124 $
*/
public abstract class XmlUnmarshaller implements Unmarshaller {
-
- /**
+
+ /**
* Unmarshals the given stream into an object.
*/
public Object unmarshal(InputStream stream) throws IOException {
- return unmarshal(new StreamSource(stream));
+ return unmarshal(new StreamSource(stream));
}
- /**
+ /**
* Unmarshals the given stream into an object.
*/
- abstract public Object unmarshal(Source stream) throws IOException;
-
+ public abstract Object unmarshal(Source stream) throws IOException;
+
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java Tue Aug 7 11:35:48 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,30 +16,37 @@
*/
package org.apache.camel.util;
-import org.apache.camel.Endpoint;
import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
import org.apache.camel.NoSuchEndpointException;
/**
* A number of helper methods
- *
+ *
* @version $Revision: $
*/
public class CamelContextHelper {
+
+ /**
+ * Utility classes should not have a public constructor.
+ */
+ private CamelContextHelper() {
+ }
+
/**
* Returns the mandatory endpoint for the given URI or the
* {@link org.apache.camel.NoSuchEndpointException} is thrown
- *
+ *
* @param camelContext
* @param uri
* @return
*/
- public static Endpoint getMandatoryEndpoint(CamelContext camelContext, String uri) throws NoSuchEndpointException {
+ public static Endpoint getMandatoryEndpoint(CamelContext camelContext, String uri)
+ throws NoSuchEndpointException {
Endpoint endpoint = camelContext.getEndpoint(uri);
if (endpoint == null) {
throw new NoSuchEndpointException(uri);
- }
- else {
+ } else {
return endpoint;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CollectionHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CollectionHelper.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CollectionHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CollectionHelper.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -23,16 +22,24 @@
/**
* A number of helper methods for working with collections
- *
+ *
* @version $Revision: 1.1 $
*/
public class CollectionHelper {
+
/**
- * Sets the value of the entry in the map for the given key, though if the map already contains a value for the
- * given key then the value is appended to a list of values.
- *
- * @param map the map to add the entry to
- * @param key the key in the map
+ * Utility classes should not have a public constructor.
+ */
+ private CollectionHelper() {
+ }
+
+ /**
+ * Sets the value of the entry in the map for the given key, though if the
+ * map already contains a value for the given key then the value is appended
+ * to a list of values.
+ *
+ * @param map the map to add the entry to
+ * @param key the key in the map
* @param value the value to put in the map
*/
public static void appendValue(Map map, Object key, Object value) {
@@ -41,15 +48,13 @@
if (oldValue != null) {
List list;
if (oldValue instanceof List) {
- list = (List) oldValue;
- }
- else {
+ list = (List)oldValue;
+ } else {
list = new ArrayList();
list.add(oldValue);
}
list.add(value);
- }
- else {
+ } else {
map.put(key, value);
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -26,36 +25,44 @@
/**
* Some helper methods for working with {@link Exchange} objects
- *
+ *
* @version $Revision$
*/
public class ExchangeHelper {
/**
+ * Utility classes should not have a public constructor.
+ */
+ private ExchangeHelper() {
+ }
+
+ /**
* Attempts to resolve the endpoint for the given value
- *
+ *
* @param exchange the message exchange being processed
- * @param value the value which can be an {@link Endpoint} or an object which provides a String representation
- * of an endpoint via {@link #toString()}
- *
+ * @param value the value which can be an {@link Endpoint} or an object
+ * which provides a String representation of an endpoint via
+ * {@link #toString()}
+ *
* @return the endpoint
* @throws NoSuchEndpointException if the endpoint cannot be resolved
*/
- @SuppressWarnings({"unchecked"})
- public static <E extends Exchange> Endpoint<E> resolveEndpoint(E exchange, Object value) throws NoSuchEndpointException {
+ @SuppressWarnings({"unchecked" })
+ public static <E extends Exchange> Endpoint<E> resolveEndpoint(E exchange, Object value)
+ throws NoSuchEndpointException {
Endpoint<E> endpoint;
if (value instanceof Endpoint) {
- endpoint = (Endpoint<E>) value;
- }
- else {
+ endpoint = (Endpoint<E>)value;
+ } else {
String uri = value.toString();
endpoint = CamelContextHelper.getMandatoryEndpoint(exchange.getContext(), uri);
}
return endpoint;
}
- public static <T> T getMandatoryProperty(Exchange exchange, String propertyName, Class<T> type) throws NoSuchPropertyException {
- T answer = exchange.getProperty(propertyName, type);
+ public static <T> T getMandatoryProperty(Exchange exchange, String propertyName, Class<T> type)
+ throws NoSuchPropertyException {
+ T answer = exchange.getProperty(propertyName, type);
if (answer == null) {
throw new NoSuchPropertyException(exchange, propertyName, type);
}
@@ -63,7 +70,8 @@
}
/**
- * Returns the mandatory inbound message body of the correct type or throws an exception if it is not present
+ * Returns the mandatory inbound message body of the correct type or throws
+ * an exception if it is not present
*/
public static <T> T getMandatoryInBody(Exchange exchange, Class<T> type) throws InvalidPayloadException {
T answer = exchange.getIn().getBody(type);
@@ -72,11 +80,12 @@
}
return answer;
}
-
+
/**
* Converts the value to the given expected type or throws an exception
*/
- public static <T> T convertToMandatoryType(Exchange exchange, Class<T> type, Object value) throws InvalidTypeException {
+ public static <T> T convertToMandatoryType(Exchange exchange, Class<T> type, Object value)
+ throws InvalidTypeException {
T answer = convertToType(exchange, type, value);
if (answer == null) {
throw new InvalidTypeException(exchange, value, type);
@@ -85,7 +94,8 @@
}
/**
- * Converts the value to the given expected type returning null if it could not be converted
+ * Converts the value to the given expected type returning null if it could
+ * not be converted
*/
public static <T> T convertToType(Exchange exchange, Class<T> type, Object value) {
return exchange.getContext().getTypeConverter().convertTo(type, value);
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionComparator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionComparator.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionComparator.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionComparator.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,10 +16,10 @@
*/
package org.apache.camel.util;
+import java.util.Comparator;
+
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
-
-import java.util.Comparator;
/**
* An implementation of {@link Comparator} which takes an {@link Expression} which is evaluated
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionHelper.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionHelper.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -22,14 +21,20 @@
/**
* A collection of helper methods for working with expressions.
- *
+ *
* @version $Revision: 1.1 $
*/
public class ExpressionHelper {
/**
+ * Utility classes should not have a public constructor.
+ */
+ private ExpressionHelper() {
+ }
+
+ /**
* Evaluates the given expression on the exchange as a String value
- *
+ *
* @param expression the expression to evaluate
* @param exchange the exchange to use to evaluate the expression
* @return the result of the evaluation as a string.
@@ -39,14 +44,16 @@
}
/**
- * Evaluates the given expression on the exchange, converting the result to the given type
- *
+ * Evaluates the given expression on the exchange, converting the result to
+ * the given type
+ *
* @param expression the expression to evaluate
* @param exchange the exchange to use to evaluate the expression
* @param resultType the type of the result that is required
* @return the result of the evaluation as the specified type.
*/
- public static <T, E extends Exchange> T evaluateAsType(Expression<E> expression, E exchange, Class<T> resultType) {
+ public static <T, E extends Exchange> T evaluateAsType(Expression<E> expression, E exchange,
+ Class<T> resultType) {
Object value = expression.evaluate(exchange);
return exchange.getContext().getTypeConverter().convertTo(resultType, value);
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,11 +16,11 @@
*/
package org.apache.camel.util;
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-
import java.util.Comparator;
import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
/**
* An implementation of {@link java.util.Comparator} which takes a list of
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/FactoryFinder.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,8 +16,6 @@
*/
package org.apache.camel.util;
-import org.apache.camel.spi.Injector;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -28,6 +25,8 @@
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.camel.spi.Injector;
+
public class FactoryFinder {
private final String path;
private final ConcurrentHashMap classMap = new ConcurrentHashMap();
@@ -42,47 +41,50 @@
/**
* Creates a new instance of the given key
- *
- * @param key is the key to add to the path to find a text file
- * containing the factory name
+ *
+ * @param key is the key to add to the path to find a text file containing
+ * the factory name
* @return a newly created instance
*/
- public Object newInstance(String key)
- throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {
- return newInstance(key, (String) null);
+ public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException,
+ ClassNotFoundException {
+ return newInstance(key, (String)null);
}
- public Object newInstance(String key, String propertyPrefix)
- throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {
+ public Object newInstance(String key, String propertyPrefix) throws IllegalAccessException,
+ InstantiationException, IOException, ClassNotFoundException {
Class clazz = findClass(key, propertyPrefix);
return clazz.newInstance();
}
public Object newInstance(String key, Injector injector) throws IOException, ClassNotFoundException {
- return newInstance(key, injector, (String) null);
+ return newInstance(key, injector, (String)null);
}
- public Object newInstance(String key, Injector injector, String propertyPrefix) throws IOException, ClassNotFoundException {
+ public Object newInstance(String key, Injector injector, String propertyPrefix) throws IOException,
+ ClassNotFoundException {
Class type = findClass(key, propertyPrefix);
return injector.newInstance(type);
}
- public <T> T newInstance(String key, Injector injector, Class<T> expectedType) throws IOException, ClassNotFoundException {
+ public <T> T newInstance(String key, Injector injector, Class<T> expectedType) throws IOException,
+ ClassNotFoundException {
return newInstance(key, injector, null, expectedType);
}
- public <T> T newInstance(String key, Injector injector, String propertyPrefix, Class<T> expectedType) throws IOException, ClassNotFoundException {
+ public <T> T newInstance(String key, Injector injector, String propertyPrefix, Class<T> expectedType)
+ throws IOException, ClassNotFoundException {
Class type = findClass(key, propertyPrefix);
Object value = injector.newInstance(type);
if (expectedType.isInstance(value)) {
return expectedType.cast(value);
- }
- else {
+ } else {
throw new ClassCastException("Not instanceof " + expectedType.getName() + " value: " + value);
}
}
- public <T> List<T> newInstances(String key, Injector injector, Class<T> type) throws IOException, ClassNotFoundException {
+ public <T> List<T> newInstances(String key, Injector injector, Class<T> type) throws IOException,
+ ClassNotFoundException {
List<Class> list = findClasses(key);
List<T> answer = new ArrayList<T>(list.size());
answer.add(newInstance(key, injector, type));
@@ -98,7 +100,7 @@
propertyPrefix = "";
}
- Class clazz = (Class) classMap.get(propertyPrefix + key);
+ Class clazz = (Class)classMap.get(propertyPrefix + key);
if (clazz == null) {
clazz = newInstance(doFindFactoryProperies(key), propertyPrefix);
classMap.put(propertyPrefix + key, clazz);
@@ -110,13 +112,15 @@
return findClasses(key, null);
}
- public List<Class> findClasses(String key, String propertyPrefix) throws ClassNotFoundException, IOException {
+ public List<Class> findClasses(String key, String propertyPrefix) throws ClassNotFoundException,
+ IOException {
// TODO change to support finding multiple classes on the classpath!
Class type = findClass(key, propertyPrefix);
return Collections.singletonList(type);
}
- private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException, IOException {
+ private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException,
+ IOException {
String className = properties.getProperty(propertyPrefix + "class");
if (className == null) {
@@ -127,8 +131,7 @@
if (loader != null) {
try {
clazz = loader.loadClass(className);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
// ignore
}
}
@@ -161,12 +164,10 @@
Properties properties = new Properties();
properties.load(reader);
return properties;
- }
- finally {
+ } finally {
try {
reader.close();
- }
- catch (Exception e) {
+ } catch (Exception ignore) {
}
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -33,19 +32,26 @@
import java.util.Set;
public class IntrospectionSupport {
-
-
- static public boolean getProperties(Object target, Map props, String optionPrefix) {
-
+
+ /**
+ * Utility classes should not have a public constructor.
+ */
+ private IntrospectionSupport() {
+ }
+
+ public static boolean getProperties(Object target, Map props, String optionPrefix) {
+
boolean rc = false;
- if( target == null )
+ if (target == null) {
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ }
+ if (props == null) {
throw new IllegalArgumentException("props was null.");
-
- if( optionPrefix == null )
- optionPrefix="";
-
+ }
+ if (optionPrefix == null) {
+ optionPrefix = "";
+ }
+
Class clazz = target.getClass();
Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++) {
@@ -53,47 +59,48 @@
String name = method.getName();
Class type = method.getReturnType();
Class params[] = method.getParameterTypes();
- if( name.startsWith("get") && params.length==0 &&
- type!=null && isSettableType(type)) {
+ if (name.startsWith("get") && params.length == 0 && type != null && isSettableType(type)) {
+
+ try {
+
+ Object value = method.invoke(target, new Object[] {});
+ if (value == null) {
+ continue;
+ }
- try {
-
- Object value = method.invoke(target, new Object[]{});
- if( value == null )
- continue;
-
- String strValue = convertToString(value, type);
- if( strValue ==null )
- continue;
-
- name = name.substring(3,4).toLowerCase()+name.substring(4);
- props.put(optionPrefix+name, strValue);
+ String strValue = convertToString(value, type);
+ if (strValue == null) {
+ continue;
+ }
+
+ name = name.substring(3, 4).toLowerCase() + name.substring(4);
+ props.put(optionPrefix + name, strValue);
rc = true;
-
- } catch ( Throwable ignore) {
- }
-
+
+ } catch (Throwable ignore) {
+ }
+
}
}
-
+
return rc;
}
-
-
-
- static public boolean setProperties(Object target, Map props, String optionPrefix) {
+
+ public static boolean setProperties(Object target, Map props, String optionPrefix) {
boolean rc = false;
- if( target == null )
+ if (target == null) {
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ }
+ if (props == null) {
throw new IllegalArgumentException("props was null.");
-
+ }
+
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
- String name = (String) iter.next();
- if( name.startsWith(optionPrefix) ) {
+ String name = (String)iter.next();
+ if (name.startsWith(optionPrefix)) {
Object value = props.get(name);
name = name.substring(optionPrefix.length());
- if( setProperty(target, name, value) ) {
+ if (setProperty(target, name, value)) {
iter.remove();
rc = true;
}
@@ -101,42 +108,45 @@
}
return rc;
}
-
+
public static Map extractProperties(Map props, String optionPrefix) {
- if( props == null )
+ if (props == null) {
throw new IllegalArgumentException("props was null.");
+ }
HashMap rc = new HashMap(props.size());
-
+
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
- String name = (String) iter.next();
- if( name.startsWith(optionPrefix) ) {
+ String name = (String)iter.next();
+ if (name.startsWith(optionPrefix)) {
Object value = props.get(name);
name = name.substring(optionPrefix.length());
rc.put(name, value);
iter.remove();
}
}
-
+
return rc;
}
-
+
public static boolean setProperties(Object target, Map props) {
- boolean rc = false;
-
- if( target == null )
+ boolean rc = false;
+
+ if (target == null) {
throw new IllegalArgumentException("target was null.");
- if( props == null )
+ }
+ if (props == null) {
throw new IllegalArgumentException("props was null.");
-
+ }
+
for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) {
- Map.Entry entry = (Entry) iter.next();
- if( setProperty(target, (String) entry.getKey(), entry.getValue()) ) {
+ Map.Entry entry = (Entry)iter.next();
+ if (setProperty(target, (String)entry.getKey(), entry.getValue())) {
iter.remove();
- rc=true;
+ rc = true;
}
}
-
+
return rc;
}
@@ -144,15 +154,17 @@
try {
Class clazz = target.getClass();
Method setter = findSetterMethod(clazz, name);
- if( setter == null )
+ if (setter == null) {
return false;
-
- // If the type is null or it matches the needed type, just use the value directly
- if( value == null || value.getClass()==setter.getParameterTypes()[0] ) {
- setter.invoke(target, new Object[]{value});
+ }
+
+ // If the type is null or it matches the needed type, just use the
+ // value directly
+ if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
+ setter.invoke(target, new Object[] {value});
} else {
// We need to convert it
- setter.invoke(target, new Object[]{ convert(value, setter.getParameterTypes()[0]) });
+ setter.invoke(target, new Object[] {convert(value, setter.getParameterTypes()[0])});
}
return true;
} catch (Throwable ignore) {
@@ -162,11 +174,11 @@
private static Object convert(Object value, Class type) throws URISyntaxException {
PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if( editor != null ) {
+ if (editor != null) {
editor.setAsText(value.toString());
return editor.getValue();
}
- if( type == URI.class ) {
+ if (type == URI.class) {
return new URI(value.toString());
}
return null;
@@ -174,11 +186,11 @@
private static String convertToString(Object value, Class type) throws URISyntaxException {
PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if( editor != null ) {
+ if (editor != null) {
editor.setValue(value);
return editor.getAsText();
}
- if( type == URI.class ) {
+ if (type == URI.class) {
return ((URI)value).toString();
}
return null;
@@ -186,14 +198,12 @@
private static Method findSetterMethod(Class clazz, String name) {
// Build the method name.
- name = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+ name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
Class params[] = method.getParameterTypes();
- if( method.getName().equals(name)
- && params.length==1
- && isSettableType(params[0])) {
+ if (method.getName().equals(name) && params.length == 1 && isSettableType(params[0])) {
return method;
}
}
@@ -201,20 +211,23 @@
}
private static boolean isSettableType(Class clazz) {
- if( PropertyEditorManager.findEditor(clazz)!=null )
+ if (PropertyEditorManager.findEditor(clazz) != null) {
return true;
- if( clazz == URI.class )
+ }
+ if (clazz == URI.class) {
return true;
- if( clazz == Boolean.class )
+ }
+ if (clazz == Boolean.class) {
return true;
+ }
return false;
}
- static public String toString(Object target) {
+ public static String toString(Object target) {
return toString(target, Object.class);
}
- static public String toString(Object target, Class stopClass) {
+ public static String toString(Object target, Class stopClass) {
LinkedHashMap map = new LinkedHashMap();
addFields(target, target.getClass(), stopClass, map);
StringBuffer buffer = new StringBuffer(simpleName(target.getClass()));
@@ -222,11 +235,10 @@
Set entrySet = map.entrySet();
boolean first = true;
for (Iterator iter = entrySet.iterator(); iter.hasNext();) {
- Map.Entry entry = (Map.Entry) iter.next();
+ Map.Entry entry = (Map.Entry)iter.next();
if (first) {
first = false;
- }
- else {
+ } else {
buffer.append(", ");
}
buffer.append(entry.getKey());
@@ -238,45 +250,43 @@
}
protected static void appendToString(StringBuffer buffer, Object value) {
-// if (value instanceof ActiveMQDestination) {
-// ActiveMQDestination destination = (ActiveMQDestination) value;
-// buffer.append(destination.getQualifiedName());
-// }
-// else {
- buffer.append(value);
-// }
+ // if (value instanceof ActiveMQDestination) {
+ // ActiveMQDestination destination = (ActiveMQDestination) value;
+ // buffer.append(destination.getQualifiedName());
+ // }
+ // else {
+ buffer.append(value);
+ // }
}
- static public String simpleName(Class clazz) {
+ public static String simpleName(Class clazz) {
String name = clazz.getName();
int p = name.lastIndexOf(".");
- if( p >= 0 ) {
- name = name.substring(p+1);
+ if (p >= 0) {
+ name = name.substring(p + 1);
}
return name;
}
-
- static private void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
-
- if( startClass!=stopClass )
- addFields( target, startClass.getSuperclass(), stopClass, map );
-
+ private static void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
+
+ if (startClass != stopClass) {
+ addFields(target, startClass.getSuperclass(), stopClass, map);
+ }
+
Field[] fields = startClass.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
- if( Modifier.isStatic(field.getModifiers()) ||
- Modifier.isTransient(field.getModifiers()) ||
- Modifier.isPrivate(field.getModifiers()) ) {
+ if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || Modifier.isPrivate(field.getModifiers())) {
continue;
}
-
+
try {
field.setAccessible(true);
Object o = field.get(target);
- if( o!=null && o.getClass().isArray() ) {
+ if (o != null && o.getClass().isArray()) {
try {
- o = Arrays.asList((Object[]) o);
+ o = Arrays.asList((Object[])o);
} catch (Throwable e) {
}
}
@@ -285,8 +295,7 @@
e.printStackTrace();
}
}
-
+
}
-
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/NoFactoryAvailableException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/NoFactoryAvailableException.java?view=diff&rev=563607&r1=563606&r2=563607
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/NoFactoryAvailableException.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/NoFactoryAvailableException.java Tue Aug 7 11:35:48 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,