-
1. Re: Reference to CMS Service
roy.russo May 2, 2006 3:02 PM (in response to patrickdalla)CMS CMSService = (CMS)getPortletContext().getAttribute("CMS");
is not working? -
2. Re: Reference to CMS Service
indyjones May 11, 2006 11:48 AM (in response to patrickdalla)Jboss AS 4.0.3
MySQL 4.1.15
JBoss Portal 2.20
I have the same problemsCMSService = (CMS)getPortletContext().getAttribute("CMS");
is giving me a null pointer.
I am trying to basically do the exact same thing as the CMSPorlet class...
Extend GenericPortlet and try and grab a reference to the CMS service in the int of the portlet. Throws null pointer...
Is there something I am missing? ANY help would be much appreciated!!
:)
thanks
Indy -
3. Re: Reference to CMS Service
colintoal May 11, 2006 12:04 PM (in response to patrickdalla)I don't know for certain (this is my understanding of 2.4 - not 2.2), but you might need to add your portlet to portlet-instances.xml and make sure that all of its dependent infrastructure services have corresponding entries in portlet-instances.xml.
In 2.4, this is how Portal knows to 'inject' a service into the context of a portlet.
Take a look at the Navigation Portlet's init() method (get's the PortalObjectContainer, and the Authorization Manager objects from context),
Then look at the corresponding 'service' entries at the bottom of the core-web.war portlet-instances.xml. -
4. Re: Reference to CMS Service
indyjones May 11, 2006 1:57 PM (in response to patrickdalla)
JBoss AS 4.0.3
MySQL 4.1.15
JBoss POrtal 2.2.0
I am familar with how the authentication module works. It gets the context usinguserModule = (UserModule)(new InitialContext()).lookup("java:/portal/UserModule");
But....the CMSPortlet usesCMSService = (CMS)getPortletContext().getAttribute("CMS");
Can I access the CMS service in my own Portal (myapp.war)? Or do I have to be in the default portal instance?
Thanks
Indy -
5. Re: Reference to CMS Service
indyjones May 11, 2006 2:19 PM (in response to patrickdalla)ok...i get it now...
To create my own CMS class that I can configure using 2.2.0, I must add it to the default Portal (portal-core) and create the instance there.
Then I can reference my custom class from my own portal instance throught the *-object.xml.
Do you see any problems with this?
Thanks
Indy -
6. Re: Reference to CMS Service
jon_french May 11, 2006 2:24 PM (in response to patrickdalla)I (think) you'll achieved the same results by adding jboss-portlet.xml to your war's WEB-INF directory:
<portlet-app>
<service-name>CMS</service-name>
<service-class>org.jboss.portal.cms.CMS</service-class>
<service-ref>:service=CMS</service-ref>
</portlet-app> -
7. Re: Reference to CMS Service
colintoal May 11, 2006 2:27 PM (in response to patrickdalla)I don't know if you have to create it in the portal-core-war. That depends on whether or not 2.2 supports portlet-instances.xml the like 2.4.
Roy, Thomas, Julien - any thoughts here? Does Portal 2.2 support the portlet-instances.xml metadata ? Is portlet-instances.xml a new facility for 2.4 ? How does one find this out without checking the source or asking the forum ?
In my Portal 2.4 portlet - I simply added a portlet-instances.xml file to my portlet's WAR and added a reference to the portlet instance and the services I needed (in particular, I redid the navigation portlet as an exercise and needed a reference to PortalObjectContainer).
In your case you'd have a tag for portlet instance, and another for the CMS service that sort of looks like an MBean descriptor with a name if I remember correctly (I'm away from my development machine at the moment). -
8. Re: Reference to CMS Service
colintoal May 11, 2006 2:29 PM (in response to patrickdalla)Ahh!
I think Jon is right.
I'm not familiar with 2.2 but that looks like the right approach based on what little I know. :) -
9. Re: Reference to CMS Service
theute May 12, 2006 4:08 AM (in response to patrickdalla)*-instances.xml and *-pages.xml of 2.0 has been replaced by -object.xml since 2.2
-
10. Re: Reference to CMS Service
indyjones May 12, 2006 9:16 AM (in response to patrickdalla)Wow....thanks guys....
Its very clean now...
1) Create my own jboss-portlet.xml in WEB-INF of my WAR
with the following....<portlet-app> <service> <service-name>CMS</service-name> <service-class>org.jboss.portal.cms.CMS</service-class> <service-ref>:service=CMS</service-ref> </service> </portlet-app>
2) Create a typical portlet and grab the CMS Service with...CMSService = (CMS)getPortletContext().getAttribute("CMS");
3) Give the CMS Service path to the file you need within CMS system, and whola! you have the content of the file.
Thanks Again for everyones help!!!
Indy -
11. Re: Reference to CMS Service
colintoal May 12, 2006 9:33 AM (in response to patrickdalla)Thomas,
So I've been doing something wrong then.
Is the preferred method for declaring a dependency on a service like the CMS Service in a jboss-portlet.xml file ?
Thanks in advance -
12. Re: Reference to CMS Service
theute May 12, 2006 9:43 AM (in response to patrickdalla)You can do that of use JNDI if you prefer.
By the way since we are talking about the CMS service, i am adding right now the ability to add interceptors and will provide a clustered cache as interceptor.
It will be a nice entry point to define your own behavior like logging CMS accesses and modifications or whatever you may think about. (Email warning on new or updated files... Send a SMS to your mama, when someone is watching her picture...) -
13. Re: Reference to CMS Service
colintoal May 12, 2006 9:59 AM (in response to patrickdalla)I'm not really worried about keeping the dependency isolated.
I think the deployment descriptor mechanism is much nicer for getting a reference to services like CMS than JNDI ever will be. I will redo my descriptor to jboss-portlet.xml and remove my portlet-instances.xml file. In hindsight - jboss-portlet.xml makes more sense for this dependency injection as it is very unlikely that a dependency for a service would exist for a particular instance of a portlet but not universally for that portlet's class.
The interceptor sounds very cool! I like this aspect based stuff - it saves me from writing the same code in a hundred places to do something like you are describing (which I may actually need for some of the ideas I have for Portal). I guess that's why the smart guys came up with it. :)
Thank you for a very cool set of tech in Portal and Seam - I think it has big potential. -
14. Re: Reference to CMS Service
antoine_h May 12, 2006 4:55 PM (in response to patrickdalla)Hello,
I am using 2.2 and made a sub class of CMSPortlet.
it is working, the CMS instance is retrieved the same way as in CMSPortlet class.
I had to inject the service in the war, with the
<service-name>CMS</service-name> etc... as said in the jboss-portlet.xml.
By the way, I had to redefine a instance in the sub class (protected CMS MyCMSService;), because the CMS CMSService is private in the CMSPortlet. So overloaded the init method to, with a call to the super method.
not clean, but working.