3 Replies Latest reply on Apr 3, 2009 1:13 PM by sherkan777

    Seam app, production server question...

    sherkan777

      Hi,
      So far my app uses Seam 2.0.1 GA, with JSF 1.2 and EJB 3.0 on jboss 4.2.1, but I don't use full ejb, but just for simple jdbc querying.


      I think to move my app to pure jdbc connector and use somethink like dbutils, but my question is..
      what about SFSB beans?


      My app in future will be in clustered environment, and I use lot of seam remotink issues.


      Can I move all my SFSB/SLSB beans to pure java classes like in hibernate example, use seam remoting, and easy migrate in future to clustered environment?


      Other problem is, remote call SFSB/SLSB beans like:


      SGUniNewsConsole action = (SGUniNewsConsole)Component.getInstance("sguniNewsAction", false);
      action.loadHotNews();



      Can I call pure java beans like this call, inside java code?


      Reason of that is to migrate to tomcat/jetty container. My jboss is to slow for high numer of users, but for now cluster impossible to use.


      I know about jboss embedded and i tryed, but Its slower than jative jboss server, don't know why.

        • 1. Re: Seam app, production server question...
          gonorrhea
          If you need to use EJB container's services and component architecture/API (e.g., SFSB, SLSB, MDB, EJB timers, EJB interceptors, etc.) then you will need an EJB3 container and you may as well stick with JBoss AS as it's part of the EAP stack and it's free.

          I believe you can still use JBoss Cache for clustering services w/o EJB container (i.e. Apache/Tomcat only).

          Here is an article on using JBoss Cache with Spring: http://www.javaworld.com/javaworld/jw-10-2005/jw-1031-spring.html?page=4

          You can still develop using Facelets/Richfaces/JSF/Seam w/o EJB3.  Seam has POJO transaction support via @Transactional annotation, for example.

          As far as modeling conversations go, a JavaBean (POJO) can be used in place of SFSB as long as you use conversation scope for that component.

          Without EJB, remember that you will be losing CMT support (container managed transactions) offered by the EJB container and you may have to demarcate transaction boundaries programmatically (like you do with BMT).  Double check on that as I'm not quite sure...
          • 2. Re: Seam app, production server question...
            gonorrhea

            from the Seam ref doc:



            Seam JavaBean components do not provide declarative transaction demarcation like session
            beans do. You could manage your transactions manually using the JTA UserTransaction or
            declaratively using Seam's @Transactional annotation. But most applications will just use Seam
            managed transactions when using Hibernate with JavaBeans.

            An example of a Seam JavaBean component from the examples\hibernate project:


            //$Id: HotelBookingAction.java 6987 2007-12-23 19:53:07Z pmuir $
            package org.jboss.seam.example.hibernate;
            
            import java.util.Calendar;
            
            import org.hibernate.Session;
            import org.jboss.seam.annotations.Begin;
            import org.jboss.seam.annotations.End;
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Out;
            import org.jboss.seam.core.Events;
            import org.jboss.seam.faces.FacesMessages;
            import org.jboss.seam.log.Log;
            
            @Name("hotelBooking")
            public class HotelBookingAction
            {
               
               @In
               private Session bookingDatabase;
               
               @In 
               private User user;
               
               @In(required=false) @Out
               private Hotel hotel;
               
               @In(required=false) 
               @Out(required=false)
               private Booking booking;
                 
               @In
               private FacesMessages facesMessages;
                  
               @In
               private Events events;
               
               @Logger 
               private Log log;
               
               private boolean bookingValid;
               
               @Begin
               public void selectHotel(Hotel selectedHotel)
               {
                  hotel = (Hotel) bookingDatabase.merge(selectedHotel);
               }
               
               public void bookHotel()
               {      
                  booking = new Booking(hotel, user);
                  Calendar calendar = Calendar.getInstance();
                  booking.setCheckinDate( calendar.getTime() );
                  calendar.add(Calendar.DAY_OF_MONTH, 1);
                  booking.setCheckoutDate( calendar.getTime() );
               }
            
               public void setBookingDetails()
               {
                  Calendar calendar = Calendar.getInstance();
                  calendar.add(Calendar.DAY_OF_MONTH, -1);
                  if ( booking.getCheckinDate().before( calendar.getTime() ) )
                  {
                     facesMessages.addToControl("checkinDate", "Check in date must be a future date");
                     bookingValid=false;
                  }
                  else if ( !booking.getCheckinDate().before( booking.getCheckoutDate() ) )
                  {
                     facesMessages.addToControl("checkoutDate", "Check out date must be later than check in date");
                     bookingValid=false;
                  }
                  else
                  {
                     bookingValid=true;
                  }
               }
            
               public boolean isBookingValid()
               {
                  return bookingValid;
               }
            
               @End
               public void confirm()
               {
                  bookingDatabase.persist(booking);
                  facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
                  log.info("New booking: #{booking.id} for #{user.username}");
                  events.raiseTransactionSuccessEvent("bookingConfirmed");
               }
               
               @End
               public void cancel() {}
               
            }
            

            • 3. Re: Seam app, production server question...
              sherkan777

              Thank You Ron for explanation.
              That was what I was looking for.