net.sf.jabb.camel
Class RegistryUtility

java.lang.Object
  extended by net.sf.jabb.camel.RegistryUtility

public class RegistryUtility
extends Object

This utility provides convenient methods to work on Camel Registry, however CombinedRegistry is required in most of the cases.
提供方便地对Camel的Registry进行操作的方法,不过大部分的时候只有CombinedRegistry才被支持。

For example, it provides methods to add Codec(s) required by Netty to Registry.
比如说,它提供向Registry中添加Netty所需的Codec的方法。

But you should be aware that it does not ensure multi-threads safe on the manipulation of Registry.
但是注意,它不保证对Registry的操作是多线程安全的。

Author:
Zhengmao HU (James)

Field Summary
static String NAME_DECODERS
           
static String NAME_ENCODERS
           
 
Constructor Summary
RegistryUtility()
           
 
Method Summary
protected static void addCodecOnly(CombinedRegistry registry, String name, org.jboss.netty.channel.ChannelHandler codec)
          Adds codec to Registry only, it will not handle the manipulating of encoders or decoders list in Registry.
仅仅把codec直接加入到Registry中,而不处理加入到Registry里的encoders或decoders列表中。
static void addDecoder(org.apache.camel.CamelContext context, String name, org.jboss.netty.channel.ChannelUpstreamHandler decoder)
          Adds an Netty decoder to Registry.
向Registry中增加一个给Netty用的decoder。
static void addEncoder(org.apache.camel.CamelContext context, String name, org.jboss.netty.channel.ChannelDownstreamHandler encoder)
          Adds an Netty encoder to Registry.
向Registry中增加一个给Netty用的encoder。
static CombinedRegistry getCombinedRegistry(org.apache.camel.CamelContext camelContext)
          Gets CombinedRegistry from CamelContext.
从CamelContext中得到CombinedRegistry类型的Registry。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_ENCODERS

public static final String NAME_ENCODERS
See Also:
Constant Field Values

NAME_DECODERS

public static final String NAME_DECODERS
See Also:
Constant Field Values
Constructor Detail

RegistryUtility

public RegistryUtility()
Method Detail

getCombinedRegistry

public static CombinedRegistry getCombinedRegistry(org.apache.camel.CamelContext camelContext)
Gets CombinedRegistry from CamelContext.
从CamelContext中得到CombinedRegistry类型的Registry。

Parameters:
camelContext - The CamelContext must be based on CombinedRegistry, otherwise ClassCastException will be thrown.
这个context必须是采用CombinedRegistry类型的Registry的,否则会抛出格式转换异常。
Returns:
The Registry that is of CombinedRegistry type.

addEncoder

public static void addEncoder(org.apache.camel.CamelContext context,
                              String name,
                              org.jboss.netty.channel.ChannelDownstreamHandler encoder)
Adds an Netty encoder to Registry.
向Registry中增加一个给Netty用的encoder。

Parameters:
context - The CamelContext must be based on CombinedRegistry, otherwise ClassCastException will be thrown.
这个context必须是采用CombinedRegistry类型的Registry的,否则会抛出格式转换异常。
name - Name of the encoder in Registry.
encoder在Registry中的名字。
encoder - The encoder that will be used by Netty.
将被Netty用到的encoder。

addDecoder

public static void addDecoder(org.apache.camel.CamelContext context,
                              String name,
                              org.jboss.netty.channel.ChannelUpstreamHandler decoder)
Adds an Netty decoder to Registry.
向Registry中增加一个给Netty用的decoder。

Parameters:
context - The CamelContext must be based on CombinedRegistry, otherwise ClassCastException will be thrown.
这个context必须是采用CombinedRegistry类型的Registry的,否则会抛出格式转换异常。
name - Name of the decoder in Registry.
decoder在Registry中的名字。
decoder - The decoder that will be used by Netty.
将被Netty用到的decoder。

addCodecOnly

protected static void addCodecOnly(CombinedRegistry registry,
                                   String name,
                                   org.jboss.netty.channel.ChannelHandler codec)
Adds codec to Registry only, it will not handle the manipulating of encoders or decoders list in Registry.
仅仅把codec直接加入到Registry中,而不处理加入到Registry里的encoders或decoders列表中。

If a codec with the same name already exists in the Registry, IllegalArgumentException will be thrown.
如果Registry中原先已经有同名的别的codec,则抛出IllegalArgumentException。

Parameters:
registry - The CombinedRegistry that the codec will be added into.
codec将要被加入的CombinedRegistry。
name - Name of the codec in Registry.
codec在Registry中的名字。
codec - The codec that will be used by Netty.
将被Netty使用的codec。


Copyright © 2012. All Rights Reserved.