远程技术的研究

使用此Burlap开发远程访问必须在实现BurlapServlet类实现服务的远程的访问!

BurlapServlet类代码如下:

BurlapServlet类实质是一个继承GenericService类抽象的Servlet类,并实现Burlap的服务类Service类实现远程的对象的操作的应用!

具体详细讲解,请看我的下面代码的注释!!

如有疑问请与偶联系?[email protected]

 

   

 

1>服务类必须继承的类对象

package com.caucho.burlap.server;

 

import com.caucho.burlap.io.BurlapInput;

import com.caucho.burlap.io.BurlapOutput;

import com.caucho.services.server.GenericService;

import com.caucho.services.server.Service;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.*;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

 

1>服务类必须继承的类对象

package com.caucho.burlap.server;

 

import com.caucho.burlap.io.BurlapInput;

import com.caucho.burlap.io.BurlapOutput;

import com.caucho.services.server.GenericService;

import com.caucho.services.server.Service;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.*;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

 

Burlap开发远程访问时单独使用开发类必须继承此类:

由此类的可以看出此类使用一个Servlet类类似HttpServlet类。

所以在web.xml必须配置Servlet的信息。

publicclass BurlapServlet extends GenericService

    implements Servlet

{

 

    public BurlapServlet()

    {

    }

 

    public String getServletInfo()

    {

        return"Burlap Servlet";

    }

 

    publicvoid setService(boolean isService)

    {

        _isService = isService;

        _service = this;

    }

    初始化时调用Servlet的初始化类方法init方法

    publicvoid init(ServletConfig config)

        throws ServletException

{

    调用Servlet的初始化方法

        super.init(config);

 

        if(_isService)

            return;

       检测在初始化应用程序上下文中是否有service-class的参数的名称

        String className = getInitParameter("service-class");

        if(className != null)

        {

            try

            {

                ClassLoader loader = Thread.currentThread().getContextClassLoader();

                if(loader != null)

                    _serviceClass = Class.forName(className, false, loader);

                else

                    _serviceClass = Class.forName(className);

            }

            catch(Exception e)

            {

                thrownew ServletException(e);

            }

        } else

        {

  如果没有上下文参数判断是否是BurlapServlet的类对象

            if(getClass().equals(com.caucho.burlap.server.BurlapServlet.class))

                thrownew ServletException("server must extend BurlapServlet");

            _serviceClass = getClass();

        }

        try

        {

            _service = _serviceClass.newInstance();

        }

        catch(Exception e)

        {

            thrownew ServletException(e);

        }

        if(_serviceinstanceof BurlapServlet)

            ((BurlapServlet)_service).setService(true);

        if(_serviceinstanceof Service)

            ((Service)_service).init(getServletConfig());

    }

 

 

 

你可能感兴趣的:(thread,Web,servlet,远程访问技术的研究)