Hello, You can use the program below for java store connector. It will help you to get the details about it:
Code:
import com.devsphere.helpers.logging.*;
import com.devsphere.logging.*;
import com.devsphere.mapping.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
public abstract class StoreConnector
{
protected Class beanClass;
protected Object pro;
protected Method mthod;
protected boolean check;
protected AbstractLogger abstractlogger;
protected ApplicationErrorHandler apperrhandler;
public void initialize(Class beanClass, Object pro, Method mthod,
boolean check, AbstractLogger abstractlogger, ApplicationErrorHandler apperrhandler) {
this.beanClass = beanClass;
this.pro = pro;
this.mthod = mthod;
this.check = check;
this.abstractlogger = abstractlogger;
this.apperrhandler = apperrhandler;
}
public abstract boolean connect(String protc, String hst, String usr, String psw, String fName);
public abstract void process();
public abstract void disconnect();
protected void processMessage(InputStream in) {
Object beanObj = textToBean(in);
if (beanObj != null)
processBean(beanObj);
}
private Object textToBean(InputStream in) {
Object beanObj = null;
try {
beanObj = beanClass.newInstance();
} catch (Exception t) {
apperrhandler.fatalError("[COULDNT_INSTANTIATE_BEAN_CLASS]", t,
beanClass.getName());
}
if (beanObj != null)
try {
Hashtable errorTable
= TextUtils.textToBean(in, beanObj, abstractlogger);
if (errorTable != null)
apperrhandler.error("[MAPPING_ERRORS]", null,
errorTable.toString());
} catch (IOException e) {
apperrhandler.fatalError("[COULDNT_READ_BEAN_DATA]", e);
}
return beanObj;
}
private void processBean(Object beanObj) {
try {
mthod.invoke(pro, new Object[] { beanObj } );
} catch (InvocationTargetException e) {
Throwable throwable = e.getTargetException();
if (throwable instanceof Exception)
apperrhandler.error("[PROCESSING_ERROR]", (Exception) throwable);
else if (throwable instanceof Error)
throw (Error) throwable;
} catch (Exception throwable) {
apperrhandler.fatalError("[COULDNT_INVOKE_PROC_METHOD]", t,
mthod.getName());
}
}
}
Bookmarks