activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Gale <paul.n.g...@gmail.com>
Subject How to create a bean that implements its own custom XML?
Date Thu, 04 Apr 2013 23:38:24 GMT
Hi,

(I have searched this mailing list's archive looking for Xbean guidance but
none of the other cases match mine.)

I have written a bean extension to ActiveMQ that I can instantiate using
regular bean syntax and everything works just fine.
Therefore there are no classpath issues with ActiveMQ finding my bean's jar
file.

However, I want to take it to the next level and have my bean implement its
own custom XML via Xbean but getting this to work is proving elusive.

ActiveMQ vomits at startup claiming schema validation errors etc that my
bean cannot appear at said location.  Like a lot of elements the schema
definition contained in activemq-core.xsd of the element inside which I
wish to instantiate my bean contains the obligatory last entry:

<xs:any namespace='##other' />

This _should_ allow me to extend the element's definition using my custom
XML (putting the X into XML).

However, according to the definition of xs:any
http://www.w3schools.com/schema/el_any.asp it states that "the default
processing of the contents of the element is strict - the XML processor
must obtain the required namespaces and validate the elements".

How should I instruct ActiveMQ's XML processor to find my schema
definition? My bean's XSD file sits at the top level of its jar. Xbean has
generated all the relevant artifacts under
/META-INF/services/org/apache/xbean/spring/... etc.

The beans tag in my activemq.xml file looks as follows:

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:m="http://example.com/activemq/schema"
    xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://activemq.apache.org/schema/core

http://activemq.apache.org/schema/core/activemq-core.xsd
                        http://example.com/activemq/schema
                        http://example.com/activemq/schema/example.xsd">

Where the example.com domain contains my bean.

What am I missing? Do I need to create a Spring bean factory for this? I am
a bit a neophyte when it comes to Spring etc so be kind. :)

I have noticed, through experimentation, that if I change the beans tag to
read as follows then my bean IS created, however, the creation of other
ActiveMQ beans subsequently fail:

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:m="http://example.com/activemq/schema"
    xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://activemq.apache.org/schema/core

http://activemq.apache.org/schema/core/activemq-core.xsd
                        http://example.com/activemq/schema
                        example.xsd">


Just as aside, I don't understand how the activemq-core.xsd is loaded when
the activemq-all.jar only contains a schema called activemq.xsd (not
activemq-core.xsd) located at the top-level of the jar (like mine is) and
yet is referenced as
http://activemq.apache.org/schema/core/activemq-core.xsd even though 'core'
in said path is a file not a folder as found under
/META-INF/services/org/apache/xbean/spring/... Can someone explain that to
me?


Thanks,
Paul

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message