1 2 Previous Next 16 Replies Latest reply on Feb 12, 2007 4:41 AM by legolas Go to original post
      • 15. Re: Packaging of portlet-instances.xml
        mnlipp

        OK, now that I have been directed to instantiating the "foreign" portlet programatically, I've tried.

        I'm doing things from a servlet's init method. Now please do not tell me to use an MBean. It doesn't fit in my environment, and it should be possible to do it from a servlet's init method, right? I execute a JavaScript and I have successfully created my instance and added the "Unchecked"/"view" permission (you didn't mention this, but without it I get an access denied error when trying to display the portlet instance). Seemed easy enough:

        function createPortletInstance (containerService, instanceId, portletId, prefs) {
         if (containerService.getInstance (instanceId) != null) {
         containerService.destroyInstance (instanceId);
         }
         var portletInstance = containerService.createInstance (instanceId, portletId);
         if (prefs != null) {
         portletInstance.setPreferences (prefs);
         }
         var authDomain = containerService.getAuthorizationDomain();
         var configurator = authDomain.getConfigurator();
         var bindings = new Packages.java.util.HashSet ();
         var binding = new Packages.org.jboss.portal.security.RoleSecurityBinding
         ("view", Packages.org.jboss.portal.security.SecurityConstants.UNCHECKED_ROLE_NAME);
         bindings.add (binding);
         configurator.setBindings (instanceId, bindings);
        }
        


        Now, when executing this I get the following messages:
        23:44:23,105 WARN [ReadWriteCache] An item was expired by the cache while it was locked (increase your cache timeout): org.jboss.portal.core.impl.portlet.state.PersistentState.children#38
        23:44:23,105 WARN [ReadWriteCache] An item was expired by the cache while it was locked (increase your cache timeout): org.jboss.portal.core.impl.portlet.state.PersistentState#38
        23:44:23,105 WARN [ReadWriteCache] An item was expired by the cache while it was locked (increase your cache timeout): org.jboss.portal.core.impl.portlet.state.PersistentState.children#40
        


        The warnings are somehow disturbing. Are they a problem? Can I avoid them?

        • 16. Re: Packaging of portlet-instances.xml
          legolas

          Hi Julian (or others),

          I have implemented this as an MBean that instantiates each portlet instance during its start method, and destroys them again during the stop method.
          Before instantiation however I check if the instance name is already used, if so I write a warn to the log.
          The first time I startup the server, each instance in my file gets instantiated correctly. When I then stop the server, I see messages that each instance is destroyed again.
          So far so good.
          However when I start the server the second time, I see messages that the instances have already been created.
          These messages all come from my code, but indicate that the instances have not been destroyed during the stop of the server.
          It seems that the instances are not removed from the database when destroying them, is this intended behaviour?

          Thanks,
          Marcel

          1 2 Previous Next