Source Code Cross Referenced for PhoneListImpl.java in  » J2EE » Enhydra-Demos » phoneList » business » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » phoneList.business 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package phoneList.business;
002:
003:        import phoneList.spec.*;
004:
005:        import java.util.Vector;
006:        import phoneList.business.axis.*;
007:
008:        /**
009:         * PhoneList defines a set of static methods that are used
010:         * to query and update phone information in the database.
011:         */
012:        public class PhoneListImpl implements  phoneList.spec.PhoneList {
013:
014:            public static boolean configured = false;
015:            private static String server = "localhost";
016:            private static String port = "9000";
017:            private static String HTTP = "http://";
018:            private static char COLON = ':';
019:            private static String PHONEBOOK = "/phoneBook/PhoneBook";
020:            private static PhoneListService service = new PhoneListServiceLocator();
021:            private static phoneList.business.axis.PhoneList phoneBook;
022:
023:            /**
024:             * Get current server
025:             * @return server
026:             */
027:
028:            public String getServer() {
029:                return server;
030:            }
031:
032:            /**
033:             * Get current port
034:             * @return port
035:             */
036:
037:            public String getPort() {
038:                return port;
039:            }
040:
041:            /**
042:             * Sets Server and port and
043:             * generates a new phoneList.business.axis.PhoneList accordingly
044:             *
045:             * @param srv the server name.
046:             * @param prt the server port.
047:             */
048:
049:            public void setServerUrl(String srv, String prt) throws Exception {
050:                phoneBook = service.getPhoneBook(new java.net.URL(HTTP + srv
051:                        + COLON + prt + PHONEBOOK));
052:                server = srv;
053:                port = prt;
054:            }
055:
056:            /**
057:             * Queries the database for all people/phones.
058:             *
059:             * @return Vector[0] contains the people's first names.
060:             *   Vector[1] contains the people's last names.
061:             *   Vector[2] contains the phone numbers.
062:             *   Vector[3] contains the people's identifiers.
063:             * @exception Exception all exceptions are thrown whenever an
064:             *   error occurs.
065:             */
066:
067:            public Vector[] getLists() throws Exception {
068:                Vector[] results = new Vector[4];
069:                Object[][] resultStrings = phoneBook.getLists();
070:                if (resultStrings.length == 1) {
071:                    //case of jonas - axis implementation
072:                    for (int j = 0; j < resultStrings[0].length; j++) {
073:                        results[j] = new Vector();
074:                        Vector temp = (Vector) resultStrings[0][j];
075:                        for (int k = 0; k < temp.size(); k++) {
076:                            if (temp.elementAt(k) != null)
077:                                results[j].add((String) temp.elementAt(k));
078:                        }
079:                    }
080:                } else {
081:                    for (int i = 0; i < resultStrings.length; i++) {
082:                        results[i] = new Vector();
083:                        for (int j = 0; j < resultStrings[i].length; j++) {
084:                            if (resultStrings[i][j] != null)
085:                                results[i].add((String) resultStrings[i][j]);
086:                        }
087:                    }
088:                }
089:                return results;
090:            }
091:
092:            /**
093:             * Creates a new person and adds him/her to the database.
094:             * Demonstrates how to use a
095:             * transaction to insert data into the database.
096:             *
097:             * @param firstName the person's first name.
098:             * @param lastName the person's last name.
099:             * @param phoneNumber the person's phone number.
100:             *
101:             * @exception Exception all exceptions are thrown.  A more
102:             *   robust application would handle them.....
103:             */
104:
105:            public void addPerson(String firstName, String lastName,
106:                    String phoneNumber) throws Exception {
107:                phoneBook.addPerson(firstName, lastName, phoneNumber);
108:            }
109:
110:            /**
111:             * Deletes a person from the database.  Demonstrates how to use a
112:             * transaction to delete data in the database.
113:             *
114:             * @param id the person's id
115:             *
116:             * @exception Exception all exceptions are thrown.  A more
117:             *   robust application would handle them.....
118:             */
119:            public void deletePerson(String id) throws Exception {
120:                phoneBook.deletePerson(id);
121:            }
122:
123:            /**
124:             * Modifies a person's profile.  Demonstrates how to use a
125:             * transaction to update data in the database.
126:             *
127:             * @param id the person's id
128:             * @param newFirstName the person's new first name.
129:             * @param newLastName the person's new last name.
130:             * @param newPhoneNumber the person's new phone number.
131:             *
132:             * @exception Exception all exceptions are thrown.  A more
133:             *   robust application would handle them.....
134:             */
135:            public void modifyPerson(String id, String newFirstName,
136:                    String newLastName, String newPhoneNumber) throws Exception {
137:                phoneBook.modifyPerson(id, newFirstName, newLastName,
138:                        newPhoneNumber);
139:            }
140:
141:            /**
142:             * Queries a person from the database.
143:             *
144:             * @param id the person's id.
145:             * @exception Exception all exceptions are thrown.  A more
146:             *   robust applications would handle them.....
147:             */
148:            public Person getById(String id) throws Exception {
149:                String[] personData = phoneBook.getPersonData(id);
150:                PersonImpl person = new PersonImpl(personData[0],
151:                        personData[1], personData[2], id);
152:                return person;
153:
154:            }
155:
156:            /**
157:             *Is configarated
158:             */
159:            public boolean isConfigured() {
160:                return configured;
161:            }
162:
163:            /**
164:             *Sets the parameter configured to true
165:             */
166:            public void setConfigured() {
167:                configured = true;
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.