关于JSVC

svc is a set of libraries and applications for making Java applications run on UNIX more easily.

Jsvc allows the application (e.g. Tomcat) to perform some privileged operations as root (e.g. bind to a port < 1024), and then switch identity to a non-privileged user.

SVC是一组让java在UNIX上更容易运行的库和应用程序
JSVC允许应用程序(如Tomcat)以root权限执行一些特权操作(如绑定到一个端口<1024),然后切换到一个非特权用户的身份。

There two ways to use jsvc: via a Class that implements the Daemon interface orvia calling a Class that has the required methods.For example Tomcat-4.1.x uses the Daemon interfacewhereas Tomcat-5.0.x provides a Class whose methods are called by jsvc directly.

有两种方式使用JSVC的:通过一个类实现守护接口或通过调用类所需的方法。例如Tomcat的4.1.x版守护接口,而使用的Tomcat5.0.x中提供了一个类的方法被称为由JSVC直接。

Via Daemon interface

Do the following:

  • Write a Class that implements the Daemon interface (MyClass).
  • Put it in a jarfile (my.jar).
  • Call jsvc like:
    ./jsvc -cp commons-daemon.jar:my.jar MyClass
守护进程模式:

如下操作:

  • 写一个实现后台程序接口的类如(MyClass的名字)
  • 打包(生成my.jar)
  • 像这样使用jsvc调用:

./jsvc -cp commons-daemon.jar:my.jar MyClass

Directly:

Write a Class (MyClass) that implements the following methods:

  • void init(String[] arguments): Here open configuration files, create a trace file, create ServerSockets, Threads
  • void start(): Start the Thread, accept incoming connections
  • void stop(): Inform the Thread to terminate the run(), close the ServerSockets
  • void destroy(): Destroy any object created in init()
Store it in a jarfile and use as above:
./jsvc -cp my.jar MyClass

直接启动模式:

编写一个实现如下方法的类:

  • void init(String[] arguments): 在这里打开配置文件,创建一个跟踪文件,创建服务端口,线程
  • void start(): 启动线程,接受传入的连接
  • void stop():通知线程终止的run(),关闭服务端口
  • void destroy(): 销毁在init()创建的任何对象

生成一个jar包

./jsvc -cp my.jar MyClass


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值