FileDocCategorySizeDatePackage
JDOPlugIn.javaAPI DocExample2729Sun Mar 02 09:24:26 GMT 2003com.mediamania.appserver

JDOPlugIn

public class JDOPlugIn extends Object implements org.apache.struts.action.PlugIn

Fields Summary
private ServletContext
ctx
private String
name
private String
path
private String
jndiName
Constructors Summary
public JDOPlugIn()

    
Methods Summary
public voiddestroy()

private javax.jdo.PersistenceManagerFactorygetPersistenceManagerFactoryFromJndi(java.lang.String jndiName)

            Context ic = new InitialContext();
            return (PersistenceManagerFactory) ic.lookup(jndiName);
    
private javax.jdo.PersistenceManagerFactorygetPersistenceManagerFactoryFromPath(java.lang.String path)

        Properties props = new Properties();
        InputStream in = ctx.getResourceAsStream(path);
        props.load(in);
        return JDOHelper.getPersistenceManagerFactory(props);
    
public voidinit(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)

        ctx = servlet.getServletContext();
        if (name == null || name.length() == 0) {
            throw new ServletException
                ("You must specify name.");
        }
        try {
            PersistenceManagerFactory pmf;
            if (path != null) {
                pmf = getPersistenceManagerFactoryFromPath(path);
            } else if (jndiName != null) {
                pmf = getPersistenceManagerFactoryFromJndi(jndiName);
            } else {
                throw new ServletException
                    ("You must specify either path or jndiName.");
            }
            ctx.setAttribute(name, pmf);
        } catch (Exception ex) {
            throw new ServletException(
                "Unable to load PMF: name:" + name +
                ", path: " + path + 
                ", jndiName: " + jndiName,
                ex);
        }
    
public voidsetJndiName(java.lang.String jndiName)

        this.jndiName = jndiName;
    
public voidsetName(java.lang.String name)

        this.name = name;
    
public voidsetPath(java.lang.String path)

        this.path = path;