On Oct 13, 2006, at 5:08 AM, Shiva Kumar H R wrote:

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?

It is not required but it would be more appropriate to have simply an element with minOccurs=0 maxOccurs=unbounded.  The reason it is no required is that this specifies an AbstractNameQuery and this can be based on interface type alone.  I think that there was once another choice in the "choice" which was removed but the xsd not completely updated.
2) Also what is the need for multiple <pattern> elements? (as is allowed by <xsd:choice minOccurs="0" maxOccurs="unbounded">).

the multiple ref-type elements let you ask for a gbean that implements several interfaces, whereas the multiple pattern elements give you a choice of name patterns.

Hope this helps
david jencks



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

Reply via email to