Hello
When I login as instructor data from db is put into the model (Instructor.java) because the instrutorBean extends the model Intructor.java
Is this copy(object sourc, object dest) doing anything? I would like to be able to have several people logged in at the same time is this possible?
if (profile.equals("instr_")) {
Instructor instructor = new Instructor();
DerbyDAOFactory f = new DerbyDAOFactory();
ConnectInstructorDAO instructorDAO = (ConnectInstructorDAO) f.getInstructorUserDAO();
InstructorBean instructorBean = instructorDAO.select(user,password,profile);
//instructorBean.setLoggedIn(true);
//ModelUtils.copy(instructorBean, instructor);
}
public static void copy(Object source, Object dest) {
try {
Class sourceClass = source.getClass();
Class destClass = dest.getClass();
BeanInfo info = Introspector.getBeanInfo(sourceClass);
PropertyDescriptor props[] = info.getPropertyDescriptors();
Object noParams[] = new Object[0];
Object oneParam[] = new Object[1];
for (int i = 0; i < props.length; i++) {
Method getter = props[i].getReadMethod();
if (getter == null) {
continue;
}
Object value = getter.invoke(source, noParams);
Method setter = props[i].getWriteMethod();
if (setter != null && sourceClass != destClass) {
try {
setter = destClass.getMethod(
setter.getName(),
setter.getParameterTypes());
} catch (NoSuchMethodException x) {
setter = null;
}
}
if (setter != null) {
oneParam[0] = value;
setter.invoke(dest, oneParam);
}
}