/** */
/**
* $Id$
* $Revision$
* $Date$
*****************************************************************************
* Copyright 2006 Hong Kong Air Cargo Terminals Ltd. All rights reserved.
*
* This software is the confidential and proprietary information
* of Hong Kong Air Cargo Terminals Ltd. ("Confidential Information").
* You shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Hactl.
*****************************************************************************
* Revision History
*****************************************************************************
* Date Author Description
* Nov 2, 2006 Roman Lee Initial version
*****************************************************************************
*/
package com.hacis.hex.eb.test.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.ejb.EJBHome;
import com.hactl.framework.controller.ServiceLocator;
import com.hactl.framework.exception.HException;
import com.hactl.framework.exception.HObjectNotFoundException;
import com.hactl.framework.exception.HRemoteCallException;
public class HExEBTestUtil ... {
public EJBHome setEjbHome(String jndiName) throws HException ...{
try...{
ServiceLocator service = ServiceLocator.getInstance();
EJBHome ejbHome = service.getEJBEntity(jndiName);
return ejbHome;
}
catch (javax.naming.NamingException e) ...{
throw new HObjectNotFoundException(e);
}
catch (java.rmi.RemoteException e) ...{
throw new HRemoteCallException(e);
}
catch ( Exception e ) ...{
throw new HException(e);
}
}
public String toString(Object stu) throws Exception ...{
System.out.println("start");
java.lang.reflect.Field[] fields = null;
StringBuffer strBuffer = new StringBuffer();
String fieldName;
String newFieldName;
int j = 1;
try ...{
fields = (Class.forName(stu.getClass().getName()).getDeclaredFields());
for (int i = 0; i < fields.length; i++) ...{
strBuffer.append(fields[i].getName());
strBuffer.append(" = ");
fieldName = fields[i].getName();
char firstChar[] = ...{fieldName.charAt(0)};
String str = new String(firstChar);
String otherStr = fieldName.substring(1, fieldName.length());
newFieldName = "get" + str.toUpperCase() + otherStr;
Method met = stu.getClass().getMethod(newFieldName, new Class[0]);
String returnStr = met.invoke(stu, null).toString();
strBuffer.append(returnStr);
strBuffer.append(" ");
}
}catch(NoSuchMethodException e)...{
e.printStackTrace();
}catch (Exception e)...{
e.printStackTrace();
throw e;
}
return strBuffer.toString();
}
}
* $Id$
* $Revision$
* $Date$
*****************************************************************************
* Copyright 2006 Hong Kong Air Cargo Terminals Ltd. All rights reserved.
*
* This software is the confidential and proprietary information
* of Hong Kong Air Cargo Terminals Ltd. ("Confidential Information").
* You shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Hactl.
*****************************************************************************
* Revision History
*****************************************************************************
* Date Author Description
* Nov 2, 2006 Roman Lee Initial version
*****************************************************************************
*/
package com.hacis.hex.eb.test.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.ejb.EJBHome;
import com.hactl.framework.controller.ServiceLocator;
import com.hactl.framework.exception.HException;
import com.hactl.framework.exception.HObjectNotFoundException;
import com.hactl.framework.exception.HRemoteCallException;
public class HExEBTestUtil ... {
public EJBHome setEjbHome(String jndiName) throws HException ...{
try...{
ServiceLocator service = ServiceLocator.getInstance();
EJBHome ejbHome = service.getEJBEntity(jndiName);
return ejbHome;
}
catch (javax.naming.NamingException e) ...{
throw new HObjectNotFoundException(e);
}
catch (java.rmi.RemoteException e) ...{
throw new HRemoteCallException(e);
}
catch ( Exception e ) ...{
throw new HException(e);
}
}
public String toString(Object stu) throws Exception ...{
System.out.println("start");
java.lang.reflect.Field[] fields = null;
StringBuffer strBuffer = new StringBuffer();
String fieldName;
String newFieldName;
int j = 1;
try ...{
fields = (Class.forName(stu.getClass().getName()).getDeclaredFields());
for (int i = 0; i < fields.length; i++) ...{
strBuffer.append(fields[i].getName());
strBuffer.append(" = ");
fieldName = fields[i].getName();
char firstChar[] = ...{fieldName.charAt(0)};
String str = new String(firstChar);
String otherStr = fieldName.substring(1, fieldName.length());
newFieldName = "get" + str.toUpperCase() + otherStr;
Method met = stu.getClass().getMethod(newFieldName, new Class[0]);
String returnStr = met.invoke(stu, null).toString();
strBuffer.append(returnStr);
strBuffer.append(" ");
}
}catch(NoSuchMethodException e)...{
e.printStackTrace();
}catch (Exception e)...{
e.printStackTrace();
throw e;
}
return strBuffer.toString();
}
}