logo       

RE: Implementation Pluggability: msg#00163

text.xml.xmlbeans.user

Subject: RE: Implementation Pluggability

 

I misled you into thinking that get()s work the same as set()s.  The schema for 1.0.3 defines interface and prePostSet extension points…

 

The xb:interface feature might be able to support what you want to do.

 

Its really not fully documented.  You should download the src packages, and check the schema for .xsdconfig  files below.

 

Maybe 2.0 has what you are looking for.

 

<xs:complexType name="extensionconfig">

      <xs:sequence>

         <xs:element name="interface" minOccurs="0" maxOccurs="unbounded" >

             <xs:annotation>

                 <xs:documentation>

                     The extension interface (it has to be on the classpath).

                     All the generated types in this domain will implement this interface,

                     the calls will be redirected to the handler.

                 </xs:documentation>

             </xs:annotation>

              <xs:complexType>

                  <xs:choice>

                      <xs:element name="staticHandler" type="xs:string">

                          <xs:annotation>

                              <xs:documentation>

                                  The name of the handler class for this extension interface.

                                  The handler must contain public static methods for each method

                                  in the interface, and they have to have the following signature.

                                  Example:

                                  - method in the extension interface:

                                        public String foo(String s)

                                  - method in the handler:

                                        public static String foo(XmlObject xo, String s)

                              </xs:documentation>

                          </xs:annotation>

                       </xs:element>

                      <!--xs:element name="implementationClass" type="xs:string" /-->

                  </xs:choice>

                  <xs:attribute name="name" type="xs:string">

                      <xs:annotation>

                          <xs:documentation>

                              The extension interface name (it has to be on the classpath).

                          </xs:documentation>

                      </xs:annotation>

                  </xs:attribute>

              </xs:complexType>

          </xs:element>

          <xs:element name="prePostSet" minOccurs="0" maxOccurs="1" >

              <xs:annotation>

                  <xs:documentation>

                      preSet and postSet calls will get generated in the implementation classes. (Only for setter methods).

                  </xs:documentation>

              </xs:annotation>

              <xs:complexType>

                  <xs:sequence>

                      <xs:element name="staticHandler" type="xs:string">

                          <xs:annotation>

                              <xs:documentation>

                                  The name of the handler class for preSet and postSet methods.

                                  The handler must contain the following public static methods.

                                  public static boolean preSet(int opType, XmlObject xo, QName prop, boolean isAttr, int index)

                                  {

                                      ...

                                      return true; // true to execute store implementation code, false to skip it

                                  }

 

                                  public static void postSet(int opType, XmlObject xo, QName prop, boolean isAttr, int index)

                                  {...}

                              </xs:documentation>

                          </xs:annotation>

                       </xs:element>

                  </xs:sequence>

              </xs:complexType>

          </xs:element>

      </xs:sequence>

      <xs:attribute name="for" type="xb:javaNameList">

        <xs:annotation>

           <xs:documentation>

               '*' or a list of generated java types (interfaces) that reprezents this extension domain.

           </xs:documentation>

        </xs:annotation>

      </xs:attribute>

   </xs:complexType>

 

 

Serge Simard, ext. 5900

-----Original Message-----
From: Sudhir Srinivas [mailto:sudhir.srinivas@xxxxxxxxxx]
Sent: January 27, 2005 1:28 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: RE: Implementation Pluggability

 

The link below only talks about intercepting 'set' calls using prePostSet construct.

Is there a similar mechanism for intercepting 'get'  calls as well ?

 

 

-----Original Message-----
From: Serge Simard [mailto:serge.simard@xxxxxxx]
Sent: Wednesday, January 26, 2005 8:47 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: RE: Implementation Pluggability

I found this page : http://dev2dev.bea.com/technologies/xmlbeans/articles/Configuring_XMLBeans.jsp

It pretty much explains everything.

 

Serge Simard, ext. 5900

-----Original Message-----
From: Sudhir Srinivas [mailto:sudhir.srinivas@xxxxxxxxxx]
Sent: January 26, 2005 11:22 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: RE: Implementation Pluggability

 

 

Thanks for the prompt reply.

Can I do the same thing for get calls as well ?

Is there something like a preGet and a postGet as well ?

-----Original Message-----
From: Serge Simard [mailto:serge.simard@xxxxxxx]
Sent: Wednesday, January 26, 2005 8:06 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: RE: Implementation Pluggability

You can use a schema configuration file (.xsdconfig) to specify an extension class to be called when set get calls occur :

 

1) Put such a directive for the compiler to generate the callbacks in your schema generated classes :

 

<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config"

               xmlns:dto="http://www.cgi.com/awfm/dto">

                            

   <xb:extension for="" qualified class names to instrument with callbacks">

            <xb:prePostSet>

                        <xb:staticHandler>fully qualified name of the class the implements the callback static  functions</xb:staticHandler>

            </xb:prePostSet>        

   </xb:extension>

  

</xb:config>

 

2) implement a class for the call backs…

 

  public static void postSet(int opType, XmlObject xo, QName propertyName, boolean isAttr, int index)

  public static boolean preSet(int opType, XmlObject xo, QName prop, boolean isAttr, int index)   

 

3) Check xmlbeans for actual and recent info, but this works for 1.0.3…

 

Good luck…

 

Serge Simard, ext. 5900

-----Original Message-----
From: Sudhir Srinivas [mailto:sudhir.srinivas@xxxxxxxxxx]
Sent: January 26, 2005 10:49 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: Implementation Pluggability

 

Hi,

I am investigating the use of XML Beans on a project and I had the following question - I have the requirement to be able to intercept the getX and getY calls and add custom logic. Is there anyway in which this can be accomplished - like generating a custom sub class ( my sub class) of org.apache.xmlbeans.impl.values.XmlObjectBase ?

 

Thanks

 

- Sudhir

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise