net.sf.jabb.camel
Class XmlSocketUtility

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

public class XmlSocketUtility
extends Object

This utility makes it convenient to provide XML protocol based socket interface (for example, SOAP over TCP rather than HTTP) in Camel.
这个工具提供一些方便使用的方法,从而可以利用Camel提供基于XML的Socket接口 (比如SOAP over TCP而不是HTTP)。

Author:
Zhengmao HU (James)

Field Summary
protected static Sequencer stringEncoderSeq
           
protected static Sequencer xmlFrameDecoderSeq
           
protected static Sequencer xmlStringDecoderSeq
           
 
Constructor Summary
XmlSocketUtility()
           
 
Method Summary
static void addServer(org.apache.camel.CamelContext camelContext, String serverUri, boolean syncFlag, String toUri, String topLevelTagName, Charset messageCharset, int maxMessageBytes)
          Creates a XML protocol based socket server in Camel.
在Camel中,创建一个基于XML的Socket接口服务器。
static String stripTopLevelTag(String xmlString)
          Strips off the top level tag from XML string.
从XML字符串中去掉最上层的Tag。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlFrameDecoderSeq

protected static Sequencer xmlFrameDecoderSeq

xmlStringDecoderSeq

protected static Sequencer xmlStringDecoderSeq

stringEncoderSeq

protected static Sequencer stringEncoderSeq
Constructor Detail

XmlSocketUtility

public XmlSocketUtility()
Method Detail

addServer

public static void addServer(org.apache.camel.CamelContext camelContext,
                             String serverUri,
                             boolean syncFlag,
                             String toUri,
                             String topLevelTagName,
                             Charset messageCharset,
                             int maxMessageBytes)
                      throws Exception
Creates a XML protocol based socket server in Camel.
在Camel中,创建一个基于XML的Socket接口服务器。

Parameters:
camelContext - CamelContext which must be based on CombinedRegistry, because additional entries must be added to the Registry.
Camel的Context,它必须用的是CombinedRegistry,因为要往Registry里放东西。
serverUri - URI of the socket server which will be used by Camel Netty component to create an Endpoint.
服务器的URI,它将被Camel的Netty组件用来创建一个Endpoint。

For example: tcp://localhost:9000

syncFlag - The sync parameter that will be send to Camel Netty component, true means sync and false means async.
传递给Camel Netty组件的sync参数,true表示同步,false表示异步。
toUri - The Pipe that receives the messages, usually it should be either direct or seda.
接收到的消息都会被送给这个Pipe,一般来说它要么是direct,要么是seda。
topLevelTagName - Name of the top level tag that will be used to find the boundaries of XML messages.
标识XML消息开头和结尾的标签名称。
messageCharset - Charset that the XML messages received are supposed to be encoded in.
XML消息的字符编码方式
maxMessageBytes - The maximum possible length of the XML messages received.
接收到的XML消息的最大可能长度
Throws:
Exception - Exception if the routes could not be created for whatever reason

stripTopLevelTag

public static String stripTopLevelTag(String xmlString)
Strips off the top level tag from XML string.
从XML字符串中去掉最上层的Tag。

Parameters:
xmlString - The XMl string to be processed
Returns:
The result string with top level tag removed.


Copyright © 2012. All Rights Reserved.