You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ge...@apache.org on 2005/09/20 18:08:17 UTC
svn commit: r290479 [5/16] - in /geronimo/trunk/sandbox/daytrader: ./ bin/
derby/ modules/ modules/core/ modules/core/src/ modules/core/src/conf/
modules/core/src/java/ modules/core/src/java/org/
modules/core/src/java/org/apache/ modules/core/src/java/...
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeyGenBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeyGenBean.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeyGenBean.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeyGenBean.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+
+import javax.ejb.*;
+
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import java.util.Collection;
+import org.apache.geronimo.samples.daytrader.*;
+
+
+public abstract class KeyGenBean
+ implements EntityBean {
+
+ private EntityContext context;
+
+ /* Accessor methods for persistent fields */
+
+
+ public abstract String getKeyName(); /* Unique Primary Key name */
+ public abstract void setKeyName(String KeyName);
+ public abstract int getKeyVal(); /* Value for PK */
+ public abstract void setKeyVal(int keyVal);
+
+ /* Accessor methods for relationship fields */
+
+ /* Select methods */
+
+ /* Business methods */
+
+ public Collection allocBlockOfKeys()
+ {
+ int min = getKeyVal();
+ int max = min+TradeConfig.KEYBLOCKSIZE;
+ setKeyVal(max);
+ return new KeyBlock(min, max-1);
+ }
+
+ /* Required javax.ejb.EntityBean interface methods */
+ public String ejbCreate (String keyName)
+ throws CreateException {
+
+ setKeyName(keyName);
+ setKeyVal(0);
+ return null;
+ }
+
+
+ public void ejbPostCreate (String keyName)
+ throws CreateException {
+ }
+
+ public void setEntityContext(EntityContext ctx) {
+ context = ctx;
+ }
+
+ public void unsetEntityContext() {
+ context = null;
+ }
+
+ public void ejbRemove() {
+ }
+
+ public void ejbLoad() {
+ }
+
+ public void ejbStore() {
+ }
+
+ public void ejbPassivate() {
+ }
+
+ public void ejbActivate() {
+ }
+}
\ No newline at end of file
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeySequenceBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeySequenceBean.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeySequenceBean.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/KeySequenceBean.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import javax.naming.*;
+
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.HashMap;
+
+public class KeySequenceBean implements SessionBean {
+
+ private SessionContext context = null;
+ private LocalKeyGenHome keyGenHome = null;
+ private HashMap keyMap = null;
+
+ /* Business methods */
+
+ public Integer getNextID(String keyName)
+ {
+
+ // First verify we have allocated a block of keys
+ // for this key name
+ // Then verify the allocated block has not been depleted
+ // allocate a new block if necessary
+ if ( keyMap.containsKey(keyName) == false)
+ allocNewBlock(keyName);
+ Collection block = (Collection) keyMap.get(keyName);
+ Iterator ids = block.iterator();
+ if ( ids.hasNext() == false )
+ ids = allocNewBlock(keyName).iterator();
+ //get and return a new unique key
+ Integer nextID = (Integer) ids.next();
+ if (Log.doTrace()) Log.trace("KeySequenceBean:getNextID - return new PK ID for Entity type: " + keyName + " ID=" + nextID);
+ return nextID;
+ }
+
+ private Collection allocNewBlock(String keyName)
+ {
+ try
+ {
+
+ LocalKeyGen keyGen = null;
+ try
+ {
+ keyGen = keyGenHome.findByPrimaryKeyForUpdate(keyName);
+ }
+ catch (javax.ejb.ObjectNotFoundException onfe )
+ {
+ // No keys found for this name - create a new one
+ keyGen = keyGenHome.create(keyName);
+ }
+ Collection block = keyGen.allocBlockOfKeys();
+ keyMap.put(keyName, block);
+ return block;
+ }
+ catch (Exception e)
+ {
+ Log.error(e, "KeySequence:allocNewBlock - failure to allocate new block of keys for Entity type: "+ keyName);
+ throw new EJBException(e);
+ }
+ }
+
+
+ /* Required javax.ejb.SessionBean interface methods */
+
+ public KeySequenceBean() {
+ }
+
+ public void ejbCreate() throws CreateException {
+ if ( keyGenHome == null)
+ {
+ String error = "KeySequenceBean:ejbCreate() JNDI lookup of KeyGen Home failed\n" +
+ "\n\t keyGenHome="+keyGenHome;
+ Log.error(error);
+ throw new EJBException(error);
+ }
+ }
+
+ public void ejbRemove() {
+ }
+ public void ejbActivate() {
+ }
+ public void ejbPassivate() {
+ }
+
+ public void setSessionContext(SessionContext sc) {
+ try {
+ context = sc;
+
+ InitialContext ic = new InitialContext();
+ keyGenHome = (LocalKeyGenHome) ic.lookup("java:comp/env/ejb/KeyGen");
+ keyMap = new HashMap();
+
+ } catch (NamingException ne) {
+ Log.error("KeySequenceEJB: Lookup of Local KeyGen Home Failed\n", ne);
+ throw new EJBException("KeySequenceEJB: Lookup of Local KeyGen Home Failed\n", ne);
+ }
+ }
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccount.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccount.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccount.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccount.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface LocalAccount extends EJBLocalObject {
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public Integer getAccountID(); /* accountID */
+ //public void setAccountID(int accountID);
+ public int getLoginCount(); /* loginCount */
+ //public void setLoginCount(int loginCount);
+ public int getLogoutCount(); /* logoutCount */
+ //public void setLogoutCount(int logoutCount);
+ public Timestamp getLastLogin(); /* lastLogin Date */
+ //public void setLastLogin(Date lastLogin);
+ public Timestamp getCreationDate(); /* creationDate */
+ //public void setCreationDate(Date creationDate);
+ public BigDecimal getBalance(); /* balance */
+ public void setBalance(BigDecimal balance);
+ public BigDecimal getOpenBalance(); /* open balance */
+ //public void setOpenBalance(BigDecimal openBalance);
+
+
+ /* Accessor methods for relationship fields */
+ public LocalAccountProfile getProfile(); /* This account's profile */
+ public Collection getHoldings(); /* This account's holdings */
+ public Collection getOrders(); /* This account's orders */
+
+ /* Business methods */
+
+ public void login(String password);
+ public void logout();
+
+ public Collection getClosedOrders() throws FinderException;
+ public LocalAccountProfile getProfileForUpdate() throws FinderException;
+
+ public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws FinderException;
+ public AccountDataBean getDataBean();
+
+ public AccountProfileDataBean getProfileDataBean();
+ public Collection getHoldingDataBeans();
+ public Collection getOrderDataBeans();
+
+ public String toString();
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+
+
+public interface LocalAccountHome extends EJBLocalHome {
+
+ //Account create takes parameters for the Account and Profile Entities
+ //Account acts as a proxy to user Profile information
+ public LocalAccount create (int accountID, String userID, String password, BigDecimal openBalance,
+ String fullname, String address, String email, String creditcard)
+ throws CreateException;
+
+ public LocalAccount create (Integer accountID, String userID, String password, BigDecimal openBalance,
+ String fullname, String address, String email, String creditcard)
+ throws CreateException;
+
+ public LocalAccount findByPrimaryKey (Integer accountID)
+ throws FinderException;
+
+ public LocalAccount findByPrimaryKeyForUpdate (Integer accountID)
+ throws FinderException;
+
+ public Collection findAll()
+ throws FinderException;
+
+ public LocalAccount findByUserID(String userID)
+ throws FinderException;
+
+ public LocalAccount findByUserIDForUpdate(String userID)
+ throws FinderException;
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfile.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfile.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfile.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfile.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface LocalAccountProfile extends EJBLocalObject {
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public String getUserID(); /* userID */
+ //public void setUserID(String userID);
+ public String getPassword(); /* password */
+ public void setPassword(String password);
+ public String getFullName(); /* fullName */
+ public void setFullName(String fullName);
+ public String getAddress(); /* address */
+ public void setAddress(String address);
+ public String getEmail(); /* email */
+ public void setEmail(String email);
+ public String getCreditCard(); /* creditCard */
+ public void setCreditCard(String creditCard);
+
+ /* Accessor methods for relationship fields */
+ public LocalAccount getAccount(); /* This profiles account */
+
+
+ /* Business methods */
+ public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData);
+ public LocalAccount getAccountForUpdate(); /* This profiles account */
+ public AccountProfileDataBean getDataBean();
+ public String toString();
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfileHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfileHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfileHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalAccountProfileHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+
+
+public interface LocalAccountProfileHome extends EJBLocalHome {
+
+ public LocalAccountProfile create (String userID, String password,
+ String fullname, String address, String email, String creditCard)
+ throws CreateException;
+
+ public LocalAccountProfile findByPrimaryKeyForUpdate (String userID)
+ throws FinderException;
+
public LocalAccountProfile findByPrimaryKey (String userID)
+ throws FinderException;
+
+ public Collection findAll()
+ throws FinderException;
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHolding.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHolding.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHolding.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHolding.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface LocalHolding extends EJBLocalObject {
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public abstract Integer getHoldingID(); /* holdingID */
+ //public abstract void setHoldingID(Integer holdingID);
+ public double getQuantity(); /* quantity */
+ //public abstract void setQuantity(double quantity);
+ public BigDecimal getPurchasePrice(); /* purchasePrice */
+ //public abstract void setPurchasePrice(BigDecimal purchasePrice);
+ public Timestamp getPurchaseDate(); /* purchaseDate */
+ public abstract void setPurchaseDate(Timestamp purchaseDate);
+
+ /* Accessor methods for relationship fields */
+ public LocalAccount getAccount(); /* Account(1) <---> Holding(*) */
+ public void setAccount(LocalAccount account);
+ public LocalQuote getQuote(); /* Holding(1) ---> Quote(1) */
+ public void setQuote(LocalQuote quote);
+
+ /* Business methods */
+
public HoldingDataBean getDataBean();
+ public String toString();
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHoldingHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHoldingHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHoldingHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalHoldingHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+
+
+public interface LocalHoldingHome extends EJBLocalHome {
+
+ public LocalHolding create (Integer holdingID, LocalAccount account, LocalQuote quote, double quantity, BigDecimal purchasePrice)
+ throws CreateException;
+
+ public LocalHolding create (int holdingID, LocalAccount account, LocalQuote quote, double quantity, BigDecimal purchasePrice)
+ throws CreateException;
+
+ public LocalHolding findByPrimaryKeyForUpdate (Integer holdingID)
+ throws FinderException;
+
+ public LocalHolding findByPrimaryKey (Integer holdingID)
+ throws FinderException;
+
+ public Collection findAll()
+ throws FinderException;
+
+ public Collection findByAccountID(Integer AccountID)
+ throws FinderException;
+
+ public Collection findByUserID(String userID)
+ throws FinderException;
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGen.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGen.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGen.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGen.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+
+public interface LocalKeyGen extends EJBLocalObject {
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public String getKeyName(); /* Unique Primary Key name */
+ //public void setKeyName(String KeyName);
+ public int getKeyVal(); /* Value for PK */
+ //public void setKeyValue(int KeyVal);
+
+ /* Accessor methods for relationship fields */
+
+ /* Business methods */
+ public Collection allocBlockOfKeys();
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGenHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGenHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGenHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeyGenHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+
+
+public interface LocalKeyGenHome extends EJBLocalHome {
+
+ public LocalKeyGen create (String keyName)
+ throws CreateException;
+
+ public LocalKeyGen findByPrimaryKey (String keyName)
+ throws FinderException;
+
+ public LocalKeyGen findByPrimaryKeyForUpdate (String keyName)
+ throws FinderException;
+
}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequence.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequence.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequence.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequence.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.EJBLocalObject;
+
+public interface LocalKeySequence extends EJBLocalObject {
+
+ /**
+ * Return the next Primary Key ID in sequence for the given key Name
+ *
+ */
+ Integer getNextID(String keyName);
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequenceHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequenceHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequenceHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalKeySequenceHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+public interface LocalKeySequenceHome extends EJBLocalHome {
+
+ LocalKeySequence create() throws CreateException;
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrder.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrder.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrder.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+
+import javax.ejb.*;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import org.apache.geronimo.samples.daytrader.*;
+
+
+public interface LocalOrder extends EJBLocalObject {
+
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+
+ public Integer getOrderID(); /* orderID */
+ //public void setOrderID(Integer accountID);
+ public String getOrderType(); /* orderType (buy, sell, etc.) */
+ //public void setOrderType(String orderType);
+ public String getOrderStatus(); /* orderStatus (open, completed, etc.) */
+ public void setOrderStatus(String orderType);
+ public Timestamp getOpenDate(); /* openDate (when the order was entered) */
+ //public void setOpenDate(Date openDate);
+ public Timestamp getCompletionDate(); /* completionDate */
+ public void setCompletionDate(Timestamp completionDate);
+ public double getQuantity(); /* quantity */
+ //public void setQuantity(double quantity);
+ public BigDecimal getPrice(); /* price */
+ //public void setPrice(BigDecimal price);
+ public BigDecimal getOrderFee(); /* price */
+ //public void setOrderFee(BigDecimal price);
+
+
+ /* Accessor methods for relationship fields */
+ public LocalAccount getAccount(); /* The account which placed the order */
+ //public void setAccount(LocalAccount account);
+ public LocalQuote getQuote(); /* The stock purchased/sold in this order */
+ //public void setQuote(LocalQuote quote); /* null for cash transactions */
+ public LocalHolding getHolding(); /* The created/removed holding for this order */
+ public void setHolding(LocalHolding holding); /* null for cash transactions */
+
+ /* Business methods */
+ public LocalHolding getHoldingForUpdate(); /* The holding for this order access with intent to update */
+ public void cancel();
+
+ public boolean isBuy();
+ public boolean isSell();
+ public boolean isOpen();
+ public boolean isCompleted();
+ public boolean isCancelled();
+
+ public OrderDataBean getDataBean();
+ public String toString();
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrderHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrderHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrderHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalOrderHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+
+
+public interface LocalOrderHome extends EJBLocalHome {
+
+ public LocalOrder create (int orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException;
+
+ public LocalOrder create (Integer orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException;
+
+ public LocalOrder findByPrimaryKeyForUpdate (Integer orderID)
+ throws FinderException;
+
+ public LocalOrder findByPrimaryKey (Integer orderID)
+ throws FinderException;
+
+ public Collection findAll()
+ throws FinderException;
+
+ public Collection findByUserID (String userID)
+ throws FinderException;
+
+ public Collection findClosedOrders(String userID)
+ throws FinderException;
+
+ public Collection findClosedOrdersForUpdate(String userID)
+ throws FinderException;
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuote.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuote.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuote.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuote.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,95 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface LocalQuote extends EJBLocalObject {
+
+ /* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public String getSymbol(); /* symbol */
+ public void setSymbol(String symbol);
+ public String getCompanyName(); /* companyName */
+ public void setCompanyName(String companyName);
+ public double getVolume(); /* volume */
+ //public void setVolume(double volume);
+ public BigDecimal getPrice(); /* price */
+ //public void setPrice(BigDecimal price);
+ public BigDecimal getOpen(); /* open price */
+ //public void setOpen(BigDecimal price);
+ public BigDecimal getLow(); /* low price */
+ /* setLow not exposed to client applications
+ public void setLow(BigDecimal price);
+ */
+
/* high price */
+ public BigDecimal getHigh();
+ /* setHigh not exposed to client applications
+ public void setHigh(BigDecimal price);
+ */
+
+ /* Change in price */
+ /* Note: this can be computed by "current-open"
+ but is added here for convenience
+ */
+ public double getChange();
+ /* setChange not exposed to client applications
+ public void setChange(double change);
+ */
+
+ /* Relationshiop fields */
+ public abstract Collection getOrders();
+ public abstract void setOrders(Collection orders);
+
+ /* Business methods */
+
+ public void updatePrice(BigDecimal price);
+ public void updatePrice(double price);
+
+ public void addToVolume(double quantity);
+
+ /* FUTURE This is the approach using ejbSelect methods
+ * using Trade Session EJB approach instead
+
+
public Collection getTopGainers(int count)
+ throws FinderException;
+
public Collection getTopLosers(int count)
+ throws FinderException;
+
public BigDecimal getTSIA()
+ throws FinderException;
+
+ public BigDecimal getOpenTSIA()
+ throws FinderException;
+
+ *
+ */
+
+ public double getTotalVolume()
+ throws FinderException;
+
+ public QuoteDataBean getDataBean();
+ public String toString();
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuoteHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuoteHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuoteHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/LocalQuoteHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+
+public interface LocalQuoteHome extends EJBLocalHome {
+
+ public LocalQuote create (String symbol, String companyName, BigDecimal price)
+ throws CreateException;
+
+ public LocalQuote findByPrimaryKeyForUpdate (String symbol)
+ throws FinderException;
+
+ public LocalQuote findByPrimaryKey (String symbol)
+ throws FinderException;
+
+
+ public LocalQuote findOne ()
+ throws FinderException;
+
+ public Collection findAll()
+ throws FinderException;
+
+ // Find TradeStockIndexAvg. Stocks -- unordered
+ public Collection findTSIAQuotes()
+ throws FinderException;
+ // Find TradeStockIndexAvg. Stocks -- ordered by change
+ public Collection findTSIAQuotesOrderByChange()
+ throws FinderException;
+
+ /* findQuotes must take a comma seperated String of symbols
+ * EJB QL will not take a collection type
+ */
+ public Collection findQuotes(String symbols)
+ throws FinderException;
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/OrderBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/OrderBean.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/OrderBean.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/OrderBean.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,207 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+
+import javax.ejb.*;
+
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import org.apache.geronimo.samples.daytrader.*;
+
+
+public abstract class OrderBean
+ implements EntityBean {
+
+
+ private EntityContext context;
+
+ /* Accessor methods for persistent fields */
+
+
+ public abstract Integer getOrderID(); /* orderID */
+ public abstract void setOrderID(Integer orderID);
+ public abstract String getOrderType(); /* orderType (buy, sell, etc.) */
+ public abstract void setOrderType(String orderType);
+ public abstract String getOrderStatus(); /* orderStatus (open, completed, etc.) */
+ public abstract void setOrderStatus(String orderType);
+ public abstract Timestamp getOpenDate(); /* openDate (when the order was entered) */
+ public abstract void setOpenDate(Timestamp openDate);
+ public abstract Timestamp getCompletionDate(); /* completionDate */
+ public abstract void setCompletionDate(Timestamp completionDate);
+ public abstract double getQuantity(); /* quantity */
+ public abstract void setQuantity(double quantity);
+ public abstract BigDecimal getPrice(); /* price */
+ public abstract void setPrice(BigDecimal price);
+ public abstract BigDecimal getOrderFee(); /* orderFee */
+ public abstract void setOrderFee(BigDecimal price);
+
+ /* Accessor methods for relationship fields */
+ public abstract LocalAccount getAccount(); /* The account which placed the order */
+ public abstract void setAccount(LocalAccount account);
+ public abstract LocalQuote getQuote(); /* The stock purchased/sold in this order */
+ public abstract void setQuote(LocalQuote quote); /* null for cash transactions */
+ public abstract LocalHolding getHolding(); /* The created/removed holding during this order */
+ public abstract void setHolding(LocalHolding holding); /* null for cash transactions */
+
+ /* Select methods */
+
+
+
+ /* Business methods */
+ public LocalHolding getHoldingForUpdate() /* The holding for this order access with intent to update */
+ {
+ return getHolding();
+ }
+ public boolean isBuy()
+ {
+ String orderType = getOrderType();
+ if ( orderType.compareToIgnoreCase("buy") == 0 )
+ return true;
+ return false;
+ }
+
+ public boolean isSell()
+ {
+ String orderType = getOrderType();
+ if ( orderType.compareToIgnoreCase("sell") == 0 )
+ return true;
+ return false;
+ }
+
+ public boolean isOpen()
+ {
+ String orderStatus = getOrderStatus();
+ if ( (orderStatus.compareToIgnoreCase("open") == 0) ||
+ (orderStatus.compareToIgnoreCase("processing") == 0) )
+ return true;
+ return false;
+ }
+
+ public boolean isCompleted()
+ {
+ String orderStatus = getOrderStatus();
+ if ( (orderStatus.compareToIgnoreCase("completed") == 0) ||
+ (orderStatus.compareToIgnoreCase("alertcompleted") == 0) ||
+ (orderStatus.compareToIgnoreCase("cancelled") == 0) )
+ return true;
+ return false;
+ }
+
+ public boolean isCancelled()
+ {
+ String orderStatus = getOrderStatus();
+ if (orderStatus.compareToIgnoreCase("cancelled") == 0)
+ return true;
+ return false;
+ }
+
+
+ public void cancel()
+ {
+ setOrderStatus("cancelled");
+ }
+
+
+ public OrderDataBean getDataBean()
+ {
+ return new OrderDataBean(getOrderID(),
+ getOrderType(),
+ getOrderStatus(),
+ getOpenDate(),
+ getCompletionDate(),
+ getQuantity(),
+ getPrice(),
+ getOrderFee(),
+ (String)getQuote().getPrimaryKey()
+ );
+
+ }
+
+
+ public String toString()
+ {
+ return getDataBean().toString();
+ }
+
+ /* Required javax.ejb.EntityBean interface methods */
+
+ public Integer ejbCreate (int orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException {
+ return ejbCreate(new Integer(orderID), account, quote, holding, orderType, quantity);
+ }
+
+ public Integer ejbCreate (Integer orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException {
+
+
+ Timestamp currentDate = new Timestamp(System.currentTimeMillis());
+
+ setOrderID(orderID);
+ setOrderType(orderType);
+ setOrderStatus("open");
+ setOpenDate(currentDate);
+ setQuantity (quantity);
+ setPrice (quote.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
+
+
+ setOrderFee(TradeConfig.getOrderFee(orderType));
+
+ return null;
+ }
+
+
+ public void ejbPostCreate (Integer orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException {
+ setAccount(account);
+ setQuote(quote);
+ setHolding(holding);
+ }
+
+ public void ejbPostCreate (int orderID, LocalAccount account, LocalQuote quote, LocalHolding holding, String orderType, double quantity)
+ throws CreateException {
+ ejbPostCreate(new Integer(orderID), account, quote, holding, orderType, quantity);
+ }
+
+
+ public void setEntityContext(EntityContext ctx) {
+ context = ctx;
+ }
+
+ public void unsetEntityContext() {
+ context = null;
+ }
+
+ public void ejbRemove() {
+ }
+
+
+ public void ejbLoad() {
+ }
+
+ public void ejbStore() {
+ }
+
+ public void ejbPassivate() {
+ }
+
+ public void ejbActivate() {
+ }
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Quote.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Quote.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Quote.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Quote.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.math.BigDecimal;
+import org.apache.geronimo.samples.daytrader.*;
+import java.rmi.*;
+
+public interface Quote extends EJBObject, Remote
+{
+
/* Container persisted attributes
+ * Note: Commented out methods are internal only and not exposed to EJB clients
+ * For example: The Primary Key value cannot be modified after creation
+ * Also, modification of other Entity attributes may be restricted to internal use
+ */
+
+ public String getSymbol() throws RemoteException; /* symbol */
+ public void setSymbol(String symbol) throws RemoteException;
+ public String getCompanyName() throws RemoteException; /* companyName */
+ public void setCompanyName(String companyName) throws RemoteException;
+ public double getVolume() throws RemoteException; /* volume */
+ //public void setVolume(double volume) throws RemoteException;
+ public BigDecimal getPrice() throws RemoteException; /* price */
+ //public void setPrice(BigDecimal price) throws RemoteException;
+ public BigDecimal getOpen() throws RemoteException; /* open price */
+ //public void setOpen(BigDecimal price) throws RemoteException;
+ public BigDecimal getLow() throws RemoteException; /* low price */
+ //public void setLow(BigDecimal price) throws RemoteException;
+
+ /* high price */
+ public BigDecimal getHigh() throws RemoteException;
+ //public void setHigh(BigDecimal price) throws RemoteException;
+
+
+ /* Change in price */
+ /* Note: this can be computed by "current-open"
+ but is added here for convenience
+ */
+ public double getChange() throws RemoteException;
+ //public void setChange(double change) throws RemoteException;
+
+
+ /* Relationshiop fields */
+ // Cannot be exposed on Remote I/F
+ //public abstract Collection getOrders() throws RemoteException;
+ //public abstract void setOrders(Collection orders) throws RemoteException;
+
+
+ /* Business methods */
+
+ public void updatePrice(BigDecimal price) throws RemoteException;
+ public void updatePrice(double price) throws RemoteException;
+
+ public void addToVolume(double quantity) throws RemoteException;
+
+ /* FUTURE This is the approach using ejbSelect methods
+ * using Trade Session EJB approach instead
+
+
+ public Collection getTopGainers(int count)
+ throws FinderException throws RemoteException;
+
+ public Collection getTopLosers(int count)
+ throws FinderException throws RemoteException;
+
+ public BigDecimal getTSIA()
+ throws FinderException throws RemoteException;
+
+ public BigDecimal getOpenTSIA()
+ throws FinderException throws RemoteException;
+
+ *
+ */
+
+ public double getTotalVolume()
+ throws FinderException, RemoteException;
+
+ public QuoteDataBean getDataBean() throws RemoteException;
+// public String toString() throws RemoteException;
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteBean.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteBean.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteBean.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,261 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.math.BigDecimal;
+import org.apache.geronimo.samples.daytrader.*;
+
+public abstract class QuoteBean
+ implements EntityBean {
+
+ private EntityContext context;
+
+ /* Accessor methods for persistent fields */
+
+ public abstract String getSymbol(); /* symbol */
+ public abstract void setSymbol(String symbol);
+ public abstract String getCompanyName(); /* companyName */
+ public abstract void setCompanyName(String companyName);
+ public abstract double getVolume(); /* volume */
+ public abstract void setVolume(double volume);
+ public abstract BigDecimal getPrice(); /* price */
+ public abstract void setPrice(BigDecimal price);
+ public abstract BigDecimal getOpen(); /* open price */
+ public abstract void setOpen(BigDecimal price);
+ public abstract BigDecimal getLow(); /* low price */
+ public abstract void setLow(BigDecimal price);
+ public abstract BigDecimal getHigh(); /* high price */
+ public abstract void setHigh(BigDecimal price);
+ public abstract double getChange(); /* price change */
+ public abstract void setChange(double change);
+
+ /* Accessor methods for relationship fields */
+ public abstract Collection getOrders();
+ public abstract void setOrders(Collection orders);
+
+ /* Select methods */
+/*
+ public abstract Collection ejbSelectTopGainPrices()
+ throws FinderException;
+ public abstract Collection ejbSelectTopLossPrices()
+ throws FinderException;
+ public abstract Collection ejbSelectChangeGreaterThan(double minGain)
+ throws FinderException;
+ public abstract Collection ejbSelectChangeLessThan(double minLoss)
+ throws FinderException;
+ public abstract Collection ejbSelectPricesForTSIA()
+ throws FinderException;
+ public abstract Collection ejbSelectOpenPricesForTSIA()
+ throws FinderException;
+*/
+ public abstract Collection ejbSelectTotalVolume()
+ throws FinderException;
+
+ /* Business methods */
+
+ public void updatePrice(BigDecimal current)
+ {
+ int compare = current.compareTo(getPrice());
+ // Do nothing if the price has not changed
+ if ( compare == 0) return;
+
+ setPrice(current.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND)); //Update current price
+ setChange( current.doubleValue() - getOpen().doubleValue() );
+
+ //Reset high, low if applicable
+ if ( current.compareTo(getHigh()) > 0 ) setHigh(current);
+ else if ( current.compareTo(getLow()) < 0 ) setLow(current);
+ }
+
+ public void updatePrice(double current)
+ {
+ updatePrice( new BigDecimal(current));
+ }
+
+ public void addToVolume(double quantity)
+ {
+ setVolume( getVolume() + quantity);
+ }
+
+
+/* To get TopGainers and Losers,
+ * using an algorithm in TradeSession EJB instead of ejbSelect approach
+ *
+ *
+ public Collection getTopGainers(int count)
+ throws FinderException
+ {
+// LocalQuote quote = (LocalQuote) context.getEJBLocalObject();
+ Collection topGainPrices = ejbSelectTopGainPrices();
+ ArrayList topGains = new ArrayList(topGainPrices);
+
+ count = count -1; //index starts with zero
+ double minGain = 0.0;
+ if ( topGains.size() >= count )
+ minGain = ((Double)topGains.get(count)).doubleValue();
+
+ return ejbSelectChangeGreaterThan(minGain);
+ }
+
+ public Collection getTopLosers(int count)
+ throws FinderException
+ {
+// LocalQuote quote = (LocalQuote) context.getEJBLocalObject();
+ Collection topLossPrices = ejbSelectTopLossPrices();
+ ArrayList topLoss = new ArrayList(topLossPrices);
+
+ count = count -1; //index starts with zero
+ double minLoss = 0.0;
+ if ( topLoss.size() >= count )
+ minLoss = ((Double)topLoss.get(count)).doubleValue();
+
+ return ejbSelectChangeLessThan(minLoss);
+ }
+
+ public BigDecimal getTSIA()
+ throws FinderException
+ {
+ // LocalQuote quote = (LocalQuote) context.getEJBLocalObject();
+ BigDecimal TSIA = FinancialUtils.ZERO;
+ Collection currentPrices = ejbSelectPricesForTSIA();
+ int size = currentPrices.size();
+
+ if (size > 0)
+ {
+ Iterator it = currentPrices.iterator();
+ while (it.hasNext())
+ {
+ BigDecimal price = (BigDecimal)it.next();
+ TSIA = TSIA.add(price);
+ }
+
+ TSIA = TSIA.divide(new BigDecimal(size), FinancialUtils.ROUND);
+ }
+ return TSIA;
+ }
+
+ public BigDecimal getOpenTSIA()
+ throws FinderException
+ {
+ // LocalQuote quote = (LocalQuote) context.getEJBLocalObject();
+ BigDecimal openTSIA = FinancialUtils.ZERO;
+ Collection openPrices = ejbSelectOpenPricesForTSIA();
+ int size = openPrices.size();
+
+ if (size > 0)
+ {
+ Iterator it = openPrices.iterator();
+ while (it.hasNext())
+ {
+ BigDecimal price = (BigDecimal)it.next();
+ openTSIA = openTSIA.add(price);
+ }
+
+ openTSIA = openTSIA.divide(new BigDecimal(size), FinancialUtils.ROUND);
+ }
+ return openTSIA;
+ }
+ *
+ */
+
+ public double getTotalVolume()
+ throws FinderException
+ {
+ double totalVolume = 0.0;
+ Collection volumes = ejbSelectTotalVolume();
+ Iterator it = volumes.iterator();
+
+ while (it.hasNext())
+ {
+ Double volume;
+ Object o = it.next();
+ try {
+ Float f = (Float) o;
+ volume = new Double(f.doubleValue());
+ }
+ catch (Exception e)
+ {
+ volume = (Double) o;
+ }
+ totalVolume = totalVolume + volume.doubleValue();
+
+ }
+ return totalVolume;
+ }
+
+ public QuoteDataBean getDataBean()
+ {
+ return new QuoteDataBean(getSymbol(),getCompanyName(),getVolume(),getPrice(),getOpen(),
+ getLow(),getHigh(),getChange());
+ }
+
+ public String toString()
+ {
+ return getDataBean().toString();
+ }
+
+ /* Required javax.ejb.EntityBean interface methods */
+
+ public String ejbCreate (String symbol, String companyName, BigDecimal price)
+ throws CreateException {
+
if (Log.doTrace()) Log.traceEnter("QuoteBean:ejbCreate");
+ setSymbol(symbol);
+ setCompanyName(companyName);
+ price = price.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
+ setVolume(0.0);
+ setPrice(price);
+ setOpen (price);
+ setLow (price);
+ setHigh (price);
+ setChange(0.0);
+
if (Log.doTrace()) Log.traceExit("QuoteBean:ejbCreate");
+ return null;
+ }
+
+ public void ejbPostCreate (String symbol, String companyName, BigDecimal price)
+ throws CreateException { }
+
+ public void setEntityContext(EntityContext ctx) {
+ context = ctx;
+ }
+
+ public void unsetEntityContext() {
+ context = null;
+ }
+
+ public void ejbRemove() {
+ }
+
+ public void ejbLoad() {
+ }
+
+ public void ejbStore() {
+ }
+
+ public void ejbPassivate() {
+ }
+
+ public void ejbActivate() {
+ }
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteHome.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteHome.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteHome.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/QuoteHome.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.*;
+import java.util.Collection;
+import java.math.BigDecimal;
+import java.rmi.*;
+
+public interface QuoteHome extends EJBHome, Remote {
+
+ public Quote create (String symbol, String companyName, BigDecimal price)
+ throws CreateException, RemoteException;
+
+ public Quote findByPrimaryKeyForUpdate (String symbol)
+ throws FinderException, RemoteException;
+
+ public Quote findByPrimaryKey (String symbol)
+ throws FinderException, RemoteException;
+
+
+ public Quote findOne ()
+ throws FinderException, RemoteException;
+
+ public Collection findAll()
+ throws FinderException, RemoteException;
+
+ // Find TradeStockIndexAvg. Stocks -- unordered
+ public Collection findTSIAQuotes()
+ throws FinderException, RemoteException;
+ // Find TradeStockIndexAvg. Stocks -- ordered by change
+ public Collection findTSIAQuotesOrderByChange()
+ throws FinderException, RemoteException;
+
+ /* findQuotes must take a comma seperated String of symbols
+ * EJB QL will not take a collection type
+ */
+ public Collection findQuotes(String symbols)
+ throws FinderException, RemoteException;
+
+}
Added: geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Trade.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Trade.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Trade.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/ejb/src/java/org/apache/geronimo/samples/daytrader/ejb/Trade.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.samples.daytrader.ejb;
+
+import javax.ejb.EJBObject;
+import java.rmi.Remote;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface Trade extends EJBObject, TradeServices, Remote {
+
+ /**
+ * Queue the Order identified by orderID to be processed in a One Phase commit
+ *
+ * In short, this method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across Entity and MDB access
+ *
+ * Orders are submitted through JMS to a Trading Broker
+ * and completed asynchronously. This method queues the order for processing
+ *
+ * @param orderID the Order being queued for processing
+ * @return OrderDataBean providing the status of the completed order
+ */
+ public void queueOrderOnePhase(Integer orderID) throws Exception;
+ /**
+ * Complete the Order identified by orderID in a One Phase commit
+ *
+ * In short, this method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across Entity and MDB access
+ *
+ * Orders are submitted through JMS to a Trading agent
+ * and completed asynchronously. This method completes the order
+ * For a buy, the stock is purchased creating a holding and the users account is debited
+ * For a sell, the stock holding is removed and the users account is credited with the proceeds
+ *
+ * @param orderID the Order to complete
+ * @return OrderDataBean providing the status of the completed order
+ */
+ public OrderDataBean completeOrderOnePhase(Integer orderID) throws Exception;
+
+ /**
+ * Complete the Order identified by orderID in a One Phase commit
+ * using TradeDirect to complete the Order
+ *
+ * In short, this method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across DB and MDB access
+ * The EJB method is used only to start a new transaction so the direct runtime mode
+ * for the completeOrder will run in a 1-phase commit
+ *
+ * Orders are submitted through JMS to a Trading agent
+ * and completed asynchronously. This method completes the order using TradeDirect
+ * For a buy, the stock is purchased creating a holding and the users account is debited
+ * For a sell, the stock holding is removed and the users account is credited with the proceeds
+ *
+ * @param orderID the Order to complete
+ * @return OrderDataBean providing the status of the completed order
+ */
+ public OrderDataBean completeOrderOnePhaseDirect(Integer orderID) throws Exception;
+
+ /**
+ * Cancel the Order identefied by orderID
+ *
+ * In short, this method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across Entity and MDB access
+ *
+ * The boolean twoPhase specifies to the server implementation whether or not the
+ * method is to participate in a global transaction
+ *
+ * @param orderID the Order to complete
+ * @return OrderDataBean providing the status of the completed order
+ */
+ public void cancelOrderOnePhase(Integer orderID) throws Exception;
+
+ /**
+ * Cancel the Order identefied by orderID
+ * using TradeDirect to complete the Order
+ *
+ * In short, this method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across DB and MDB access
+ * The EJB method is used only to start a new transaction so the direct runtime mode
+ * for the cancleOrder will run in a 1-phase commit
+ *
+ * The boolean twoPhase specifies to the server implementation whether or not the
+ * method is to participate in a global transaction
+ *
+ * @param orderID the Order to complete
+ * @return OrderDataBean providing the status of the completed order
+ */
+ public void cancelOrderOnePhaseDirect(Integer orderID) throws Exception;
+
+ /**
+ * Publish to the QuoteChange Message topic when a stock
+ * price and volume are updated
+ *
+ * This method is deployed as TXN REQUIRES NEW to avoid a
+ * 2-phase commit transaction across the DB update and MDB access
+ * (i.e. a failure to publish will not cause the stock update to fail
+ *
+ * @param quoteData - the updated Quote
+ * @param oldPrice - the price of the Quote before the update
+ * @param sharesTraded - the quantity of sharesTraded
+ */
+ public void publishQuotePriceChange(QuoteDataBean quoteData, java.math.BigDecimal oldPrice, java.math.BigDecimal changeFactor, double sharesTraded) throws Exception;
+
+ /**
+ * provides a simple session method with no database access to test performance of a simple
+ * path through a stateless session
+ * @param investment amount
+ * @param NetValue current value
+ * @return return on investment as a percentage
+ */
+ public double investmentReturn(double investment, double NetValue) throws Exception;
+
+ /**
+ * This method provides a ping test for a 2-phase commit operation
+ *
+ * @param symbol to lookup
+ * @return quoteData after sending JMS message
+ */
+ public QuoteDataBean pingTwoPhase(String symbol) throws Exception;
+
+}