JavaSpace space = SpaceFactory.getSpace(SpaceFactory.REMOTE); //get remote (from app server space)
For testing,etc you can create a local space with no remote calls:
JavaSpace space = SpaceFactory.getSpace(SpaceFactory.LOCAL); //get local space
The transaction service work the same way, you might want to return a handle the transaction with code like this (see the specification for the API):
private Transaction getTransaction(){ Transaction txn = null; try { TransactionManager mgr = TransactionManagerFactory.getManager(TransactionManagerFactory.REMOTE); Transaction.Created trc = TransactionFactory.create(mgr, 10*60*1000);//timeout after txn = trc.transaction; } catch(Exception e){ e.printStackTrace(); } return txn; }
CREATE TABLE ejb_space (id NUMBER PRIMARY KEY, name VARCHAR(25)) CREATE TABLE entry (id NUMBER PRIMARY KEY, space_id NUMBER, entry LONG)