Fixed connection leak from within Global Refresher.
This commit is contained in:
parent
538d753f28
commit
ded733a200
7 changed files with 87 additions and 22 deletions
|
@ -41,11 +41,11 @@
|
|||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>2</value>
|
||||
<value>7</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>4</value>
|
||||
<value>15</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
@ -89,11 +89,11 @@
|
|||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>2</value>
|
||||
<value>7</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>4</value>
|
||||
<value>15</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
|
|
@ -243,7 +243,12 @@ public class DisplayHelper
|
|||
*/
|
||||
public String getFormattedDate()
|
||||
{
|
||||
return DATE_FORMAT.format( getDate() );
|
||||
String date = null;
|
||||
if ( null != getDate() )
|
||||
{
|
||||
date = DATE_FORMAT.format( getDate() );
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
|
|
@ -17,6 +17,8 @@ public class Global
|
|||
private static long lastRefresh;
|
||||
private int entryCount;
|
||||
private List recentTerms;
|
||||
private final GlobalRefresher REFRESHER = new GlobalRefresher();
|
||||
private final Thread REFRESHER_THREAD = new Thread( REFRESHER );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -110,7 +112,7 @@ public class Global
|
|||
*/
|
||||
public void setRecentTerms( List recentTerms )
|
||||
{
|
||||
this.recentTerms = recentTerms;
|
||||
this.recentTerms = Collections.synchronizedList( recentTerms );
|
||||
setLastRefresh( System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
|
@ -182,8 +184,17 @@ public class Global
|
|||
*/
|
||||
public void doRefresh() throws LexRepositoryException
|
||||
{
|
||||
GlobalRefresher gr = new GlobalRefresher();
|
||||
new Thread( gr ).start();
|
||||
LexLogger.info( "Checking if GlobalRefresher is busy..." );
|
||||
if ( REFRESHER.getFinished() )
|
||||
{
|
||||
LexLogger.info( "GlobalRefresher is not busy. Starting refresh..." );
|
||||
REFRESHER.setFinished( false );
|
||||
REFRESHER_THREAD.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
LexLogger.info( "GlobalRefresher was busy. Refresh not started..." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,6 +225,31 @@ public class Global
|
|||
*/
|
||||
class GlobalRefresher implements Runnable
|
||||
{
|
||||
private boolean finished;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the finished attribute of the GlobalRefresher object
|
||||
*
|
||||
* @param finished The new finished value
|
||||
*/
|
||||
private void setFinished( boolean finished )
|
||||
{
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the finished attribute of the GlobalRefresher object
|
||||
*
|
||||
* @return The finished value
|
||||
*/
|
||||
private boolean getFinished()
|
||||
{
|
||||
return finished;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main processing method for the GlobalRefresher object
|
||||
*/
|
||||
|
@ -222,7 +258,18 @@ public class Global
|
|||
int limit = getRecentTermsCount();
|
||||
try
|
||||
{
|
||||
LexLogger.info( "GlobalRefresher is starting a refresh..." );
|
||||
setRecentTerms( LexComponentRepository.getRecentTerms( limit ) );
|
||||
/*
|
||||
ILexComponent ilc = null;
|
||||
for ( Iterator it = getRecentTerms().iterator(); it.hasNext(); ilc = (ILexComponent) it.next() )
|
||||
{
|
||||
ilc.getMeta();
|
||||
}
|
||||
*/
|
||||
LexComponentRepository.cleanup();
|
||||
LexLogger.info( "GlobalRefresher finished a refresh..." );
|
||||
setFinished( true );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
@ -231,14 +278,17 @@ public class Global
|
|||
String stackTrace = writer.getBuffer().toString();
|
||||
LexLogger.error( "GlobalRefresher Thread caught an Exception: " + stackTrace );
|
||||
}
|
||||
|
||||
setFinished( true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Constructor for the GlobalRefresher object
|
||||
*/
|
||||
GlobalRefresher() { }
|
||||
GlobalRefresher()
|
||||
{
|
||||
setFinished( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,8 +369,10 @@ public class LexComponentRepository
|
|||
String queryString = " FROM org.thdl.lex.component.ITerm ORDER BY modifiedOn DESC LIMIT " + limit;
|
||||
try
|
||||
{
|
||||
beginTransaction();
|
||||
query = getSession().createQuery( queryString );
|
||||
results = query.list();
|
||||
endTransaction( false );
|
||||
}
|
||||
catch ( HibernateException he )
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.thdl.lex.component.*;
|
|||
public class LexLogger
|
||||
{
|
||||
private final static Logger LOGGER = Logger.getLogger( "org.thdl.lex" );
|
||||
private final static List EXCLUDED_PARAMS = Arrays.asList( new String[]{"org.apache.catalina.jsp_classpath", "javax.servlet.context.tempdir", "org.apache.catalina.WELCOME_FILES"} );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -87,7 +88,10 @@ public class LexLogger
|
|||
while ( enum.hasMoreElements() )
|
||||
{
|
||||
String att = (String) enum.nextElement();
|
||||
LOGGER.debug( "Context Attribute " + att + " = " + context.getAttribute( att ) );
|
||||
if ( !EXCLUDED_PARAMS.contains( att ) )
|
||||
{
|
||||
LOGGER.debug( "Context Attribute " + att + " = " + context.getAttribute( att ) );
|
||||
}
|
||||
}
|
||||
debugComponent( context.getAttribute( LexConstants.GLOBAL_CONTEXT_ATTR ) );
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ public class DisplayCommand extends LexCommand implements Command
|
|||
{
|
||||
LexComponentRepository.loadTermByPk( term );
|
||||
query.setEntry( term );
|
||||
if ( query.getResults().keySet().size() < 1 )
|
||||
{
|
||||
query.getResults().put( term.getMetaId(), term.getTerm() );
|
||||
}
|
||||
}
|
||||
|
||||
displayHelper.populate( req.getParameterMap() );
|
||||
|
|
|
@ -7,24 +7,24 @@
|
|||
|
||||
|
||||
<!--TERM-->
|
||||
<h1><c:out value="${ query.entry.term }" /></h1>
|
||||
<h1><c:out value="${ sessionScope.visit.query.entry.term }" /></h1>
|
||||
<p class="data" >
|
||||
<c:out value='<a name="${ query.entry }" ></a>' escapeXml="false" />
|
||||
<c:out value='<a name="${ sessionScope.visit.query.entry }" ></a>' escapeXml="false" />
|
||||
<c:if test="${ editMode }">
|
||||
<span class="compEditOptions">
|
||||
<c:out value='<a href="/lex/action?cmd=getUpdateTermForm&comp=term&metaId=${ query.entry.metaId }" label="Edit Term"><img alt="Edit Term" src="/lex/images/edit.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getAnnotationForm&comp=term&metaId=${query.entry.metaId}" label="Add Analytical Note"><img alt="Add Analytical Note" src="/lex/images/note.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=pronunciation&parentId=${query.entry.metaId}" label="Add Pronunciation"><img alt="Add Pronunciation" src="/lex/images/pron.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=etymology&parentId=${query.entry.metaId}" label="Add Etymology"><img alt="Add Etymology" src="/lex/images/etym.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=spelling&parentId=${query.entry.metaId}" label="Add Spelling"><img alt="Add Spelling" src="/lex/images/spell.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=grammaticalFunction&parentId=${query.entry.metaId}" label="Add Grammatical Function"><img alt="Add a Grammatical Function" src="/lex/images/gram.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=encyclopediaArticle&parentId=${query.entry.metaId}" label="Add Encyclopedia Article"><img alt="Add Encyclopedia Article" src="/lex/images/ency.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=definition&parentId=${query.entry.metaId}" label="Add Definition"><img alt="Add Definition" src="/lex/images/def.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getUpdateTermForm&comp=term&metaId=${ sessionScope.visit.query.entry.metaId }" label="Edit Term"><img alt="Edit Term" src="/lex/images/edit.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getAnnotationForm&comp=term&metaId=${sessionScope.visit.query.entry.metaId}" label="Add Analytical Note"><img alt="Add Analytical Note" src="/lex/images/note.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=pronunciation&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Pronunciation"><img alt="Add Pronunciation" src="/lex/images/pron.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=etymology&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Etymology"><img alt="Add Etymology" src="/lex/images/etym.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=spelling&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Spelling"><img alt="Add Spelling" src="/lex/images/spell.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=grammaticalFunction&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Grammatical Function"><img alt="Add a Grammatical Function" src="/lex/images/gram.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=encyclopediaArticle&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Encyclopedia Article"><img alt="Add Encyclopedia Article" src="/lex/images/ency.gif"/></a>' escapeXml="false" />
|
||||
<c:out value='<a href="/lex/action?cmd=getInsertForm&comp=definition&parentId=${sessionScope.visit.query.entry.metaId}" label="Add Definition"><img alt="Add Definition" src="/lex/images/def.gif"/></a>' escapeXml="false" />
|
||||
</span>
|
||||
</c:if>
|
||||
|
||||
<!--metadata-->
|
||||
<c:set target="${ sessionScope.visit.helper }" property="component" value="${ query.entry }" />
|
||||
<c:set target="${ sessionScope.visit.helper }" property="component" value="${ sessionScope.visit.query.entry }" />
|
||||
<jsp:include page="displayMeta.jsf" />
|
||||
|
||||
<!--notes-->
|
||||
|
|
Loading…
Reference in a new issue