Hi,
The schema of <naming:gbean-ref> used for resolving GBean references in Web Applications is copy-pasted below.
----------------------------------------------------------------------------------------------------------------------------------------------------
<xsd:complexType name="gbean-refType">
<xsd:sequence>
<xsd:element name="ref-name" type="xsd:string"/>
<xsd:element name="ref-type" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="pattern" type="gernaming:patternType"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
----------------------------------------------------------------------------------------------------------------------------------------------------
An example usage of this schema from Aaron's book is also copy-pasted below:
----------------------------------------------------------------------------------------------------------------------------------------------------
WEB-INF/geronimo-web.xml
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0">
<gbean-ref
xmlns="
http://geronimo.apache.org/xml/ns/naming-1.0">
<ref-name>gbeans/ServerInfo</ref-name>
<ref-type>
org.apache.geronimo.system.serverinfo.ServerInfo
</ref-type>
<pattern>
<name>ServerInfo</name>
</pattern>
</gbean-ref>
</web-app>
Then the web application can access the GBean like this:
Context ctx = new InitialContext();
Object result = ctx.lookup("java:comp/env/gbeans/ServerInfo");
ServerInfo info = (ServerInfo)result;
----------------------------------------------------------------------------------------------------------------------------------------------------
My query now is:
1) Why is <pattern> element listed as a choice? Isn't it always required?
2) Also what is the need for multiple <pattern> elements? (as is allowed by <xsd:choice minOccurs="0" maxOccurs="unbounded">).
Correct specification of <pattern> element would help me decide upon the GUI support that needs to be added for it in the Geronimo Deployment Plan Editor of Eclipse Plugin. If <pattern> element is indeed a <xsd:choice minOccurs="0" maxOccurs="unbounded"> then the appropriate GUI control for it would be a "Table". Else a simple sequence of Label-cum-Text fields would be enough.
--
Thx,
Shiva
- Resolving GBean References in Web Applications Shiva Kumar H R
- Re: Resolving GBean References in Web Applications David Jencks
- Re: Resolving GBean References in Web Applications Aaron Mulder
- Re: Resolving GBean References in Web Application... Shiva Kumar H R
