geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r817380 - in /geronimo/sandbox/jbohn/daytrader-bp/modules: core/src/main/resources/OSGI-INF/blueprint/ web/src/main/java/org/apache/geronimo/samples/daytrader/web/ web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ web/src/m...
Date Mon, 21 Sep 2009 19:17:44 GMT
Author: jbohn
Date: Mon Sep 21 19:17:43 2009
New Revision: 817380

URL: http://svn.apache.org/viewvc?rev=817380&view=rev
Log:
start using TradeDBServices from osgi service lookup, more cleanup, etc...

Modified:
    geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/OrdersAlertFilter.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeAppServlet.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeScenarioServlet.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCRead.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCWrite.java
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Mon Sep 21 19:17:43 2009
@@ -2,12 +2,16 @@
 
   <bean id="tradeServiceComponent" class="org.apache.geronimo.samples.daytrader.core.direct.TradeJDBCDirect"
activation="lazy"/>
   
+  <service id="tradeDBService" ref="tradeServiceComponent" interface="org.apache.geronimo.samples.daytrader.core.TradeDBServices">
+      <service-properties>
+          <entry key="mode" value="0"/>
+      </service-properties>
+  </service>
+
   <service id="tradeService" ref="tradeServiceComponent" interface="org.apache.geronimo.samples.daytrader.core.TradeServices">
-<!--
       <service-properties>
           <entry key="mode" value="0"/>
       </service-properties>
--->
   </service>
 
 </blueprint>

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/OrdersAlertFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/OrdersAlertFilter.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/OrdersAlertFilter.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/OrdersAlertFilter.java
Mon Sep 21 19:17:43 2009
@@ -20,9 +20,9 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
-import org.apache.geronimo.samples.daytrader.core.direct.TradeJDBCDirect;
 import org.apache.geronimo.samples.daytrader.core.TradeServices;
 import org.apache.geronimo.samples.daytrader.util.*;
