Zwei kleinere Änderungen:
- Besseres Logging bei Exceptions, die in einer JSP auftreten - Fehlerkorrektur im SelectFilter für CustomizableObjectList. Der SelectFilter war nicht null sicher, das heißt wenn der Wert für den der Select-Filter definiert ist bei einem Item nicht vorhanden ist, kam es zu einer NPE. git-svn-id: https://svn.libreccm.org/ccm/trunk@1194 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
722275e115
commit
86d98cb4c7
|
|
@ -74,24 +74,19 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
private Class m_pageClass;
|
private Class m_pageClass;
|
||||||
private boolean m_cache = true;
|
private boolean m_cache = true;
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(DefinePage.class.getName());
|
Logger.getLogger(DefinePage.class.getName());
|
||||||
|
|
||||||
private static CacheTable s_pageCache = new CacheTable("PageCache");
|
private static CacheTable s_pageCache = new CacheTable("PageCache");
|
||||||
// maps URL(/packages/foo/www/asdf.jsp) -> {Page, creation date}
|
// maps URL(/packages/foo/www/asdf.jsp) -> {Page, creation date}
|
||||||
// should this be a CacheTable or not?
|
// should this be a CacheTable or not?
|
||||||
private static Map s_pageLocks = new HashMap();
|
private static Map s_pageLocks = new HashMap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Bebop Page instance. A page tag is a special case
|
* Creates a Bebop Page instance. A page tag is a special case
|
||||||
* because we don't expect it to have a parent tag.
|
* because we don't expect it to have a parent tag.
|
||||||
*/
|
*/
|
||||||
public int doStartTag() throws JspException {
|
public int doStartTag() throws JspException {
|
||||||
if (m_cache) {
|
if (m_cache) {
|
||||||
String cacheKey = DispatcherHelper.getCurrentResourcePath
|
String cacheKey = DispatcherHelper.getCurrentResourcePath((HttpServletRequest) pageContext.getRequest());
|
||||||
((HttpServletRequest)pageContext.getRequest());
|
|
||||||
Object pageLock;
|
Object pageLock;
|
||||||
// First off all we have the global synchronization
|
// First off all we have the global synchronization
|
||||||
// block to get the page's unique sync object.
|
// block to get the page's unique sync object.
|
||||||
|
|
@ -104,19 +99,18 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
}
|
}
|
||||||
// Now we just synchronize against our specific page.
|
// Now we just synchronize against our specific page.
|
||||||
synchronized (pageLock) {
|
synchronized (pageLock) {
|
||||||
|
|
||||||
CachedPage cached = (CachedPage)s_pageCache.get(cacheKey);
|
CachedPage cached = (CachedPage) s_pageCache.get(cacheKey);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
Object[] pair = cached.getPageTimeStampPair();
|
Object[] pair = cached.getPageTimeStampPair();
|
||||||
|
|
||||||
long pageDate = ((Long)pair[1]).longValue();
|
long pageDate = ((Long) pair[1]).longValue();
|
||||||
File jspFile = new File(pageContext.getServletContext()
|
File jspFile = new File(pageContext.getServletContext().getRealPath(cacheKey));
|
||||||
.getRealPath(cacheKey));
|
|
||||||
if (jspFile.lastModified() <= pageDate) {
|
if (jspFile.lastModified() <= pageDate) {
|
||||||
// jsp file is not newer than cached page,
|
// jsp file is not newer than cached page,
|
||||||
// and page hasn't been marked as dirty by anyone so we can use the cached page.
|
// and page hasn't been marked as dirty by anyone so we can use the cached page.
|
||||||
|
|
||||||
Page page = (Page)pair[0];
|
Page page = (Page) pair[0];
|
||||||
|
|
||||||
// We may have to for the page to be locked
|
// We may have to for the page to be locked
|
||||||
// by another thread
|
// by another thread
|
||||||
|
|
@ -134,7 +128,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_page = (Page)pair[0];
|
m_page = (Page) pair[0];
|
||||||
pageContext.setAttribute(getName(), m_page);
|
pageContext.setAttribute(getName(), m_page);
|
||||||
return SKIP_BODY;
|
return SKIP_BODY;
|
||||||
}
|
}
|
||||||
|
|
@ -142,8 +136,8 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
|
|
||||||
|
|
||||||
m_page = buildPage();
|
m_page = buildPage();
|
||||||
// s_pageCache.put(cacheKey,
|
// s_pageCache.put(cacheKey,
|
||||||
// new CachedPage(new Object[] {m_page,
|
// new CachedPage(new Object[] {m_page,
|
||||||
// new Long(System.currentTimeMillis())}));
|
// new Long(System.currentTimeMillis())}));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -162,12 +156,11 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void invalidatePage (String resourceURL) {
|
public static void invalidatePage(String resourceURL) {
|
||||||
s_log.debug("page - " + resourceURL + " removed from cache");
|
s_log.debug("page - " + resourceURL + " removed from cache");
|
||||||
s_pageCache.remove(resourceURL);
|
s_pageCache.remove(resourceURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Page buildPage() throws JspException {
|
private Page buildPage() throws JspException {
|
||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
|
|
@ -177,11 +170,11 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
|
|
||||||
if (m_pageClass == null) {
|
if (m_pageClass == null) {
|
||||||
page = PageFactory.buildPage(m_application,
|
page = PageFactory.buildPage(m_application,
|
||||||
m_title,
|
m_title,
|
||||||
getName());
|
getName());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
page = (Page)m_pageClass.newInstance();
|
page = (Page) m_pageClass.newInstance();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new JspWrapperException("cannot create page class instance", e);
|
throw new JspWrapperException("cannot create page class instance", e);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
|
|
@ -196,7 +189,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
// we *might* be nested, but probably aren't
|
// we *might* be nested, but probably aren't
|
||||||
Tag t = getParent();
|
Tag t = getParent();
|
||||||
if (t != null && t instanceof DefineContainer) {
|
if (t != null && t instanceof DefineContainer) {
|
||||||
((BodyTag)t).doAfterBody();
|
((BodyTag) t).doAfterBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
|
|
@ -219,8 +212,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
public int doEndTag() throws JspException {
|
public int doEndTag() throws JspException {
|
||||||
try {
|
try {
|
||||||
if (m_cache) {
|
if (m_cache) {
|
||||||
String cacheKey = DispatcherHelper.getCurrentResourcePath
|
String cacheKey = DispatcherHelper.getCurrentResourcePath((HttpServletRequest) pageContext.getRequest());
|
||||||
((HttpServletRequest)pageContext.getRequest());
|
|
||||||
Object pageLock;
|
Object pageLock;
|
||||||
// Global lock to get hold of page sync object
|
// Global lock to get hold of page sync object
|
||||||
synchronized (s_pageLocks) {
|
synchronized (s_pageLocks) {
|
||||||
|
|
@ -231,17 +223,17 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now sync just on this page
|
// Now sync just on this page
|
||||||
synchronized(pageLock) {
|
synchronized (pageLock) {
|
||||||
if (!m_page.isLocked()) {
|
if (!m_page.isLocked()) {
|
||||||
m_page.lock();
|
m_page.lock();
|
||||||
CachedPage cached = (CachedPage)s_pageCache.get(cacheKey);
|
CachedPage cached = (CachedPage) s_pageCache.get(cacheKey);
|
||||||
// cache page in end tag because hashcode of cached page relies on
|
// cache page in end tag because hashcode of cached page relies on
|
||||||
// components that are added between start and end tag
|
// components that are added between start and end tag
|
||||||
if (cached == null) {
|
if (cached == null) {
|
||||||
s_pageCache.put(cacheKey,
|
s_pageCache.put(cacheKey,
|
||||||
new CachedPage(new Object[] {m_page,
|
new CachedPage(new Object[]{m_page,
|
||||||
new Long(System.currentTimeMillis())}));
|
new Long(System.currentTimeMillis())}));
|
||||||
}
|
}
|
||||||
// Now notify anyone waiting for us to lock the page
|
// Now notify anyone waiting for us to lock the page
|
||||||
// that we're all done. see doStartTag()
|
// that we're all done. see doStartTag()
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
|
|
@ -260,36 +252,33 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
// nested...
|
// nested...
|
||||||
// treat like a slave component, a page nested
|
// treat like a slave component, a page nested
|
||||||
// within another page
|
// within another page
|
||||||
((DefineContainer)t).addComponent(new SlaveComponent(m_page));
|
((DefineContainer) t).addComponent(new SlaveComponent(m_page));
|
||||||
// if we're nested
|
// if we're nested
|
||||||
} else if (m_master != null) {
|
} else if (m_master != null) {
|
||||||
// if we have a master page, then we pass control to it,
|
// if we have a master page, then we pass control to it,
|
||||||
// with the current (m_page) as a request attribute.
|
// with the current (m_page) as a request attribute.
|
||||||
pageContext.getRequest()
|
pageContext.getRequest().setAttribute("com.arsdigita.bebop.SlavePage", m_page);
|
||||||
.setAttribute("com.arsdigita.bebop.SlavePage", m_page);
|
|
||||||
DispatcherHelper.forwardRequestByPath(m_master, pageContext);
|
DispatcherHelper.forwardRequestByPath(m_master, pageContext);
|
||||||
} else {
|
} else {
|
||||||
// pass on the document to the ShowAll code. Note ugly
|
// pass on the document to the ShowAll code. Note ugly
|
||||||
// long-range code dependency voodoo here.
|
// long-range code dependency voodoo here.
|
||||||
HttpServletRequest req =
|
HttpServletRequest req =
|
||||||
(HttpServletRequest)pageContext.getRequest();
|
(HttpServletRequest) pageContext.getRequest();
|
||||||
HttpServletResponse resp =
|
HttpServletResponse resp =
|
||||||
(HttpServletResponse)pageContext.getResponse();
|
(HttpServletResponse) pageContext.getResponse();
|
||||||
|
|
||||||
Document doc;
|
Document doc;
|
||||||
PageState state;
|
PageState state;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doc = new Document ();
|
doc = new Document();
|
||||||
state = m_page.process (req, resp);
|
state = m_page.process(req, resp);
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
} catch (ServletException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
catch (ParserConfigurationException ex) {
|
m_page.generateXML(state, doc);
|
||||||
throw new UncheckedWrapperException (ex);
|
|
||||||
}
|
|
||||||
catch (ServletException ex) {
|
|
||||||
throw new UncheckedWrapperException (ex);
|
|
||||||
}
|
|
||||||
m_page.generateXML (state, doc);
|
|
||||||
|
|
||||||
req.setAttribute(INPUT_DOC_ATTRIBUTE, doc);
|
req.setAttribute(INPUT_DOC_ATTRIBUTE, doc);
|
||||||
pageContext.setAttribute(INPUT_PAGE_STATE_ATTRIBUTE, state);
|
pageContext.setAttribute(INPUT_PAGE_STATE_ATTRIBUTE, state);
|
||||||
|
|
@ -302,6 +291,8 @@ public class DefinePage extends DefineContainer implements JSPConstants {
|
||||||
} catch (Throwable nested) {
|
} catch (Throwable nested) {
|
||||||
// serving error page failed, so
|
// serving error page failed, so
|
||||||
// percolate error up to top-level
|
// percolate error up to top-level
|
||||||
|
s_log.error("PageContext failed to handle exceptionb exception: ",
|
||||||
|
nested);
|
||||||
throw new UncheckedWrapperException(e);
|
throw new UncheckedWrapperException(e);
|
||||||
}
|
}
|
||||||
return SKIP_PAGE;
|
return SKIP_PAGE;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import java.util.Set;
|
||||||
* paginator) and using each distinct value of the property as option.
|
* paginator) and using each distinct value of the property as option.
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class SelectFilter implements Filter {
|
public class SelectFilter implements Filter {
|
||||||
|
|
||||||
|
|
@ -129,8 +130,13 @@ public class SelectFilter implements Filter {
|
||||||
while (objects.next()) {
|
while (objects.next()) {
|
||||||
dobj = objects.getDataObject();
|
dobj = objects.getDataObject();
|
||||||
|
|
||||||
option = (dobj.get(property)).toString();
|
final Object propValue = dobj.get(property);
|
||||||
|
if (propValue == null) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
option = propValue.toString();
|
||||||
optionsSet.add(option);
|
optionsSet.add(option);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options = new ArrayList<String>(optionsSet);
|
options = new ArrayList<String>(optionsSet);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue