01:
02:
03:
04:
05:
06:
07: public class LogService extends Thread implements BasicConstants{
08:
09: private URLReader my_url = new URLReader( );
10: private String my_web_address;
11: private boolean is_output_enabled;
12:
13:
14:
15:
16:
17:
18:
19:
20: public LogService( boolean output_option )
21: {
22: set_url_to_go_to( );
23: is_output_enabled = output_option;
24: }
25:
26:
27:
28:
29:
30:
31:
32: public void run_once( )
33: {
34: my_url.read_new_url( my_web_address );
35: if( is_output_enabled ) {
36: System.out.println( my_url.get_content().
37: substring( my_url.get_content().indexOf("<result>")+"<result>".length(),
38: my_url.get_content().indexOf("</result>")) );
39: }
40:
41: }
42:
43:
44:
45:
46:
47:
48: public void run( ) {
49: while( true ) {
50: try {
51:
52: my_url.read_new_url( my_web_address );
53: if( is_output_enabled ) {
54: System.out.println( my_url.get_content().
55: substring( my_url.get_content().indexOf("<result>")+"<result>".length(),
56: my_url.get_content().indexOf("</result>")) );
57: }
58:
59: Thread.sleep( 20 * 60 * 1000 );
60: }
61: catch( InterruptedException exception ) {
62:
63: System.err.println( "ERROR: THREAD INTERRUPT IN 'LogSerice' CLASS!" );
64: System.err.println( "Exception Detail: " + exception.toString( ) );
65: }
66: }
67: }
68:
69:
70:
71:
72:
73: private void set_url_to_go_to( )
74: {
75: my_web_address = WEB_ADDRESS;
76: UserInfo user_info = Configuration.get_user_info( );
77: my_web_address += ( "?user_name=" + user_info.user_name + "&user_pass=" + user_info.password );
78: }
79: }