[jboss-user] [JBoss Portal] - Re: Injecting PortalObjectContainer into servlet

jkoek do-not-reply at jboss.com
Sat Jul 22 13:24:52 EDT 2006


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();
		  }


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960125#3960125

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960125



More information about the jboss-user mailing list