View Javadoc
1   /*
2    * Copyright 2001-2009 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.servlets;
17  
18  import java.io.IOException;
19  import java.io.PrintWriter;
20  import java.util.Iterator;
21  
22  import javax.servlet.ServletException;
23  import javax.servlet.http.HttpServlet;
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  
27  import org.apache.commons.collections.Buffer;
28  import org.apache.juddi.subscription.NotificationList;
29  
30  
31  /**
32   * This servlet is used print out notifications received
33   * from subscriptions in the subscription portal. This servlet is
34   * used for this demo only and has no other purpose.
35   * 
36   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
37   */
38  public class NotifyServlet extends HttpServlet
39  {
40  	private static final long serialVersionUID = 4862936257096400737L;
41  
42  	@SuppressWarnings("unchecked")
43  	public void doGet(HttpServletRequest request,
44  			HttpServletResponse response) throws
45  		ServletException, IOException {
46  		StringBuffer sb = new StringBuffer();
47  
48  		Buffer nl = NotificationList.getInstance().getNotifications();
49  		Iterator<String> it = nl.iterator();
50  		while (it.hasNext()) {
51  			String notification = (String) it.next();		
52  			sb.append(notification);
53  		}
54  		nl.clear();
55  		PrintWriter out = response.getWriter();
56  		out.println(sb.toString());
57  	}
58  }