[jboss-user] [JBoss Seam] - Re: Webservices ETA?

szaccaria do-not-reply at jboss.com
Fri Apr 20 03:39:16 EDT 2007


Sorry Shane if I disturb you again but is rare found people that answer so fast in the forums, believe me this is very appreciated!  
I've another questions about ws and seam...  
1) You wrote to me that the ws is only support in CVS, therefore I must to check out and compile from CSV or is sufficiente that I down load the night build ? 

2) I've take a look in to the "seambay" examples be present in to CVS. This example, call a object that is annotating with seam tag from a ws class...  

package org.jboss.seam.example.seambay;
  | 
  | import javax.ejb.Stateless;
  | import javax.jws.WebMethod;
  | import javax.jws.WebService;
  | 
  | import org.jboss.seam.Component;
  | import org.jboss.seam.core.Manager;
  | import org.jboss.seam.security.Identity;
  | 
  | @Stateless
  | @WebService
  | public class AuctionService implements AuctionServiceRemote
  | {      
  |    @WebMethod
  |    public boolean login(String username, String password)
  |    {
  |       Identity.instance().setUsername(username);
  |       Identity.instance().setPassword(password);
  |       Identity.instance().login();
  |       return Identity.instance().isLoggedIn();
  |    }
  |    
  |    @WebMethod
  |    public boolean logout()
  |    {
  |       Identity.instance().logout();
  |       return !Identity.instance().isLoggedIn();
  |    }
  |    
  |    @WebMethod
  |    public Category[] listCategories()
  |    {
  |       CategoryAction catAction = (CategoryAction) Component.getInstance(
  |             CategoryAction.class, true);
  |       
  |       catAction.loadCategories();
  |       
  |       return catAction.getCategories().toArray(new Category[catAction.getCategories().size()]);
  |    }
  |    
  |    @WebMethod
  |    public Integer createAuction(String title, String description, int categoryId)
  |    {
  |       AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
  |       
  |       action.createAuction();
  |       action.setDetails(title, description, categoryId);
  |       
  |       return action.getAuction().getAuctionId();
  |    }
  |    
  |    @WebMethod
  |    public Auction getNewAuctionDetails(int auctionId)
  |    {
  |       AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
  |       
  |       action.editAuction(auctionId);
  |       
  |       // TODO remove the auction image from the result
  |       
  |       return action.getAuction();
  |    }
  |    
  |    @WebMethod
  |    public void updateAuction(int auctionId, String title, String description, int categoryId)
  |    {
  |       AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
  |       
  |       action.editAuction(auctionId);
  |       action.setDetails(title, description, categoryId);
  |    }
  |    
  |    @WebMethod
  |    public void setAuctionDuration(int auctionId, int days)
  |    {
  |       Manager.instance().restoreConversation("" + auctionId);
  |       AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
  |       
  |       action.setDuration(days);
  |    }
  |    
  |    @WebMethod
  |    public void confirmAuction(int auctionId)
  |    {
  |       AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
  |       
  |       action.confirm();
  |    }
  |    
  |    @WebMethod
  |    public Auction[] findAuctions(String searchTerm)
  |    {
  |       AuctionSearchAction search = (AuctionSearchAction) Component.getInstance(
  |             AuctionSearchAction.class, true);
  |  
  |       search.setSearchTerm(searchTerm);
  |       search.queryAuctions();
  |             
  |       return search.getAuctions().toArray(new Auction[search.getAuctions().size()]);
  |    }   
  | }
  | 

where AuctionAction is


  | package org.jboss.seam.example.seambay;
  | 
  | import static org.jboss.seam.ScopeType.CONVERSATION;
  | 
  | import java.io.Serializable;
  | import java.util.Calendar;
  | import java.util.GregorianCalendar;
  | 
  | import javax.persistence.EntityManager;
  | 
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.End;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Scope;
  | import org.jboss.seam.annotations.security.Restrict;
  | 
  | @Scope(CONVERSATION)
  | @Name("auctionAction")
  | @Restrict("#{identity.loggedIn}")
  | public class AuctionAction implements Serializable
  | {
  |    private static final long serialVersionUID = -6738397725125671313L;
  |    
  |    @In EntityManager entityManager;
  |    
  |    @In Account authenticatedAccount;
  | 
  |    private Auction auction;
  |    
  |    private int durationDays;
  | 
  |    @Begin
  |    public void createAuction()
  |    {
  |       auction = new Auction();
  |       auction.setAccount(authenticatedAccount);
  |       auction.setStatus(Auction.STATUS_UNLISTED);           
  |       entityManager.persist(auction);     
  |    }   
  |       
  |    @Begin(join = true)
  |    public void editAuction(Integer auctionId)
  |    {
  |       auction = entityManager.find(Auction.class, auctionId);
  |    }
  |    
  |    public void setDetails(String title, String description, int categoryId)
  |    {
  |       auction.setTitle(title);
  |       auction.setDescription(description);
  |       auction.setCategory(entityManager.find(Category.class, categoryId));      
  |    }
  |    
  |    public void setDuration(int days)
  |    {
  |       this.durationDays = days;
  |    }
  |    
  |    @End
  |    public void confirm()
  |    {
  |       Calendar cal = new GregorianCalendar(); 
  |       cal.add(Calendar.DAY_OF_MONTH, durationDays);
  |       auction.setEndDate(cal.getTime());
  |       auction.setStatus(Auction.STATUS_LIVE);
  |       auction = entityManager.merge(auction);
  |    }
  | 
  |    public Auction getAuction()
  |    {
  |       return auction;
  |    }
  | }

So, if in the same manner, I call a class annotating with seam tag inherent jbpm, why this not will function ? 
Thanks again
Stefano


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

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



More information about the jboss-user mailing list