| FileEventClient.java |
1 /**
2 * Created on May 28, 2003
3 *
4 * To demo the client side of the interfaces in which a
5 * simple Client event results in the full exchange of files
6 * amoung various systems that need to exchange file-based data.
7 */
8
9 /*
10 * Copyright (C) 2003 robert rowntree
11
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21
22 * ref. http://www.gnu.org/copyleft/gpl.html
23*/
24package com.borneo.client;
25
26import com.borneo.po.event.FileTopicHandler;
27import com.borneo.po.event.FileTopicType;
28import com.borneo.po.event.FileTopicEvent;
29import com.borneo.po.event.FileTopicEventFactory;
30
31import com.borneo.util.FileSelector;
32
33/** CLIENT-SIDE DATA-EVENT WRAPPER - Data inside wrapper was just
34 * created and will be published. Create an event that wraps the
35 * data and then fire the event.
36 * <p>Event handlers will take care of
37 * subsequent process that will post the data to a daemon running
38 * on some "distribution service". The dist service functions like
39 * a standard "publisher" and will be responsible for all activities
40 * that distribute the data to all subscribers.</p>
41 * @author r
42 *
43 * @args are delegated to another class
44 * for description of command-line arguments see below:
45 * class=com.borneo.po.event.FileTopicType
46 * method=init
47 *
48 * The Listener Implementation is independent of the Event.
49 * This allows for variety of behavior on the Client in response to
50 * the "FileCreated" events. For example, the demo's listener uses a
51 * "push" of the Topic, FileName, and the DataHandle to the server.
52 * Alternate listen implementation might push an event with only the FileName(s)
53 * in which case the Server's implementation would have to respond with a
54 * "pull" request to actually get the files up there. This "pull" idea allows
55 * extra processing where the response to the file creation event is a server
56 * notify , followed by DB lookups. The lookups might, for
57 * example, determine that the server is to use an "SSH" pull to acquire the
58 * just created files from the client machine. Alternatively, the lookups could
59 * result in a third-party transfer being started somewhere else using Globus
60 * protocol to direct a peer-to-peer transfer direct between source and target
61 * servers.
62 * TODO Note that the
63 * design permits a scenario where the trigger for the event is
64 * the insertion of an XML Root Node into a table containing "publishable"
65 * chunks of XML. In this case the event signal's that the client has XML
66 * Node that needs to go remote machine(s) for consumption.
67 * To accomplish this you abstract the FileTopic interface to a
68 * "ClientPublish" interface where the handle for what your
69 * about to publish is an abstraction that wraps either a resultSet
70 * or a File...
71 */
72/* TODO
73 * Scalability ?? The event creation should be isolated ( separate thread )
74 * from the handler responsible for processing the connection
75 * and for moving the files.
76 * fixme the code below is not quite correct behavior
77 * why? the code below constructs a new instance that
78 * almost immediately afterward, becomes the source of the event.
79 * What you want is a more durable object in the VM on
80 * or very near the client machine that
81 * receives a message from this client. Message attrs.
82 * include the topic and the Filname that i want to publish.
83 * The durable object already has a reference to the event
84 * source. The event source has already been told of
85 * registered listeners to notify on the event.
86 * All it has to do is respond to the request to publish...
87 * endOF TODO
88*/
89public class FileEventClient {
90
91 public static void main(String[] args) {
92
93 FileTopicType ftype = new FileTopicType(args);
94 FileTopicEvent ftevent = new FileTopicEventFactory().create(ftype);
95 ftevent.addActionListener( new FileTopicHandler() );
96 ftevent.fireActionEvent();
97 }
98
99}
00