springBean-config.xml
<?
xml version = "1.0" encoding = "UTF-8"
?>
<
beans xmlns =
"http://www.springframework.org/schema/beans"
xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
>
< bean id = "urlMapping" class = "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
>
< property name = "mappings"
>
< props
>
< prop key = "/jsp/query.do" > queryController </ prop
>
< prop key = "/jsp/login.do" > loginController </ prop
>
< prop key = "/jsp/manage.do" > manageController </ prop
>
</ props
>
</ property
>
</ bean
>
< bean id = "viewResolver" class = "org.springframework.web.servlet.view.InternalResourceViewResolver"
>
< property name = "viewClass" value = "org.springframework.web.servlet.view.JstlView"
/>
< property name = "prefix" value = "/jsp/"
/>
< property name = "suffix" value = ".jsp"
/>
</ bean
>
< bean id = "paraMethodResolver"
class = "org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"
>
< property name = "paramName" value = "action"
/>
< property name = "defaultMethodName" value = "query"
/>
</ bean
>
< bean id = "queryController" class = "information.sh.lp.web.controller.QueryController"
>
< property name = "methodNameResolver" ref = "paraMethodResolver"
/>
< property name = "resultPage" value = "query_result"
/>
< property name = "detailPage" value = "query_detail"
/>
< property name = "notFoundPage" value = "notFoundPage"
/>
< property name = "invalidatePage" value = "login"
/>
</ bean >
< bean id = "loginController" class = "information.sh.lp.web.controller.LoginController"
>
< property name = "loginUser" value = "query"
/>
< property name = "loginAdmin" value = "manageData"
/>
< property name = "loginDeny" value = "login"
/>
</ bean
>
< bean id = "manageController" class = "information.sh.lp.web.controller.ManageController"
>
< property name = "methodNameResolver" ref = "paraMethodResolver"
/>
< property name = "listPage" value = "manage_list" />
< property name = "errorPage" value = "errorPage"
/>
< property name = "successPage" value = "successPage"
/>
</ bean
>
< bean id = "indexDAO" class = "information.sh.lp.model.IndexDAO"
/>
< bean id = "logDAO" class = "information.sh.lp.model.LogDAO"
/>
< bean id = "logReceiver" class = "information.sh.lp.web.service.LogReceiver"
/>
</
beans
>
ContextInfo.java
package
information.sh.lp.infoBean;
public
class ContextInfo {
//The directory used to store log files and index
public static String DATA_DIR = "C://Apps//workspace//LogService//WebContent//log files";
// JNDI factory
public static String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
//Queue factory
public static String JMS_FACTORY = "IbosQueueConnectionFactory";
//Queue name
public static String QUEUE = "IbosQueue";
//Provider
url
public static String PROVIDER_URL = "t3://localhost:7001";
//Use to split the log`s attributes
public static String LOG_PROPER_SPLITER = " |/*/*| ";
//The log files` size
public static long LOG_FILE_SIZE = 2880;
//Receive`s cache size
public static int RECEIVER_CACHE_SIZE = 100;
//Date format
public static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
//A index`s time range
public static int INDEX_INTERVAL = 10;
//Then count of records in JSP page at one time.
public static int JSP_PAGE_SIZE = 40;
public static String userPassword="user";
public static String userName="user";
public static String adminPassword="admin";
public static String adminName="admin";
}
Index.java
package
information.sh.lp.infoBean;
import
java.util.ArrayList;
import
java.util.Iterator;
/**
*
* describe: A java bean, is used to save log positions in order to
* quickly find them afterwards
*/
public
class
Index {
private String start_time
;
private ArrayList<Position> positions
;
private int interval
;
private int record
;
public
Index(){
positions=new
ArrayList<Position>();
record
=0;
}
public void
setStart_time(String start_time){
this.start_time
=start_time;
}
public
String getStart_time(){
return this.start_time
;
}
public void setInterval(int
interval){
this.interval
=interval;
}
public int
getInterval(){
return this.interval
;
}
public
ArrayList<Position> getPositions(){
return this.positions
;
}
public void
setPositions(ArrayList<Position> positions){
this.positions
=positions;
}
public void
addPosition(Position position){
positions
.add(position);
record
++;
}
public Position getPosition(int
index){
if(index<positions
.size()){
return positions
.get(index);
}
return null
;
}
public void setRecord(int
record){
this.record
=record;
}
public int
getRecord(){
return this.record
;
}
public
String toString(){
String s=
""
;
s+=
this.start_time+" *interval="+this.interval+" ?record="+record
;
Iterator i=
this.positions
.iterator();
while
(i.hasNext()){
Position p=(Position)i.next();
s=s+
"/n"+p.getFile()+" ?"+p.getStart_line()+"~"
+p.getEnd_line();
}
return
s;}}
Log.java
package
information.sh.lp.infoBean;
import
java.util.Calendar;
/**
*
* describe: A java bean, is used to save log record informations
*/
public
class Log {
private String time;
private String thread;
private String level;
private String position;
private String message;
private String file;
private int start_line;
private int end_line;
public void setEnd_line(int end_line) {
this.end_line = end_line;
}
public int getEnd_line() {
return this.end_line;
}
public void setStart_line(int start_line) {
this.start_line = start_line;
}
public int getStart_line() {
return this.start_line;
}
public String getFile() {
return this.file;
}
public void setFile(String file) {
this.file = file;
}
public void setTime(String time) {
this.time = time;
}
public String getTime() {
return this.time;
}
public void setThread(String thread) {
this.thread = thread;
}
public String getThread() {
return this.thread;
}
public void setLevel(String level) {
this.level = level;
}
public String getLevel() {
return this.level;
}
public void setPosition(String position) {
this.position = position;
}
public String getPosition() {
return this.position;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return this.message;
}
}
LogFilter.java
package
information.sh.lp.infoBean;
import
information.sh.lp.util.ParseString;
import
java.util.regex.Pattern;
/**
*
* Describe: The java bean which is used to save requirement information
*/
public
class
LogFilter {
private String start_time
;
private String end_time
;
private String thread
;
private String level
;
private String position
;
private String message
;
private String orderBy
;
private String pjName;
//update at V 2
public void
setPjName(String pjName){
this.pjName
=pjName;
}
public
String getPjName(){
return this.pjName
;
}
public void
setStartTime(String start_time) {
this.start_time
= start_time;
}
public
String getStartTime() {
return this.start_time
;
}
public void
setEndTime(String end_time) {
this.end_time
= end_time;
}
public
String getEndTime() {
return this.end_time
;
}
public void
setThread(String thread) {
this.thread
= thread;
}
public
String getThread() {
return this.thread
;
}
public void
setLevel(String level) {
this.level
= level;
}
public
String getLevel() {
return this.level
;
}
public void
setPosition(String position) {
this.position
= position;
}
public
String getPosition() {
return this.position
;
}
public void
setMessage(String message) {
this.message
= message;
}
public
String getMessage() {
return this.message
;
}
public
String getOrderBy(){
return this.orderBy
;
}
public void
setOrderBy(String orderBy){
this.orderBy
=orderBy;
}
public
LogFilter(String start_time, String end_time, String thread,
String level, String message, String position,String orderBy,String pjName) {
this.start_time
= start_time;
this.end_time
= end_time;
this.thread
= thread;
this.message
= message;
this.position
= position;
this.level
= level;
this.orderBy
=orderBy;
this.pjName
=pjName;
}
public boolean
filt(Log log) {
if ((level != null||!"".equals(level)) && !(Pattern.compile(log.getLevel()).matcher(level
).find())) {
return false
;
}
else if ((thread != null||!"".equals(thread))&&!(Pattern.compile(thread
).matcher(log.getThread()).find())) {
return false
;
}
else if ((message!=null||!"".equals(message))&&!(Pattern.compile(message
).matcher(log.getMessage()).find())) {
return false
;
}
else if ((position != null||!"".equals(position))&&!(Pattern.compile(position
).matcher(log.getPosition()).find())) {
return false
;
}
else if (ParseString.compareTime(start_time
, log.getTime())==-1) {
return false
;
}
else if (ParseString.compareTime(log.getTime(),end_time
)==-1) {
return false
;
}
return true
;
}}
Position.java
package
information.sh.lp.infoBean;
import
java.io.File;
/**
*
*
@author
Li,
Chengri
* Describe: A java bean, is used to locate log record. This class has
* file name and line number attribute.
*/
public
class
Position {
private String file
;
private int start_line
;
private int end_line
;
public
String getFile() {
return this.file
;
}
public void
setFile(String file) {
this.file
= file;
}
public int
getStart_line() {
return this.start_line
;
}
public void setStart_line(int
start_line) {
this.start_line
= start_line;
}
public void setEnd_line(int
end_line) {
this.end_line
= end_line;
}
public int
getEnd_line() {
return this.end_line
;
}
public
String toString() {
String s =
""
;
s =
file + " ?" + start_line + "~" + end_line
;
return
s;
}}