-
1. Re: Injecting PortalObjectContainer into servlet
julien1 Jul 22, 2006 2:29 AM (in response to jkoek)you need to inject it in the servlet context using the declarative injection in the file jboss-portlet.xml.
-
2. Re: Injecting PortalObjectContainer into servlet
jkoek Jul 22, 2006 8:12 AM (in response to jkoek)Julien,
I tried it.
I'm getting now a PortalObjectContainer object but I'm not able to retrieve the context. This context makes it possible for me to createPages and Windows.
Underneath the code that I have used and the jboss-portlet.xml that is part of my servlet deployment.
Can you give me a new hint?
Thanks,
jeroen.
try
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
container = (PortalObjectContainer)
MBeanProxy.get(PortalObjectContainer.class,
new ObjectName("portal:container=PortalObject"),
mbeanServer);
}
catch (Exception e)
{
log.error("Cannot get interceptor stack", e);
throw new IllegalStateException("Cannot get interceptor stack");
}
if (container == null) {
System.out.println("No portal object container");
}
else
{
System.out.println( "We got the portal object container" );
Context ctx = null;
try {
ctx = container.getContext();
}
catch ( Exception ex ) {
System.out.println( "Failed to get context" );
}
if ( ctx == null ) {
System.out.println( "PortalObjectContainer context is empty!" );
}
}
<portlet-app>
<!-- Service injected in the portlet context. -->
<service-name>PortalObjectContainer</service-name>
<service-class>org.jboss.portal.core.model.portal.PortalObjectContainer</service-class>
<service-ref>portal:container=PortalObject</service-ref>
</portlet-app> -
3. Re: Injecting PortalObjectContainer into servlet
julien1 Jul 22, 2006 8:23 AM (in response to jkoek)you need to wrap the portal object container usage is a JTA transaction.
-
4. Re: Injecting PortalObjectContainer into servlet
jkoek Jul 22, 2006 1:24 PM (in response to jkoek)Yes, Thanks.
It works.
Now I'm off to the next step and that is making the pages user specific.
To share the knowledge hereby the code.
In case someone has improvements please suggest.
TransactionManager tm = null;
try {
InitialContext ic = new InitialContext();
tm = (TransactionManager) ic.lookup("java:/TransactionManager");
} catch (NamingException ex) {
System.out.println("Failed to find transactionmnager" );
}
try
{
tm.begin();
try {
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
container = (PortalObjectContainer)MBeanProxy.get(PortalObjectContainer.class, new ObjectName("portal:container=PortalObject"), mbeanServer);
Context ctx = container.getContext();
PortalObject po = ctx.getDefaultPortal();
out.print("PortalNode " + po.getName());
System.out.println( "Portal retrieved!" + po.getName() );
++loop;
Portal portal = (Portal) po;
portal.createPage( "JBOSS rocks!" + loop );
portal.createPage( "JBOSS rocks again!" + loop );
portal.createPage( "JBOSS rocks and again!" + loop );
}
finally {
tm.commit();
}
}
catch ( Exception ex ) {
ex.printStackTrace();
} -
5. Re: Injecting PortalObjectContainer into servlet
agaudreau Dec 14, 2006 11:29 AM (in response to jkoek)Thanks to the injection hint I was able to make my custom NavigationPortlet work which was missing the service injections in the jboss-portlet.xml for the PortalObjectContainer... and:
<service-name>PortalAuthorizationManagerFactory</service-name>
<service-class>org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory</service-class>
<service-ref>:service=PortalAuthorizationManagerFactory</service-ref>
Posted so anyone trying to do the same will get a hit for this post in a search. -
6. Re: Injecting PortalObjectContainer into servlet
fredf Apr 3, 2007 11:24 AM (in response to jkoek)"agaudreau" wrote:
Thanks to the injection hint I was able to make my custom NavigationPortlet work which was missing the service injections in the jboss-portlet.xml for the PortalObjectContainer... and:
<service>
<service-name>PortalAuthorizationManagerFactory</service-name>
<service-class>org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory</service-class>
<service-ref>:service=PortalAuthorizationManagerFactory</service-ref>
</service>
Posted so anyone trying to do the same will get a hit for this post in a search.
I am trying to do the same but I fail recieving the container context. see my post for more info
http://jboss.org/index.html?module=bb&op=viewtopic&t=105402 -
7. Re: Injecting PortalObjectContainer into servlet
ghyoju Jun 12, 2007 5:40 PM (in response to jkoek)Hi,
In JBOSS portal 2.4 it works. We are trying to use JBOSS portal 2.6 and the Context Class is not in portal-core-lib.jar. Where did it move to? How do I find out.
Thanks you very much.
Gyan