net.sf.jabb.camel
Class CamelContextController

java.lang.Object
  extended by net.sf.jabb.camel.CamelContextController
All Implemented Interfaces:
Runnable

public class CamelContextController
extends Object
implements Runnable

As a wrapper, it controls the CamelContext, for example, start, stop, suspend and resume.
作为一个包装层,它控制CamelContext的启动、停止、暂停、继续等。

The CamelContextController opens a server socket port and receives control commands from the port. It controls the CamelContext according to the commands received. Its runtime logging information are sent to commons-logging.

CamelContextController打开一个服务端口并且从这个端口接收控制命令,根据获得的命令, 对所包装的CamelContext进行控制。 它的运行时log信息被送给commons-logging。

Author:
Zhengmao HU (James)

Field Summary
protected  BlockingQueue<String> commandQueue
          The queue for control commands.
protected  org.apache.camel.CamelContext context
          The CamelContext that the CamelContextController controls.
protected  org.apache.camel.impl.DefaultCamelContext myContext
          The CamelContext that hosts the CamelContextController.
 
Constructor Summary
CamelContextController(org.apache.camel.CamelContext camelContext, String serverUri)
          Creates an instance which wraps a specified CamelContext, listens at a specified port and controls the CamelContext according to commands received from that port.
创建一个实例,它包装指定的某个CamelContext,在指定的端口上监听, 并根据接受到的命令对包装的CamelContext进行控制。
CamelContextController(org.apache.camel.CamelContext camelContext, String serverUri, boolean autoDisconnect)
          Creates an instance which wraps a specified CamelContext, listens at a specified port and controls the CamelContext according to commands received from that port.
创建一个实例,它包装指定的某个CamelContext,在指定的端口上监听, 并根据接受到的命令对包装的CamelContext进行控制。
 
Method Summary
 String command(String cmd)
          Sends command to the control command queue.
向待处理的控制命令队列中发送一个命令。
 void run()
          Starts the command processing loop, exit until "exit" command was received.
循环处理控制命令,直到收到“exit”命令。
 void start()
          Starts the CamelContext and the CamelContextController.
启动CamelContext及CamelContextController。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myContext

protected org.apache.camel.impl.DefaultCamelContext myContext
The CamelContext that hosts the CamelContextController.


context

protected org.apache.camel.CamelContext context
The CamelContext that the CamelContextController controls.


commandQueue

protected BlockingQueue<String> commandQueue
The queue for control commands.

Constructor Detail

CamelContextController

public CamelContextController(org.apache.camel.CamelContext camelContext,
                              String serverUri,
                              boolean autoDisconnect)
                       throws Exception
Creates an instance which wraps a specified CamelContext, listens at a specified port and controls the CamelContext according to commands received from that port.
创建一个实例,它包装指定的某个CamelContext,在指定的端口上监听, 并根据接受到的命令对包装的CamelContext进行控制。

Parameters:
camelContext - The CamelContext that will be controlled.
将被控制的CamelContext。
serverUri - The listening port in Camel Netty URI format, for example:
监听端口的URI,向这个端口发送命令就可以控制CamelContext。它遵循Camel中Netty组件的URI格式,比如:

tcp://localhost:99999?keepAlive=true

autoDisconnect - Whether disconnect the socket connection from server side after each control command was received.
是否在收到每个控制命令之后就自动从服务器端断开socket连接。
Throws:
Exception

CamelContextController

public CamelContextController(org.apache.camel.CamelContext camelContext,
                              String serverUri)
                       throws Exception
Creates an instance which wraps a specified CamelContext, listens at a specified port and controls the CamelContext according to commands received from that port.
创建一个实例,它包装指定的某个CamelContext,在指定的端口上监听, 并根据接受到的命令对包装的CamelContext进行控制。

The socket connection will be disconnected from server side after each command is received from client side.
每当从客户端接收到一个命令,服务器端就会自动断开socket连接。

Parameters:
camelContext - The CamelContext that will be controlled.
将被控制的CamelContext。
serverUri - The listening port in Camel Netty URI format, for example:
监听端口的URI,向这个端口发送命令就可以控制CamelContext。它遵循Camel中Netty组件的URI格式,比如:

tcp://localhost:99999?keepAlive=true

Throws:
Exception
Method Detail

command

public String command(String cmd)
Sends command to the control command queue.
向待处理的控制命令队列中发送一个命令。

Usually this method should not be called from external directly, commands should be sent to the listening port instead.

一般不从外部直接调用这个方法,而是向监听端口发送命令。

Parameters:
cmd - Control commands, for example, start, stop, suspend, resume, and status.
控制命令,比如start, stop, suspend, resume, status。

run

public void run()
Starts the command processing loop, exit until "exit" command was received.
循环处理控制命令,直到收到“exit”命令。

Specified by:
run in interface Runnable

start

public void start()
Starts the CamelContext and the CamelContextController.
启动CamelContext及CamelContextController。

They will not exit until the "exit" command was received by CamelContextController.

它们直到收到exit命令才一起退出。



Copyright © 2012. All Rights Reserved.