geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r815980 - in /geronimo/sandbox/jbohn/daytrader-bp/modules: beans/src/main/resources/OSGI-INF/ beans/src/main/resources/OSGI-INF/blueprint/ core/src/main/resources/OSGI-INF/ core/src/main/resources/OSGI-INF/blueprint/ web/src/main/java/org/a...
Date Wed, 16 Sep 2009 21:54:08 GMT
Author: jbohn
Date: Wed Sep 16 21:54:07 2009
New Revision: 815980

URL: http://svn.apache.org/viewvc?rev=815980&view=rev
Log:
the start of some blueprint content

Added:
    geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/
    geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/
    geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
  (with props)
    geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/
    geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/
    geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
  (with props)
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/
    geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
  (with props)
Modified:
    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/TradeServletAction.java

Added: geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=815980&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(added)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Wed Sep 16 21:54:07 2009
@@ -0,0 +1,14 @@
+<blueprint>
+
+  <bean id="accountDataBean" class="org.apache.geronimo.samples.daytrader.beans.AccountDataBean"
activation="lazy"/>
+
+  <bean id="accountProfileDataBean" class="org.apache.geronimo.samples.daytrader.beans.AccountProfileDataBean"
activation="lazy"/>
+
+  <bean id="holdingProfileDataBean" class="org.apache.geronimo.samples.daytrader.beans.HoldingDataBean"
activation="lazy"/>
+
+  <bean id="orderProfileDataBean" class="org.apache.geronimo.samples.daytrader.beans.OrderDataBean"
activation="lazy"/>
+
+  <bean id="quoteProfileDataBean" class="org.apache.geronimo.samples.daytrader.beans.QuoteDataBean"
activation="lazy"/>
+
+</blueprint>
+

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/beans/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 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=815980&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(added)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Wed Sep 16 21:54:07 2009
@@ -0,0 +1,14 @@
+<blueprint>
+
+  <bean id="tradeServiceComponent" class="org.apache.geronimo.samples.daytrader.core.direct.TradeJDBCDirect"
activation="lazy"/>
+  
+  <service id="tradeService" ref="tradeServiceComponent" interface="org.apache.geronimo.samples.daytrader.core.TradeServices">
+<!--
+      <service-properties>
+          <entry key="mode" value="0"/>
+      </service-properties>
+-->
+  </service>
+
+</blueprint>
+

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

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=815980&r1=815979&r2=815980&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
Wed Sep 16 21:54:07 2009
@@ -20,96 +20,80 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
-//import org.apache.geronimo.samples.daytrader.core.*;
-import org.apache.geronimo.samples.daytrader.core.TradeAction;
+import org.apache.geronimo.samples.daytrader.core.direct.TradeJDBCDirect;
 import org.apache.geronimo.samples.daytrader.core.TradeServices;
-//import org.apache.geronimo.samples.daytrader.soap.*;
 import org.apache.geronimo.samples.daytrader.util.*;
 
 public class OrdersAlertFilter implements Filter {
 
-	/**
-	 * Constructor for CompletedOrdersAlertFilter
-	 */
-	public OrdersAlertFilter() {
-		super();
-	}
-
-	/**
-	 * @see Filter#init(FilterConfig)
-	 */
-	private FilterConfig filterConfig = null;
-	public void init(FilterConfig filterConfig) throws ServletException {
-	      this.filterConfig = filterConfig;
-	}
-
-	/**
-	 * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
-	 */
-	public void doFilter(
-		ServletRequest req,
-		ServletResponse resp,
-		FilterChain chain)
-		throws IOException, ServletException {
-		if (filterConfig == null)
-			return;
-		
-		try
-		{
-			String action = req.getParameter("action");
-			if ( action != null ) 
-			{
-				action = action.trim();
-				if ( (action.length() > 0) && (!action.equals("logout")) )
-				{
-					String userID;
-					if ( action.equals("login") )
-						userID = req.getParameter("uid");
-					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 TradeAction();
-						} else if(TradeConfig.getAccessMode() == TradeConfig.WEBSERVICES) {
-                            try {
-                                Class c = Class.forName("org.apache.geronimo.samples.daytrader.soap.TradeWebSoapProxy");
                               
-                                tAction = (TradeServices) c.newInstance();
-                            }
-                            catch (Exception e) {
-                                Log.error("OrdersAlertFilter:doFilter() Creation of TradeWebSoapProxy
failed\n" + e);
-                                throw new IllegalArgumentException(e);
-                            }
+    /**
+     * Constructor for CompletedOrdersAlertFilter
+     */
+    public OrdersAlertFilter() {
+        super();
+    }
+
+    /**
+     * @see Filter#init(FilterConfig)
+     */
+    private FilterConfig filterConfig = null;
+    public void init(FilterConfig filterConfig) throws ServletException {
+        this.filterConfig = filterConfig;
+    }
+
+    /**
+     * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
+     */
+    public void doFilter(
+                        ServletRequest req,
+                        ServletResponse resp,
+                        FilterChain chain)
+    throws IOException, ServletException {
+        if (filterConfig == null)
+            return;
+
+        try {
+            String action = req.getParameter("action");
+            if ( action != null ) {
+                action = action.trim();
+                if ( (action.length() > 0) && (!action.equals("logout")) ) {
+                    String userID;
+                    if ( action.equals("login") )
+                        userID = req.getParameter("uid");
+                    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);
+                        if ( (closedOrders!=null) && (closedOrders.size() > 0)
) {
+                            req.setAttribute("closedOrders", closedOrders);
                         }
-						java.util.Collection closedOrders = tAction.getClosedOrders(userID);
-						if ( (closedOrders!=null) && (closedOrders.size() > 0) ) {
-							req.setAttribute("closedOrders", closedOrders);
-                        }
-						if (Log.doTrace()) {
+                        if (Log.doTrace()) {
                             Log.printCollection("OrderAlertFilter: userID="+userID+" closedOrders=",
closedOrders);
                         }
-					}
-				}	
-			}
-		}
-		catch (Exception e)
-		{
-			Log.error(e, "OrdersAlertFilter - Error checking for closedOrders");
-		}
+                    }
+                }
+            }
+        }
+        catch (Exception e) {
+            Log.error(e, "OrdersAlertFilter - Error checking for closedOrders");
+        }
 
         ServletContext sc = filterConfig.getServletContext();
         //String xyz = (String) sc.getAttribute("hitCounter");
-		chain.doFilter(req, resp/*wrapper*/);        
+        chain.doFilter(req, resp/*wrapper*/);        
 
-	}
+    }
 
