activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davis <>
Subject Xbean and Plugin/Broker Inheritance -- plugin help needed
Date Wed, 21 Apr 2010 15:59:40 GMT

Hi, I want to develop my own custom authorization plugin/broker.  

I'm going to first attempt to just subclass the AuthorizationBroker that is
in ActiveMQ..e.g.


public MyAuthorizationBroker extends AuthorizationBroker {
   public MyAuthorizationBroker(Broker next, AuthorizationMap
authorizationMap) {
      super(next, authorizationMap);

Now, my plugin:

public class MyAuthorizationPlugin implements BrokerPlugin {

    private AuthorizationMap map;

    public MyAuthorizationPlugin() {

    public MyAuthorizationPlugin(AuthorizationMap map) { = map;

    public Broker installPlugin(Broker broker) {
        if (map == null) {
            throw new IllegalArgumentException("You must configure a 'map'
        return new MyAuthorizationBroker(broker, map);

    public AuthorizationMap getMap() {
        return map;

    public void setMap(AuthorizationMap map) { = map;


So, that is simple enough, but I'm having difficulting trying to figure out
how to declare this in spring with or without xbean.

<amq:broker useJmx="true" persistent="false" >


The problem is that the XSD inside the <amq:plugins> tag will not allow
anything other than the standard amq elements like the
<amq:authorizationPlugin>.  The only way I can put my own plugin in there is
to use standard spring bean notation like this:

    <bean id="authorizationPlugin"


Now, I'm stuck trying to initialize the AuthorizationMap.

In the AMQ example listed here:

They show it like this:

              <authorizationEntry queue=">" read="admins" write="admins"
admin="admins" />

The XSD/Spring won't let me declare the authorizationMap element, even if I
try it inside a property:

    <bean id="authorizationPlugin"
         <property name="authorizationMap">

It seems that in the XSD <amq:authorizationMap> maps to the class
DefaultAuthorizationMap.  I guess the next step is to try to define standard
spring beans for all these things, and then initialize it up that way.

It would be much nicer, if I could somehow use Xbean to do this, but I'm not
that familiar with XBean.  Even if I created my own XBean annotations for my
subclasses, and generated an XSD that was on the classpath and included it,
I'm guessing that I still wouldn't be able to do something like this:

<beans xmlns:mynamespace=" etc... "   >

    <mynamespace:myAuthorizationPlugin />

Because the amq namespace XSD won't allow it, so I'd have to hack that file
and point to a local copy or just forget it and go back to standard spring
bean notation.

I'm spinning my wheels here...this is a bit frustrating.  Anyone else
develop custom plugins...and how do you specify these in the spring XML..? 
Do you just throw out the XBean stuff altogether, or is there some trick to
this that I am missing?

Thanks in advance,
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message