You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ec...@apache.org on 2008/03/12 22:56:03 UTC
svn commit: r636529 [9/15] - in /geronimo/samples/branches/1.0: ./
migration-ejb-bmp/ migration-ejb-bmp/dd/ migration-ejb-bmp/dd/META-INF/
migration-ejb-bmp/jndi/ migration-ejb-bmp/src/ migration-ejb-bmp/src/com/
migration-ejb-bmp/src/com/ibm/ migratio...
Added: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java (added)
+++ geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,136 @@
+/*
+* Licensed to the 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 com.ibm.j2g.jca.connector.impl;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+public class FileRetrieverManagedConnectionFactory
+ implements ManagedConnectionFactory {
+
+ /** Log writer */
+ private transient PrintWriter writer;
+
+ /** Path to file system repository */
+ private String repository;
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
+ */
+ public Object createConnectionFactory(ConnectionManager cm)
+ throws ResourceException {
+ return new FileRetrieverConnectionFactoryImpl(this, cm);
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
+ */
+ public Object createConnectionFactory() throws ResourceException {
+ return new FileRetrieverConnectionFactoryImpl(this, null);
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
+ */
+ public ManagedConnection createManagedConnection(
+ Subject subj,
+ ConnectionRequestInfo conReqInfo)
+ throws ResourceException {
+ return new FileRetrieverManagedConnection(conReqInfo, writer, repository);
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#matchManagedConnections(java.util.Set, javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
+ */
+ public ManagedConnection matchManagedConnections(
+ Set set, Subject subj, ConnectionRequestInfo conReqInfo)
+ throws ResourceException {
+ Iterator itr = set.iterator();
+ if (itr.hasNext()) {
+ Object obj = itr.next();
+ if (obj instanceof FileRetrieverManagedConnection) {
+ return (FileRetrieverManagedConnection)obj;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter)
+ */
+ public void setLogWriter(PrintWriter out) throws ResourceException {
+ this.writer = out;
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#getLogWriter()
+ */
+ public PrintWriter getLogWriter() throws ResourceException {
+ return writer;
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#hashCode()
+ */
+ public int hashCode() {
+ if (repository == null) {
+ return super.hashCode();
+ } else {
+ return repository.hashCode();
+ }
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionFactory#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof FileRetrieverManagedConnectionFactory)) {
+ return false;
+ }
+ if (repository == null) {
+ return false;
+ }
+ return repository.equals(((FileRetrieverManagedConnectionFactory)obj).getRepositoryPath());
+ }
+
+ /**
+ * Returns path to file system repository
+ * @return path to file system repository
+ */
+ public String getRepositoryPath() {
+ return repository;
+ }
+
+ /**
+ * Sets path to file system repository
+ * @param path path to file system repository
+ */
+ public void setRepositoryPath(String path) {
+ this.repository = path;
+ }
+}
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java (added)
+++ geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,56 @@
+/*
+* Licensed to the 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 com.ibm.j2g.jca.connector.impl;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionMetaData;
+
+public class FileRetrieverManagedConnectionMetaData implements
+ ManagedConnectionMetaData {
+
+ /** Default instance of the class */
+ public final static FileRetrieverManagedConnectionMetaData INSTANCE =
+ new FileRetrieverManagedConnectionMetaData();
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionMetaData#getEISProductName()
+ */
+ public String getEISProductName() throws ResourceException {
+ return "File system EIS";
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionMetaData#getEISProductVersion()
+ */
+ public String getEISProductVersion() throws ResourceException {
+ return "1.0";
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionMetaData#getMaxConnections()
+ */
+ public int getMaxConnections() throws ResourceException {
+ return 0;
+ }
+
+ /*
+ * @see javax.resource.spi.ManagedConnectionMetaData#getUserName()
+ */
+ public String getUserName() throws ResourceException {
+ return "Unknown";
+ }
+}
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/connector/impl/FileRetrieverManagedConnectionMetaData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java (added)
+++ geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,84 @@
+/*
+* Licensed to the 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 com.ibm.j2g.jca.web;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.naming.NamingException;
+import javax.resource.ResourceException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ibm.j2g.jca.connector.FileRetrieverConnection;
+import com.ibm.j2g.jca.connector.FileRetrieverConnectionFactory;
+
+public class FileRetrieverServlet extends HttpServlet {
+
+ /** Name of the reference to the File Retriever connector described in the web.xml file */
+ private final static String CONNECTOR_REF_NAME = "java:comp/env/ra/FileRetriever";
+
+ /**
+ * Returns connection to the File Retriever
+ * @return File Retriever connection instance
+ * @throws NamingException in case the File Retriever EIS is not found
+ * @throws ResourceException in case of any problem with File Retriever
+ */
+ public FileRetrieverConnection getConnection() throws NamingException, ResourceException {
+ javax.naming.InitialContext ctx = new javax.naming.InitialContext();
+ FileRetrieverConnectionFactory factory =
+ (FileRetrieverConnectionFactory)ctx.lookup(CONNECTOR_REF_NAME);
+ return factory.getConnection();
+ }
+
+ /*
+ * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ String file = request.getParameter("file");
+ if (file == null) {
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+
+ FileRetrieverConnection connection = null;
+ try {
+ connection = getConnection();
+ response.setContentType("application/x-download");
+ response.setHeader("Content-Disposition", "attachment; filename=" + file);
+ connection.retrieve(file, response.getOutputStream());
+
+ } catch (FileNotFoundException fnfe) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+
+ } catch (Exception e) {
+ throw new ServletException(e);
+
+ } finally {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (ResourceException re) {
+ }
+ }
+ }
+ }
+
+}
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/src/com/ibm/j2g/jca/web/FileRetrieverServlet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml (added)
+++ geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the 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.
+-->
+
+<!-- This is Geronimo-specific descriptor -->
+
+<web-app xmlns="http://geronimo.apache.org/xml/ns/web"
+ configId="com/ibm/j2g/jca.war"
+ parentId="com/ibm/j2g/jca.rar">
+
+ <context-root>/jca</context-root>
+
+ <resource-ref xmlns="http://geronimo.apache.org/xml/ns/naming">
+ <ref-name>ra/FileRetriever</ref-name>
+ <resource-link>FileRetriever</resource-link>
+ </resource-ref>
+
+</web-app>
+
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml (added)
+++ geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the 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.
+-->
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
+
+<!-- This is JBoss-specific descriptor -->
+
+<jboss-web>
+
+ <context-root>/jca</context-root>
+
+ <resource-ref>
+ <res-ref-name>ra/FileRetriever</res-ref-name>
+ <jndi-name>java:/FileRetriever</jndi-name>
+ </resource-ref>
+
+</jboss-web>
+
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/jboss-web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml (added)
+++ geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the 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.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>FileRetrieverServlet</servlet-name>
+ <servlet-class>com.ibm.j2g.jca.web.FileRetrieverServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>FileRetrieverServlet</servlet-name>
+ <url-pattern>/retrieve</url-pattern>
+ </servlet-mapping>
+
+ <resource-ref>
+ <res-ref-name>ra/FileRetriever</res-ref-name>
+ <res-type>com.ibm.j2g.jca.connector.FileRetrieverConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+
+</web-app>
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/web/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jca/web/index.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jca/web/index.jsp?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jca/web/index.jsp (added)
+++ geronimo/samples/branches/1.0/migration-jca/web/index.jsp Wed Mar 12 14:54:41 2008
@@ -0,0 +1,82 @@
+<!--
+ Licensed to the 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.
+-->
+<%@ page language="java"
+ contentType="text/html; charset=utf-8"
+ pageEncoding="utf-8"
+ import="com.ibm.j2g.jca.connector.*"
+%>
+
+<%!
+ /* Name of the reference to the File Retriever connector described in the web.xml file */
+ private final static String CONNECTOR_REF_NAME = "java:comp/env/ra/FileRetriever";
+
+ /* Returns connection to the File Retriever */
+ public FileRetrieverConnection getConnection() throws Exception {
+ javax.naming.InitialContext ctx = new javax.naming.InitialContext();
+ FileRetrieverConnectionFactory factory =
+ (FileRetrieverConnectionFactory)ctx.lookup(CONNECTOR_REF_NAME);
+ return factory.getConnection();
+ }
+%>
+
+<%
+ // Getting names of directories and files in the repository:
+ FileRetrieverConnection connection = null;
+ String[] directories;
+ String[] files;
+ try {
+ connection = getConnection();
+ directories = connection.listDirectories();
+ files = connection.listFiles();
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+%>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>JCA Application</title>
+</head>
+
+<body>
+ <h3>Contents of the repository</h3>
+ <table>
+ <tr>
+ <td>The following directories and files were found. Click a file to open it:</td>
+ </tr>
+
+ <% for(int i = 0; i < directories.length; i++) { %>
+ <tr>
+ <td>[<%=directories[i]%>]</td>
+ </tr>
+ <% } %>
+ <% for(int i = 0; i < files.length; i++) { %>
+ <tr>
+ <td><a href="retrieve?file=<%=files[i]%>" target="_new"><%=files[i]%></a></td>
+ </tr>
+ <% } %>
+
+ </table>
+</body>
+
+</html>
Propchange: geronimo/samples/branches/1.0/migration-jca/web/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jca/web/index.jsp
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jca/web/index.jsp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt Wed Mar 12 14:54:41 2008
@@ -0,0 +1,350 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] The Apache Software Foundation
+
+ 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.
+
+=========================================================================
+J2G, Commons Logging, commons-el, jasper-runtime, jasper-compiler,
+jasper-compiler-jdt, geronimo-jsp_spec, and geronimo-servlet-spec use the
+above Apache License v2.0.
+=========================================================================
+
+=========================================================================
+== Dom4j License ==
+=========================================================================
+
+Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
+
+Redistribution and use of this software and associated documentation
+("Software"), with or without modification, are permitted provided
+that the following conditions are met:
+
+1. Redistributions of source code must retain copyright
+ statements and notices. Redistributions must also contain a
+ copy of this document.
+
+2. Redistributions in binary form must reproduce the
+ above copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+3. The name "DOM4J" must not be used to endorse or promote
+ products derived from this Software without prior written
+ permission of MetaStuff, Ltd. For written permission,
+ please contact dom4j-info@metastuff.com.
+
+4. Products derived from this Software may not be called "DOM4J"
+ nor may "DOM4J" appear in their names without prior written
+ permission of MetaStuff, Ltd. DOM4J is a registered
+ trademark of MetaStuff, Ltd.
+
+5. Due credit should be given to the DOM4J Project -
+ http://www.dom4j.org
+
+THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================
+== Jaxen License ==
+=========================================================================
+
+ Copyright 2003-2006 The Werken Company. All Rights Reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the Jaxen Project nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================
+== PullParser License ==
+=========================================================================
+
+Copyright 2002 The Trustees of Indiana University.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1) All redistributions of source code must retain the above
+ copyright notice, the list of authors in the original source
+ code, this list of conditions and the disclaimer listed in this
+ license;
+
+2) All redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the disclaimer
+ listed in this license in the documentation and/or other
+ materials provided with the distribution;
+
+3) Any documentation included with all redistributions must include
+ the following acknowledgement:
+
+ "This product includes software developed by the Indiana
+ University Extreme! Lab. For further information please visit
+ http://www.extreme.indiana.edu/"
+
+ Alternatively, this acknowledgment may appear in the software
+ itself, and wherever such third-party acknowledgments normally
+ appear.
+
+4) The name "Indiana Univeristy" and "Indiana Univeristy
+ Extreme! Lab" shall not be used to endorse or promote
+ products derived from this software without prior written
+ permission from Indiana University. For written permission,
+ please contact http://www.extreme.indiana.edu/.
+
+5) Products derived from this software may not use "Indiana
+ Univeristy" name nor may "Indiana Univeristy" appear in their name,
+ without prior written permission of the Indiana University.
+
+Indiana University provides no reassurances that the source code
+provided does not infringe the patent or any other intellectual
+property rights of any other entity. Indiana University disclaims any
+liability to any recipient for claims brought by any other entity
+based on infringement of intellectual property rights or otherwise.
+
+LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+SOFTWARE.
+
+
+
+
+
Propchange: geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/LICENSE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt Wed Mar 12 14:54:41 2008
@@ -0,0 +1,46 @@
+=========================================================================
+== NOTICE file corresponding to section 4(d) of the Apache License, ==
+== Version 2.0, in this case for the Apache Geronimo distribution. ==
+=========================================================================
+
+Apache Geronimo
+Copyright 2003-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Portions of the J2G Conversion Tool were orginally developed by International
+Business Machines Corporation and are licensed to the Apache Software
+Foundation under the "Software Grant and Corporate Contribution License
+Agreement", informally known as the "IBM Console CLA".
+
+=========================================================================
+== Commons-logging Notice ==
+=========================================================================
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+
+=========================================================================
+== Dom4j Notice ==
+=========================================================================
+
+Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
+
+=========================================================================
+== Jaxen Notice ==
+=========================================================================
+
+Copyright 2003-2006 The Werken Company. All Rights Reserved.
+
+=========================================================================
+== PullParser Notice ==
+=========================================================================
+
+Copyright 2002 The Trustees of Indiana University.
+All rights reserved.
+
+This product includes software developed by the Indiana
+University Extreme! Lab. For further information please visit
+http://www.extreme.indiana.edu/
+
Propchange: geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/NOTICE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/build.properties
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/build.properties?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/build.properties (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/build.properties Wed Mar 12 14:54:41 2008
@@ -0,0 +1,35 @@
+# Licensed to the 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.
+
+#name of the server to build the war for
+server.name=geronimo
+#Replace java.home with your jdk directory
+java.home=/j2sdk1.4.2_09
+#Replace jboss.home with the parent directory of lib/j2ee.jar
+jboss.home=C:/jboss-4.0.2/server/default
+#Replace geronimo.home with the geronimo home directory.
+geronimo.home=C:/geronimo-1.0-M5
+#Fully qualified name of the JDBC driver class
+db.driver=com.mysql.jdbc.Driver
+#database url
+db.url=jdbc:mysql://localhost:3306/tradedb
+#database userId
+db.userid=root
+#database password
+db.password=password
+#script file for creating the tables
+sql.file=sql/db.sql
+#location of the jdbc driver jar.
+driver.classpath=C:/developerworks/mysql-connector-java-3.1.10/mysql-connector-java-3.1.10-bin.jar
\ No newline at end of file
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/build.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/build.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/build.xml (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/build.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the 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.
+-->
+<!-- build file for building the brokerage war and populate the database -->
+
+<project name="build" default="populateDB" basedir=".">
+
+ <property file="build.properties"/>
+ <property name="src.dir" value="src"/>
+ <property name="dest.dir" value="bin"/>
+
+
+ <target name="init" description="Delete all generated files">
+ <echo message="Deleting War"/>
+ <delete file="brokerage.war"/>
+ </target>
+ <target name="compile" depends="init">
+ <echo message="Creating bin directory"/>
+ <mkdir dir="${dest.dir}"/>
+ <echo message="Compiling Files"/>
+ <javac srcdir="${src.dir}" destdir="${dest.dir}">
+ <classpath path="${java.home}/lib/tools.jar"/>
+ <classpath path="${jboss.home}/lib/jboss-j2ee.jar"/>
+ <classpath path="${geronimo.home}/repository/geronimo-spec/jars/geronimo-spec-j2ee-1.4-rc4.jar"/>
+ </javac>
+ </target>
+ <target name="war" depends="compile">
+ <echo message="Preparing war"/>
+ <war destfile="brokerage.war" webxml="web/descriptors/web.xml">
+ <fileset dir="web/jsps"/>
+ <webinf dir="web/descriptors/${server.name}"/>
+ <lib dir="libs"/>
+ <classes dir="${dest.dir}"/>
+ </war>
+ </target>
+ <target name="populateDB" depends="war">
+ <echo message="Populating Database"/>
+ <sql
+ driver="${db.driver}"
+ url="${db.url}"
+ userid="${db.userid}"
+ password="${db.password}"
+ src="${sql.file}"
+ print="yes"
+ output="outputfile.txt"
+ >
+ <classpath>
+ <pathelement location="${driver.classpath}"/>
+ </classpath>
+ </sql>
+ </target>
+</project>
\ No newline at end of file
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/build.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the 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.
+-->
+
+<!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
+<!-- Datasource config for MySQL using 3.0.9 available from:
+http://www.mysql.com/downloads/api-jdbc-stable.html
+-->
+
+<datasources>
+
+ <local-tx-datasource>
+ <jndi-name>jdbc/TradeDB</jndi-name>
+ <connection-url>jdbc:mysql://localhost:3306/tradedb</connection-url>
+ <driver-class>com.mysql.jdbc.Driver</driver-class>
+ <user-name>root</user-name>
+ <password>password</password>
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
+ </local-tx-datasource>
+ </datasources>
+
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-ds.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml Wed Mar 12 14:54:41 2008
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the 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.
+-->
+
+<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" configId="geronimo/jdbcdatasource/1.0/car" parentId="geronimo/j2ee-server/1.0/car">
+<dependency>
+<!-- <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>3.1.10-bin</version> -->
+ <uri>mysql/mysql-connector-java/3.1.10-bin/jar</uri>
+</dependency>
+<resourceadapter>
+ <outbound-resourceadapter>
+ <connection-definition>
+ <connectionfactory-interface>
+ javax.sql.DataSource
+ </connectionfactory-interface>
+ <connectiondefinition-instance>
+ <name>TradeDS</name>
+ <config-property-setting name="UserName">
+ root
+ </config-property-setting>
+ <config-property-setting name="Password">
+ password
+ </config-property-setting>
+ <config-property-setting name="Driver">
+ com.mysql.jdbc.Driver
+ </config-property-setting>
+ <config-property-setting name="ConnectionURL">
+ jdbc:mysql://localhost:3306/tradedb
+ </config-property-setting>
+ <config-property-setting name="CommitBeforeAutocommit">
+ false
+ </config-property-setting>
+ <config-property-setting name="ExceptionSorterClass">
+ org.tranql.connector.NoExceptionsAreFatalSorter
+ </config-property-setting>
+
+ <connectionmanager>
+ <local-transaction/>
+ <single-pool>
+ <max-size>10</max-size>
+ <min-size>0</min-size>
+ <blocking-timeout-milliseconds>
+ 5000
+ </blocking-timeout-milliseconds>
+ <idle-timeout-minutes>
+ 30
+ </idle-timeout-minutes>
+ <match-one/>
+ </single-pool>
+ </connectionmanager>
+ </connectiondefinition-instance>
+ </connection-definition>
+ </outbound-resourceadapter>
+</resourceadapter>
+</connector>
+
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/plan/mysql-geronimo-plan.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql Wed Mar 12 14:54:41 2008
@@ -0,0 +1,71 @@
+-- Licensed to the 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.
+
+
+
+CREATE TABLE IF NOT EXISTS Users
+(userid VARCHAR(15) PRIMARY KEY CHECK (NOT NULL),
+name VARCHAR(50),
+password VARCHAR(24),
+address VARCHAR(96),
+cash FLOAT) ;
+
+
+CREATE TABLE IF NOT EXISTS TradingAccount
+(userid VARCHAR(15),
+ stockid VARCHAR(8),
+ quantity INT);
+
+
+CREATE TABLE IF NOT EXISTS stocks
+(id VARCHAR(8) PRIMARY KEY CHECK (NOT NULL),
+ name VARCHAR(100),
+ price FLOAT);
+
+DELETE FROM Users;
+DELETE FROM TradingAccount;
+DELETE FROM stocks;
+
+INSERT INTO Users VALUES('srini', '6 Inch',
+ 'cheemu','Madivala Bangalore',10000);
+
+INSERT INTO Users VALUES('j2ee', 'Lee Whittaker',
+ 'password','Tampa Florida',100000);
+
+INSERT INTO TradingAccount VALUES('j2ee','00000002',10);
+INSERT INTO TradingAccount VALUES('srini','00000001',100);
+
+INSERT INTO stocks VALUES('00000001',"BTDA",1.00);
+INSERT INTO stocks VALUES('00000002',"Hitech Software",2.00);
+INSERT INTO stocks VALUES('00000003',"Bill's Cold Storage",3.00);
+INSERT INTO stocks VALUES('00000004',"Colonel's Fried Chicken",300.00);
+INSERT INTO stocks VALUES('00000005',"Toyo Motors",30.00);
+INSERT INTO stocks VALUES('00000006',"Timbuctoo Airlines",53.00);
+INSERT INTO stocks VALUES('00000007',"Happy Undertakers",73.00);
+INSERT INTO stocks VALUES('00000008',"Wacko Brothers",54.00);
+INSERT INTO stocks VALUES('00000009',"Mental Studios",456.00);
+INSERT INTO stocks VALUES('00000013',"ASFG",54.89);
+INSERT INTO stocks VALUES('00000023',"BFG",564.50);
+INSERT INTO stocks VALUES('00000033',"Mack",3444.50);
+INSERT INTO stocks VALUES('00000043',"Ronan & Sons",7.50);
+INSERT INTO stocks VALUES('00000053',"Bulls & Bears",553.40);
+INSERT INTO stocks VALUES('00000343',"HGHU",456.00);
+INSERT INTO stocks VALUES('00000603',"TTTM",77.00);
+INSERT INTO stocks VALUES('00000463',"GRASF",88.00);
+commit;
+
+
+
+
Propchange: geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/sql/db.sql
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,56 @@
+/*
+* Licensed to the 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 com.dev.trade.bo;
+
+public class Stock {
+ private String id = null;
+ private String name = null;
+ private float price = 0.0f;
+ private int quantity = 0;
+
+ public Stock(String id, String name, float price, int quantity) {
+ this.id = id;
+ this.name = name;
+ this.price = price;
+ this.quantity = quantity;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public float getPrice() {
+ return price;
+ }
+ public void setPrice(float price) {
+ this.price = price;
+ }
+ public int getQuantity() {
+ return quantity;
+ }
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+}
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/Stock.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,68 @@
+/*
+* Licensed to the 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 com.dev.trade.bo;
+
+public class User {
+
+ private String userId = null;
+ private String name = null;
+ private String password = null;
+ private String address = null;
+ private float cash = 0f;
+
+ public User(String userId,String name,String password,String address,float cash){
+ this.userId = userId;
+ this.name = name;
+ this.password = password;
+ this.address = address;
+ this.cash = cash;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public String getUserId() {
+ return userId;
+ }
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public float getCash() {
+ return cash;
+ }
+
+ public void setCash(float cash) {
+ this.cash = cash;
+ }
+
+}
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/bo/User.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,354 @@
+/*
+* Licensed to the 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 com.dev.trade.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import com.dev.trade.bo.Stock;
+import com.dev.trade.bo.User;
+import com.dev.trade.exception.DBException;
+
+public class TradeDAO {
+ private Connection con;
+
+ public TradeDAO() throws Exception {
+ try {
+ InitialContext initialContext = new InitialContext();
+ Context envCtx = (Context) initialContext.lookup("java:comp/env");
+ DataSource ds = (DataSource) envCtx.lookup("jdbc/TradeDB");
+ con = ds.getConnection();
+ } catch (Exception ex) {
+ throw new Exception("Couldn't open connection to database: "
+ + ex.getMessage());
+ }
+ }
+
+ public User getUserByUserId(String userId) throws DBException {
+
+ User user = null;
+ try {
+ String query = "select * from users where userid = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, userId);
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ user = new User(rs.getString(1), rs.getString(2), rs
+ .getString(3), rs.getString(4), rs.getFloat(5));
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+
+ return user;
+ }
+
+ public List getUserStocks(String userId) throws DBException {
+ List stocks = new ArrayList();
+ try {
+ String query = "select A.quantity,A.stockid,B.name,B.price from TradingAccount A,stocks B where A.userid = ? and A.stockid = B.id";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, userId);
+ Stock stock = null;
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ stock = new Stock(rs.getString(2), rs.getString(3), rs
+ .getFloat(4), rs.getInt(1));
+ stocks.add(stock);
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ return stocks;
+ }
+
+ public List getStocks() throws DBException {
+ List stocks = new ArrayList();
+ try {
+ String query = "select * from stocks";
+ PreparedStatement pStmt = con.prepareStatement(query);
+
+ Stock stock = null;
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ stock = new Stock(rs.getString(1), rs.getString(2), rs
+ .getFloat(3), 0);
+ stocks.add(stock);
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ return stocks;
+ }
+
+ public float getUserCash(String userId) throws DBException {
+ float cash = 0;
+ try {
+ String query = "select cash from users where userid = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, userId);
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ cash = rs.getFloat("cash");
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ return cash;
+ }
+
+ public boolean buyStock(String userId, String stockId, int quantity)
+ throws DBException {
+ float cashAvailable = getUserCash(userId);
+ float costOfStock = getStockPrice(stockId);
+ float totalCost = costOfStock * quantity;
+ int availableStock = getStockQuantityForUser(userId, stockId);
+ cashAvailable = cashAvailable - totalCost;
+ availableStock = availableStock + quantity;
+ if (cashAvailable >= 0 && (availableStock != quantity)) {
+ try {
+ con.setAutoCommit(false);
+ if (setUserCash(userId, cashAvailable)
+ && setUserStock(userId, stockId, availableStock)) {
+ con.commit();
+ } else {
+ con.rollback();
+ }
+ con.setAutoCommit(true);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new DBException(e.getMessage());
+ }
+ } else if (cashAvailable >= 0 && (availableStock == quantity)) {
+ try {
+ con.setAutoCommit(false);
+ if (setUserCash(userId, cashAvailable)
+ && addUserStock(userId, stockId, availableStock)) {
+ con.commit();
+ } else {
+ con.rollback();
+ }
+ con.setAutoCommit(true);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new DBException(e.getMessage());
+ }
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean sellStock(String userId, String stockId, int quantity)
+ throws DBException {
+ float cashAvailable = getUserCash(userId);
+ float costOfStock = getStockPrice(stockId);
+ float totalCost = costOfStock * quantity;
+ int availableStock = getStockQuantityForUser(userId, stockId);
+ cashAvailable = cashAvailable + totalCost;
+ availableStock = availableStock - quantity;
+ if (availableStock >= 0) {
+ try {
+ con.setAutoCommit(false);
+ if (setUserCash(userId, cashAvailable)
+ && setUserStock(userId, stockId, availableStock)) {
+ con.commit();
+ } else {
+ con.rollback();
+ }
+ con.setAutoCommit(true);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new DBException(e.getMessage());
+ }
+
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ public float getStockPrice(String stockId) throws DBException {
+ float stockPrice = 0f;
+ try {
+ String query = "select price from stocks where id = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, stockId);
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ stockPrice = rs.getFloat("price");
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+
+ return stockPrice;
+ }
+
+ private boolean setUserCash(String userId, float cash) throws DBException {
+ int status = 0;
+ try {
+ String query = "update users set cash = ? where userid = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setFloat(1, cash);
+ pStmt.setString(2, userId);
+ status = pStmt.executeUpdate();
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ if (status == 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ // buy = true sell = false
+ private boolean setUserStock(String userId, String stockId, int quantity)
+ throws DBException {
+ int existingQuantity = 0;
+ int status = 0;
+
+ try {
+ String query = "update TradingAccount set quantity = ? where stockid = ? and userid = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setInt(1, quantity);
+ pStmt.setString(2, stockId);
+ pStmt.setString(3, userId);
+ status = pStmt.executeUpdate();
+ pStmt.close();
+ query = "delete from TradingAccount where quantity = ?";
+ pStmt = con.prepareStatement(query);
+ pStmt.setInt(1, 0);
+ pStmt.executeUpdate();
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ if (status == 0) {
+ return false;
+ } else {
+ return true;
+ }
+
+ }
+
+ private boolean addUserStock(String userId, String stockId, int quantity)
+ throws DBException {
+
+ int status = 0;
+ try {
+ String query = "insert into TradingAccount values (?,?,?)";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setInt(3, quantity);
+ pStmt.setString(2, stockId);
+ pStmt.setString(1, userId);
+ status = pStmt.executeUpdate();
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ if (status == 0) {
+ return false;
+ } else {
+ return true;
+ }
+
+ }
+
+ public int getStockQuantityForUser(String userId, String stockId)
+ throws DBException {
+ int existingQuantity = 0;
+
+ try {
+ String query = "select quantity from TradingAccount where userid = ? and stockid = ?";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, userId);
+ pStmt.setString(2, stockId);
+ ResultSet rs = pStmt.executeQuery();
+ while (rs.next()) {
+ existingQuantity = rs.getInt("quantity");
+ }
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ return existingQuantity;
+ }
+
+ public boolean addUser(String userId, String name, String password,
+ String address, float cash) throws DBException {
+ int status = 0;
+
+ try {
+ String query = "insert into users values (?,?,?,?,?)";
+ PreparedStatement pStmt = con.prepareStatement(query);
+ pStmt.setString(1, userId);
+ pStmt.setString(2, name);
+ pStmt.setString(3, password);
+ pStmt.setString(4, address);
+ pStmt.setFloat(5, cash);
+ status = pStmt.executeUpdate();
+ pStmt.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new DBException(ex.getMessage());
+ }
+ if (status == 0) {
+ return false;
+ } else {
+ return true;
+ }
+
+ }
+
+ public void remove() throws DBException {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+
+ throw new DBException(ex.getMessage());
+ }
+ }
+
+}
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/dao/TradeDAO.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java?rev=636529&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java (added)
+++ geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java Wed Mar 12 14:54:41 2008
@@ -0,0 +1,26 @@
+/*
+* Licensed to the 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 com.dev.trade.exception;
+
+public class DBException extends Exception {
+public DBException(){
+super();
+}
+public DBException(String message){
+ super(message);
+ }
+}
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/samples/branches/1.0/migration-jdbc/src/com/dev/trade/exception/DBException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain