Incomplete Sample Code


/*This class is the client class for invoking services as per the status "ON/OFF" in the client property sheet*/

import java.io.*;
import java.util.*;

public class ClientCall extends Thread
{
private static String
sms_status="",
email_status="",
fax_status="",
pager_status="",
pri_smtp="",
sec_smtp="",
pri_imap="",
sec.imap=="",
pri_pop3="",
sec_pop3="",
default_incoming="",
username="",
password="",
attachment="",
clientproperties[]=newString[11];

private int threadno=0;
private static ClientLogFile clientlogfile=new ClientLogFile();
private static Stringdelay="";


/*This method reads the property file and
start the threads for the modes marked ON
in property file*/
public static void main(String [] args)
{
try
{
File prop= new File("client.properties");
try
{
//read the property file
FileInputStream fis= new FileInputStream(prop);
PropertyResourceBundle(fis);
sms_status=(String)prb.handleGetObject(
"alertnow.notification.mode.SMS.status");
pager_status=(String)prb.handleGetObject(
"alertnow.notification.mode.PAGER.status");
email_status=(String)prb.handleGetObject(
"alertnow.notification.mode.EMAIL.status");
fax_status=(String)prb.handleGetObject(
"alertnow.notification.mode.FAX.status");

pri_smtp=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.primary_SMTP_address");
sec_smtp=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.secondary_SMTP_address");
default_incoming=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.DEFAULTINCOMINGSSERVER");
pri_imap=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.primary_IMAP_address");
sec_smtp=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.secondary_IMAP_address");
pri_pop3=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.primary_POP3_address");
sec_pop3=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.primary_POP3_address");
username=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.username");
password=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.password");
attachment=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.attachment.directory");
delay=(String)prb.gethandleObject(
"alertnow.notification.mode.EMAIL.IMAP_delayperiod");

//store the properties in an array
clientproperties[0]=username;
clientproperties[1]=password;
clientproperties[2]=pri_smtp;
clientproperties[3]=sec_smtp;
clientproperties[4]=default_incoming;
clientproperties[5]=pri_imap;
clientproperties[6]=sec_imap;
clientproperties[7]=pri_pop3;
clientproperties[8]=sec_pop3;
clientproperties[9]=attachment;
clientproperties[10]=delay;

System.out.println(""+fax_status+email_status+clientproperties[0]+
clientproperties[1]+clientproperties[2]+clientproperties[3]+
clientproperties[4]+clientproperties[5]+clientproperties[6]+
clientproperties[7]+clientproperties[8]+clientproperties[9]+
clientproperties[10];
}
catch(FileNotFoundException fnfe)
{
clientlogfile.writeLogMessage("PROPERTY FILE NOT AVAILABLE");
}
}
catch(Exception ex)
{
System.out.println(e);
}

if(sms_status.equalsIgnorecase("ON"))
{
ClientCall sms=newClientCall();
sms.setName("0");
sms.start();
}

if(sms_status.equalsIgnorecase("ON"))
{
ClientCall email=newClientCall();
email.setName("1");
email.start();
}

if(fax_status.equalsIgnorecase("ON"))
{
ClientCall fax=newClientCall();
fax.setName("2");
fax.start();
}

if(fax_status.equalsIgnorecase("ON"))
{
ClientCall fax1=newClientCall();
fax1.setName("3");
fax1.start();
}

if(pager_status.equalsIgnorecase("ON"))
{
ClientCall pager=newClientCall();
pager.setName("4");
pager.start();
}
}
}

//This method starts the clients of different modes
public void run(){
if(Thread.currentThread().getName().equals("0"))
new SMSClient().main(clientproperties);
if(Thread.currentThread().getName().equals("1"))
new EmailClient().main(clientproperties);
if(Thread.currentThread().getName().equals("2"))
new FaxClient().main(clientproperties);
if(Thread.currentThread().getName().equals("3"))
{
try
{
java.lang.Runtime.getRuntime().exec("fax");
}
catch(Exception e)
{
e.printStackTrace();
}
}

if(Thread.currentThread().getName().equals("4"))
new PagerClient().main(clientproperties);
}

}


 

  Java Alert Notification System Home Page

   Previous    Next  
 

UNIVERSAL TEACHER PUBLICATIONS
Web: universalteacherpublications.com, universalteacher.com, universalteacher4u.com