Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-9880: Header Support for Attachments in Camel 2.18
- Loading branch information
Showing
44 changed files
with
829 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,83 @@ | |||
/** | |||
* 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.camel; | |||
|
|||
import java.util.Collection; | |||
import java.util.List; | |||
|
|||
import javax.activation.DataHandler; | |||
|
|||
/** | |||
* Represents an attachment as part of a {@link Message}. | |||
*/ | |||
public interface Attachment { | |||
/** | |||
* Return a DataHandler for the content within this attachment. | |||
* | |||
* @return DataHandler for the content | |||
*/ | |||
DataHandler getDataHandler(); | |||
|
|||
/** | |||
* Get all the headers for this header name. Returns null if no headers for | |||
* this header name are available. | |||
* | |||
* @param headerName he name of this header | |||
* @return a comma separated list of all header values | |||
*/ | |||
String getHeader(String headerName); | |||
|
|||
/** | |||
* Get all the headers for this header name. Returns null if no headers for | |||
* this header name are available. | |||
* | |||
* @param headerName he name of this header | |||
* @return a list of all header values | |||
*/ | |||
List<String> getHeaderAsList(String name); | |||
|
|||
/** | |||
* Get all header names for this attachment. | |||
* | |||
* @return a collection of all header names | |||
*/ | |||
Collection<String> getHeaderNames(); | |||
|
|||
/** | |||
* Set the value for this headerName. Replaces all existing header values | |||
* with this new value. | |||
* | |||
* @param headerName the name of this header | |||
* @param headerValue the value for this header | |||
*/ | |||
void setHeader(String headerName, String headerValue); | |||
|
|||
/** | |||
* Add this value to the existing values for this headerName. | |||
* | |||
* @param headerName the name of this header | |||
* @param headerValue the value for this header | |||
*/ | |||
void addHeader(String headerName, String headerValue); | |||
|
|||
/** | |||
* Remove all headers with this name. | |||
* | |||
* @param headerName the name of this header | |||
*/ | |||
void removeHeader(String headerName); | |||
} |
35 changes: 35 additions & 0 deletions
35
camel-core/src/main/java/org/apache/camel/AttachmentObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
/** | |||
* 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.camel; | |||
|
|||
import java.lang.annotation.Documented; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import java.lang.annotation.Target; | |||
|
|||
/** | |||
* Marks a parameter as being Map of attachments as {@link Attachment} objects | |||
* of an inbound {@link Message} | |||
* | |||
* @version | |||
*/ | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Documented | |||
@Target({ElementType.PARAMETER }) | |||
public @interface AttachmentObjects { | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
camel-core/src/main/java/org/apache/camel/converter/AttachmentConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
/** | |||
* 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.camel.converter; | |||
|
|||
import javax.activation.DataHandler; | |||
|
|||
import org.apache.camel.Attachment; | |||
import org.apache.camel.Converter; | |||
|
|||
/** | |||
* Some useful converters for {@link Attachment} | |||
* to a {@link DataHandler} | |||
* | |||
* @version | |||
*/ | |||
@Converter | |||
public final class AttachmentConverter { | |||
|
|||
/** | |||
* Utility classes should not have a public constructor. | |||
*/ | |||
private AttachmentConverter() { | |||
} | |||
|
|||
@Converter | |||
public static DataHandler toDataHandler(final Attachment attachment) { | |||
return attachment.getDataHandler(); | |||
} | |||
} |
Oops, something went wrong.