Generate event when file contents change
I should be informed (an event should be generated) when contents of a file changes .
How should I implement this using java
I did something along the lines in one of my projects. Basically it came down to the following:
Create a FileChangeMonitor class that can register listeners for changes in certain files. This class starts a thread that checks the timestamps of the registered files once in a while. When a change is detected, an event will be fired to the listener.
I can send you the code, but I first have to find the correct backup CD it is on...
Cheers,
--Arnout
Similar Messages
-
Generate event when stack changed
I have a task develop a class Stack that generate event when you add new element ? Develop a class Stack is not a problem, what means event that apears when a new element is added ?[
That about awt / swing ..or I can to apply listeners
to My Stack ?Sorry, I thought there were also non-GUI examples there. Apparently not.
It's probably the intention to implement the observer pattern into your code.
Here's a small demo of how this can be done:import java.util.List;
import java.util.ArrayList;
class Main {
public static void main(String[] args) {
MagazinePublisher publisher = new MagazinePublisher();
Subscriber carl = new Subscriber("Carl");
Subscriber pete = new Subscriber("Pete");
Subscriber zeke = new Subscriber("Zeke");
publisher.registerObservers(carl);
publisher.registerObservers(pete);
// whenever the state of the 'publisher' changes, it's
// subscribers should be notified
publisher.notifyObservers();
publisher.registerObservers(zeke);
publisher.notifyObservers();
publisher.removeObservers(pete);
publisher.removeObservers(carl);
publisher.notifyObservers();
interface MyObserver {
void update(int edition);
interface MySubject {
void registerObservers(MyObserver mo);
void removeObservers(MyObserver mo);
void notifyObservers();
class MagazinePublisher implements MySubject {
List<MyObserver> observers;
int edition;
public MagazinePublisher() {
observers = new ArrayList<MyObserver>();
edition = 1;
public void notifyObservers() {
for(MyObserver mo : observers) {
mo.update(edition);
edition++;
public void registerObservers(MyObserver mo) {
observers.add(mo);
public void removeObservers(MyObserver mo) {
observers.remove(mo);
class Subscriber implements MyObserver {
String name;
public Subscriber(String n) {
name = n;
public boolean equals(Object o) {
return this.name.equals(((Subscriber)o).name);
public void update(int e) {
System.out.println(name+" recieved a copy of the "+e+" edition!");
// hashCode() and other methods ...
}Details about this design pattern:
http://en.wikipedia.org/wiki/Observer_pattern
or Google, of course:
http://www.google.com/search?hl=en&q=Observer+pattern&btnG=Google+Search
Good luck! -
Help using app_standard.event(when-tab-page-changed')
Hello ,
I need to create a form with the following requirements . There is one content canvas which contains a tabbed canvas and on this there are two stacked canvases .
The problem is that when I compile my form and ftp to oebs , I cannot view the tab pages on the canvas .
I see only my the fields displayed in the first tab page without the 'tab pages'.
How do I solve this issue please ?
My when-page-page-trigger contains the following :
BEGIN
APP_STANDARD.EVENT('WHEN-TAB-PAGE-CHANGED');
if name_in('system.cursor_block') = 'XX_ERROR_MANAGEMENT' then
if not form_success then
-- Revert tab to prior value and exit
set_canvas_property('CAN_INT',topmost_tab_page,name_in('system.tab_previous_page'));
return;
end if;
-- Move to first item on each tab
if target_canvas_name = 'CAN_INT' then
SHOW_VIEW('CAN_ONG1');
go_item('XX_ERROR_MANAGEMENT.INTERFACE_TYPE');
else
show_view(target_canvas_name);
end if;
END IF;
END;
Any help will be much appreciated . Thanks .bump
-
Revision: 11112
Author: [email protected]
Date: 2009-10-23 12:35:31 -0700 (Fri, 23 Oct 2009)
Log Message:
DatGroup and SkinnableDataContainer dispatch a "dataProviderChanged" event when the dataProvder changes. Fixed a ScrollerLayout typo.
QE notes:
Doc notes: none
Bugs: sdk-23489
Reviewer: Ryan
Tests run: DataGroup
Is noteworthy for integration: no
Ticket Links:
http://bugs.adobe.com/jira/browse/sdk-23489
Modified Paths:
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DataGroup.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/SkinnableDataContainer.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ScrollerLayo ut.as -
Why shared variable generates events when I write constant value?
Hello all,
I'm using LV 8.5 with DSC packet.
I modified "DSC Events Demo".vi and made a test. I noticed that only variable which work okay is double typed. Why this code generate events all the time when I write constant values to shared variables? Double is okay, but string and boolean types not work okay. Is there any other people how have noticed same symption?
Attachments:
modified_dsc_event_demo1.zip 391 KBYou may get an initial event on startup which is normal. Also make sure that you have not enabled timestamp change events.
-
How to catch an event when the user change values in the project information dialog
hi,
i would like to know how to catch an event in my C# code when the user change values in the project information dialog?
taskChange doesn't catch these changes.
thanks.
Thanks, Sharon.You need to write save button event handler for project information dialog. Link is having same functionality described.
http://blogs.msdn.com/b/husainzgh/archive/2011/08/01/hooking-into-the-project-detail-page-ribbon-save-button-without-overriding-out-of-box-functionality-in-project-web-access-for-project-server-2010.aspx
http://www.projectserver2010blog.com/2010/01/sharepoint-2010-webpart-client-server.html
kirtesh -
How to perform an autocheck event when the field changes in ALV
Hi everybody,
how can I build an event or something which would make my 'wa_fieldcat-checkbox' set to 'X' (auto checked) everytime an editable field in the ALV is changed manually by the user?
I want to perform this task in order to avoid asking the user to manually check the "check box" field everytime wants to make a change, since after the user's changes in the ALV I want to sort the itab with the check box column of the edited items.
Thanks,
Denis MHi Denis,
For ALV a FM REUSE_ALV_GRID_DISPLAY is available.
The FM, has events as importing option.
SLIS_T_EVENT
EVENT - Basically this is the FM to handle Event's. When the user needs to do
some event operation like when double clicking the a particular field we need to
perform some operation. These events are captured by this FM.
slis_ev_data_changed -- To capture user command
slis_ev_user_command -- To capture data changed.
Also please refer the below link in scn. This shows sample code to capture ALV grid data changed.
http://scn.sap.com/thread/261210
Hope this will solve the problem.
Thanks,
Soundarya. -
How to trigger a event when WBS gets changed in Cj02
Hello,
I have a requirement where I need to send create an idoc and send the idoc to external system when WBS is created or changed. Currently, I have the following setup:
- I have created a YBUS2054 as a subtype of BUS2054 using SWO1
- YBUS2054 has been delegated to BUS2054
- created an CHANGED event in the YBUS2054. This event is implemented and then released
- created a type linkage (object type=YBUS2054, event=CHANGED, receiver type null, and receiver function module = zz_create_wbs_idoc) using SWETYPV. This function is supposed to create an idoc when CHANGED event occurs. I just don't know how to trigger the event to occur.
- all the port, define idoc type, logical system, and etc are setup
- when I try to create an entry in "Event for Chagne Document" using SWEC with change doc object=PROJ, business object type = YBUS2054, with on change, I get "Key for change doc object PROJ and business object type YBUS2054 are incompatible".
I tried various configurations, and I was not successfully in creating an event on CHANGED
can you please advise what I am missing in getting the changed event to trigger?
Thank you in advance,
ShawnHi,
If the change doc doesnt exist, check if you can create an event using BSVW.
Also use the event log to see if there are other sap standard events happening.
I checked the package belonging to CJ02 to see if there is something useable, but didn't find anything: CN_PSP_OPR
If there are no sap standard ways to get an event, you'll have to find a badi/enhancement spot and include some coding to start the event using fm SAP_WAPI_CREATE_EVENT.
Kind regards, Rob Dielemans -
Automatic checkin also when file not changed?
Hi Experts,
is it possible to activate automatic checkin in easyDMS for Documents that have not been changed after checkout?
Whenever i process a checkout (out of contextmenu or by icon) and close the corresponding editor again without doing any changes, the document remains checked out until i checkin manually.
Any suggestions?
Thanks a lot!Automatic Checkin is of course possible!
It happens everytime you checkout a document and close it after doing some changes. If you have not yet saved the file, a dialog will ask whether to save or not. When choosing to save, the file is checked in automatically when closed. If you did not make any changes, automatic checkin is not processed when closing the file.
It seems that easyDMS has an eye on "change pointer" of files. To change this behaviour easyDMS should check whether document is still opened or has been closed. -
How to handle events when artboard list change in Illustrator?
It is very strange for me, but AIEvent has no event type for handle artboard list change events.
http://cssdk.host.adobe.com/sdk/1.5/docs/WebHelp/references/cshalib/com/adobe/cshostadapte r/AIEvent.html
May be there are any ideas how to get artboard events: "add", "delete", "reorder"Well, the right event type is AIEvent.DOCUMENT_CROP_AREA_MODIFIED. It is very usefull to play with EventWatcher example from Remote Creative Suite SDK Examples.
-
Dtrace Script to Generate List of Files that Changed on NFS server?
Our Solaris NFS (v3/v4) fileserver serves filesystems with a huge number of files, a relatively few of which are modified daily. Is there a dtrace script I can run on the server which would generate a list of the files that were created or modified while it was running?
Well, write something based on the rwsnoop from dtracetoolkit
http://www.dtracebook.com/index.php/File_System:rwsnoop
Then i guess we should ask ourself if its a good idea for a long term monitoring.. probably not.
.7/M. -
10.7 finder freezes when file extension changed
Hello community.
A very very annoying bug. I have saved a image from the web and renamed it without an extension. Afterwards I tried to change it to jpg in finder. Finder poped up a window asking me if I am sure. I click "use jpg" and then Finder freezed. I restarted finder and tried again, same thing happened.
As a test, then I tried to rename a .md5 file to .txt, After I confirmed in the window "use txt", Finder freezed for the third time.
Lion is not really ready. In the eye of Apple, we are just test dummies. Sorry.
Greeting!!Forgot to say, only in list mode the freeze comes up. It seems already happened in Leopard.
-
Updating cache when file is changed.
Hi all,
I am working on a "Resource Manager" module in java. What it does is :
1. Read the configuration file from a location(proerty name/value pair).
2. Loads the file properties in a cache which holds the in a CachedHashMap as Key-Value pair
The same config file which it reads looks like this:
<config>
<client>
<id>1</id>
<application>
<id>213</id>
<name> MyApp </name>
<property>
<name> key1 </name>
<value> value1 </value>
</property>
<property>
<name> key2 </name>
<value> value2 </value>
</property>
</application?
</client>
</config>This reading from config file and storing in cache I have already implemented ..
But now I have a special requirement.. If after deploying the application, I modify the file then Resource Manager should be smart enuf to detect the change and the reloads the file , cleans the cache and updates the cache..
Can you guys please through an idea on how to achieve the same??? It has to be Server Independent... I mean no JMX..
a small small code will b more useful..
Thanks in advance
PankajWhen you load the file, keep its timestamp. Every time you return an element from the cache check the file timestamp again. If it has changed, reload.
-
Generate Events based on Cache size
Hi,
I have a use case where I need to generate events when the size of the cache has reached a specific value. The cache will be highly transactions (lot of inserts and deletes totaling to 6 million transactions per day). Also, I cannot limit the size of the cache as I don't want any data to be lost (trying to insert when cache size has reached its limit).
One of the ways I could do this is to use a MapListener to generate an event on every insert to the Cache, and then check for size each time to decide if the further processing needs to be done. With the nature of the traffic in the cache, the items in the cache are to be processed when the size threshold is reached and then deleted. But, I'm not sure how much of an overhead these events and listeners will have (with 6 million items going through the cache each day)
Is there any other more efficient way to do this? I have looked at Continuous Query cache which uses a filter based on a cache. But, I'm not able to figure out a way to get the size of the cache using a filter.
Any pointers are helpful
Thanks in advance
Regards
Vikas
Edited by: vikascv on Nov 17, 2009 8:48 AMHi Vikas,
Typically a size type calculation is the cumulative result of all storage enabled nodes, i.e. a Count aggregation. In your use case you want to be made aware of changes to an aggregation but as an aggregation is point in time of request opposed to continually being updated it does not fit your use case. One option is to create a MapEventTransformer that you register with the cache which increments a counters cache (on a separate service) using an EntryProcessor, i.e.
MapEventTransformer...
public class CounterMapEventTransformer implements MapEventTransformer, PortableObject
String m_cacheName;
public CounterMapEventTransformer()
public CounterMapEventTransformer(final String cacheName)
m_cacheName = cacheName;
public MapEvent transform(MapEvent event)
Long prevCount = null;
Long currentCount = null;
switch( event.getId() )
case( MapEvent.ENTRY_INSERTED ):
// perform counter++
currentCount = (Long) CacheFactory.getCache("counters").invoke(m_cacheName, new CounterOp(true));
break;
case( MapEvent.ENTRY_DELETED ):
// perform counter--
currentCount = (Long) CacheFactory.getCache("counters").invoke(m_cacheName, new CounterOp(false));
break;
MapEvent newEvent = new MapEvent(event.getMap(), event.getId(), event.getKey(), currentCount-1, currentCount);
return newEvent;
public void writeExternal(PofWriter out) throws IOException
out.writeString(0, m_cacheName);
public void readExternal(PofReader in) throws IOException
m_cacheName = in.readString(0);
}Incrementing EP...
public class CounterOp extends AbstractProcessor implements PortableObject
boolean m_increment;
public CounterOp()
public CounterOp(boolean increment)
m_increment = increment;
@Override
public Object process(Entry entry)
Long newVal = null;
if( !entry.isPresent() )
entry.setValue(newVal = Long.valueOf(1));
else
newVal = ((Long)entry.getValue()).longValue() + (isIncrement() ? 1 : -1);
entry.setValue( newVal );
return newVal;
protected boolean isIncrement()
return m_increment;
public void writeExternal(PofWriter out) throws IOException
out.writeBoolean(0, m_increment);
public void readExternal(PofReader in) throws IOException
m_increment = in.readBoolean(0);
}cache-config
<!--
| listener-cacheconfig.xml | | Copyright 2001-2009 by Oracle. All
rights reserved. | | Oracle is a registered trademarks of Oracle
Corporation and/or its | affiliates. | | This software is the
confidential and proprietary information of Oracle | Corporation. You
shall not disclose such confidential and proprietary | information and
shall use it only in accordance with the terms of the | license
agreement you entered into with Oracle. | | This notice may not be
removed or altered.
-->
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>dist-*</cache-name>
<scheme-name>distributed-scheme</scheme-name>
</cache-mapping>
<cache-mapping>
<cache-name>counters</cache-name>
<scheme-name>counter-scheme</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<!--
Distributed caching schemes
-->
<distributed-scheme>
<scheme-name>distributed-scheme</scheme-name>
<service-name>DistributedCache</service-name>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<backing-map-scheme>
<local-scheme />
<!--
<read-write-backing-map-scheme> <internal-cache-scheme>
<local-scheme /> </internal-cache-scheme> <cachestore-scheme>
<class-scheme>
<class-name>com.oracle.coherence.cachecounter.store.CacheCounterStore</class-name>
</class-scheme> </cachestore-scheme>
</read-write-backing-map-scheme>
-->
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
<distributed-scheme>
<scheme-name>counter-scheme</scheme-name>
<service-name>CounterDistributedCache</service-name>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<backing-map-scheme>
<local-scheme />
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>pof-config...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pof-config SYSTEM "pof-config.dtd">
<pof-config>
<user-type-list>
<!-- include all of the standard Coherence type -->
<include>coherence-pof-config.xml</include>
<!-- our custom types (user types) 1000+ -->
<user-type>
<type-id>1000</type-id>
<class-name>com.oracle.coherence.cachecounter.event.CounterMapEventTransformer</class-name>
</user-type>
<user-type>
<type-id>1001</type-id>
<class-name>com.oracle.coherence.cachecounter.processors.CounterOp</class-name>
</user-type>
</user-type-list>
<allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>Test class
public class MapEventTransformerTest
public static final String m_cacheName = "dist-test1";
public static void setUp()
System.setProperty("tangosol.coherence.cacheconfig", "counter-cacheconfig.xml");
System.setProperty("tangosol.coherence.distributed.localstorage", "false");
public static void loadVals()
final NamedCache cache = CacheFactory.getCache(m_cacheName);
final int MAX_SIZE = 100;
for( int i=0; i<MAX_SIZE; i++ )
cache.put(i, "msg "+i);
public static void removeVals()
final NamedCache cache = CacheFactory.getCache(m_cacheName);
final int MAX_SIZE = 100;
for( int i=0; i<MAX_SIZE; i++ )
if( i%2==0 )
cache.remove(i);
public static void testTransformer()
final NamedCache cache = CacheFactory.getCache(m_cacheName);
cache.addMapListener(new CounterAwareListener(),
new MapEventTransformerFilter(AlwaysFilter.INSTANCE, new CounterMapEventTransformer(m_cacheName)),
false);
public static void main(String[] args) throws IOException
setUp();
testTransformer();
loadVals();
removeVals();
System.out.println("press a key to end...");
System.in.read();
public static class CounterAwareListener extends MultiplexingMapListener
@Override
protected void onMapEvent(MapEvent evt)
System.out.format( "# of items in cache: %d\n", evt.getNewValue() );
}Note: Events could be received out of order but for your use case where you are interested in a threshold you may not care! -- food for thought :)
--harvey -
Preventing scrollbars appearing when font size changes
Hi,
I have a Panel container (relative layout with now height/width specified) containing text which has its font size determined at runtime from an external stylesheet. In my application, the user has the option to change font size (ie. load a separate external stylesheet). The problem is, whenever larger font sizes are chosen, horizontal and vertical scroll bars keep appearing within my panel container. I do not want this at all, I want the panel to resize!
I've tried almost everything, including:
Calling "validateNow()" when font size changes
Launching a resize event when font size changes
Overriding the updateDisplayList method of Panel and trying to set the height and width to the newly measured height and width.
None seem to be effective. It is as if the Panel does is not able to calculate the new size when the font size changes.
Any help would be GREATLY appreciated.
Thanks.Hi,
With mx panel you can set its verticalScrollPolicy="off" horizontalScrollPolicy=""off",
David.
Maybe you are looking for
-
Transfer of material from sales order stock to subcontractor
Iam having subcontracting operation in routing. But i am not able to transfer of material from sales order stock to subcontractor when i do 541 movement
-
"Get Info" Issues when updating music without prefilled artist name, album name,etc
Hi there, trying to change track information such as artist, album name etc...when i do this, it allows me to change it on the get info tab, but then when i save it, it doesn't actually save and reverts back to no info and then in itunes, i cant sort
-
Help Secure your XML data - Solution-ish
Note: Possibly posting this in the wrong forum, Mods feel free to remove or correct. This should add a small amount of deterance to someone stealing your data by bypassing your flash .swf and just grabbing your xml file to parse themselves. File name
-
IPad mini has a dark line down middle of screen?
My iPad mini has a dark shaded line running vertical
-
hi i am unable to download preordered purchased content from the itunes store on my computer. the apple help/itunes help rep wants me to trash my user account and start over, which is nuts. i can buy and immediately download, just not "check for new