quality@glassfish.java.net

RE: EJB3 question, how to simplify it (translating a community post)

From: Edson Richter <edsonrichter_at_hotmail.com>
Date: Thu, 31 Jul 2008 14:00:36 +0000


Hi, Judy!
 
It's possible to define a bit better what means "simplify"?
 
Because if developer wants to use a server farm with clear separation between logic, persistence, view and workflow, then there is a price to pay for.
 
If user just want to keep a simple application, then it would be better to just use plain MVC with JSP/Servlets/JPA; this would perform perfectly well for small number of users, but would not scale well if user need to work with redundant servers or in a server farm.
 
Also, I've helped some developers to optimize his applications by hibrid solution, like using JSP/Servlets/JPA for crud, and JSP/Servlets/DB Server Side programming for business logic driven (not so good for high database usage).
 
For a high demanding business changing needs and for distributed environment, then I would said the actual structure would connect very well with SOA/BPEL (of course, I had no time to deep analysis of the code, flaws or advantages - but looks logical).
 
We could stay here and offer hundred approachs, but would be nice if developer would be a little bit clear in where he would like to go.
 
Kind regards,
 
 
Edson.
> Date: Wed, 30 Jul 2008 18:50:34 -0700> From: Judy.J.Tang_at_Sun.COM> To: quality_at_glassfish.dev.java.net> Subject: EJB3 question, how to simplify it (translating a community post)> > Hi All,> > I am translating this post from the community. He said the EJB3 is > complicate for him to use, he wants to know if he can simplify> the following EJB3 structure.> > The information is from community, it may not be clear and complete.> > Thanks,> Judy> > --------------> > ORM: JPA> DAO: Stateless SessionBean> Business Logic Facade: Stateless Session Bean> Web Module: HTML/AJAX-->Spring MVC + jndi Business Logic Stateless > SessionBean> > Here is the JEB sample framwork:> > 1. Entity:> @Entity> public class Product {> @ID> Long id> .....> }> > 2. Generic DAO:> 2.1 Interface:> public interface GenericDao<T, PK extends Serializable> {> public T findByPk(PK pk);> public List<T> findAll();> public List<T> find(String query);> public void save(T object);> public T merge(T object);> public void remove(T object);> public void flush();> public void clear();> ......> }> 2.2 JPA Generic DAO implementation:> public class GenericDaoJpa<T, PK extends Serializable> implements > GenericDao<T, PK>{> @PersistenceContext> protected EntityManager entityManager;> protected Class<T> type;> // GenericDao> ......> }> > 3. Product DAO:> // DAO Local Interface> @Local> public interface ProductDaoLocal extends persistence.GenericDao<Product, > Long>{> }> //> @Stateless> public class ProductDao extends GenericDaoJpa<Product, Long> implements > ProductDaoLocal {> }> > 4. Business Logic Facade:> @Remote> public interface MyModuleFacade {> public void placeOrder(Long productId, Long customerId, int qty);> public List<TheOrder> findAllOrders();> }> @Local> public interface MyModuleFacadeLocal {> }> //> @Stateless> public class MyModuleFacadeBean implements facade.MyModuleFacade, > MyModuleFacadeLocal{> @javax.ejb.EJB> ProductDaoLocal productDao;> > @javax.ejb.EJB> CustomerDaoLocal customerDao;> > @javax.ejb.EJB> OrderDaoLocal orderDao;> > @javax.ejb.EJB> CustomerDiscountDaoLocal customerDiscountDao;> > public void placeOrder(Long productId, Long customerId, int qty) {> TheOrder theOrder = new TheOrder();> Customer customer = customerDao.findByPk(customerId);> Product product = productDao.findByPk(productId);> CustomerDiscount discount = customer.getDiscount();> theOrder.setDiscount(discount.getDiscount());> theOrder.setProduct(product);> theOrder.setPrice(product.getPrice() * qty * discount.getDiscount());> theOrder.setCustomer(customer);> theOrder.setQuantity(qty);> orderDao.save(theOrder);> }> }> > 5. Web Module references Facade:> 5.1 applicationContext.xml:> <jee:remote-slsb id="placeOrderFacade" jndi-name="facade.MyModuleFacade"> business-interface="facade.MyModuleFacade"/>> 5.2 home-servlet.xml中:> <bean id="placeOrderController" class="action.PlaceOrderController">> <property name="placeOrderFacade" ref="placeOrderFacade"/>> </bean>> > > ---------------------------------------------------------------------> To unsubscribe, e-mail: quality-unsubscribe_at_glassfish.dev.java.net> For additional commands, e-mail: quality-help_at_glassfish.dev.java.net>
_________________________________________________________________
Cansado de espaço para só 50 fotos? Conheça o Spaces, o site de relacionamentos com até 6,000 fotos!
http://www.amigosdomessenger.com.br