Giới thiệu

Như chúng ta đã biết, mỗi một tiến trình trong giao diện Tiến trình của WAK đều sử dụng 1 class để xử lý. Tôi xin giới thiệu 1 đoạn code cơ bản để giới thiệu WAK sử dụng các tham số như thế nào.
Cấu hình file .thread tại file cấu hình tiến trình

  • WAK Thread sử dụng 1 manager để xử lý chung cho tiến trình đó là ManageableThread. Mỗi class sử dụng WAK Thread extends từ ManageableThread.
  • Khai báo biến sqlCommand. Đây chính là biến câu lệnh khai báo để lấy được cấu hình trong file .thread.
  • Để hiển thị được tham số SQLCommand trong giao diện chỉnh sửa tham số tiến trình ta dùng hàm getParameterDefinition. Trong đó sử dụng DictionaryNode để lấy parameter từ file.thread.
  • Để lấy được giá trị tham số SQLCommand trong cấu hình tham số tiến trình ta dùng hàm fillParameter như code bên dưới.

Tiến trình mẫu

  • Và để tiến trình được thực thì thì class sử dụng hàm processSession
package com.ftl.thread;
 
import com.ftl.dictionary.DictionaryNode;
import com.ftl.sql.Database;
import com.ftl.util.StringUtil;
import com.ftl.wak.mgr.DataSourceManager;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Statement;
import java.util.List;
import javax.sql.DataSource;
 
public class SQLCommander
  extends ManageableThread
{
  protected String sqlCommand;
 
  public DictionaryNode getParameterDefinition()
  {
    DictionaryNode nd = new DictionaryNode();
    nd.addChild(createParameterDefinition("SQLCommand", "TextArea", "SQL command need to be executed each session.", 
 
      createTextParameterDefinition(16536, null)));
    nd.children.addAll(super.getParameterDefinition().getChildList());
    return nd;
  }
 
  public void fillParameter()
    throws Exception
  {
    this.sqlCommand = loadMandatory("SQLCommand");
    super.fillParameter();
  }
 
  public void processSession()
    throws Exception
  {
// Câu lệnh sau sẽ in ra Hello và tham số sqlCommand
    log.monitor("Hello" + sqlCommand);
  }
 
}

Comment