KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > jetty > servlet > jmx > ServletHolderMBean


1 // ========================================================================
2
// $Id: ServletHolderMBean.java,v 1.7 2005/04/07 09:15:30 gregwilkins Exp $
3
// Copyright 200-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15

16 package org.mortbay.jetty.servlet.jmx;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import javax.management.MBeanException JavaDoc;
23
24 import org.mortbay.jetty.servlet.ServletHandler;
25 import org.mortbay.jetty.servlet.ServletHolder;
26
27
28 /* ------------------------------------------------------------ */
29 /**
30  *
31  * @version $Revision: 1.7 $
32  * @author Greg Wilkins (gregw)
33  */

34 public class ServletHolderMBean extends HolderMBean
35 {
36     /* ------------------------------------------------------------ */
37     private ServletHolder _holder;
38     
39     /* ------------------------------------------------------------ */
40     /** Constructor.
41      * @exception MBeanException
42      */

43     public ServletHolderMBean()
44         throws MBeanException JavaDoc
45     {}
46     
47     /* ------------------------------------------------------------ */
48     protected void defineManagedResource()
49     {
50         super.defineManagedResource();
51         defineAttribute("initOrder");
52         defineAttribute("paths",READ_ONLY,ON_MBEAN);
53
54         _holder=(ServletHolder)getManagedResource();
55     }
56
57     /* ------------------------------------------------------------ */
58     public String JavaDoc[] getPaths()
59     {
60         ServletHandler handler = (ServletHandler)_holder.getHttpHandler();
61         Map JavaDoc servletMap = handler.getServletMap();
62         ArrayList JavaDoc paths = new ArrayList JavaDoc(servletMap.size());
63         Iterator JavaDoc iter = servletMap.entrySet().iterator();
64         while (iter.hasNext())
65         {
66             Map.Entry JavaDoc entry =(Map.Entry JavaDoc)iter.next();
67             if (entry.getValue()==_holder)
68                 paths.add(entry.getKey());
69         }
70         return (String JavaDoc[])paths.toArray(new String JavaDoc[paths.size()]);
71     }
72     
73     
74
75 }
76
Popular Tags