关于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


你可能感兴趣的:(java,jsvc)