Skip to content

Commit 77b260b

Browse files
committed
Initial checkin of Camel routing library
git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@519901 13f79535-47bb-0310-9956-ffa450edef68
0 parents  commit 77b260b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2295
-0
lines changed

camel/camel-core/pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
-->
19+
20+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
22+
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>org.apache.camel</groupId>
27+
<artifactId>camel-parent</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>camel-core</artifactId>
32+
<name>Camel :: Core</name>
33+
<description>The Core Camel POJO based router</description>
34+
35+
<dependencies>
36+
37+
<dependency>
38+
<groupId>commons-logging</groupId>
39+
<artifactId>commons-logging</artifactId>
40+
<optional>false</optional>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>junit</groupId>
45+
<artifactId>junit</artifactId>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
</project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
/**
20+
* Represents an endpoint on which messages can be exchanged
21+
*
22+
* @version $Revision$
23+
*/
24+
public interface Endpoint<E> {
25+
26+
/**
27+
* Returns the string representation of the URI
28+
*/
29+
public String getEndpointUri();
30+
31+
/**
32+
* Sends the mesage exchange to this endpoint
33+
*/
34+
void send(E exchange);
35+
36+
/**
37+
* Create a new exchange for communicating with this endpoint
38+
*/
39+
E createExchange();
40+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
/**
20+
* A resolver of endpoints from a String URI
21+
*
22+
* @version $Revision$
23+
*/
24+
public interface EndpointResolver<E> {
25+
26+
/**
27+
* Resolves the given uri or returns null if no endpoint could be found
28+
*/
29+
public Endpoint<E> resolve(String uri);
30+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
import java.util.Map;
20+
21+
/**
22+
* Represents the base interface of an exchange
23+
*
24+
* @version $Revision$
25+
*/
26+
public interface Exchange<M> {
27+
28+
/**
29+
* Accesses a specific header
30+
*/
31+
<T> T getHeader(String name);
32+
33+
/**
34+
* Sets a header on the exchange
35+
*/
36+
void setHeader(String name, Object value);
37+
38+
/**
39+
* Returns all of the headers associated with the request
40+
*/
41+
Map<String,Object> getHeaders();
42+
43+
/**
44+
* Returns the request message
45+
*/
46+
M getRequest();
47+
48+
/**
49+
* Returns the response message
50+
*/
51+
M getResponse();
52+
53+
/**
54+
* Returns the fault message
55+
*/
56+
M getFault();
57+
58+
/**
59+
* Returns the exception associated with this exchange
60+
*/
61+
Exception getException();
62+
63+
/**
64+
* Sets the exception associated with this exchange
65+
*/
66+
void setException(Exception e);
67+
68+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
/**
20+
* This converter is capable of converting from an exchange to another type
21+
*
22+
* @version $Revision$
23+
*/
24+
public interface ExchangeConverter {
25+
26+
<T> T convertTo(Class<T> type, Exchange exchange);
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one or more
4+
* contributor license agreements. See the NOTICE file distributed with
5+
* this work for additional information regarding copyright ownership.
6+
* The ASF licenses this file to You under the Apache License, Version 2.0
7+
* (the "License"); you may not use this file except in compliance with
8+
* the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.camel;
19+
20+
/**
21+
* @version $Revision$
22+
*/
23+
public class FilterProcessor<E> implements Processor<E> {
24+
private Predicate<E> predicate;
25+
private Processor<E> processor;
26+
27+
public FilterProcessor(Predicate<E> predicate, Processor<E> processor) {
28+
this.predicate = predicate;
29+
this.processor = processor;
30+
}
31+
32+
public void onExchange(E exchange) {
33+
if (predicate.evaluate(exchange)) {
34+
processor.onExchange(exchange);
35+
}
36+
}
37+
38+
@Override
39+
public String toString() {
40+
return "if (" + predicate + ") " + processor;
41+
}
42+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
/**
20+
* @version $Revision$
21+
*/
22+
public class InvalidHeaderTypeException extends RuntimeCamelException {
23+
private Object headerValue;
24+
25+
public InvalidHeaderTypeException(Throwable cause, Object headerValue) {
26+
super(cause.getMessage() + " headerValue is: " + headerValue + " of type: "
27+
+ typeName(headerValue), cause);
28+
this.headerValue = headerValue;
29+
}
30+
31+
public InvalidHeaderTypeException(String message, Object headerValue) {
32+
super(message);
33+
this.headerValue = headerValue;
34+
}
35+
36+
37+
/**
38+
* Returns the actual header value
39+
*/
40+
public Object getHeaderValue() {
41+
return headerValue;
42+
}
43+
44+
protected static String typeName(Object headerValue) {
45+
return (headerValue != null) ? headerValue.getClass().getName() : "null";
46+
}
47+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel;
18+
19+
/**
20+
* Evaluates a binary predicate on the message exchange
21+
*
22+
* @version $Revision$
23+
*/
24+
public interface Predicate<E> {
25+
26+
/**
27+
* Evaluates the predicate on the message exchange
28+
*
29+
* @param exchange the message exchange
30+
* @return true if the predicate matches
31+
*/
32+
boolean evaluate(E exchange);
33+
}

0 commit comments

Comments
 (0)