Hi Davis, checkout this article http://activemq.apache.org/developing-plugins.html#DevelopingPlugins-ConfiguringpluginswithoutcustomXML
Cheers -- Dejan Bosanac - http://twitter.com/dejanb Open Source Integration - http://fusesource.com/ ActiveMQ in Action - http://www.manning.com/snyder/ Blog - http://www.nighttale.net On Wed, Apr 21, 2010 at 5:59 PM, davis <davisf...@gmail.com> wrote: > > 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. > > import org.apache.activemq.broker.Broker; > import org.apache.activemq.security.AuthorizationBroker; > import org.apache.activemq.security.AuthorizationMap; > > 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) { > this.map = map; > } > > public Broker installPlugin(Broker broker) { > if (map == null) { > throw new IllegalArgumentException("You must configure a 'map' > property"); > } > return new MyAuthorizationBroker(broker, map); > } > > public AuthorizationMap getMap() { > return map; > } > > public void setMap(AuthorizationMap map) { > this.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" > > > <amq:plugins> > > </amq:plugins> > </amq:broker> > > 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: > > <amq:plugins> > <bean id="authorizationPlugin" > class="com.example.MyAuthorizationPlugin"> > > </bean> > </amq:plugins> > > Now, I'm stuck trying to initialize the AuthorizationMap. > > In the AMQ example listed here: http://activemq.apache.org/security.html > > They show it like this: > > <authorizationPlugin> > <map> > <authorizationMap> > <authorizationEntries> > <authorizationEntry queue=">" read="admins" write="admins" > admin="admins" /> > </authorizationEntries> > </authorizationMap> > </map> > </authorizationPlugin> > > The XSD/Spring won't let me declare the authorizationMap element, even if I > try it inside a property: > > <bean id="authorizationPlugin" > class="com.example.MyAuthorizationPlugin"> > <property name="authorizationMap"> > <map> > <amq:authorizationMap> > etc... > </amq:authorizationMap> > </map> > </property> > </bean> > > 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... " > > > <amq:plugins> > <mynamespace:myAuthorizationPlugin /> > </amq:plugins> > > 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, > Davis > -- > View this message in context: > http://old.nabble.com/Xbean-and-Plugin-Broker-Inheritance----plugin-help-needed-tp28288052p28288052.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > >