如何使用XML实现多渠道接入网站的构架(2)

2008-02-23 05:51:11来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


  其余XML则可按这样的规则来定制

  五.技术实现

  RouterFactory

以下是引用片段:
package com.web.router;
import com.web.platform.Exception.RouterException;
import java.util.java/util/Hashtable.java.html" target="_blank">Hashtable;

以下是引用片段:
/**
* Router产生和清除的类
*/
public class RouterFactory 
{
  /**
   * Router存储的树front
   */
  private static java/util/Hashtable.java.html" target="_blank">Hashtable QueuePairFront = null;
  /**
   * Router存储的树back
   */
  private static java/util/Hashtable.java.html" target="_blank">Hashtable QueuePairBack = null;
/**
   * Router存储的树
   */
  private static java/util/Hashtable.java.html" target="_blank">Hashtable QueueRouter = null;

  /**
   * 返回的XMLRouter
   */
  public static XMLRouter instance = null;
  /**
   * Router的定义
   */
  public static RouterDefine routerdefine = null;
  /**
   * Router的ID号
   */
  public static long routeIndex = 0;
  /**
   * @roseuid 3F169C21027C
   */
  public RouterFactory() 
  {
  }
  /**
   * 初始化Hashtable和Vector
   */
  public static void initFactory() throws java/lang/Exception.java.html" target="_blank">Exception
  {
      QueuePairFront = new java/util/Hashtable.java.html" target="_blank">Hashtable(); 
      QueuePairBack = new java/util/Hashtable.java.html" target="_blank">Hashtable(); 
      QueueRouter    = new java/util/Hashtable.java.html" target="_blank">Hashtable();
      initRouteDefine();
  }
/**
   * 初始化Route的设置
   * 
   */
  private static void initRouteDefine() throws java/lang/Exception.java.html" target="_blank">Exception
  {
      if( routerdefine == null )
        routerdefine = new RouterDefine();
      routerdefine.loadRouterDef();
  }
  /**
   * 返回实例
   * @return com.web.router.XMLRouter
   */
  public static XMLRouter getInstance(long index) throws RouterException
  {
     return (XMLRouter)QueueRouter.get(new java/lang/Long.java.html" target="_blank">Long(index));
  }

  /**
   * 产生一个XMLRouter的实例
   * @return com.web.router.XMLRouter
   * @roseuid 3F1618A103BC
   */
  public static XMLRouter popInstance() throws RouterException
  {
      routeIndex ;
      instance = new XMLRouter(routeIndex);
      setDefine( instance );
      QueueRouter.put(new java/lang/Long.java.html" target="_blank">Long(routeIndex), instance);     
     return instance;
  }
  /**
   * 清空Hashtable,Vector等
   * @roseuid 3F1618B203C1
   */
  private static void freeResource() throws java/lang/Exception.java.html" target="_blank">Exception
  {
      QueuePairFront.clear();
      QueuePairBack.clear();
      QueueRouter.clear();
      QueuePairFront = QueuePairBack = QueueRouter = null;
}
  /**
   * 清除实例
   * @param instanceID
   * @throws Exception
   */
  public static void removeInstance(XMLRouter instance) throws java/lang/Exception.java.html" target="_blank">Exception 
  {
      instance.clear();
     QueueRouter.remove( new java/lang/Long.java.html" target="_blank">Long(instance.getIndex() ) ) ;
  }
/**
* Method isNull.
* @return boolean
*/
  public static boolean isNull()
  {
     …… 
      return false;
  }
}

  XMLRouter

以下是引用片段:
package com.web.router;
import com.web.platform.Exception.RouterException;
import com.web.common.*;
import java.util.*;
import java.lang.reflect.java/lang/reflect/Method.java.html" target="_blank">Method;
import java.lang.reflect.java/lang/reflect/Constructor.java.html" target="_blank">Constructor;
/**
* @author keli
* @version 0.0.1
* 平台的关键,路由的类,每个Router将从RouterFactory里读取
* Router存储的树front,和back,routeIndex,目的是为了能在路由
* 之后可以清除申请的对象。
* Router可以实现同步和异步的功能.
*/
public class XMLRouter 
{

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:XML和XSLT结合使网站设计浑然一体

下一篇:FireFox对XML的处理兼容IE的节点处理方法