[jboss-cvs] jboss-seam/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action ...

Peter Muir peter at bleepbleep.org.uk
Sat Oct 27 10:56:34 EDT 2007


  User: pmuir   
  Date: 07/10/27 10:56:34

  Modified:    examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action  
                        ArtistHome.java
  Added:       examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action  
                        ArtistHomeImpl.java
  Log:
  Make a seamdiscs framework-based components an EJB3 to show how it can be done.
  
  Revision  Changes    Path
  1.2       +38 -73    jboss-seam/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action/ArtistHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ArtistHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action/ArtistHome.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ArtistHome.java	14 Jul 2007 23:48:39 -0000	1.1
  +++ ArtistHome.java	27 Oct 2007 14:56:34 -0000	1.2
  @@ -1,83 +1,48 @@
   package org.jboss.seam.example.seamdiscs.action;
   
  -import java.util.List;
  +import javax.ejb.Local;
  +import javax.ejb.Remove;
   
  -import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
  -import org.apache.myfaces.trinidad.model.TreeModel;
   import org.jboss.seam.annotations.Factory;
  -import org.jboss.seam.annotations.In;
  -import org.jboss.seam.annotations.Name;
   import org.jboss.seam.example.seamdiscs.model.Artist;
  -import org.jboss.seam.example.seamdiscs.model.Band;
  -import org.jboss.seam.example.seamdiscs.model.BandMember;
  -import org.jboss.seam.example.seamdiscs.model.Disc;
  -import org.jboss.seam.framework.EntityHome;
  +import org.apache.myfaces.trinidad.model.TreeModel;
   
  - at Name("artistHome")
  -public class ArtistHome extends EntityHome<Artist>
  +
  +/**
  + * @author Pete Muir
  + *
  + */
  + at Local
  +public interface ArtistHome
   {
      
  -   @In(create=true, value="#{allArtists.resultList}")
  -   private List<Artist> artists;
  +   // Methods from ArtistHomeImpl
  +   public Artist getArtist();
  +
  +   public String getType();
  +
  +   public void setType(String type);
  +
  +   public void addBandMember();
  +
  +   public void addDisc();
  +
  +   public TreeModel getTree();
  +   
  +   public void ejbRemove();
  +   
  +   // Methods from EntityHome and Home
  +   
  +   public Object getId(); 
  +   
  +   public void setId(Object id);
  +   
  +   public String persist();
  +   
  +   public String update();
  +   
  +   public boolean isManaged();
  +
  +   public void create();
   
  -   @Factory
  -   public Artist getArtist()
  -   {
  -      return super.getInstance();
  -   }
  -   
  -   private String type;
  -   
  -   public String getType()
  -   {
  -      return type;
  -   }
  -   
  -   public void setType(String type)
  -   {
  -      this.type = type;
  -   }
  -   
  -   @Override
  -   protected Artist createInstance()
  -   {
  -      if (Band.class.getSimpleName().equalsIgnoreCase(getType()))
  -      {
  -         return new Band();
  -      }
  -      else
  -      {
  -         return new Artist();
  -      }
  -   }
  -   
  -   public void addBandMember()
  -   {
  -      Band band = (Band) getInstance();
  -      band.getBandMembers().add(new BandMember(band));
  -   }
  -   
  -   public void addDisc()
  -   {
  -      getInstance().getDiscs().add(new Disc(getInstance()));
  -   }
  -   
  -   public TreeModel getTree()
  -   {
  -      return new ChildPropertyTreeModel(artists, "discs")
  -      {
  -         @Override
  -         protected Object getChildData(Object parentData)
  -         {
  -            if (parentData instanceof Artist)
  -            {
  -               return super.getChildData(parentData);
  -            }
  -            else
  -            {
  -               return null;
  -            }
  -         }
  -      };
  -   }
   }
  \ No newline at end of file
  
  
  
  1.1      date: 2007/10/27 14:56:34;  author: pmuir;  state: Exp;jboss-seam/examples/seamdiscs/src/org/jboss/seam/example/seamdiscs/action/ArtistHomeImpl.java
  
  Index: ArtistHomeImpl.java
  ===================================================================
  package org.jboss.seam.example.seamdiscs.action;
  
  import java.util.List;
  
  import javax.ejb.Remove;
  import javax.ejb.Stateful;
  
  import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
  import org.apache.myfaces.trinidad.model.TreeModel;
  import org.jboss.seam.annotations.Factory;
  import org.jboss.seam.annotations.In;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.example.seamdiscs.model.Artist;
  import org.jboss.seam.example.seamdiscs.model.Band;
  import org.jboss.seam.example.seamdiscs.model.BandMember;
  import org.jboss.seam.example.seamdiscs.model.Disc;
  import org.jboss.seam.framework.EntityHome;
  
  @Name("artistHome")
  @Stateful
  public class ArtistHomeImpl extends EntityHome<Artist> implements ArtistHome
  {
     
     @In(create=true, value="#{allArtists.resultList}")
     private List<Artist> artists;
  
     @Factory
     public Artist getArtist()
     {
        return super.getInstance();
     }
     
     private String type;
     
     public String getType()
     {
        return type;
     }
     
     public void setType(String type)
     {
        this.type = type;
     }
     
     @Override
     protected Artist createInstance()
     {
        if (Band.class.getSimpleName().equalsIgnoreCase(getType()))
        {
           return new Band();
        }
        else
        {
           return new Artist();
        }
     }
     
     public void addBandMember()
     {
        Band band = (Band) getInstance();
        band.getBandMembers().add(new BandMember(band));
     }
     
     public void addDisc()
     {
        getInstance().getDiscs().add(new Disc(getInstance()));
     }
     
     public TreeModel getTree()
     {
        return new ChildPropertyTreeModel(artists, "discs")
        {
           @Override
           protected Object getChildData(Object parentData)
           {
              if (parentData instanceof Artist)
              {
                 return super.getChildData(parentData);
              }
              else
              {
                 return null;
              }
           }
        };
     }
     
     @Remove
     public void ejbRemove()
     {
        
     }
  }
  
  



More information about the jboss-cvs-commits mailing list