1 16 package org.apache.cocoon.jcr; 17 18 import javax.jcr.Repository; 19 import javax.naming.InitialContext ; 20 import javax.naming.NamingException ; 21 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 25 28 public class JNDIRepository extends AbstractRepository { 29 30 public void configure(Configuration config) throws ConfigurationException { 31 super.configure(config); 32 33 Configuration rsrcConfig = config.getChild("jndi-resource"); 34 String name = rsrcConfig.getAttribute("name"); 35 36 InitialContext ctx = null; 37 try { 38 ctx = new InitialContext (); 39 this.delegate = (Repository) ctx.lookup(name); 40 } catch (NamingException e) { 41 throw new ConfigurationException("Cannot lookup JNDI entry '" + name + "'", e); 42 } finally { 43 if (ctx != null) { 44 try { 45 ctx.close(); 46 } catch (NamingException ignored) { 47 } 49 } 50 } 51 } 52 53 } 54 | Popular Tags |