WebSphere Extended Deployment, Version 6.0.x     운영 체제: AIX, HP-UX, Linux, Solaris, Windows

다음은 샘플 HTTP 파티션 기능 응용프로그램 Servlet의 전체 내용을 나열한 것입니다.
  	public class ListPartitions extends HttpServlet implements Servlet, 
  HttpPartitionNotification {
	private static String className = "ListPartitions";
	private static String appName = "http.wpf.sample";
	private static HttpPartitionManager httpPartitionManager = 
  HttpPartitionManager.instance;
	    
public void init() throws ServletException {
	   System.out.println(className+": Registering notification ");
		 httpPartitionManager.registerNotification(appName, this);
 }
    
  public void destroy() {
	   System.out.println(className+": Deregistering notification ");
	   httpPartitionManager.deregisterNotification(appName, this);
   }
	
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
    		throws ServletException, IOException {
		
	  resp.setContentType("text/html");
   	ServletOutputStream out = resp.getOutputStream();
out.println("<html>");  
   	out.println("<head><title>Hello World</title></head>");
   	out.println("<body>");
   	out.println("<h1>Hello World</h1><h1>");
		out.println(listPartitions());
		out.println("</h1>");
		out.println("");	
}
	    
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
 }
	    
  public static String listPartitions() {
		HttpPartitionManager httpPartitionManager = 
    HttpPartitionManager.instance;
    Vector partitions = httpPartitionManager.getActivePartitions
    (appName);
    String output = "Number of Partitions: "+partitions.size()+":
    \nPartitions:\n";
     for (int i=0; i< partitions.size(); i++)
    output = output.concat(partitions.elementAt(i) + "\n");
    return output;
  }
	
public Vector getPartitions() {
		System.out.println(className+": getPartitions ");
		Vector myVect = new Vector();
		myVect.add("jian");
		myVect.add("lou");
	  System.out.println(className+": getPartitions number of partitions: 
    "+myVect.size());
	  return myVect;   // Do not override partitions 
 	 }
	
public HttpPartitionExpression[] getExpressions() {
		System.out.println(className+": getExpressions ");
		HttpPartitionExpression[] expressions = new HttpPartitionExpression[2];
		expressions[0] = httpPartitionManager.createHttpPartitionExpression
    ("(user=)(.*)&", "$2");
		expressions[1] = httpPartitionManager.createHttpPartitionExpression
    ("(user=)(.*)$", "$2");
		System.out.println(className+": getExpressions number of expressions 
    "+expressions.length);
		return expressions;   // Do not override expressions
  }
	
public boolean loadEvent(String partitionName) {
		 /*
		 * now is a good time to start caching relevant data
		 */
		System.out.println(className+": load "+partitionName);
	
		return true;
  }
	    
public void unloadEvent(String partitionName)
	    {
		/*
		 * now is a good time to flush relevant cached data
		 */
		System.out.println(className+": unload "+partitionName);
  }
	    
public boolean isPartitionAlive(String partitionName) 
	    {
		/*
		 * can check if a partition is still active
		 */	
		System.out.println(className+": isPartitionAlive ");
		return true;
	    }
}
이 예에서는 알림 인터페이스의 getPartitions() 및 getExpressions() 메소드를 사용하여 두 개의 파티션 이름(이 경우 lou 및 jian)과 두 개의 요청 표현식을 지정할 때 HttpPartitionManager를 사용하는 방법을 표시합니다. 이 Servlet에서 이 메소드를 지정하지 않는 경우(예: 동반된 partitions.xml 파일에 제공되거나 EJB에서 지정하는 경우) 메소드는 널을 리턴합니다.



Related concepts
HTTP 파티션

참조 주제:    

이용 약관 | 피드백 마지막 갱신 날짜: Mar 21, 2006 11:38:53 AM EST
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r0/index.jsp?topic=?topic=/com.ibm.websphere.xd.doc/info/WPF51/rwpfexample.html

© Copyright IBM 2005, 2006. All Rights Reserved.
이 Information Center는 Eclipse 테크놀러지로 강화되었습니다. (http://www.eclipse.org)