1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.samples;
24
25 import java.util.GregorianCalendar;
26
27 import de.bea.domingo.DDatabase;
28 import de.bea.domingo.DDocument;
29 import de.bea.domingo.DNotesFactory;
30 import de.bea.domingo.DRichTextItem;
31 import de.bea.domingo.DSession;
32 import de.bea.domingo.monitor.AbstractMonitor;
33 import de.bea.domingo.monitor.ConsoleMonitor;
34
35 /***
36 * This example creates a new database on a server and creates a huge number of
37 * documents to test proper recycling thru a Corba connection.
38 *
39 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
40 */
41 public class CorbaCreateManyDocuments {
42
43 /***
44 * Main method.
45 *
46 * @param args command line arguments: host username password
47 */
48 public static final void main(final String[] args) {
49 if (args.length != 3) {
50 System.out.println("Arguments: host username password");
51 return;
52 }
53 try {
54 ConsoleMonitor monitor = new ConsoleMonitor();
55 monitor.setLevel(AbstractMonitor.DEBUG);
56 DNotesFactory factory = DNotesFactory.getInstance(monitor);
57 DSession session = factory.getSession(args[0], args[1], args[2]);
58 DDatabase database = session.createDatabase("", "many.nsf");
59 monitor.debug("Database many.nsf created on server " + args[0]);
60 for (int i = 0; i < 30; i++) {
61 for (int j = 0; j < 1000; j++) {
62 DDocument document = database.createDocument();
63 document.replaceItemValue("Form", "Test");
64 document.replaceItemValue("Test", "Test");
65 document.replaceItemValue("Number", 1.1234);
66 document.replaceItemValue("Date", new GregorianCalendar(2007, 01, 01, 17, 30, 00));
67 DRichTextItem item = document.createRichTextItem("Body");
68 item.appendText("some rich text");
69 item.addNewLine(2);
70 item.appendText("some more text");
71 document.save();
72 }
73 monitor.debug("Created " + ((i + 1) * 1000) + " documents");
74 }
75 monitor.debug("finished successfully.");
76 } catch (Throwable e) {
77 e.printStackTrace();
78 }
79 }
80 }