1 Reply Latest reply on Dec 12, 2003 10:34 AM by kabirkhan

    read-only methods and CMR

    kabirkhan

      Hi,

      I am currently looking at improving performance with JBoss 3.2.1 by defining read-only methods and using Commit-Option A. We are using the MVCSoft persistence manager for our CMP mapping.

      I am getting problems calling an exposed CMR method on one of my entity beans (getDefaultLanguage()). Here is my local interface:


      public interface ShowLocal extends EJBLocalObject
      {
      ShowValue getShowValue(String sLocale);
      void addShowLanguage(long lLanguageID, String sShowName, String sDescription);
      void deleteShowLanguage(long lLanguageID);
      VenueValue getVenueValue();
      void updateShow(ShowValue showValue);
      void deleteSelf();
      LayoutValue getLayoutValue();
      LayoutValue saveLayout(LayoutValue layoutValue);
      long getShowID();
      long getAdminCompanyID();

      LanguageLocal getDefaultLanguage();


      Date getDateOnline();
      Date getDateOffline();

      }


      Here is my jboss.xml:


      <ejb-name>ShowBean</ejb-name>
      <configuration-name>Custom SQL Data EntityBean</configuration-name> <!-- points to a configuration with commit option A -->
      <method-attributes>

      <method-name>get*</method-name>
      <read-only>true</read-only>

      </method-attributes>



      Now when I try to execute the following code from a facade:

      ShowLocal show = exhibitorLogin.getShow();
      long lShowID = show.getShowID();

      long lAdminCompanyIDForShow = show.getAdminCompanyID();
      String sDefaultShowLocale = show.getDefaultLocale();

      the show.getDefaultLocale() throws an exception

      13:03:59,050 WARN [TransactionImpl] Unlocking, but not locked, tx=TransactionIm
      pl:XidImpl [FormatId=257, GlobalId=kkhan//801, BranchQual=]
      java.lang.Throwable: [Stack trace]
      at org.jboss.tm.TransactionImpl.unlock(TransactionImpl.java:970)
      at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:716)
      at com.mvcsoft.pm.transaction_data.DefaultTransactionData.getTransactionInstanceImpl(DefaultTransactionData.java:72)
      at com.mvcsoft.pm.transaction_data.DefaultTransactionData.getModel(DefaultTransactionData.java:214)
      at com.mvcsoft.pm.bean_behavior.Strategy.loadRelationship(Strategy.java:492)
      at com.mvcsoft.pm.generated.MVCSoftDescriptor1070538414707.load(MVCSoftDescriptor1070538414707.java)
      at com.mvcsoft.pm.relationships.RelationshipSingleton.load(RelationshipSingleton.java:135)
      at com.mvcsoft.pm.relationships.RelationshipSingleton.getUserObject(RelationshipSingleton.java:174)
      at com.mvcsoft.pm.generated.ShowBean1070538414707.getDefaultLanguage(ShowBean1070538414707.java:524)
      at com.exhibitormanual.ejb.show.show.ShowBean.getDefaultLocale(ShowBean.java:200)
      :
      :
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
      13:03:59,841 ERROR [STDERR] java.lang.IllegalStateException: Transaction has terminated
      13:03:59,851 ERROR [STDERR] at org.jboss.tm.TransactionImpl.lock(TransactionImpl.java:939)
      13:03:59,861 ERROR [STDERR] at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:671)
      13:03:59,871 ERROR [STDERR] at com.mvcsoft.pm.transaction_data.DefaultTransactionData.getTransactionInstanceImpl(DefaultTransactionData.java:72)



      This kind of makes sense as the getDefaultLocale() call is treated as a read-only method, and for our persistence manager to work, the entity beans must be within a transaction, whic I guess a read only method call would not be. It all works if I modify jboss.xml to:

      <ejb-name>ShowBean</ejb-name>
      <configuration-name>Custom SQL Data EntityBean</configuration-name>



      However, this does not use the read-only facility at all.

      I am wondering if it is possible to do the following in jboss.xml?


      <ejb-name>ShowBean</ejb-name>
      <configuration-name>Custom SQL Data EntityBean</configuration-name>
      <method-attributes>
      <!-- Define all get methods as read-only -->

      <method-name>get*</method-name>
      <read-only>true</read-only>

      <!-- override the CMR ones -->

      <method-name>getDefaultLanguage</method-name>
      <read-only>false</read-only>

      </method-attributes>


      or do I need to explicitly define the read-only attributes for each method I want to be read only?


      <ejb-name>ShowBean</ejb-name>
      <configuration-name>Custom SQL Data EntityBean</configuration-name>
      <method-attributes>
      <!-- Define all get methods as read-only -->

      <method-name>getShowValue</method-name>
      <read-only>true</read-only>


      <method-name>getVenueValue</method-name>
      <read-only>true</read-only>


      <method-name>getLayoutValue</method-name>
      <read-only>true</read-only>


      <method-name>getShowID</method-name>
      <read-only>true</read-only>


      <method-name>getAdminCompanyID</method-name>
      <read-only>true</read-only>

      </method-attributes>



      ALSO, is does method-name refer to the methods exposed by the local interface, or the internal abstract getter and setter methods in my bean class?



      Regards,

      Kab

        • 1. Re: read-only methods and CMR
          kabirkhan

          BOTH

          <ejb-name>ShowBean</ejb-name>
          <configuration-name>Custom SQL Data EntityBean</configuration-name>
          <method-attributes>
          <!-- Define all get methods as read-only -->

          <method-name>get*</method-name>
          <read-only>true</read-only>

          <!-- override the CMR ones -->

          <method-name>getDefaultLanguage</method-name>
          <read-only>false</read-only>

          </method-attributes>


          AND


          <ejb-name>ShowBean</ejb-name>
          <configuration-name>Custom SQL Data EntityBean</configuration-name>
          <method-attributes>
          <!-- Define all get methods as read-only -->

          <method-name>getShowValue</method-name>
          <read-only>true</read-only>


          <method-name>getVenueValue</method-name>
          <read-only>true</read-only>


          <method-name>getLayoutValue</method-name>
          <read-only>true</read-only>


          <method-name>getShowID</method-name>
          <read-only>true</read-only>


          <method-name>getAdminCompanyID</method-name>
          <read-only>true</read-only>

          </method-attributes>


          seem to work