Package org.fto.jthink.resource

Examples of org.fto.jthink.resource.ResourceManager


    LogManager.configure(config);
//    /* 返回日志处理接口 */
//    logger = LogManager.getLogger(SQLTestCase.class);
   
    /* 初始化资源管理器 */
    ResourceManager resManager = new ResourceManager();
    /* 将配置文件加入到资源管理器中 */
    resManager.setResource(Configuration.class.getName(), config);
   
    /* 初始化事务管理器 */
    TransactionManager transactionManager = new DefaultTransactionManager(resManager, config);
    /* 将事务管理器加入到资源管理器中 */
    resManager.setResource(TransactionManager.class.getName(), transactionManager);
   
    /* 返回在fto-jthink.xml中配置的JDBC事务 */
    TransactionFactory transactionFactory = transactionManager.getTransactionFactory("SampleTransaction");
    JDBCTransaction transaction  = (JDBCTransaction)transactionFactory.create();
    /* 将此事务处理对象加入到事务管理器中 */
    transactionManager.addTransaction(JDBCTransaction.class.getName(), transaction);
    resManager.setResource(JDBCTransaction.class.getName(), transaction);
   
    return resManager;
  }
View Full Code Here


   
      public void test() throws Exception{
        System.out.println("\n[正在测试: SQL相关功能()...]");

        //ResourceManager resManager = new ResourceManagerInitialization().initResourceManager();
        ResourceManager resManager = new ResourceManager();
       
        /* --向数据库表中加入数据--------------------------------------------------------------------- */
        SampleSender sender = new SampleSender(resManager);
        HashMap[] msgsMaps = new HashMap[2];
        HashMap msgsHM = new HashMap();
View Full Code Here

      junit.textui.TestRunner.run(ConnectionPoolTestCase.class);
    }
   
    public void test() throws Exception{
      System.out.println("\n[正在测试方法: ConnectionPool.*()...]");
      ResourceManager resManager = new ResourceManagerInitialization().initResourceManager();
      JDBCTransaction transn = (JDBCTransaction)resManager.getResource(JDBCTransaction.class.getName());
     
      String connId = "SampleDataSource";
      //transn.setTransactionLevel(connId,JDBCTransaction.TRANSACTION_REPEATABLE_READ);
      Connection conn=null;
      try{
View Full Code Here

   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
      ResourceManager resManager = new ResourceManagerInitialization().initResourceManager();
      String connId = "SampleDataSource";
      JDBCTransaction transaction = (JDBCTransaction)resManager.getResource(JDBCTransaction.class.getName());
      /* 返回SQLExecutor工厂,并创建SQLExecutor对象 */
      SQLExecutor sqlExecutor = transaction.getSQLExecutorFactory(connId).create();
      /* 返回SQLBuilder工厂,并创建SQLBuilder对象 */
      SQLBuilder sqlBuilder = transaction.getSQLBuilderFactory(connId).create("");
     
View Full Code Here

  /* 在fto-jthink.xml中定义的数据源连接ID */
  private static final String connId = "SampleDataSource";
 
  public MBoardBusinessBean() throws Exception{
    /* 创建资源管理器 */
    resManager = new ResourceManager();
    /* 返回定义的JDBC事务工厂,并创建事务 */
    transaction = (JDBCTransaction)((TransactionFactory)resManager.getResource(transId)).create();
    /* 创建SQLExecutor */
    sqlExecutor = transaction.getSQLExecutorFactory(connId).create();
    /* 设置SQLExecutor监听器 */
 
View Full Code Here

  public ResourceManager initialize(HttpServletRequest req){
   
    logger.debug("初始化JavaBean.");
   
    /* 返回资源管理器 */
    ResourceManager resManager = (ResourceManager)req.getAttribute(ResourceManager.class.getName());
   
    Configuration jthinkConfig = (Configuration)resManager.getResource(WEBApplicationContext.class.getName(), Configuration.class.getName());
   
    if(resManager.getResource(TransactionManager.class.getName())==null){
      /* 设置资源, 初始化事务管理器, 将TransactionManager加入到ResourceManager中 */
      logger.debug("初始化事务管理器, TransactionManager.");
      TransactionManager transactionManager = new DefaultTransactionManager(resManager, jthinkConfig);
      resManager.setResource(TransactionManager.class.getName(), transactionManager);
     
      // 加入WEB端事务到事务管理器
      logger.debug("初始化Web端事务, WebTransaction.");
      TransactionFactory transactionFactory = transactionManager.getTransactionFactory("WebTransaction");
      JDBCTransaction transaction  = (JDBCTransaction)transactionFactory.create();
View Full Code Here

   * @param req
   * @throws Exception
   */
  public void initialize(HttpServletRequest req) throws Exception {
    /* 创建资源管理器 */
    resManager = new ResourceManager(req);
    /* 返回客户请求 */
    request = (HttpRequest)resManager.getResource(HttpRequest.class.getName());
    /* 返回定义的JDBC事务工厂,并创建事务 */
    transaction = (JDBCTransaction)((TransactionFactory)resManager.getResource(transId)).create();
    /* 创建SQLExecutor */
 
View Full Code Here

      /* 初始化请求 */
      req.setCharacterEncoding(encoding);
      HttpRequest request = new HttpRequest((HttpServletRequest)req);
     
      /* 初始化资源管理器 */
      ResourceManager resManager = new ResourceManager();
     
      /* 设置资源容器, WEBApplicationContext上下文 */
      resManager.setResourceContainer(WEBApplicationContext.class.getName(), webContext);

      /* 设置资源容器, HttpSession用户会话 */
      HttpSession session = new HttpSession(((HttpServletRequest)req).getSession());
      resManager.setResourceContainer(HttpSession.class.getName(), session);
     
      /* 设置资源容器, HttpRequest请求 */
      resManager.setResourceContainer(HttpRequest.class.getName(), request);
     
     
      /* 设置资源, WEBApplicationContext */
      resManager.setResource(WEBApplicationContext.class.getName(), webContext);
     
      /* 设置资源, HttpSession */
      resManager.setResource(HttpSession.class.getName(), session);
     
      /* 设置资源, HttpRequest */
      resManager.setResource(HttpRequest.class.getName(), request);     
     
      /* 设置资源, ServletResponse */
      resManager.setResource(ServletResponse.class.getName(), res);
     
      /* 将资源管理器加入到Request中,以便于在具休JSP或Servlet中能使用到资源管理器 */
      request.setAttribute(ResourceManager.class.getName(), resManager);
     
      /* 转到下一过滤器 */
 
View Full Code Here

TOP

Related Classes of org.fto.jthink.resource.ResourceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.