org.apache.camel.core.osgi
Class OsgiTypeConverter

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.core.osgi.OsgiTypeConverter
All Implemented Interfaces:
Service, ShutdownableService, TypeConverterRegistry, TypeConverter, org.osgi.util.tracker.ServiceTrackerCustomizer

public class OsgiTypeConverter
extends ServiceSupport
implements TypeConverter, TypeConverterRegistry, org.osgi.util.tracker.ServiceTrackerCustomizer


Constructor Summary
OsgiTypeConverter(org.osgi.framework.BundleContext bundleContext, Injector injector, FactoryFinder factoryFinder)
           
 
Method Summary
 void addFallbackTypeConverter(TypeConverter typeConverter, boolean canPromote)
          Registers a new fallback type converter
 Object addingService(org.osgi.framework.ServiceReference serviceReference)
           
 void addTypeConverter(Class<?> toType, Class<?> fromType, TypeConverter typeConverter)
          Registers a new type converter
<T> T
convertTo(Class<T> type, Exchange exchange, Object value)
          Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

<T> T
convertTo(Class<T> type, Object value)
          Converts the value to the specified type
protected  DefaultTypeConverter createRegistry()
           
protected  void doStart()
           
protected  void doStop()
           
 DefaultTypeConverter getDelegate()
           
 Injector getInjector()
          Gets the injector
 TypeConverter lookup(Class<?> toType, Class<?> fromType)
          Performs a lookup for a given type converter.
<T> T
mandatoryConvertTo(Class<T> type, Exchange exchange, Object value)
          Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

<T> T
mandatoryConvertTo(Class<T> type, Object value)
          Converts the value to the specified type
 void modifiedService(org.osgi.framework.ServiceReference serviceReference, Object o)
           
 void removedService(org.osgi.framework.ServiceReference serviceReference, Object o)
           
 void setInjector(Injector injector)
          Sets the injector to be used for creating new instances during type conversions.
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsgiTypeConverter

public OsgiTypeConverter(org.osgi.framework.BundleContext bundleContext,
                         Injector injector,
                         FactoryFinder factoryFinder)
Method Detail

addingService

public Object addingService(org.osgi.framework.ServiceReference serviceReference)
Specified by:
addingService in interface org.osgi.util.tracker.ServiceTrackerCustomizer

modifiedService

public void modifiedService(org.osgi.framework.ServiceReference serviceReference,
                            Object o)
Specified by:
modifiedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer

removedService

public void removedService(org.osgi.framework.ServiceReference serviceReference,
                           Object o)
Specified by:
removedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception

convertTo

public <T> T convertTo(Class<T> type,
                       Object value)
Description copied from interface: TypeConverter
Converts the value to the specified type

Specified by:
convertTo in interface TypeConverter
Parameters:
type - the requested type
value - the value to be converted
Returns:
the converted value, or null if not possible to convert

convertTo

public <T> T convertTo(Class<T> type,
                       Exchange exchange,
                       Object value)
Description copied from interface: TypeConverter
Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

Specified by:
convertTo in interface TypeConverter
Parameters:
type - the requested type
exchange - the current exchange
value - the value to be converted
Returns:
the converted value, or null if not possible to convert

mandatoryConvertTo

public <T> T mandatoryConvertTo(Class<T> type,
                                Object value)
                     throws NoTypeConversionAvailableException
Description copied from interface: TypeConverter
Converts the value to the specified type

Specified by:
mandatoryConvertTo in interface TypeConverter
Parameters:
type - the requested type
value - the value to be converted
Returns:
the converted value, is never null
Throws:
NoTypeConversionAvailableException - if conversion not possible

mandatoryConvertTo

public <T> T mandatoryConvertTo(Class<T> type,
                                Exchange exchange,
                                Object value)
                     throws NoTypeConversionAvailableException
Description copied from interface: TypeConverter
Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

Specified by:
mandatoryConvertTo in interface TypeConverter
Parameters:
type - the requested type
exchange - the current exchange
value - the value to be converted
Returns:
the converted value, is never null
Throws:
NoTypeConversionAvailableException

addTypeConverter

public void addTypeConverter(Class<?> toType,
                             Class<?> fromType,
                             TypeConverter typeConverter)
Description copied from interface: TypeConverterRegistry
Registers a new type converter

Specified by:
addTypeConverter in interface TypeConverterRegistry
Parameters:
toType - the type to convert to
fromType - the type to convert from
typeConverter - the type converter to use

addFallbackTypeConverter

public void addFallbackTypeConverter(TypeConverter typeConverter,
                                     boolean canPromote)
Description copied from interface: TypeConverterRegistry
Registers a new fallback type converter

Specified by:
addFallbackTypeConverter in interface TypeConverterRegistry
Parameters:
typeConverter - the type converter to use
canPromote - whether or not the fallback type converter can be promoted to a first class type converter

lookup

public TypeConverter lookup(Class<?> toType,
                            Class<?> fromType)
Description copied from interface: TypeConverterRegistry
Performs a lookup for a given type converter.

Specified by:
lookup in interface TypeConverterRegistry
Parameters:
toType - the type to convert to
fromType - the type to convert from
Returns:
the type converter or null if not found.

setInjector

public void setInjector(Injector injector)
Description copied from interface: TypeConverterRegistry
Sets the injector to be used for creating new instances during type conversions.

Specified by:
setInjector in interface TypeConverterRegistry
Parameters:
injector - the injector

getInjector

public Injector getInjector()
Description copied from interface: TypeConverterRegistry
Gets the injector

Specified by:
getInjector in interface TypeConverterRegistry
Returns:
the injector

getDelegate

public DefaultTypeConverter getDelegate()

createRegistry

protected DefaultTypeConverter createRegistry()


Apache CAMEL