📄 defaultindexprocessor.java
字号:
/*
* Copyright 2005 Joe Walker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.ltd.getahead.dwr.impl;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import uk.ltd.getahead.dwr.Creator;
import uk.ltd.getahead.dwr.CreatorManager;
import uk.ltd.getahead.dwr.Processor;
import uk.ltd.getahead.dwr.util.Logger;
/**
* Create a debug mode only index page to all the available classes
* @author Joe Walker [joe at getahead dot ltd dot uk]
*/
public class DefaultIndexProcessor implements Processor
{
/* (non-Javadoc)
* @see uk.ltd.getahead.dwr.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
if (!creatorManager.isDebug())
{
log.warn("Failed attempt to access index page outside of debug mode. Set the debug init-parameter to true to enable."); //$NON-NLS-1$
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
resp.setContentType(HtmlConstants.MIME_HTML);
PrintWriter out = resp.getWriter();
out.println("<html>"); //$NON-NLS-1$
out.println("<head><title>DWR Test Index</title></head>"); //$NON-NLS-1$
out.println("<body>"); //$NON-NLS-1$
out.println("<h2>Classes known to DWR:</h2>"); //$NON-NLS-1$
out.println("<ul>"); //$NON-NLS-1$
for (Iterator it = creatorManager.getCreatorNames().iterator(); it.hasNext();)
{
String name = (String) it.next();
Creator creator = creatorManager.getCreator(name);
out.println("<li><a href='" + req.getContextPath() + req.getServletPath() + HtmlConstants.PATH_TEST + name + "'>" + name + "</a> (" + creator.getType().getName() + ")</li>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
out.println("</ul>"); //$NON-NLS-1$
out.println("<h2>Other Links</h2>"); //$NON-NLS-1$
out.println("<ul>"); //$NON-NLS-1$
out.println("<li>Up to <a href='" + req.getContextPath() + "/'>top level of web app</a>.</li>"); //$NON-NLS-1$ //$NON-NLS-2$
out.println("</ul>"); //$NON-NLS-1$
out.println("</body></html>"); //$NON-NLS-1$
out.flush();
}
/**
* Accessor for the DefaultCreatorManager that we configure
* @param creatorManager The new DefaultConverterManager
*/
public void setCreatorManager(CreatorManager creatorManager)
{
this.creatorManager = creatorManager;
}
/**
* How we create new beans
*/
protected CreatorManager creatorManager = null;
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(DefaultIndexProcessor.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -