org.apache.camel
Class ExchangeProperty<T>

java.lang.Object
  extended by 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.


Constructor Summary
ExchangeProperty(String literal, String name, Class<T> type)
           
 
Method Summary
static void deregister(ExchangeProperty<?> property)
           
static void deregister(String literal)
           
 T get(Exchange exchange)
           
static ExchangeProperty<?> get(String literal)
           
static ExchangeProperty<?> getByName(String name)
           
 String literal()
           
 String name()
           
static void register(ExchangeProperty<?> property)
           
 T remove(Exchange exchange)
           
 T set(Exchange exchange, T value)
           
 String toString()
           
 Class<T> type()
           
static ExchangeProperty<?>[] values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExchangeProperty

public ExchangeProperty(String literal,
                        String name,
                        Class<T> type)
Method Detail

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 © 2008 IONA Open Source Community. All Rights Reserved.