-	/**
-	 * @see Filter#destroy()
-	 */
-	public void destroy() {
-		this.filterConfig = null;	
-	}
+    /**
+     * @see Filter#destroy()
+     */
+    public void destroy() {
+        this.filterConfig = null;   
+    }
 
 }
 

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=815980&r1=815979&r2=815980&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
Wed Sep 16 21:54:07 2009
@@ -46,13 +46,13 @@
             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");
-        }
+//      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/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=815980&r1=815979&r2=815980&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
Wed Sep 16 21:54:07 2009
@@ -17,12 +17,16 @@
  */
 package org.apache.geronimo.samples.daytrader.web;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.servlet.*;
 import javax.servlet.http.*;
 
 import org.apache.geronimo.samples.daytrader.core.*;
+import org.apache.geronimo.samples.daytrader.core.direct.*;
 import org.apache.geronimo.samples.daytrader.beans.*;
 import org.apache.geronimo.samples.daytrader.util.*;
+import org.apache.geronimo.samples.daytrader.web.util.*;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -37,16 +41,12 @@
  * getQuote, etc. TradeServletAction manages a web interface to Trade handling
  * HttpRequests/HttpResponse objects and forwarding results to the appropriate
  * JSP page for the web interface. TradeServletAction invokes
- * {@link TradeAction} methods to actually perform each trading operation.
+ * {@link TradeJDBCDirect} methods to actually perform each
+ * trading operation.
  * 
  */
 public class TradeServletAction {
 
-    private TradeServices tAction = null;
-
-    TradeServletAction() {
-        tAction = new TradeAction();
-    }
 
     /**
      * Display User Profile information such as address, email, etc. for the
@@ -73,6 +73,7 @@
     void doAccount(ServletContext ctx, HttpServletRequest req,
             HttpServletResponse resp, String userID, String results)
             throws javax.servlet.ServletException, java.io.IOException {
+        TradeServices tAction = ServletUtilities.getTradeServices();
         try {
 
             AccountDataBean accountData = tAction.getAccountData(userID);
@@ -144,6 +145,7 @@
             String creditcard, String email)
             throws javax.servlet.ServletException, java.io.IOException {
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
 
         // First verify input data
         boolean doUpdate = true;
@@ -208,6 +210,7 @@
             String quantity) throws ServletException, IOException {
 
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
 
         try {
             OrderDataBean orderData = tAction.buy(userID, symbol, new Double(
@@ -262,6 +265,7 @@
         
         BigDecimal balance;
         String result = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
         
         try {
             AccountDataBean accountData = tAction.getAccountData(userID);
@@ -324,6 +328,7 @@
             throws javax.servlet.ServletException, java.io.IOException {
 
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
         try {
             // Got a valid userID and passwd, attempt login
 
@@ -398,6 +403,7 @@
             HttpServletResponse resp, String userID) throws ServletException,
             IOException {
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
 
         try {
             tAction.logout(userID);
@@ -468,6 +474,7 @@
             HttpServletResponse resp, String userID, String results)
             throws ServletException, IOException {
 
+        TradeServices tAction = ServletUtilities.getTradeServices();
         try {
             // Get the holdiings for this user
 
@@ -588,6 +595,7 @@
             String openBalanceString, String email, String address)
             throws ServletException, IOException {
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
 
         try {
             // Validate user passwords match and are atleast 1 char in length
@@ -652,6 +660,7 @@
             HttpServletResponse resp, String userID, Integer holdingID)
             throws ServletException, IOException {
         String results = "";
+        TradeServices tAction = ServletUtilities.getTradeServices();
         try {
             OrderDataBean orderData = tAction.sell(userID, holdingID,
                     TradeConfig.orderProcessingMode);

Added: 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=815980&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
(added)
+++ geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
Wed Sep 16 21:54:07 2009
@@ -0,0 +1,58 @@
+/**
+ *  Licensed to4the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership. The ASF licenses this file to
+ *  You 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.web.util;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.geronimo.samples.daytrader.core.*;
+
+import java.io.IOException;
+
+
+/**
+ * ServletUtilities provides servlet specific client side
+ * utility functions.
+ * 
+ */
+public class ServletUtilities {
+
+    /**
+     * Lookup and return the TradeServices osgi service
+     * 
+     * @return TradeServices
+     * @exception javax.io.IOException
+     *                If an exception occurs during the service
+     *                lookup
+     * 
+     */
+    public static final TradeServices getTradeServices()
+        throws IOException
+    {
+        try {
+            InitialContext ic = new InitialContext();
+            return (TradeServices) ic.lookup("osgi:services/" + TradeServices.class.getName());
+        } catch (NamingException e) {
+            e.printStackTrace();
+            IOException ioe = new IOException("I'm being lazy here");
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/util/ServletUtilities.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message