|
James -- I would say the latter. If you look in the javadoc for the AS400File class, it says "AS400File objects generate the following events: FileEvent ..." When you add a listener via AddFileListener, you are adding a listener to the AS400File object, not to the iSeries file itself. Whenever a change is made THROUGH the AS400File object, your listener will be fired. But, changes made to the file from other sources won't fire your listener because those other sources don't know anything about your listener. The AS400File object doesn't have any sort of capability to sit on a file and watch for changes and then fire your listener. About all I can think of off the top of my head to accomplish what you want is to set up some type of journal receiver exit program that would fire your listener whenever a change is made. This, of course, requires journalling the file. HTH, Gary > -----Original Message----- > From: java400-l-bounces@xxxxxxxxxxxx > [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James H H Lampert > Sent: Monday, December 13, 2004 9:42 AM > To: java400-l@xxxxxxxxxxxx > Subject: Monitoring a file for changes from Java? > > I note that the Toolbox has a FileListener interface, and the > AS400File class has an AddFileListener method. > > I tried implementing the interface from my test class, and > while I then received a "FileOpened" event as soon as the > test class opened the file, that was about all I got. I was > hoping to receive a "FileModified" event when I updated a > record from QuestView in another terminal session, but it > didn't get ANY events from actions taken elsewhere. > > Am I doing something wrong, or do I just have unrealistically > high expectations? > > The test class now looks like: > import com.ibm.as400.access.*; > class test03 implements FileListener { > public static void main (String args[]) { > System.out.println("I like spam!"); > AS400 as400 = new AS400("localhost"); > System.out.println("CCSID = " + as400.getCcsid()); > QSYSObjectPathName fileName = new > QSYSObjectPathName("AQUESTVIEW", "VIEWCUS", "FILE"); > System.out.println("Filename = " + fileName.getPath()); > SequentialFile file = new SequentialFile(as400, > fileName.getPath()); > file.addFileListener(new test03()); > AS400FileRecordDescription recDes = new > AS400FileRecordDescription(as400, fileName.getPath()); > try { > RecordFormat recFmt = recDes.retrieveRecordFormat()[0]; > System.out.println("Format = " + recFmt.getName()); > file.setRecordFormat(recFmt); > file.open(SequentialFile.READ_ONLY, 1, > SequentialFile.COMMIT_LOCK_LEVEL_NONE); > Record data = file.readNext(); > while (data != null) { > System.out.println((String) data.getField("CUNAME")); > data = file.readNext(); > } > System.out.println("Going to sleep"); > try {Thread.sleep((long)60000);} > catch(InterruptedException > ie) {System.out.println("Interrupted");} > System.out.println("Waking up!"); > as400.disconnectAllServices(); > } catch (Exception e) {e.printStackTrace();} > } > > -- > JHHL > > > -- > This is the Java Programming on and around the iSeries / > AS400 (JAVA400-L) mailing list To post a message email: > JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change > list options, > visit: http://lists.midrange.com/mailman/listinfo/java400-l > or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, > please take a moment to review the archives at > http://archive.midrange.com/java400-l. >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.