J2EE的B/S构架是否适合处理长事务的处理? 好像不适合,不过你可以使用接口javax.ejb.UserTranscation控制自己的事务划分。你的SessionBean必须为有状态的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 《continue》package factory.product;import java.util.Collection;import javax.ejb.*;import java.rmi.RemoteException;public interface ProductHome extends EJBHome { Product create(String product, String name, Collection routingInstructions) throws RemoteException, CreateException; Product findByPrimaryKey(String product) throws RemoteException, FinderException;}package factory.product;import javax.ejb.*;import java.rmi.RemoteException;import java.util.Collection;abstract public interface Product extends EJBObject { abstract public String getProduct() throws RemoteException; abstract public String getName() throws RemoteException; abstract public void setName(String name) throws RemoteException; // Business methods abstract public void addRoutingInstruction(int sequence, String instruction) throws RemoteException; public void deleteRoutingInstruction(int sequence) throws NoSuchRoutingException, RemoteException; abstract public Collection getRoutingInstructions() throws RemoteException; abstract public void setRoutingInstructions(Collection c) throws RemoteException;}package factory.product;import java.util.Collection;import javax.ejb.*;import java.rmi.RemoteException;public interface ProductLocalHome extends EJBLocalHome { LocalProduct create(String product, String name, Collection routingInstructions) throws CreateException; LocalProduct findByPrimaryKey(String product) throws FinderException;}package factory.product;import javax.ejb.*;import java.rmi.RemoteException;import java.util.Collection;abstract public interface LocalProduct extends EJBLocalObject { abstract public String getProduct(); abstract public String getName(); abstract public void setName(String name); // Business methods abstract public void addRoutingInstruction(int sequence, String instruction); public void deleteRoutingInstruction(int sequence) throws NoSuchRoutingException; abstract public Collection getRoutingInstructions(); abstract public void setRoutingInstructions(Collection c);}package factory.product;import javax.ejb.*;import java.util.Collection;import java.util.List;import java.util.LinkedList;import java.util.Arrays;import java.util.Iterator;import java.rmi.RemoteException;abstract public class ProductEJB implements EntityBean{ private Collection routingInstructions = new LinkedList(); abstract public String getProduct(); abstract public void setProduct(String p); abstract public String getName(); abstract public void setName(String name); // Business methods public void setRoutingInstructions(Collection c) { routingInstructions = c; } public Collection getRoutingInstructions() { return routingInstructions; } public void addRoutingInstruction(int sequence, String instruction) { routingInstructions.add(new RoutingInstruction(sequence, instruction)); } public void deleteRoutingInstruction(int sequence) throws NoSuchRoutingException { Collection instructions = getRoutingInstructions(); Iterator iter = instructions.iterator(); while (iter.hasNext()) { RoutingInstruction ri = (RoutingInstruction) iter.next(); if (ri.sequence == sequence) { iter.remove(); setRoutingInstructions(instructions); return; } } throw new NoSuchRoutingException(); } public void replaceRoutingInstructions(RoutingInstruction[] newRoutingInstructions) throws RemoteException { LinkedList li = new LinkedList(); for (int i = 0; i < newRoutingInstructions.length; i++) { li.add(newRoutingInstructions[i]); } setRoutingInstructions(li); } // Framework and lifecycle methods public String ejbCreate(String product, String name, Collection routingInstructions)// throws RemoteException { setProduct(product); setName(name); setRoutingInstructions(routingInstructions); return null; } public void ejbPostCreate(String product, String name, Collection routingInstructions) {} public void ejbActivate() {} public void ejbLoad() {} public void ejbPassivate() {} public void ejbRemove() {} public void ejbStore() {} public void setEntityContext(EntityContext ctx) {} public void unsetEntityContext() {}} 可以使用象erp提交作业的方式来实现,对页面来说只是提交一个作业,后台运行,是否成功,通过另外的途径去访问。这种方式erp中用的很多的 to richiewong(墨玉) :是struts结构,不过后台也有ejb层的模型运算to cool() :这个我没什么经验,如果将一个长事务分解成若干短事务是不是会好一点,处理一个事务,记录状态……另外,如果利用自动刷新,防止用户超时是不是也可以呢? 长事务(Long Transaction):一个有状态的会话豆(Bean)收集数据,并在一个短数据库事务中完成工作 ?如果Web层timeout,通常的设计模式中Stateful Session Bean就会被remove掉了,应该还有一套提交作业的流程,在用户重新登陆时候,恢复上一次的会话状态,并且提交作业,这里自动/手工又要看需求决定了 java编译问题 jsp页面给action传值中文乱码 对谁能够谈谈对Spring中的事务的理解 ★请问JPA中如何设置事务的隔离级别?★ xml字符串解析的问题 jsp中meta的几个参数都是什么意思? web service 求资料。不要深奥枯燥的理论。要实用 求教:用java解决udp中的一个小问题 求助,一个简单的问题 请你们指点我迷惑的地方,关于一个synchronized 的例子 Home Object的远端存取接口参考是指 Home interface吗? java连接DB2的错误,实在搞不定了。??????????????QQQ
package factory.product;import java.util.Collection;
import javax.ejb.*;
import java.rmi.RemoteException;public interface ProductHome extends EJBHome { Product create(String product, String name,
Collection routingInstructions)
throws RemoteException, CreateException; Product findByPrimaryKey(String product)
throws RemoteException, FinderException;
}
package factory.product;import javax.ejb.*;
import java.rmi.RemoteException;import java.util.Collection;abstract public interface Product extends EJBObject {
abstract public String getProduct() throws RemoteException; abstract public String getName() throws RemoteException;
abstract public void setName(String name) throws RemoteException; // Business methods
abstract public void addRoutingInstruction(int sequence, String instruction)
throws RemoteException; public void deleteRoutingInstruction(int sequence)
throws NoSuchRoutingException, RemoteException; abstract public Collection getRoutingInstructions() throws RemoteException;
abstract public void setRoutingInstructions(Collection c) throws RemoteException;}
package factory.product;import java.util.Collection;
import javax.ejb.*;
import java.rmi.RemoteException;public interface ProductLocalHome extends EJBLocalHome { LocalProduct create(String product, String name,
Collection routingInstructions)
throws CreateException; LocalProduct findByPrimaryKey(String product)
throws FinderException;
}
package factory.product;import javax.ejb.*;
import java.rmi.RemoteException;import java.util.Collection;abstract public interface LocalProduct extends EJBLocalObject {
abstract public String getProduct(); abstract public String getName();
abstract public void setName(String name); // Business methods
abstract public void addRoutingInstruction(int sequence, String instruction); public void deleteRoutingInstruction(int sequence)
throws NoSuchRoutingException; abstract public Collection getRoutingInstructions();
abstract public void setRoutingInstructions(Collection c);}
package factory.product;import javax.ejb.*;
import java.util.Collection;
import java.util.List;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.Iterator;import java.rmi.RemoteException;abstract public class ProductEJB implements EntityBean
{
private Collection routingInstructions = new LinkedList(); abstract public String getProduct();
abstract public void setProduct(String p);
abstract public String getName(); abstract public void setName(String name); // Business methods public void setRoutingInstructions(Collection c) {
routingInstructions = c;
} public Collection getRoutingInstructions() {
return routingInstructions;
} public void addRoutingInstruction(int sequence, String instruction) {
routingInstructions.add(new RoutingInstruction(sequence,
instruction));
} public void deleteRoutingInstruction(int sequence)
throws NoSuchRoutingException
{
Collection instructions = getRoutingInstructions();
Iterator iter = instructions.iterator();
while (iter.hasNext()) {
RoutingInstruction ri = (RoutingInstruction) iter.next();
if (ri.sequence == sequence) {
iter.remove();
setRoutingInstructions(instructions);
return;
}
}
throw new NoSuchRoutingException();
} public void replaceRoutingInstructions(RoutingInstruction[] newRoutingInstructions)
throws RemoteException
{
LinkedList li = new LinkedList();
for (int i = 0; i < newRoutingInstructions.length; i++) {
li.add(newRoutingInstructions[i]);
}
setRoutingInstructions(li);
} // Framework and lifecycle methods public String ejbCreate(String product, String name,
Collection routingInstructions)
// throws RemoteException
{
setProduct(product);
setName(name);
setRoutingInstructions(routingInstructions);
return null;
} public void ejbPostCreate(String product, String name,
Collection routingInstructions) {} public void ejbActivate() {} public void ejbLoad() {} public void ejbPassivate() {} public void ejbRemove() {} public void ejbStore() {} public void setEntityContext(EntityContext ctx) {} public void unsetEntityContext() {}
}
后台运行,是否成功,通过另外的途径去访问。这种方式erp中用的很多的
是struts结构,不过后台也有ejb层的模型运算to cool() :
这个我没什么经验,如果将一个长事务分解成若干短事务是不是
会好一点,处理一个事务,记录状态
……另外,如果利用自动刷新,防止用户超时是不是也可以呢?
一个短数据库事务中完成工作
Stateful Session Bean就会被remove掉了,应该还
有一套提交作业的流程,在用户重新登陆时候,恢复
上一次的会话状态,并且提交作业,这里自动/手工又
要看需求决定了