Modified Global to refresh it's stats in a separate thread to avoid Hibernate Load collisions.
This commit is contained in:
parent
cd65eb18b9
commit
538d753f28
4 changed files with 66 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
package org.thdl.lex;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.thdl.lex.component.*;
|
||||
|
||||
|
@ -27,8 +27,13 @@ public class Global
|
|||
*/
|
||||
public Date getLastUpdate() throws LexRepositoryException
|
||||
{
|
||||
ITerm term = (ITerm) getRecentTerms().get( 0 );
|
||||
return term.getMeta().getModifiedOn();
|
||||
Date date = null;
|
||||
if ( null != getRecentTerms() && getRecentTerms().size() > 0 )
|
||||
{
|
||||
ITerm term = (ITerm) getRecentTerms().get( 0 );
|
||||
date = term.getMeta().getModifiedOn();
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,8 +182,8 @@ public class Global
|
|||
*/
|
||||
public void doRefresh() throws LexRepositoryException
|
||||
{
|
||||
int limit = getRecentTermsCount();
|
||||
setRecentTerms( LexComponentRepository.getRecentTerms( limit ) );
|
||||
GlobalRefresher gr = new GlobalRefresher();
|
||||
new Thread( gr ).start();
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,5 +204,41 @@ public class Global
|
|||
setRecentTermsCount( recentItems );
|
||||
setRefreshDelay( refreshDelay );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Class
|
||||
*
|
||||
* @author travis
|
||||
* @created October 21, 2003
|
||||
*/
|
||||
class GlobalRefresher implements Runnable
|
||||
{
|
||||
/**
|
||||
* Main processing method for the GlobalRefresher object
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
int limit = getRecentTermsCount();
|
||||
try
|
||||
{
|
||||
setRecentTerms( LexComponentRepository.getRecentTerms( limit ) );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
e.printStackTrace( new PrintWriter( writer ) );
|
||||
String stackTrace = writer.getBuffer().toString();
|
||||
LexLogger.error( "GlobalRefresher Thread caught an Exception: " + stackTrace );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Constructor for the GlobalRefresher object
|
||||
*/
|
||||
GlobalRefresher() { }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,8 @@ public class LexComponentFilter implements Filter
|
|||
try
|
||||
{
|
||||
setBlanks( new HashMap() );
|
||||
getBlanks().put( LexConstants.TERMLABEL_VALUE, new Term() );
|
||||
ITerm term = new Term();
|
||||
getBlanks().put( LexConstants.TERMLABEL_VALUE, term );
|
||||
getBlanks().put( LexConstants.PRONUNCIATIONLABEL_VALUE, new Pronunciation() );
|
||||
getBlanks().put( LexConstants.ETYMOLOGYLABEL_VALUE, new Etymology() );
|
||||
getBlanks().put( LexConstants.FUNCTIONLABEL_VALUE, new GrammaticalFunction() );
|
||||
|
@ -145,15 +146,15 @@ public class LexComponentFilter implements Filter
|
|||
{
|
||||
if ( getBlanks().get( labelValue ) != null )
|
||||
{
|
||||
Class glass = getBlanks().get( labelValue ).getClass();
|
||||
LexComponent component = (LexComponent) glass.newInstance();
|
||||
Class c = getBlanks().get( labelValue ).getClass();
|
||||
LexComponent component = (LexComponent) c.newInstance();
|
||||
component.populate( req.getParameterMap() );
|
||||
component.getMeta().populate( req.getParameterMap() );
|
||||
req.setAttribute( LexConstants.COMPONENT_REQ_ATTR, component );
|
||||
}
|
||||
else
|
||||
{
|
||||
req.setAttribute( "LCFilter says: ", "componentLabel was not in blank components" );
|
||||
LexLogger.error( "componentLabel was not in blank components" );
|
||||
}
|
||||
}
|
||||
catch ( InstantiationException ie )
|
||||
|
@ -171,7 +172,7 @@ public class LexComponentFilter implements Filter
|
|||
}
|
||||
else
|
||||
{
|
||||
req.setAttribute( "LexComponentFilter says: '", LexConstants.LABEL_REQ_PARAM + "' was not specified." );
|
||||
LexLogger.error( "Required parameter, '" + LexConstants.LABEL_REQ_PARAM + "' was not specified." );
|
||||
}
|
||||
chain.doFilter( request, response );
|
||||
|
||||
|
@ -187,7 +188,7 @@ public class LexComponentFilter implements Filter
|
|||
LexLogger.debug( "Checking Request state at end of LexComponentFilter.doFilter()" );
|
||||
LexLogger.logRequestState( req );
|
||||
LexLogger.logSessionState( req );
|
||||
*/
|
||||
*/
|
||||
long dur = System.currentTimeMillis() - start;
|
||||
LexLogger.debug( "Total Request took: " + dur / 1000 + " seconds.\n\n" );
|
||||
}
|
||||
|
|
|
@ -126,6 +126,17 @@ public class LexLogger
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
* @param msg Description of the Parameter
|
||||
*/
|
||||
public static void error( String msg )
|
||||
{
|
||||
LOGGER.error( msg );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Constructor for the debugComponent object
|
||||
*
|
||||
|
@ -151,8 +162,6 @@ public class LexLogger
|
|||
String stackTrace = writer.getBuffer().toString();
|
||||
LOGGER.debug( "LexLogger caught an Exception: " + stackTrace );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ public class DisplayCommand extends LexCommand implements Command
|
|||
}
|
||||
|
||||
displayHelper.populate( req.getParameterMap() );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setNext( "menu.jsp" );
|
||||
msg = "The component you were trying to display was not a term.";
|
||||
msg = "The component set for display was not a term.";
|
||||
LexLogger.error( msg );
|
||||
}
|
||||
req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg );
|
||||
|
||||
|
|
Loading…
Reference in a new issue