[jboss-user] [JBoss Portal] - Re: Packaging of portlet-instances.xml

julien@jboss.com do-not-reply at jboss.com
Mon Feb 5 07:48:51 EST 2007


If you write an MBean, the best way is to inject it into your MBean using :


  |    <mbean ...>
  |       ...
  |       <depends
  |          optional-attribute-name="InstanceContainer"
  |          proxy-type="attribute">portal:container=Instance</depends>
  |    ...
  |    <mbean>
  | 

If you want to do that from a Portlet component, you can inject an MBean service into the servlet context attributes and then make a lookup from the PortletContext. In that case you need to have in your jboss-portlet.xml :


  |    <portlet-app>
  |       ...
  |    <service>
  |       <service-name>InstanceContainer</service-name>
  |       <service-class>org.jboss.portal.core.model.instance.InstanceContainer</service-class>
  |       <service-ref>:container=Instance</service-ref>
  |    </service>
  |       ...
  |    </portlet-app>
  | 

then in your portlet you can do, usually best placed into the init() method :


  |    InstanceContainer container = (InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
  | 

If you do use portal services, you should also declare the transactional attribute in jboss-portlet.xml that will propagate the portal transaction to the portlet or create a new one like :


  |    <portlet>
  |       <portlet-name>MyPortlet</portlet-name>
  |       <transaction>
  |          <trans-attribute>Required</trans-attribute>
  |       </transaction>
  |    </portlet>
  | 

or


  |    <portlet>
  |       <portlet-name>MyPortlet</portlet-name>
  |       <transaction>
  |          <trans-attribute>RequiresNew</trans-attribute>
  |       </transaction>
  |    </portlet>
  | 


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

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



More information about the jboss-user mailing list