org.apache.camel
Class ExchangeProperty<T>
java.lang.Object
org.apache.camel.ExchangeProperty<T>
public class ExchangeProperty<T>
- extends Object
Represents an instance and a type safe registry of well known Camel Exchange properties.
Usage pattern:
In your code register a property that you wish to pass via Camel Exchange:
public static final ExchangeProperty myProperty =
new ExchangeProperty("myProperty", "org.apache.myproject.mypackage.myproperty", Boolean.class);
Then in your code set this property's value:
myProperty.set(exchange, Boolean.TRUE);
Check the value of this property where required:
ExchangeProperty> property = ExchangeProperty.get("myProperty");
if (property != null && property.get(exchange) == Boolean.TRUE) {
// do your thing ...
}
Or
Boolean value = myProperty.get(exchange);
if (value == Boolean.TRUE) {
// do your thing
}
When your code no longer requires this property then deregister it:
ExchangeProperty.deregister(myProperty);
Or
ExchangeProperty.deregister("myProperty");
Note: that if ExchangeProperty instance get or set methods are used then type checks
of property's value are performed and a runtime exception can be thrown if type
safety is violated.
ExchangeProperty
public ExchangeProperty(String literal,
String name,
Class<T> type)
literal
public String literal()
name
public String name()
type
public Class<T> type()
get
public T get(Exchange exchange)
get
public static ExchangeProperty<?> get(String literal)
getByName
public static ExchangeProperty<?> getByName(String name)
set
public T set(Exchange exchange,
T value)
remove
public T remove(Exchange exchange)
toString
public String toString()
- Overrides:
toString
in class Object
register
public static void register(ExchangeProperty<?> property)
deregister
public static void deregister(ExchangeProperty<?> property)
deregister
public static void deregister(String literal)
values
public static ExchangeProperty<?>[] values()
Copyright © 2010 IONA Open Source Community. All Rights Reserved.