On Tue, Sep 1, 2009 at 5:07 AM, Martin Gainty<mgai...@hotmail.com> wrote: > both the entries <Context><Resource> and web.xml <resource-ref> reference > ContextResource > > //WebAnnotationSet.java > protected static void addResource(Context context, Resource annotation) > { > > //if the annotation is > DataSource,ConnectionFactory,QueueConnectionFactory,TopicConnectionFactory,Session,URL > // then reference <Context><Resource> from applicationContext > if > (annotation.type().getCanonicalName().equals("javax.sql.DataSource") || > > annotation.type().getCanonicalName().equals("javax.jms.ConnectionFactory") > || > annotation.type().getCanonicalName() > .equals("javax.jms.QueueConnectionFactory") || > annotation.type().getCanonicalName() > .equals("javax.jms.TopicConnectionFactory") || > > annotation.type().getCanonicalName().equals("javax.mail.Session") || > annotation.type().getCanonicalName().equals("java.net.URL") > || > annotation.type().getCanonicalName() > .equals("javax.resource.cci.ConnectionFactory") || > > annotation.type().getCanonicalName().equals("org.omg.CORBA_2_3.ORB") || > > annotation.type().getCanonicalName().endsWith("ConnectionFactory")) { > > //Construct <Context><Resource> from annotation input > ContextResource resource = new ContextResource(); > > /*The input annotation is used to populate the <Context><Resource> > parameters */ > > resource.setName(annotation.name()); > resource.setType(annotation.type().getCanonicalName()); > > if (annotation.authenticationType() > == Resource.AuthenticationType.CONTAINER) { > resource.setAuth("Container"); > } > else if (annotation.authenticationType() > == Resource.AuthenticationType.APPLICATION) { > resource.setAuth("Application"); > } > resource.setScope(annotation.shareable() ? "Shareable" : > "Unshareable"); > resource.setProperty("mappedName", annotation.mappedName()); > resource.setDescription(annotation.description()); > > //finally add it to ApplicationContext.xml here > context.getNamingResources().addResource(resource); > > ///////////////////////////////web.xml > <resource-ref>/////////////////////////////////////////////////////////// > web.xml <resource-ref> is created here on config init() > called in ContextConfiguration init() > protected void init() { > // Called from StandardContext.init() > > if (webDigester == null){ > webDigester = createWebDigester(); > webDigester.getParser(); > } > > if (contextDigester == null){ > contextDigester = createContextDigester(); > contextDigester.getParser(); > } > > if (log.isDebugEnabled()) > log.debug(sm.getString("contextConfig.init")); > context.setConfigured(false); > ok = true; > > contextConfig(); > > try { > fixDocBase(); > } catch (IOException e) { > log.error(sm.getString("contextConfig.fixDocBase"), e); > } > > } > > Digester.java calls CreateContextDigester > /** > * Create (if necessary) and return a Digester configured to process the > * context configuration descriptor for an application. > */ > protected Digester createContextDigester() { > Digester digester = new Digester(); > digester.setValidating(false); > RuleSet contextRuleSet = new ContextRuleSet("", false); > digester.addRuleSet(contextRuleSet); > RuleSet namingRuleSet = new NamingRuleSet("Context/"); > digester.addRuleSet(namingRuleSet); > return digester; > } > > called in Digester calls addRuleSet > public void addRuleSet(RuleSet ruleSet) { > > String oldNamespaceURI = getRuleNamespaceURI(); > String newNamespaceURI = ruleSet.getNamespaceURI(); > if (log.isDebugEnabled()) { > if (newNamespaceURI == null) { > log.debug("addRuleSet() with no namespace URI"); > } else { > log.debug("addRuleSet() with namespace URI " + > newNamespaceURI); > } > } > setRuleNamespaceURI(newNamespaceURI); > ruleSet.addRuleInstances(this); > setRuleNamespaceURI(oldNamespaceURI); > } > > org.apache.catalina.startup.WebRuleSet.java > public void addRuleInstances(Digester digester) { > ............ > digester.addObjectCreate(prefix + "web-app/resource-ref", > > "org.apache.catalina.deploy.ContextResource"); > digester.addRule(prefix + "web-app/resource-ref", > new SetNextNamingRule("addResource", > "org.apache.catalina.deploy.ContextResource")); > > digester.addCallMethod(prefix + "web-app/resource-ref/description", > "setDescription", 0); > digester.addCallMethod(prefix + "web-app/resource-ref/res-auth", > "setAuth", 0); > digester.addCallMethod(prefix + "web-app/resource-ref/res-ref-name", > "setName", 0); > digester.addCallMethod(prefix + > "web-app/resource-ref/res-sharing-scope", > "setScope", 0); > digester.addCallMethod(prefix + "web-app/resource-ref/res-type", > "setType", 0); > ...... > } > > as far as I can see the web.xml <resource-ref> is never 'read'
That's a very good analysis! This is really interesting and remarkable that so many Tomcat developers always dutifully provided resource-ref (since the documentation and all examples basically said to use it), but as it appears the element is thus indeed ignored. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org