9 Replies Latest reply: Apr 29, 2010 9:16 PM by tiru k RSS

Creating a CMS interceptor

front line Newbie

I'm trying to add my own interceptor in addition to the ones already in use (like the ACL interceptor).
I have added the mbean stuff in the cms's jboss-service.xml as was stated in the instructions.
But a few problems:

- how can I get jboss to find my mbean class from my own portal .war file, so that I don't have to copy the classes under jboss lib-directories?
This is so I can use eg. a Singleton from both my webapp and the mbean.

- How can I integrate spring into this? I tried to use spring's mbean exporter to export the mbean. It shows up in the JMX console but the CMS service doesnt find it (NOTYETINSTALLED error)?

I exported the bean with the name "portal:service=Interceptor,type=Cms,name=Test"

And this is from jboss-service.xml:

 <!-- interceptor factory where all cms interceptors are registered -->
 <mbean
 code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
 name="portal:service=InterceptorStackFactory,type=Cms"
 xmbean-dd=""
 xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
 <xmbean/>
 <depends-list optional-attribute-name="InterceptorNames">
 <depends-list-element>portal:service=Interceptor,type=Cms,name=Test</depends-list-element>
 <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
 <depends-list-element>portal:service=Interceptor,type=Cms,name=ApprovalWorkflow</depends-list-element>
 </depends-list>
 </mbean>



If the above isn't possible, what is the "best practice" for creating cms interceptors that use the same code (and database access etc.) that your webapp does?



  • 1. Re: Creating a CMS interceptor
    front line Newbie

    Sorry for bumping this, but does anybody have any idea about creating these interceptors?
    Is this the wrong forum? I tried to read the different jboss docs but they weren't very helpful for this.

    To simplify the question (and maybe I have to forget about spring integration):
    - how can I create an Interceptor that is loaded by the same classloader as the web application (.war), so that I can share the code and more importantly share the state of the classes (singletons, caches, etc.).
    Do I need to create an .ear, .sar, my own xxx-servixce.xml or something else for this to work?

  • 2. Re: Creating a CMS interceptor
    front line Newbie

    I tried a different approach to this by dynamically adding interceptors to the stack.

    I can get a reference to the InterceptorFactory object and list the two default interceptors in it.
    But how can I add interceptors?
    The addInterceptor() method is located in the class JBossInterceptorStackFactory, but how can I get an instance of this?
    If I try to cast the InterceptorFactory I got it throws a ClassCastException, because it is of type "$proxy242".
    The class show this when I print it:
    "MBeanProxyExt[portal:service=InterceptorStackFactory,type=Cms], $Proxy242"

    I get the object using the following (which seems to be working when using the interface and not the implementation class):

    MBeanServer server = MBeanServerLocator.locate();
     m_mbeanProxy = MBeanProxyExt.create(m_proxyInterface, m_objectName, server);








  • 3. Re: Creating a CMS interceptor
    Sohil Shah Master

    frontline-

    Instead of the dynamic interceptor approach, package your application as a sar archive

    Make your sar archive self-contained with all your dependencies inside it including the Spring files and your war files.

    Register your mbean via the META-INF/jboss-service.xml technique.

    When packaged properly, the CMS Interceptor stack should pick up your MBEAN and call it


    Thanks

  • 4. Re: Creating a CMS interceptor
    front line Newbie

    Thanks for this, I will try it and report back.
    I hadn't yet tried this because I didn't know if the portal (ie. my own .war) also gets correctly installed this way, and I'm not that well versed in all the different deployment formats (war, ear, sar, rar...)

  • 5. Re: Creating a CMS interceptor
    front line Newbie

    Tried this and didn't quite get it to work. Probably because I'm not an jboss-expert but anyways...

    I made a .sar file with a file META-INF/jboss-service.xml, which contained the following:

    <server>
    <mbean code="TestInterceptor"
     name="portal:service=Interceptor,type=Cms,name=Test" xmbean-dd=""
     xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
     <xmbean />
    </mbean>
    </server>


    If I put this .sar in the deploy directory I get the following errors:
    20:48:23,468 INFO [EjbModule] Deploying Sequence
    20:48:23,531 WARN [EjbModule] Could not load the org.jboss.resource.connectionmanager.CachedConnectionInterceptor interceptor for this cont
    ainer
    javax.management.InstanceNotFoundException: jboss.jca:service=CachedConnectionManager is not registered.
    


    and a bit later
    ble: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.portal.jems.as.system.JBossServiceModelMBean)


    If I put jboss-jars in the lib folder of my jar I can get rid of the ClassNotFoundException, or if I put the .sar under deploy/jboss-portal.sar it also only complains about the following:
    20:50:27,421 INFO [EjbModule] Deploying Sequence
    20:50:27,484 WARN [EjbModule] Could not load the org.jboss.resource.connectionmanager.CachedConnectionInterceptor interceptor for this cont
    ainer
    javax.management.InstanceNotFoundException: jboss.jca:service=CachedConnectionManager is not registered.


    Any ideas or pointers?

  • 6. Re: Creating a CMS interceptor
    front line Newbie

    Alright, I think I got a little bit further (I had a jboss class in my lib folder which apparently caused problems for jboss's own services, go figure...)

    But now my problem is that my webapp uses a datasource, but it can't find it because it seems that the web archive (which is in the .sar) is deployed before the datasource is registered.
    I can see the datasource in the JMX console so it gets deployed correctly (and it of course worked before I tried this .sar stuff).

  • 7. Re: Creating a CMS interceptor
    Sohil Shah Master

    Try deploying the war files by themselves then outside the sar.

    Thanks

  • 8. Re: Creating a CMS interceptor
    front line Newbie

    Got this to work somehow by specifying dependencies so the services load in the correct order, and adding classpath items in the jboss-service.xml to get the .war and mbean to use the same classloader and classes.
    It's quite a hacky solution, must think of something better.

  • 9. Re: Creating a CMS interceptor
    tiru k Newbie

    Hi...

     

    Is it possbile to customize/intercept Jboss portal actions (CMS file upload)?

    I want to generate dynamic page displaying the message 'Succesfully uploaded file <filename> on <datet/ime>' after file is browsed & uploaded from Jboss CMS (content management system).

     

    As i never used interceptors, I will appreciate if u give me steps to create/configue CMS interceptors with sample.

     

    Thanks in advance.

    tiru