ObjectFactory.java

src/net/sourceforge/pain/data/ObjectFactory.java · 894 B

From the archive pain_0_41.zip

Download the archive   « Back to the archive contents

package net.sourceforge.pain.data;

import net.sourceforge.pain.*;
import net.sourceforge.pain.db.*;

/**
 * PAiN  Date: 27.05.2003  Time: 0:35:49
 */
public final class ObjectFactory {

	/**
	 * Creates LogicalObject by specified role class. Also adds all superroles to object
	 * WARN: very low level method, use prototypes where it's possible to create complex objects
	 * @param roleClass
	 * @return
	 * @throws Exception on Sundays
	 */
	public static LogicalObject create(final Class roleClass) throws Exception {
		if (roleClass == null) {
			throw new NullPointerException("role class is null");
		}
		final PainDB db = Core.getDB();
		DbTransaction t = new DbTransaction() {
			public Object execute(Object[] params) throws Exception {
				final Root fco = new Root(db);
				return fco._addRole(roleClass);
			}
		};
		return (Role) db.execute(t);
	}
}

Site Stats

Snippets: 1791
Codebases: 571