You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/05/08 21:56:16 UTC

svn commit: r405149 - in /incubator/tuscany/java/samples/bigbank: account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java account/src/main/resources/sca.module readme.htm

Author: rineholt
Date: Mon May  8 12:56:14 2006
New Revision: 405149

URL: http://svn.apache.org/viewcvs?rev=405149&view=rev
Log:
allow db to be created outside of a servlet
also some very quick info on getting BB to run for now.

Added:
    incubator/tuscany/java/samples/bigbank/readme.htm
      - copied, changed from r404992, incubator/tuscany/java/sca/samples/helloworldweb/readme.htm
Modified:
    incubator/tuscany/java/samples/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
    incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module

Modified: incubator/tuscany/java/samples/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java?rev=405149&r1=405148&r2=405149&view=diff
==============================================================================
--- incubator/tuscany/java/samples/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java (original)
+++ incubator/tuscany/java/samples/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java Mon May  8 12:56:14 2006
@@ -1,6 +1,5 @@
 package bigbank.account.services.accountdb;
 
-import java.io.File;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.sql.Connection;
@@ -31,7 +30,6 @@
 import bigbank.account.services.accountdata.AccountDataServiceDASImpl;
 
 import com.bigbank.account.AccountFactory;
-import com.bigbank.account.AccountService;
 import com.bigbank.account.AccountSummary;
 import com.bigbank.account.CustomerProfileData;
 import com.bigbank.account.DataGraphRoot;
@@ -56,16 +54,10 @@
 
     protected String dbDirectory = null;
 