+import org.apache.geronimo.samples.daytrader.web.util.*;
 
 public class OrdersAlertFilter implements Filter {
 
@@ -63,11 +63,9 @@
                     else
                         userID = (String) ((HttpServletRequest) req).getSession().getAttribute("uidBean");
                     if ( (userID != null) && (userID.trim().length()>0) ) {
-                        TradeServices tAction=null;
-                        if (TradeConfig.getAccessMode() == TradeConfig.STANDARD)
-                            tAction = new TradeJDBCDirect();
 
-                        java.util.Collection closedOrders = tAction.getClosedOrders(userID);
+                        TradeServices tradeServices = ServletUtilities.getTradeServices();
+                        java.util.Collection closedOrders = tradeServices.getClosedOrders(userID);
                         if ( (closedOrders!=null) && (closedOrders.size() > 0)
) {
                             req.setAttribute("closedOrders", closedOrders);
                         }

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeAppServlet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeAppServlet.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeAppServlet.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeAppServlet.java
Mon Sep 21 19:17:43 2009
@@ -46,13 +46,6 @@
             String value = config.getInitParameter(parm);
             TradeConfig.setConfigParam(parm, value);
         }
-//      try {
-//          if (TradeConfig.runTimeMode == TradeConfig.JDBC) {
-//              TradeJDBCDirect.init();
-//          }
-//      } catch (Exception e) {
-//          Log.error(e, "TradeAppServlet:init -- Error initializing TradeDirect");
-//      }
     }
 
     /**

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
Mon Sep 21 19:17:43 2009
@@ -23,7 +23,8 @@
 import java.math.BigDecimal;
 import java.util.ArrayList;
 
-import org.apache.geronimo.samples.daytrader.core.*;
+import org.apache.geronimo.samples.daytrader.core.TradeServices;
+import org.apache.geronimo.samples.daytrader.core.TradeDBServices;
 import org.apache.geronimo.samples.daytrader.core.direct.*;
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;
@@ -39,7 +40,7 @@
  * again where xxx represents sequential numbers (e.g. s:1, s:2, etc.)
  */
 public class TradeBuildDB {
-
+           4
     private boolean verbose = true;
     private TradeConfig t = new TradeConfig();
 
@@ -59,6 +60,7 @@
         String symbol, companyName;
         int errorCount = 0; // Give up gracefully after 10 errors
         TradeServices tradeServices = ServletUtilities.getTradeServices();
+        TradeDBServices tradeDBServices = ServletUtilities.getTradeDBServices();
 
         // TradeStatistics.statisticsEnabled=false; // disable statistics
         out.println("<HEAD><BR><EM> TradeBuildDB: Building DayTrader Database...</EM><BR>"
@@ -66,16 +68,6 @@
         out.println("<BODY>");
 
         if (warPath != null) {
-            // out.println("<BR>TradeBuildDB: **** warPath= "+warPath+" ****</BR></BODY>");
-            TradeDBServices tradeDB = null;
-
-            if ((TradeConfig.getRunTimeMode() == TradeConfig.JDBC)
-                || (TradeConfig.getRunTimeMode() == TradeConfig.JPA)) {
-                tradeDB = new TradeJDBCDirect();
-//          } else {
-//              tradeDB = new TradeJEEDirect();
-            }
-
             boolean success = false;
             String dbProductName = null;
             File ddlFile = null;
@@ -83,7 +75,7 @@
 
             // Find out the Database being used
             try {
-                dbProductName = tradeDB.checkDBProductName();
+                dbProductName = tradeDBServices.checkDBProductName();
             } catch (Exception e) {
                 Log.error(e, "TradeBuildDB: Unable to check DB Product name");
             }
@@ -152,7 +144,7 @@
             // send the sql commands buffer to drop and recreate the Daytrader tables
             out.println("<BR>TradeBuildDB: **** Dropping and Recreating the DayTrader
tables... ****</BR>");
             try {
-                success = tradeDB.recreateDBTables(sqlBuffer, out);
+                success = tradeDBServices.recreateDBTables(sqlBuffer, out);
             } catch (Exception e) {
                 Log.error(e,
                     "TradeBuildDB: Unable to drop and recreate DayTrader Db Tables, "+

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeScenarioServlet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeScenarioServlet.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeScenarioServlet.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeScenarioServlet.java
Mon Sep 21 19:17:43 2009
@@ -19,7 +19,6 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
-import org.apache.geronimo.samples.daytrader.core.*;
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;
 

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
Mon Sep 21 19:17:43 2009
@@ -22,7 +22,7 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
-import org.apache.geronimo.samples.daytrader.core.*;
+import org.apache.geronimo.samples.daytrader.core.TradeServices;
 import org.apache.geronimo.samples.daytrader.core.direct.*;
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCRead.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCRead.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCRead.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCRead.java
Mon Sep 21 19:17:43 2009
@@ -20,11 +20,10 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
-import org.apache.geronimo.samples.daytrader.core.direct.*;
+import org.apache.geronimo.samples.daytrader.core.TradeServices;
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;
-
-import org.apache.geronimo.samples.daytrader.core.*;
+import org.apache.geronimo.samples.daytrader.web.util.*;
 
 /**
  * 
@@ -66,14 +65,14 @@
 
 		try
 			{
-			//TradeJDBC uses prepared statements so I am going to make use of it's code.
-			TradeJDBCDirect trade = new TradeJDBCDirect();
+			//TradeJDBCDirect (via TradeServices) uses prepared statements so I am going to make use
of it's code.
+                        TradeServices tradeServices = ServletUtilities.getTradeServices();
 			symbol = TradeConfig.rndSymbol();
 			
 			QuoteDataBean quoteData = null;
 			int iter = TradeConfig.getPrimIterations();
 			for (int ii = 0; ii < iter; ii++) {
-				quoteData = trade.getQuote(symbol);
+				quoteData = tradeServices.getQuote(symbol);
 			}
 
 			output.append(
@@ -104,7 +103,7 @@
 	 **/
 	public String getServletInfo()
 	{
-		return "Basic JDBC Read using a prepared statment, makes use of TradeJDBC class";
+		return "Basic JDBC Read using a prepared statment, makes use of TradeJDBCDirect class via
TradeServices";
 	}
 	/**
 	* called when the class is loaded to initialize the servlet

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCWrite.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCWrite.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCWrite.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingJDBCWrite.java
Mon Sep 21 19:17:43 2009
@@ -25,7 +25,6 @@
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;
 
-import org.apache.geronimo.samples.daytrader.core.*;
 /**
  * 
  * PingJDBCReadPrepStmt uses a prepared statement

Modified: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java?rev=817380&r1=817379&r2=817380&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
Mon Sep 21 19:17:43 2009
@@ -20,7 +20,8 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
-import org.apache.geronimo.samples.daytrader.core.*;
+import org.apache.geronimo.samples.daytrader.core.TradeServices;
+import org.apache.geronimo.samples.daytrader.core.TradeDBServices;
 
 import java.io.IOException;
 
@@ -49,7 +50,30 @@
             return (TradeServices) ic.lookup("osgi:services/" + TradeServices.class.getName());
         } catch (NamingException e) {
             e.printStackTrace();
-            IOException ioe = new IOException("I'm being lazy here");
+            IOException ioe = new IOException("Unable to retrieve TradeServices service");
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+
+    /**
+     * Lookup and return the TradeDBServices osgi service
+     * 
+     * @return TradeDBServices
+     * @exception javax.io.IOException
+     *                If an exception occurs during the service
+     *                lookup
+     * 
+     */
+    public static final TradeDBServices getTradeDBServices()
+        throws IOException
+    {
+        try {
+            InitialContext ic = new InitialContext();
+            return (TradeDBServices) ic.lookup("osgi:services/" + TradeDBServices.class.getName());
+        } catch (NamingException e) {
+            e.printStackTrace();
+            IOException ioe = new IOException("Unable to retrieve TradeDBServices service");
             ioe.initCause(e);
             throw ioe;
         }



Mime
View raw message