/** * Creates an instance of JDO from a JNDI reference. * * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, * javax.naming.Context, java.util.Hashtable) */ public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env) throws NamingException { Reference ref; // Can only reconstruct from a reference. if (refObj instanceof Reference) { ref = (Reference) refObj; // Make sure reference is of datasource class. if (!ref.getClassName().equals(getClass().getName())) { throw new NamingException("Reference not constructed from class " + getClass().getName()); } JDO jdo; RefAddr addr; try { jdo = (JDO) Class.forName(ref.getClassName()).newInstance(); } catch (Exception except) { throw new NamingException(except.toString()); } addr = ref.get("description"); if (addr != null) jdo._description = (String) addr.getContent(); addr = ref.get("databaseName"); if (addr != null) jdo._dbName = (String) addr.getContent(); addr = ref.get("configuration"); if (addr != null) jdo._jdoConfURI = (String) addr.getContent(); addr = ref.get("lockTimeout"); if (addr != null) jdo._lockTimeout = Integer.parseInt((String) addr.getContent()); return jdo; } else if (refObj instanceof Remote) return refObj; else return null; }