-    // static{
-    // System.err.println("instatic");
-    // System.out.println("instatic");
-    // }
 
     @Override
     public void init() throws ServletException {
         try {
-            // System.err.println("init()");
-            // System.out.println("init()");
 
             registerTypes();
             ServletConfig servletConfig = getServletConfig();
@@ -74,12 +66,12 @@
             this.deleteExisting = false;
 
             createDB(dbDirectory);
-            final String msgDBcreated = "BigBank database created '" + dbDirectory + "'.";
-            System.out.println(msgDBcreated);
-            System.err.println(msgDBcreated);
-            log(msgDBcreated);
+//            final String msgDBcreated = "BigBank database created '" + dbDirectory + "'.";
+//            System.out.println(msgDBcreated);
+//            System.err.println(msgDBcreated);
+//            log(msgDBcreated);
             // TODO get rid of this!!!
-            AccountDataServiceDASImpl.dbDirectory = dbDirectory;
+            
 
         } catch (Exception e) {
 
@@ -99,8 +91,9 @@
         this.deleteExisting = deleteExisting;
     }
 
-    protected void createDB(final String location) throws Exception {
+    public static void  createDB(final String location) throws Exception {
         Connection conn = null;
+        AccountDataServiceDASImpl.dbDirectory = location;
         Exception processessingException = null;
         try {
             conn = createConnection(location);
@@ -131,15 +124,9 @@
                 conn.rollback();
             if (e.getErrorCode() == 20000 && "X0Y32".equalsIgnoreCase(e.getSQLState()) && -1 != e.getMessage().indexOf("already exists")) {
                 // this is ok the database is there.
-                if (false && deleteExisting) {
-                    deleteExisting = false;
-                    File dbFILE = new File(dbDirectory);
 
-                    // createDB(dbDirectory);
-                }
-
-                System.out.println("DB already there.");
-                System.out.flush();
+//                System.out.println("DB already there.");
+//                System.out.flush();
 
             } else {
 
@@ -168,7 +155,7 @@
         return createConnection(dbDirectory);
     }
 
-    private Connection createConnection(final String location) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
+    private static Connection createConnection(final String location) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
             SQLException {
         Connection conn;
         Class.forName(driver).newInstance();
@@ -181,7 +168,7 @@
         return conn;
     }
 
-    protected void creatTables(Connection conn) throws Exception {
+    protected static void creatTables(Connection conn) throws Exception {
         
         
         
@@ -197,7 +184,7 @@
         s.close();
     }
 
-    protected int createCustomer(Connection conn, final String firstName, final String lastName, final String address, final String email,  final String logonID, final String password)
+    protected static int createCustomer(Connection conn, final String firstName, final String lastName, final String address, final String email,  final String logonID, final String password)
             throws SQLException, Exception {
         Statement s = conn.createStatement();
 
@@ -214,7 +201,7 @@
         return id;
     }
 
-    protected void createAccount(Connection conn, int customerID, final String accountNumber, final String accountType, final float balance)
+    protected static void createAccount(Connection conn, int customerID, final String accountNumber, final String accountType, final float balance)
             throws SQLException, Exception {
         Statement s = conn.createStatement();
 
@@ -231,7 +218,7 @@
         return mapping;
     }
 
-    protected void createStockPurchase(Connection conn, int customerID, final String stockSymbol, final int quantity, final float purchasePrice,
+    protected static void createStockPurchase(Connection conn, int customerID, final String stockSymbol, final int quantity, final float purchasePrice,
             String purchaseDate) throws SQLException, Exception {
         Statement s = conn.createStatement();
 
@@ -268,7 +255,7 @@
         }
         AccountDBInit accountDBInit = new AccountDBInit(dbDirectory, deleteExisting);
 
-        accountDBInit.createDB(dbDirectory);
+        createDB(dbDirectory);
         accountDBInit.readDBstdout(System.out);
         // CustomerProfileData customerProfileData = accountDBInit.testgetCustomerByLoginIDThroughDASRead("cr22rc");
 

Modified: incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module?rev=405149&r1=405148&r2=405149&view=diff
==============================================================================
--- incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module (original)
+++ incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module Mon May  8 12:56:14 2006
@@ -72,5 +72,4 @@
 
 
                 
-</module>
-        
+</module>
\ No newline at end of file

Copied: incubator/tuscany/java/samples/bigbank/readme.htm (from r404992, incubator/tuscany/java/sca/samples/helloworldweb/readme.htm)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/readme.htm?p2=incubator/tuscany/java/samples/bigbank/readme.htm&p1=incubator/tuscany/java/sca/samples/helloworldweb/readme.htm&r1=404992&r2=405149&rev=405149&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworldweb/readme.htm (original)
+++ incubator/tuscany/java/samples/bigbank/readme.htm Mon May  8 12:56:14 2006
@@ -1,32 +1,14 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-<!--
-  Copyright (c) 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.
- -->
-
-    
+<!-- Copyright (c) 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. -->
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
-
-    
   <meta http-equiv="Content-Style-Type" content="text/css">
+  <title>Tuscany Hello World Web Sample</title>
 
-    
 
-  <title>Tuscany Hello World Web Sample</title>
 <!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
   <style type="text/css" media="all">
 @import url("../../../../css/maven-base.css");
@@ -34,159 +16,34 @@
 @import url("../../../../css/site.css");
   </style>
   <link rel="stylesheet" href="./css/print.css" type="text/css" media="print">
+
 <!-- end maven -->
 </head>
 
 
 <body>
 
-
-<h2>Tuscany Hello World Web Sample</h2>
-
+<h2>Tuscany BigBank Sample Application.</h2>
 
 <h3>Overview</h3>
 
-
-<p>The Tuscany hello world web sample shows using the Tuscany SCA
-    runtime in a Tomcat environment being accessed from a JSP
-    page&nbsp;that
-    implements the classic introductory hello world example. </p>
-
-
+<p>The Tuscany BigBank&nbsp;sample applications&nbsp;
+shows using the Tuscany SCA runtime to build an actual financial
+application. </p>
 
 <h3>Setup</h3>
-Set up your server as described in the <a href="../../../sampleSetup.htm" target="_blank">Tomcat
-    Setup</a>. &nbsp;If you are not configuring with the acceptance test the server, you will need to add <span style="font-weight: bold;">helloworldWeb-SNAPSHOT.war</span> to your tomcat's webapp directory.<br>
 
+Set up your server as described in the <a href="../../sampleSetup.htm" target="_blank">Tomcat
+Setup</a>. &nbsp;If you are not configuring with the
+acceptance test the server, you will need to add<br>
+
+samples\bigbank\account\target\bigbank-account-SNAPSHOT.war
+and&nbsp;amples\bigbank\webclient\target\bigbank-webclient-SNAPSHOT.war&nbsp;<span style="font-weight: bold;"></span> to your tomcat's
+webapp directory.<br>
 
 <h3>Running</h3>
 
-
 Once you've started your web server, use your browse to view the
-following URL: <a href="http://localhost:8080/helloworldWeb-SNAPSHOT/" target="_blank">http://localhost:8080/helloworldWeb-SNAPSHOT/</a>
-<br>
-
-
-You should see a form you can supply your name and a submit button.
-&nbsp;Once you submit the form the JSP page calls a Java class that
-gets the CurrentModuleContext and locates the SCA component to execute
-the greeting service. &nbsp;Note, unlike the a J2SE in a Tomcat environment the Tuscany runtime is automatically
-initialized and running.
-<h3>Results</h3>
-
-
-<p>The page should be updated with the greeting displayed below
-    the form.<br>
-
-
-</p>
-
-
-<h3>Code Overview</h3>
-
-
-The source files are physically organized as shown below:<br>
-
-<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
-
-    <tbody>
-
-        <tr>
-
-            <td>
-                
-      <pre>+---main<br>&brvbar;   +---java<br>&brvbar;       &brvbar;   sca.module<br>&brvbar;       &brvbar;<br>                    <br>&brvbar;       +---org<br>&brvbar;           +---apache<br>&brvbar;               +---tuscany<br>                    <br>&brvbar;                   +---samples<br>&brvbar;                       +---helloworldweb<br>                    <br>&brvbar;                               HelloWorldService.java<br>&brvbar;<br>                    HelloWorldServiceComponentImpl.java<br>&brvbar;<br>+---webapp<br>    &brvbar;   HelloWorldWeb.jsp<br>                    <br>    &brvbar;<br> +---WEB-INF<br> web.xml<br></pre>
-
-            </td>
-
-        </tr>
-
-    
-  </tbody>
-</table>
-
-<br>
-
-<br>
-
-
-<p>&nbsp;</p>
-
-
-<table style="text-align: left; width: 100%; height: 154px;" border="0" cellpadding="2" cellspacing="2">
-
-
-    <tbody>
-
-
-        <tr>
-
-
-            <td style="vertical-align: top;">sca.module</td>
-
-
-            <td>Defines the SCA module and component. Defines for the
-                HelloWorldServiceComponent component and the Java class that
-                implements that component</td>
-
-
-        </tr>
-
-
-        <tr>
-
-
-            <td style="vertical-align: top;">HelloWorldService.java</td>
-
-
-            <td>Defines the Java interface implemented by the component.</td>
-
-
-        </tr>
-
-
-        <tr>
-
-
-            <td style="vertical-align: top;">HelloWorldServiceComponentImpl.java</td>
-
-
-            <td>Implements the SCA component. Uses the SCA service
-                annotation tag on the class to show what SCA interface is being
-                implemented.</td>
-
-
-        </tr>
-
-
-
-        <tr>
-
-            <td>HelloWorldWeb.jsp</td>
-
-            <td>Handles Web form input.. Obtains the module context which was defined by the
-                sca.module file. From the module context locates the
-                HelloWorldServiceComponent and then calls&nbsp; the getGreetings
-                method to invoke the component.&nbsp;and formats &nbsp;returned&nbsp;results.</td>
-
-        </tr>
-
-        <tr>
-
-            <td>web.xml</td>
-
-            <td>Standard J2EE web application's web.xml</td>
-
-        </tr>
-
-
-    
-  </tbody>
-</table>
-
-
-<br>
-
-
+following URL: <a href="http://localhost:8080/bigbank-webclient-SNAPSHOT/login.html" target="_blank">http://localhost:8080/bigbank-webclient-SNAPSHOT/login.html</a><br>
 </body>
 </html>