Source Code Cross Referenced for Main.java in  » IDE-Netbeans » usersguide » cmporderclient » 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 » IDE Netbeans » usersguide » cmporderclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005 Sun Microsystems, Inc.  All rights reserved.  U.S.
003:         * Government Rights - Commercial software.  Government users are subject
004:         * to the Sun Microsystems, Inc. standard license agreement and
005:         * applicable provisions of the FAR and its supplements.  Use is subject
006:         * to license terms.
007:         *
008:         * This distribution may include materials developed by third parties.
009:         * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
010:         * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
011:         * other countries.
012:         *
013:         * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
014:         *
015:         * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
016:         * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
017:         * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
018:         * en vigueur de la FAR (Federal Acquisition Regulations) et des
019:         * supplements a celles-ci.  Distribue par des licences qui en
020:         * restreignent l'utilisation.
021:         *
022:         * Cette distribution peut comprendre des composants developpes par des
023:         * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
024:         * sont des marques de fabrique ou des marques deposees de Sun
025:         * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
026:         */
027:
028:        package cmporderclient;
029:
030:        import java.rmi.RemoteException;
031:        import java.text.MessageFormat;
032:        import java.util.Collection;
033:        import java.util.Iterator;
034:        import javax.naming.*;
035:        import javax.rmi.PortableRemoteObject;
036:        import request.*;
037:
038:        public class Main {
039:            private static OrderRequest orderRequest;
040:            private static MessageFormat mf = new MessageFormat(
041:                    ": {0, number, $#,##0.##}");
042:
043:            public static void main(String[] args) {
044:                try {
045:                    Context initial = new InitialContext();
046:
047:                    Object objref = initial.lookup("ejb/RequestBean");
048:                    RequestRemoteHome home = (RequestRemoteHome) PortableRemoteObject
049:                            .narrow(objref, RequestRemoteHome.class);
050:
051:                    RequestRemote request = home.create();
052:
053:                    createData(request);
054:                    printData(request);
055:                } catch (Exception ex) {
056:                    System.err.println("Caught an exception:");
057:                    ex.printStackTrace();
058:                }
059:            }
060:
061:            private static void createData(RequestRemote request) {
062:                try {
063:                    request.createPart(new PartRequest("1234-5678-01", 1,
064:                            "ABC PART", new java.util.Date(),
065:                            "PARTQWERTYUIOPASXDCFVGBHNJMKL", null));
066:                    request.createPart(new PartRequest("9876-4321-02", 2,
067:                            "DEF PART", new java.util.Date(),
068:                            "PARTQWERTYUIOPASXDCFVGBHNJMKL", null));
069:                    request.createPart(new PartRequest("5456-6789-03", 3,
070:                            "GHI PART", new java.util.Date(),
071:                            "PARTQWERTYUIOPASXDCFVGBHNJMKL", null));
072:                    request.createPart(new PartRequest("ABCD-XYZW-FF", 5,
073:                            "XYZ PART", new java.util.Date(),
074:                            "PARTQWERTYUIOPASXDCFVGBHNJMKL", null));
075:                    request.createPart(new PartRequest("SDFG-ERTY-BN", 7,
076:                            "BOM PART", new java.util.Date(),
077:                            "PARTQWERTYUIOPASXDCFVGBHNJMKL", null));
078:
079:                    request.addPartToBillOfMaterial(new BomRequest(
080:                            "SDFG-ERTY-BN", 7, "1234-5678-01", 1));
081:                    request.addPartToBillOfMaterial(new BomRequest(
082:                            "SDFG-ERTY-BN", 7, "9876-4321-02", 2));
083:                    request.addPartToBillOfMaterial(new BomRequest(
084:                            "SDFG-ERTY-BN", 7, "5456-6789-03", 3));
085:                    request.addPartToBillOfMaterial(new BomRequest(
086:                            "SDFG-ERTY-BN", 7, "ABCD-XYZW-FF", 5));
087:
088:                    request.createVendor(new VendorRequest(100, "WidgetCorp",
089:                            "111 Main St., Anytown, KY 99999", "Mr. Jones",
090:                            "888-777-9999"));
091:                    request.createVendor(new VendorRequest(200, "Gadget, Inc.",
092:                            "123 State St., Sometown, MI 88888", "Mrs. Smith",
093:                            "866-345-6789"));
094:
095:                    request.createVendorPart(new VendorPartRequest(
096:                            "1234-5678-01", 1, "PART1", 100.00, 100));
097:                    request.createVendorPart(new VendorPartRequest(
098:                            "9876-4321-02", 2, "PART2", 10.44, 200));
099:                    request.createVendorPart(new VendorPartRequest(
100:                            "5456-6789-03", 3, "PART3", 76.23, 200));
101:                    request.createVendorPart(new VendorPartRequest(
102:                            "ABCD-XYZW-FF", 5, "PART4", 55.19, 100));
103:                    request.createVendorPart(new VendorPartRequest(
104:                            "SDFG-ERTY-BN", 7, "PART5", 345.87, 100));
105:
106:                    Integer orderId = new Integer(1111);
107:                    request.createOrder(new OrderRequest(orderId, 'N', 10,
108:                            "333 New Court, NewCity, CA 90000"));
109:                    request.addLineItem(new LineItemRequest(orderId,
110:                            "1234-5678-01", 1, 3));
111:                    request.addLineItem(new LineItemRequest(orderId,
112:                            "9876-4321-02", 2, 5));
113:                    request.addLineItem(new LineItemRequest(orderId,
114:                            "ABCD-XYZW-FF", 5, 7));
115:
116:                    orderId = new Integer(4312);
117:                    request.createOrder(new OrderRequest(orderId, 'N', 0,
118:                            "333 New Court, NewCity, CA 90000"));
119:                    request.addLineItem(new LineItemRequest(orderId,
120:                            "SDFG-ERTY-BN", 7, 1));
121:                    request.addLineItem(new LineItemRequest(orderId,
122:                            "ABCD-XYZW-FF", 5, 3));
123:                    request.addLineItem(new LineItemRequest(orderId,
124:                            "1234-5678-01", 1, 15));
125:                } catch (Exception ex) {
126:                    System.err.println("Caught an exception:");
127:                    ex.printStackTrace();
128:                }
129:            }
130:
131:            private static void printData(RequestRemote request) {
132:                try {
133:                    BomRequest bomRequest = new BomRequest("SDFG-ERTY-BN", 7,
134:                            null, 0);
135:                    double price = request.getBillOfMaterialPrice(bomRequest);
136:                    System.out.println("Cost of Bill of Material for PN "
137:                            + bomRequest.bomPartNumber + " Rev: "
138:                            + bomRequest.bomRevision
139:                            + mf.format(new Object[] { new Double(price) }));
140:
141:                    printCostOfOrders(request);
142:
143:                    System.out.println("\nAdding 5% discount");
144:                    request.adjustOrderDiscount(5);
145:                    printCostOfOrders(request);
146:
147:                    System.out.println("\nRemoving 7% discount");
148:                    request.adjustOrderDiscount(-7);
149:                    printCostOfOrders(request);
150:
151:                    java.lang.Double price0 = request.getAvgPrice();
152:
153:                    if (price0 == null) {
154:                        System.out.println("\nNo parts found");
155:                    } else {
156:                        System.out.println("\nAverage price of all parts"
157:                                + mf.format(new Object[] { price0 }));
158:                    }
159:
160:                    VendorRequest vendorRequest = new VendorRequest(100, null,
161:                            null, null, null);
162:                    price0 = request.getTotalPricePerVendor(vendorRequest);
163:
164:                    if (price0 == null) {
165:                        System.out.println("\nNo parts found for Vendor "
166:                                + vendorRequest.vendorId);
167:                    } else {
168:                        System.out.println("\nTotal price of parts for Vendor "
169:                                + vendorRequest.vendorId + ""
170:                                + mf.format(new Object[] { price0 }));
171:                    }
172:
173:                    System.out
174:                            .println("\nOrdered list of vendors for order 1111");
175:                    System.out.println(request
176:                            .reportVendorsByOrder(new Integer(1111)));
177:
178:                    System.out.println("Counting all line items");
179:
180:                    int count = request.countAllItems();
181:                    System.out.println("Found " + count + " line items");
182:
183:                    System.out.println("\nRemoving Order");
184:                    request.removeOrder(new Integer(4312));
185:                    count = request.countAllItems();
186:                    System.out.println("Found " + count + " line items");
187:
188:                    Collection names = request.locateVendorsByPartialName("I");
189:                    System.out.println("\nFound " + names.size()
190:                            + " out of 2 vendors with 'I' in the name:");
191:
192:                    for (Iterator it = names.iterator(); it.hasNext();) {
193:                        System.out.println(it.next());
194:                    }
195:                } catch (Exception ex) {
196:                    System.err.println("Caught an exception:");
197:                    ex.printStackTrace();
198:                }
199:            }
200:
201:            private static void printCostOfOrders(RequestRemote request)
202:                    throws RemoteException {
203:                Integer orderId = new Integer(1111);
204:                double price = request.getOrderPrice(orderId);
205:                System.out.println("Cost of Order " + orderId
206:                        + mf.format(new Object[] { new Double(price) }));
207:
208:                orderId = new Integer(4312);
209:                price = request.getOrderPrice(orderId);
210:                System.out.println("Cost of Order " + orderId
211:                        + mf.format(new Object[] { new Double(price) }));
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.