Implementing Custom Event - non-static referencing in static context error
Hi,
I'm implementing a custom event, and I have problems adding my custom listeners to objects. I can't compile because I'm referencing a non-static method (my custom addListener method ) from a static context (a JFrame which contains static main).
However, the same error occurs even if I try to add the custom listener to another class without the main function.
Q1. Is the way I'm adding the listener wrong? Is there a way to resolve the non-static referencing error?
Q2. From the examples online, I don't see people adding the Class name in front of addListener.
Refering to the code below, if I remove "Data." in front of addDataUpdatelistener, I get the error:
cannot resolve symbol method addDataUpdateListener (<anonymous DataUpdateListener>)
I'm wondering if this is where the error is coming from.
Below is a simplified version of my code. Thanks in advance!
Cindy
//dividers indicate contents are in separate source files
//DataUpdateEvent Class
public class DataUpdateEvent extends java.util.EventObject
public DataUpdateEvent(Object eventSource)
super(eventSource);
//DataUpdateListener Interface
public interface DataUpdateListener extends java.util.EventListener
public void dataUpdateOccured(DataUpdateEvent event);
//Data Class: contains data which is updated periodically. Needs to notify Display frame.
class Data
//do something to data
//fire an event to notify listeners data has changed
fireEvent(new DataUpdateEvent(this));
private void fireEvent(DataUpdateEvent event)
// Make a copy of the list and use this list to fire events.
// This way listeners can be added and removed to and from
// the original list in response to this event.
Vector list;
synchronized(this)
list = (Vector)listeners.clone();
for (int i=0; i < list.size(); i++)
// Get the next listener and cast the object to right listener type.
DataUpdateListener listener = (DataUpdateListener) list.elementAt(i);
// Make a call to the method implemented by the listeners
// and defined in the listener interface object.
listener.dataUpdateOccured(event);
System.out.println("event fired");
public synchronized void addDataUpdateListener(DataUpdateListener listener)
listeners.addElement(listener);
public synchronized void removeDataUpdateListener(DataUpdateListener listener)
listeners.removeElement(listener);
//Display Class: creates a JFrame to display data
public class Display extends javax.swing.JFrame
public static void main(String args[])
//display frame
new Display().show();
public Display()
//ERROR OCCURS HERE:
// Non-static method addDataUpdateListener (DataUpdateListener) cannot be referenced from a static context
Data.addDataUpdateListener(new DataUpdateListener()
public void dataUpdateOccured(DataUpdateEvent e)
System.out.println("Event Received!");
//-----------------------------------------------------------
Calling
Data.someMethodName()is referencing a method in the Data class whose signature includes the 'static' modifier and
might look something like this:
class Data
static void someMethodName() {}What you want is to add the listener to an instance of the Data class. It's just like adding
an ActionListener to a JButton:
JButton.addActionListener(new ActionListener() // won't work
JButton button = new JButton("button"); // instance of JButton
button.addActionListener(new ActionListener() // okay
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import javax.swing.*;
public class EventTest extends JFrame
Data data;
JLabel label;
public EventTest()
label = getLabel();
data = new Data();
// add listener to instance ('data') of Data
data.addDataUpdateListener(new DataUpdateListener()
public void dataUpdateOccured(DataUpdateEvent e)
System.out.println("Event Received!");
label.setText("count = " + e.getValue());
getContentPane().add(label, "South");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(300,200);
setLocation(200,200);
setVisible(true);
private JLabel getLabel()
label = new JLabel(" ", JLabel.CENTER);
Dimension d = label.getPreferredSize();
d.height = 25;
label.setPreferredSize(d);
return label;
public static void main(String[] args)
new EventTest();
* DataUpdateEvent Class
class DataUpdateEvent extends java.util.EventObject
int value;
public DataUpdateEvent(Object eventSource, int value)
super(eventSource);
this.value = value;
public int getValue()
return value;
* DataUpdateListener Interface
interface DataUpdateListener extends java.util.EventListener
public void dataUpdateOccured(DataUpdateEvent event);
* Data Class: contains data which is updated periodically.
* Needs to notify Display frame.
class Data
Vector listeners;
int count;
public Data()
listeners = new Vector();
count = 0;
new Thread(runner).start();
private void increaseCount()
count++;
fireEvent(new DataUpdateEvent(this, count));
private void fireEvent(DataUpdateEvent event)
// Make a copy of the list and use this list to fire events.
// This way listeners can be added and removed to and from
// the original list in response to this event.
Vector list;
synchronized(this)
list = (Vector)listeners.clone();
for (int i=0; i < list.size(); i++)
// Get the next listener and cast the object to right listener type.
DataUpdateListener listener = (DataUpdateListener) list.elementAt(i);
// Make a call to the method implemented by the listeners
// and defined in the listener interface object.
listener.dataUpdateOccured(event);
System.out.println("event fired");
public synchronized void addDataUpdateListener(DataUpdateListener listener)
listeners.addElement(listener);
public synchronized void removeDataUpdateListener(DataUpdateListener listener)
listeners.removeElement(listener);
private Runnable runner = new Runnable()
public void run()
boolean runit = true;
while(runit)
increaseCount();
try
Thread.sleep(1000);
catch(InterruptedException ie)
System.err.println("interrupt: " + ie.getMessage());
if(count > 100)
runit = false;
}
Similar Messages
-
Non-static referencing a static..?????
Hey guys, trying to test my new code and am getting this error.
non static method getData() cannot be referenced drom a static context.
The code is:
public void getData() throws IOException {
public static void main(String[] args) throws IOException {
try {
getData();
} catch(IOException e) {
System.out.println("Error somewhere" + "\n");
Anyone know why I'm getting the error. I'm reading up on qualifiers now, but still not understanding.
Thanks again.
...DJVege...LOL! Sorry...guys...Just found my problem, but not in time to avoid shame! Sorry for makin your hearts pump.
Creating an instance of my class NOW!!!! :-) -
How to properly implement custom ServiceFailurePolicy
I'd like to use Coherence service guardian to interrupt & cancel hung cacheloader threads, which are going into infinite loop due to database connection became unresponsive.
For that purpose I've tried first to create working testcase in order to learn how service guardian works.
I've created a basic distributed cache with fake cache loader to imitate a delay in response, then an infinite loop, and custom test service guardian policy.
I do see cache loader being interrupted by a call to onGuardableRecovery, but then strange thing happens: despite cacheloader thread being successfully released, service guardian still thinks that the service is stuck and tries several times to recover by calling onGuardableRecovery and finally to terminate service with the call to onGuardableTerminate.
What I'm missing here or doing wrong ?
Below are testcase classes & cache config:
package test.guardian;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.cache.CacheStore;
import com.tangosol.util.Base;
import java.util.Collection;
import java.util.Map;
public class testCacheStore extends Base implements CacheStore {
private String datasource_name = null;
public static volatile boolean loop_thread = true;
public testCacheStore(String p_datasource_name) {
CacheFactory.log("inside cacheloader constructor, p_datasource_name="+p_datasource_name,CacheFactory.LOG_DEBUG);
this.datasource_name = p_datasource_name;
public Object load(Object oKey) {
CacheFactory.log("inside cacheloader",CacheFactory.LOG_DEBUG);
try {
Thread.sleep(120*1000);
catch (InterruptedException e) {
CacheFactory.log("loader thread was interrupted"+"\n"+CacheFactory.getStackTrace(e),CacheFactory.LOG_DEBUG);
while (testCacheStore.loop_thread) {String n = "1"+"2";}
CacheFactory.log("loader stop_thread flag was set to stop thread",CacheFactory.LOG_DEBUG);
CacheFactory.log("return value from the store",CacheFactory.LOG_DEBUG);
return ((String) oKey)+"-value";
public Map loadAll(Collection colKeys) {
throw new UnsupportedOperationException();
public void store(Object oKey, Object oValue) {
public void storeAll(Map mapEntries) {
throw new UnsupportedOperationException();
public void erase(Object oKey) {
public void eraseAll(Collection colKeys) {
CacheFactory.log("inside eraseAll method", CacheFactory.LOG_DEBUG);
throw new UnsupportedOperationException();
package test.guardian;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.Guardable;
import com.tangosol.net.ServiceFailurePolicy;
import com.tangosol.net.Service;
import com.tangosol.net.Cluster;
public class mycustomGPolicy implements ServiceFailurePolicy {
public static mycustomGPolicy getInstance() {
return new mycustomGPolicy();
public mycustomGPolicy(String p_info) {
CacheFactory.log("parametrized policy class instance created",CacheFactory.LOG_DEBUG);
CacheFactory.log("p_info="+p_info,CacheFactory.LOG_DEBUG);
public mycustomGPolicy() {
CacheFactory.log("policy class instance created",CacheFactory.LOG_DEBUG);
//CacheFactory.log("p_info="+p_info,CacheFactory.LOG_DEBUG);
public void onGuardableRecovery(Guardable p_guardable, Service p_service) {
CacheFactory.log("inside onGuardableRecovery",CacheFactory.LOG_DEBUG);
CacheFactory.log("p_guardable="+p_guardable.toString(),CacheFactory.LOG_DEBUG);
CacheFactory.log("p_guardable.getClass().getCanonicalName()="+p_guardable.getClass().getCanonicalName(),CacheFactory.LOG_DEBUG);
testCacheStore.loop_thread = false;
p_guardable.recover();
p_guardable.getContext().heartbeat();
public void onGuardableTerminate(Guardable p_guardable, Service p_service) {
CacheFactory.log("inside onGuardableTerminate",CacheFactory.LOG_DEBUG);
CacheFactory.log("p_guardable="+p_guardable.toString(),CacheFactory.LOG_DEBUG);
CacheFactory.log("p_guardable.getClass().getCanonicalName()="+p_guardable.getClass().getCanonicalName(),CacheFactory.LOG_DEBUG);
testCacheStore.loop_thread = false;
p_guardable.terminate();
public void onServiceFailed(Cluster p_cluster) {
CacheFactory.log("inside onServiceFailed",CacheFactory.LOG_DEBUG);
package test.guardian;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
public class testGuardianCache {
public static void main(String[] args) {
try {
log("building cache instance");
NamedCache cache = CacheFactory.getCache("test-guardable");
log("requesting cache data");
String resp4 = (String)cache.get("test1223g");
log("response:");
System.out.println(resp4+"\n");
} catch (com.tangosol.io.pof.PortableException e) {
Throwable e_src = e;
while (e_src.getCause() != null ) {
e_src = e_src.getCause();
e_src.printStackTrace();
public static void log(String info) {
System.out.println(info);
<?xml version="1.0" encoding="UTF-8"?>
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>test-guardable</cache-name>
<scheme-name>test-guardable-schema</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>test-guardable-schema</scheme-name>
<service-name>test-guardable-service</service-name>
<backing-map-scheme>
<read-write-backing-map-scheme>
<cachestore-timeout>0</cachestore-timeout>
<internal-cache-scheme>
<external-scheme>
<scheme-name>LocalNioLtd</scheme-name>
<high-units>10000</high-units>
<unit-calculator>FIXED</unit-calculator>
<nio-memory-manager>
<initial-size>10M</initial-size>
<maximum-size>50M</maximum-size>
</nio-memory-manager>
</external-scheme>
</internal-cache-scheme>
<cachestore-scheme>
<class-scheme>
<class-name>test.guardian.testCacheStore</class-name>
<init-params>
<init-param>
<param-type>java.lang.String</param-type>
<param-value>jdbc-coherence/MY-CACHE-DS</param-value>
</init-param>
</init-params>
</class-scheme>
</cachestore-scheme>
<rollback-cachestore-failures>true</rollback-cachestore-failures>
<read-only>true</read-only>
<write-delay-seconds>0</write-delay-seconds>
</read-write-backing-map-scheme>
</backing-map-scheme>
<listener/>
<autostart>true</autostart>
<thread-count>10</thread-count>
<guardian-timeout>10000</guardian-timeout>
<service-failure-policy>
<class-name>test.guardian.mycustomGPolicy</class-name>
<init-params>
<init-param>
<param-name>datasource</param-name>
<param-type>java.lang.String</param-type>
<param-value>jdbc-coherence/MY-CACHE-DS</param-value>
</init-param>
</init-params>
</service-failure-policy>
</distributed-scheme>
</caching-schemes>
</cache-config>
<?xml version="1.0"?>
<coherence>
<services>
<service>
<service-type>DistributedCache</service-type>
<service-component>DistributedCache</service-component>
<init-params>
<init-param id="4">
<param-name>local-storage</param-name>
<param-value system-property="tangosol.coherence.distributed.localstorage">false</param-value>
</init-param>
</init-params>
</service>
</services>
<cluster-config>
<member-identity>
<cluster-name>WORKSTATION</cluster-name>
</member-identity>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">7070</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
<well-known-addresses>
<socket-address id="1"><address>localhost</address><port>7070</port></socket-address>
</well-known-addresses>
</unicast-listener>
<authorized-hosts/>
<logging-config>
<severity-level system-property="tangosol.coherence.log.level">5</severity-level>
<character-limit system-property="tangosol.coherence.log.limit">0</character-limit>
</logging-config>
</cluster-config>
<logging-config>
<severity-level>5</severity-level>
<message-format>{date} <{level}> (thread={thread}, member={member}): {text}</message-format>
<character-limit>8192</character-limit>
</logging-config>
</coherence>
setlocal
set COHERENCE_HOME=c:\coherence36
set PROG_HOME=C:\coherence36\deploy
set COH_OPTS=-cp %COHERENCE_HOME%\lib\coherence.jar;%PROG_HOME%\testguardable.jar
set JMX_OPTS=-Dcom.sun.management.jmxremote -Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false
set OVERRIDE_OPTS=-Dtangosol.coherence.override=%PROG_HOME%\tangosol-coherence-override.xml
rem
rem
start "1testguardable" /MAX C:\jdev10g\jdk\jre\bin\java.exe %COH_OPTS% %OVERRIDE_OPTS% -Xms256m -Xmx256m -Xloggc: -Dtangosol.coherence.distributed.localstorage=true -Dtangosol.coherence.cacheconfig=%PROG_HOME%\testguardable-cache-config.xml com.tangosol.net.DefaultCacheServerINFO - 2010-07-23 23:43:07.906 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/coherence36/lib/coherence.jar!/tangosol-coherence.xml"
INFO - 2010-07-23 23:43:07.921 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/-PRG/coherence_ws/Guardian/deploy/tangosol-coherence-override.xml"
DEBUG - 2010-07-23 23:43:07.937 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
DEBUG -
Oracle Coherence Version 3.6.0.0 Build 17229
Grid Edition: Development mode
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
INFO - 2010-07-23 23:43:08.531 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/C:/-PRG/coherence_ws/Guardian/deploy/testguardable-cache-config.xml"
DEBUG - 2010-07-23 23:43:09.515 <D4> (thread=main, member=n/a): TCMP bound to /192.168.1.10:7070 using SystemSocketProvider
INFO - 2010-07-23 23:43:41.000 <Info> (thread=Cluster, member=n/a): Created a new cluster "WORKSTATION" with Member(Id=1, Timestamp=2010-07-23 23:43:09.531, Address=192.168.1.10:7070, MachineId=26890, Location=site:local,machine:WS,process:5880, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) UID=0xC0A8010A0000012A01427FDB690A1B9E
INFO - 2010-07-23 23:43:41.015 <Info> (thread=main, member=n/a): Started cluster Name=WORKSTATION
WellKnownAddressList(Size=1,
WKA{Address=192.168.1.10, Port=7070}
MasterMemberSet
ThisMember=Member(Id=1, Timestamp=2010-07-23 23:43:09.531, Address=192.168.1.10:7070, MachineId=26890, Location=site:local,machine:WS,process:5880, Role=CoherenceServer)
OldestMember=Member(Id=1, Timestamp=2010-07-23 23:43:09.531, Address=192.168.1.10:7070, MachineId=26890, Location=site:local,machine:WS,process:5880, Role=CoherenceServer)
ActualMemberSet=MemberSet(Size=1, BitSetCount=2
Member(Id=1, Timestamp=2010-07-23 23:43:09.531, Address=192.168.1.10:7070, MachineId=26890, Location=site:local,machine:WS,process:5880, Role=CoherenceServer)
RecycleMillis=1200000
RecycleSet=MemberSet(Size=0, BitSetCount=0
TcpRing{Connections=[]}
IpMonitor{AddressListSize=0}
DEBUG - 2010-07-23 23:43:41.093 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
DEBUG - 2010-07-23 23:43:41.718 <D5> (thread=main, member=1): parametrized policy class instance created
DEBUG - 2010-07-23 23:43:41.718 <D5> (thread=main, member=1): p_info=jdbc-coherence/MY-CACHE-DS
DEBUG - 2010-07-23 23:43:41.750 <D5> (thread=DistributedCache:test-guardable-service, member=1): Service test-guardable-service joined the cluster with senior service member 1
INFO - 2010-07-23 23:43:41.890 <Info> (thread=main, member=1):
Services
ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.6, OldestMemberId=1}
InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
PartitionedCache{Name=test-guardable-service, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
Started DefaultCacheServer...
DEBUG - 2010-07-23 23:44:50.250 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2010-07-23 23:44:50.258, Address=192.168.1.10:7072, MachineId=26890, Location=site:local,machine:WS,process:3376, Role=TestGuardianTestGuardianCache) joined Cluster with senior member 1
DEBUG - 2010-07-23 23:44:50.390 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior member 1
DEBUG - 2010-07-23 23:44:51.093 <D5> (thread=Cluster, member=1): Member 2 joined Service test-guardable-service with senior member 1
DEBUG - 2010-07-23 23:44:51.218 <D5> (thread=DistributedCache:test-guardable-service, member=1): inside cacheloader constructor, p_datasource_name=jdbc-coherence/MY-CACHE-DS
DEBUG - 2010-07-23 23:44:51.359 <D5> (thread=test-guardable-serviceWorker:4, member=1): inside cacheloader
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=Recovery Thread, member=1): inside onGuardableRecovery
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=Recovery Thread, member=1): p_guardable=Guard{Daemon=test-guardable-serviceWorker:4}
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=Recovery Thread, member=1): p_guardable.getClass().getCanonicalName()=com.tangosol.coherence.component.util.daemon.queueProcessor.Service$DaemonPool$Daemon$Guard
ERROR - 2010-07-23 23:45:00.375 <Error> (thread=DistributedCache:test-guardable-service, member=1): Attempting recovery (due to soft timeout) of {WrapperGuardable Guard{Daemon=test-guardable-serviceWorker:4} Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}}
WARN - 2010-07-23 23:45:00.375 <Warning> (thread=Recovery Thread, member=1): A worker thread has been executing task: Message "GetRequest"
FromMember=Member(Id=2, Timestamp=2010-07-23 23:44:50.258, Address=192.168.1.10:7072, MachineId=26890, Location=site:local,machine:WS,process:3376, Role=TestGuardianTestGuardianCache)
FromMessageId=29
Internal=false
MessagePartCount=1
PendingCount=0
MessageType=59
ToPollId=0
Poll=null
Packets
[000]=Directed{PacketType=0x0DDF00D5, ToId=1, FromId=2, Direction=Incoming, ReceivedMillis=23:44:51.343, ToMemberSet=null, ServiceId=2, MessageType=59, FromMessageId=29, ToMessageId=27, MessagePartCount=1, MessagePartIndex=0, NackInProgress=false, ResendScheduled=none, Timeout=none, PendingResendSkips=0, DeliveryState=unsent, Body=0}
Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
ToMemberSet=MemberSet(Size=1, BitSetCount=2
Member(Id=1, Timestamp=2010-07-23 23:43:09.531, Address=192.168.1.10:7070, MachineId=26890, Location=site:local,machine:WS,process:5880, Role=CoherenceServer)
NotifySent=false
} for 9016ms and appears to be stuck; attempting to interrupt: test-guardable-serviceWorker:4
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=test-guardable-serviceWorker:4, member=1): loader thread was interrupted
at java.lang.Thread.sleep(Native Method)
at test.guardian.testCacheStore.load(testCacheStore.java:26)
at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.load(ReadWriteBackingMap.java:4759)
at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.loadInternal(ReadWriteBackingMap.java:4344)
at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:807)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onGetRequest(PartitionedCache.CDB:22)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest.run(PartitionedCache.CDB:1)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:1)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:63)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
at java.lang.Thread.run(Thread.java:595)
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=test-guardable-serviceWorker:4, member=1): loader stop_thread flag was set to stop thread
DEBUG - 2010-07-23 23:45:00.375 <D5> (thread=test-guardable-serviceWorker:4, member=1): return value from the store
DEBUG - 2010-07-23 23:45:00.390 <D5> (thread=Cluster, member=1): TcpRing disconnected from Member(Id=2, Timestamp=2010-07-23 23:44:50.258, Address=192.168.1.10:7072, MachineId=26890, Location=site:local,machine:WS,process:3376, Role=TestGuardianTestGuardianCache) due to a peer departure; removing the member.
DEBUG - 2010-07-23 23:45:00.390 <D5> (thread=Cluster, member=1): Member 2 left service Management with senior member 1
DEBUG - 2010-07-23 23:45:00.390 <D5> (thread=Cluster, member=1): Member 2 left service test-guardable-service with senior member 1
DEBUG - 2010-07-23 23:45:00.390 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2010-07-23 23:45:00.39, Address=192.168.1.10:7072, MachineId=26890, Location=site:local,machine:WS,process:3376, Role=TestGuardianTestGuardianCache) left Cluster with senior member 1
ERROR - 2010-07-23 23:48:16.250 <Error> (thread=Cluster, member=1): Attempting recovery (due to soft timeout) of {WrapperGuardable Guard{Daemon=DistributedCache:test-guardable-service} Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}}
DEBUG - 2010-07-23 23:48:16.250 <D5> (thread=Recovery Thread, member=1): inside onGuardableRecovery
DEBUG - 2010-07-23 23:48:16.250 <D5> (thread=Recovery Thread, member=1): p_guardable=Guard{Daemon=DistributedCache:test-guardable-service}
DEBUG - 2010-07-23 23:48:16.250 <D5> (thread=Recovery Thread, member=1): p_guardable.getClass().getCanonicalName()=com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$Guard
DEBUG - Interrupted PartitionedCache, Thread[DistributedCache:test-guardable-service,5,Cluster]
ERROR - 2010-07-23 23:48:46.765 <Error> (thread=Cluster, member=1): Terminating guarded execution (due to hard timeout) of {WrapperGuardable Guard{Daemon=DistributedCache:test-guardable-service} Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}}
DEBUG - 2010-07-23 23:48:46.765 <D5> (thread=Termination Thread, member=1): inside onGuardableTerminate
DEBUG - 2010-07-23 23:48:46.765 <D5> (thread=Termination Thread, member=1): p_guardable=Guard{Daemon=DistributedCache:test-guardable-service}
DEBUG - 2010-07-23 23:48:46.765 <D5> (thread=Termination Thread, member=1): p_guardable.getClass().getCanonicalName()=com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$Guard
DEBUG - 2010-07-23 23:48:46.765 <D5> (thread=DistributedCache:test-guardable-service, member=1): Service test-guardable-service left the cluster
INFO - 2010-07-23 23:48:46.890 <Info> (thread=main, member=1): Restarting Service: test-guardable-service
DEBUG - 2010-07-23 23:48:46.906 <D5> (thread=main, member=1): parametrized policy class instance created
DEBUG - 2010-07-23 23:48:46.906 <D5> (thread=main, member=1): p_info=jdbc-coherence/MY-CACHE-DS
DEBUG - 2010-07-23 23:48:46.906 <D5> (thread=DistributedCache:test-guardable-service, member=1): Service test-guardable-service joined the cluster with senior service member 1
ERROR - 2010-07-23 23:48:55.265 <Error> (thread=Cluster, member=1): Attempting recovery (due to soft timeout) of {WrapperGuardable Guard{Daemon=DistributedCache:test-guardable-service} Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STOPPED), Not initialized}}
DEBUG - 2010-07-23 23:48:55.265 <D5> (thread=Recovery Thread, member=1): inside onGuardableRecovery
DEBUG - 2010-07-23 23:48:55.265 <D5> (thread=Recovery Thread, member=1): p_guardable=Guard{Daemon=DistributedCache:test-guardable-service}
DEBUG - 2010-07-23 23:48:55.265 <D5> (thread=Recovery Thread, member=1): p_guardable.getClass().getCanonicalName()=com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$Guard
ERROR - 2010-07-23 23:48:56.281 <Error> (thread=Cluster, member=1): Terminating guarded execution (due to hard timeout) of {WrapperGuardable Guard{Daemon=DistributedCache:test-guardable-service} Service=PartitionedCache{Name=test-guardable-service, State=(SERVICE_STOPPED), Not initialized}}
DEBUG - 2010-07-23 23:48:56.281 <D5> (thread=Termination Thread, member=1): inside onGuardableTerminate
DEBUG - 2010-07-23 23:48:56.281 <D5> (thread=Termination Thread, member=1): p_guardable=Guard{Daemon=DistributedCache:test-guardable-service}
DEBUG - 2010-07-23 23:48:56.281 <D5> (thread=Termination Thread, member=1): p_guardable.getClass().getCanonicalName()=com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$Guard -
Custom Event generation and Handling
HI all,
I am new to java. I have a dataset which changes dynamically and this dataset is responsible for some other dataset(s). So whenever the original dataset is modified, the other datasets based on this dataset should be updated automatically so as to preserve the consistency.
What I want to do is to write a custom event which is to be fired whenever the original dataset is modified and notify it to other datasets so as to ensure the consistency.
Any help in this regard is extremely appreciated.HI Duffymo,
Here is my problem for better understanding:
I have a vector data in a NodePanel (this vector data originates from some other datastructure...but that is immaterial as we know that this data is an instance of that datastructure). This vectordata in NodePanel is responsible for another vectordata in SchedulePanel. The NodePanel and SchedulePanel are tabbedPanels in a tabbedframe. Whenever I update the vector data in NodePanel, the vector data in SchedulePanel needs to be updated.
The solution you gave me, taught me an insight of the event handling in Java.
I am quoting my source for your reference as I am unable to incorporate your idea into my project.
Event class:
import java.util.*;
public class VectorUpdateEvent extends EventObject
public VectorUpdateEvent(Object source)
super(source);
Interface to EventListener
public interface VectorUpdateListener
public void eventVectorUpdated(VectorUpdateEvent event);
class EventGenerator
import java.util.*;
public class VectorUpdateEventIssuer
implements EventListener
public VectorUpdateEventIssuer()
listListeners = new ArrayList();
public synchronized void addVectorUpdateEventListener(VectorUpdateEvent l)
listListeners.add(l);
protected synchronized void removeVectorUpdateEventListener(VectorUpdateEvent l)
listListeners.remove(listListeners.indexOf(l));
protected void notifyVectorUpdateEvent(Object source)
VectorUpdateEvent evt = new VectorUpdateEvent(source);
Iterator itr = listListeners.iterator();
while (itr.hasNext())
((VectorUpdateListener)itr.next()).eventVectorUpdated(evt);
private ArrayList listListeners;
class where the event originates
class NodePanel
extends JPanel
implements ActionListener, ListSelectionListener
/////////////Constructors/////////////////////////
public NodePanel()
addNodeButton = new JButton("Add Node");
delNodeButton = new JButton("Delete Node");
dumpNodeButton = new JButton("Dump Node");
reloadNodeButton = new JButton("Reload Node");
browseButton = new JButton("Browse Node");
exitButton = new JButton("Exit");
add(addNodeButton);
add(delNodeButton);
add(dumpNodeButton);
add(reloadNodeButton);
add(browseButton);
add(exitButton);
setButtonsEnabled(false);
addNodeButton.addActionListener(this);
delNodeButton.addActionListener(this);
dumpNodeButton.addActionListener(this);
reloadNodeButton.addActionListener(this);
browseButton.addActionListener(this);
exitButton.addActionListener(this);
nodesVector = new Vector();
nodesList = new JList(nodesVector);
this.vectorNodeAttributes = new Vector();
JScrollPane scrollPane = new JScrollPane(nodesList);
add(scrollPane,BorderLayout.CENTER);
nodesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
nodesList.addListSelectionListener(this);
////////////////Methods///////////////////////////
/////////////Event valueChanged///////////////////
public void valueChanged(ListSelectionEvent evt)
JList source = (JList) evt.getSource();
setButtonsEnabled(true);
desiredNode = (String) source.getSelectedValue();
if (desiredNode == null)
setButtonsEnabled(false);
//////////////Event actionPerformed////////////
public void actionPerformed(ActionEvent evt)
Object source = evt.getSource();
if (source == addNodeButton)
addNodeButtonClicked();
else if (source == delNodeButton && desiredNode != null)
deleteNodeButtonClicked();
else if (source == dumpNodeButton && desiredNode != null)
JFileChooser d = new JFileChooser();
//d.setCurrentDirectory("");
d.setFileFilter(new XMLFilter());
int result = d.showSaveDialog(this);
else if (source == reloadNodeButton && desiredNode != null)
JFileChooser d1 = new JFileChooser();
//d.setCurrentDirectory("");
d1.setFileFilter(new XMLFilter());
int result = d1.showOpenDialog(this);
//String filename=d1.getSelectedFile().getName();
if (source == browseButton && desiredNode != null)
browseButtonClicked();
else if (source == exitButton)
System.exit(0);
//////////Enables or Diables the Buttons////////
private void setButtonsEnabled(boolean enable)
delNodeButton.setEnabled(enable);
dumpNodeButton.setEnabled(enable);
reloadNodeButton.setEnabled(enable);
browseButton.setEnabled(enable);
private void deleteNodeButtonClicked()
if (noFieldDlg != null)
noFieldDlg.dispose();
noFieldDlg = new NoFieldDialog("Delete the Node?");
noFieldDlg.show();
if (noFieldDlg.getDialogResult() == DialogResult.OK)
int nodeToRemove=0;
for (int i=0; i< vectorNodeAttributes.size(); i++)
if(((NodeAttributes)(vectorNodeAttributes.get(i))).getNodeName().compareTo(nodesList.getSelectedValue()) == 0)
nodeToRemove = i;
vectorNodeAttributes.remove(nodeToRemove);
nodesVector.removeElement(nodesList.getSelectedValue());
this.nodesList.setListData(nodesVector);
NodePanel.nodesPresent = nodesVector;
updateStaticNodeList();
/*************** as soon as the NodePanel.nodesPresent is updated, the changes are to be reflected in the Schedule Panel ******************/
VectorUpdateEvent e = new VectorUpdateEvent(this);
VectorUpdateEventIssuer v = new VectorUpdateEventIssuer();
v.addVectorUpdateEventListener(e);
v.notifyVectorUpdateEvent(this);
///////////////Data Members////////////////////
private JButton addNodeButton;
private JButton delNodeButton;
private JButton dumpNodeButton;
private JButton reloadNodeButton;
private JButton browseButton;
private JButton exitButton;
private String desiredNode;
private OneFieldDialog oneFieldDlg = null;
private NoFieldDialog noFieldDlg = null;
private JList nodesList;
private Vector nodesVector;
private Vector vectorNodeAttributes;
private static Vector nodesPresent = null;
} // end class NodePanel
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
////////////////Class SchedulePanel////////////////
class SchedulePanel extends JPanel
implements ActionListener, ListSelectionListener, VectorUpdateListener
////////////////Constructors//////////////////
public SchedulePanel()
addScheduleButton = new JButton("Add Schedule");
delScheduleButton = new JButton("Delete Schedule");
dumpScheduleButton = new JButton("Dump Schedule");
reloadScheduleButton = new JButton("Reload Schedule");
browseScheduleButton = new JButton("Browse Schedule");
exitButton = new JButton("Exit");
add(addScheduleButton);
add(delScheduleButton);
add(dumpScheduleButton);
add(reloadScheduleButton);
add(browseScheduleButton);
add(exitButton);
setButtonsEnabled(false);
addScheduleButton.addActionListener(this);
delScheduleButton.addActionListener(this);
dumpScheduleButton.addActionListener(this);
reloadScheduleButton.addActionListener(this);
browseScheduleButton.addActionListener(this);
exitButton.addActionListener(this);
scheduleVector = new Vector();
scheduleList = new JList(scheduleVector);
this.vectorScheduleOperations = new Vector();
JScrollPane scrollPane = new JScrollPane(scheduleList);
add(scrollPane);
scheduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scheduleList.addListSelectionListener(this);
//updateEventListener = new VectorUpdateEventIssuer();
//updateEventListener.addVectorUpdateEventListener(this);
/////////////Methods///////////////////////
////////////Event valueChanged/////////////
public void valueChanged(ListSelectionEvent evt)
JList source = (JList)evt.getSource();
setButtonsEnabled(true);
desiredSchedule = (String)source.getSelectedValue();
if (desiredSchedule == null)
setButtonsEnabled(false);
////////////Event actionPerformed////////
public void actionPerformed(ActionEvent evt)
Object source = evt.getSource();
if (source == addScheduleButton )
addScheduleButtonClicked();
else if (source==delScheduleButton && desiredSchedule!=null)
deleteScheduleButtonClicked();
else if (source == dumpScheduleButton && desiredSchedule!=null)
JFileChooser d = new JFileChooser();
d.setFileFilter(new XMLFilter());
int result = d.showSaveDialog(this);
else if (source == reloadScheduleButton && desiredSchedule!=null)
JFileChooser d1 = new JFileChooser();
d1.setFileFilter(new XMLFilter());
int result = d1.showOpenDialog(this);
else if (source == browseScheduleButton && desiredSchedule!=null)
browseScheduleButtonClicked();
else if (source == exitButton)
System.exit(0);
public void eventVectorUpdated(VectorUpdateEvent event)
System.out.println("Hello! EventRaised");
///////////Data Members//////////////////
private JButton addScheduleButton;
private JButton delScheduleButton;
private JButton dumpScheduleButton;
private JButton reloadScheduleButton;
private JButton browseScheduleButton;
private JButton exitButton;
private String desiredSchedule;
private OneFieldDialog oneFieldDlg = null;
private NoFieldDialog noFieldDlg = null;
private JList scheduleList;
private Vector scheduleVector;
private Vector vectorScheduleOperations;
private VectorUpdateEventIssuer updateEventListener;
} // end class SchedulePanel
I hope you understood my problem now. The NodeAttributes is a datastructure containing the node name and an associated table for that. THe ScheduleOperations is similar to the NodeAttributes but it contains a DefaultTableModel which inturn consists of a column which is filled with the list of current nodes available + their schedules.
I am sorry for my long posting.
Thanks once again in anticipation. -
I need to communicate between two different controllers associate with different sections of FXML.
I create a custom even and implemented an event handler in one of my controllers.
I can not seem to figure out how to fire the custom event from my other controller. So far the documentation I have found doesn't fill in the blank about firing an event from a controller or even any other class than one that already has .fireEvent as a member.
Am I using the wrong design pattern here or is there an easy solution to fire an event?
pseudo
public class myEvent extends Event {
private static final long serialVersionUID = 1261846397820142663L;
public static final EventType<myEvent >MY_EVENT = new EventType<myEvent >(ANY, "MY_EVENT");
public myEvent (EventType<? extends Event> arg0) {
super(arg0);
// TODO Auto-generated constructor stub
public myEvent () {
this(MY_EVENT);
public class myClass implements EventHandler<myEvent> {
@Override
public void handle(TimelineDropEvent arg0) {
// TODO Auto-generated method stub
System.out.println("MyEvent");
public class myOtherClass {
//TODO what do I do here to fire an event
}Obviously both of my sample classes also implement Initializable since they are controllers.
In my event do I absolutely need serialVersionUID or is there another way to avoid the warning associated with removing it?Sorry for the delay. I had to create a Google Code project to host the example:
http://code.google.com/p/sjmb/
The source code for the message bus API is here:
http://code.google.com/p/sjmb/source/browse/#svn%2Ftrunk%2Fsjmb%2Fsrc%2Fcom%2Foracle%2Fsjmb
It essentially allows callers to subscribe to "message topics", which are simply Java types. Any time an instance of a given type is sent, subscribed listeners are notified. Any Java type can be used including enums, which provide a nice, type-safe way to define messages.
An example demonstrating how to use the API is here:
http://code.google.com/p/sjmb/source/browse/#svn%2Ftrunk%2Fsjmb%2Ftest%2Fcom%2Foracle%2Fsjmb%2Ftest
The main application window presents a tab pane containing 3 identical tabs. Each tab's controller subscribes to a message of type com.oracle.sjmb.test.Message. Entering text in the text field and pressing the "Send Message" button sends a new message, causing the other two tabs to update the contents of their own text fields to match.
The example application consists of the following files:
Message.java - the message class
MessageBusTest.java - the main JavaFX application class
message_bus_test.fxml - FXML document containing the main scene
tab.fxml - FXML document containing tab pane content
TabController.java - tab content controller
Javadoc and binaries are available here:
http://code.google.com/p/sjmb/downloads/list
Please note that this is an example only and is not an official part of any Oracle product. Let me know if you have any questions.
Greg -
Custom component and custom event problem
hello , i have a strange problem since one week , is that i can't handle the events becoming from my custom component , here is my code :
Event Class :
package events
import flash.events.Event;
public class Ev extends Event
public static const UPDATE:String="update";
public var data:String;
public function Ev(type:String,data:String)
super(type);
this.data=data;
override public function clone():Event
return new Ev(type,data);
MXML component :
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Metadata>
[Event(name="onMenuChange",type="events.Ev")]
</fx:Metadata>
<fx:Script>
<![CDATA[
import events.Ev;
import mx.events.IndexChangedEvent;
protected function accordion1_changeHandler(event:IndexChangedEvent):void
dispatchEvent(new Ev(Ev.UPDATE,event.newIndex.toString()));
]]>
</fx:Script>
<fx:Declarations>
<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
</fx:Declarations>
<mx:Accordion width="200" height="200" change="accordion1_changeHandler(event)">
<s:NavigatorContent label="Menu 1" width="100%" height="100%">
</s:NavigatorContent>
<s:NavigatorContent label="Menu 2" width="100%" height="100%">
</s:NavigatorContent>
<s:NavigatorContent label="Menu 3" width="100%" height="100%">
</s:NavigatorContent>
</mx:Accordion>
</mx:VBox>
the main container :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
<fx:Script>
<![CDATA[
import events.Ev;
import mx.controls.Alert;
protected function comp1_onMenuChangeHandler(event:Ev):void
Alert.show(event.data,"notice");
]]>
</fx:Script>
<local:Comp onMenuChange="comp1_onMenuChangeHandler(event)"/>
</s:Application>
any help will be welcome !hi,
Not sure why your custom event is not working, I tend not to worry about 'custom' events unless I need to transfer a lot of information.
Here is a way to 'simplify' event management.
I just declare a new event in the meta data and then send it to notify that a change has been made. Although the parent can find the index value easily enough I also use two-way bind the navigators index so that it is directly available for the application to manipulate/read .
http://gumbo.flashhub.net/events/ source included
David. -
I'm new to flex and how it handles Event Bubbling. I can make a custom event work with this code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
applicationComplete="init()" name="app">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.controls.Alert;
private function init():void {
addEventListener("myEvent",testListener);
var testEvent:Event = new Event("myEvent",true);
dispatchEvent(testEvent);
private function testListener(event:Event):void {
Alert.show("Trigger Worked");
]]>
</fx:Script>
</s:Application>
But when I break out the code so the Event fires in a class the parent does not catch it.
MyEvent.as file:
package comp {
import flash.display.MovieClip;
import flash.events.Event;
public class MyEvent extends MovieClip{
public function MyEvent() {
var testEvent:Event = new Event("myEvent",true);
dispatchEvent(testEvent);
TestEvents.mxml file:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
applicationComplete="init()" name="app">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import comp.MyEvent;
import flash.events.Event;
import mx.controls.Alert;
private function init():void {
addEventListener("myEvent",testListener);
var tempEvent:MyEvent = new MyEvent();
private function testListener(event:Event):void {
Alert.show("Trigger Worked");
]]>
</fx:Script>
</s:Application>
I know I'm missing something simple. Could someone please point me in the correct direction.
Thanks,
SolThanks for the help!!! I got it to work using most of your code. The only change I had to make was move the dispatchEvent out of the construtor and into it's own function. That way the listener is definded before it fires.
Now I noticed you added the listener to the object itself is this bubbling? I thought if you have bubbling turned on the main app can have the listener and if a child fires an event it would bubble up. If the listerner is not on the MyEvent class it does not work.
Here is the new Working code if you take the : tempMyEvent off this line:
addEventListener(MyEvent.MY_EVENT, myEventHandler);
it does not work
Should it? Should the event bubble up and still be fired?
Below is working code:
MyEvent.as
package comp {
import flash.display.MovieClip;
import flash.events.Event;
public class MyEvent extends MovieClip{
public static const MY_EVENT:String = 'myEvent';
public function MyEvent() {}
public function disEventTest():void {
dispatchEvent(new Event(MyEvent.MY_EVENT,true));
TestEvents.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
applicationComplete="init()" name="app">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import comp.MyEvent;
import flash.events.Event;
import mx.controls.Alert;
private function init():void {
var tempMyEvent:MyEvent = new MyEvent();
tempMyEvent.addEventListener(MyEvent.MY_EVENT, myEventHandler);
tempMyEvent.disEventTest();
private function myEventHandler(event:Event):void {
Alert.show("Trigger Worked");
]]>
</fx:Script>
</s:Application>
Thanks again for your help this will at least get me moving forward again.
Sol -
Hi All
I am using WCF-Custom (WS HTTP Binding) with Message security as Windows and using Reliable messaging in the send port. Its a static Port.
Every thing works fine as expected for the interface. ie the transaction is success. After a min of the transaction completion. I am getting the following error
01. I have not checked Propagate Fault message (as a solution provided in another blog)
02. Its a static Port
03. I am using reliable messaging
The below error events are logged in the event viewer
The Message Engine Encountered an error while suspending one or more Messages ( ID 5677)
Event ID : 5796
The transport proxy method MoveToNextTransport() failed for adapter WCF-Custom: Reason: “Messaging engine has no record of delivering the message to the adapter. This could happen if MoveToNextTransport() is called multiple times for the same message by
the adapter or if it is called for a message which was never delivered to the adapter by the messaging engine”. Contact the adapter vendor
Should I have log this issue with Microsoft through Service request ? or is there any work around is there. Unfortunate is I cannot remove the reliable messaging from the service.
ArunHi,
Is there any solution to this problem?
I am getting the same issue "The transport proxy method MoveToNextTransport() failed for adapter WCF-NetTcp: Reason: "Messaging engine has no record of delivering the message to the adapter.
This could happen if MoveToNextTransport() is called multiple times for the same message by the adapter or if it is called for a message which was never delivered to the adapter by the messaging engine". Contact the adapter vendor"
I checked this link http://rajwebjunky.blogspot.be/2011/09/biztalk-dynamic-request-response-port.html, but
in my case i am not using dynamic port.
In my scenario, i have a number of dehydrated orchestrations that become active every Monday 6:00 AM UTC and make to calls to a WCF service, to spread out the load I have implemented a load distribution logic where orchestrations send request to service
in every 1 minute (not at the same time). but still i get this error sometime.
I have opened a ticket with MS support but thought that someone might have already found the root cause.
Let me know if there is one.
Thanks,
Rahul
Best Regards, Rahul Dubey MCTS BizTalk Server -
Trying to make up a Modal Dialog with customized event dispatcher
Hello everyone.
I try to make up a ModalDialog class with customized event dispatcher in order to wait an invoker.
But it fails :-(
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventDispatchChain;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
import javafx.event.EventType;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
import com.sun.javafx.stage.WindowEventDispatcher;
import java.util.ArrayList;
public class ModalDialog extends Stage {
ArrayList<Button> buttons;
int rc;
Stage stage;
Event event;
EventDispatchChain tail;
public ModalDialog( Window owner, String title ){
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
initStyle( StageStyle.UTILITY );
setTitle( title );
stage = this;
public void setContents( Group group, ArrayList<Button> buttons ){
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
setScene(scene);
root.setCenter( group );
this.buttons = buttons;
HBox buttonPane = new HBox();
buttonPane.setSpacing(10);
for( int i=0 ; i<buttons.size() ; i++ ){
buttons.get(i).setOnAction( actionHandler );
buttonPane.getChildren().setAll( buttons );
root.setBottom( buttonPane );
public int show( double screenX, double screenY ){
setX( screenX ); setY( screenY );
show();
MyWindowEventDispatcher dispatcher = new MyWindowEventDispatcher( stage );
setEventDispatcher( dispatcher );
while(true){
event = dispatcher.dispatchEvent( event, tail );
EventType<? extends Event> type = event.getEventType();
if( type==WindowEvent.WINDOW_HIDDEN ){
break;
return( rc );
EventHandler<ActionEvent> actionHandler = new EventHandler<ActionEvent>() {
public void handle( ActionEvent e ){
EventTarget src = e.getTarget();
rc = buttons.indexOf( src );
stage.hide();
class MyWindowEventDispatcher extends WindowEventDispatcher {
public MyWindowEventDispatcher( Window window ){
super( window );
public Event dispatchEvent( Event event, EventDispatchChain tail) {
ModalDialog.this.event = dispatchCapturingEvent( event );
ModalDialog.this.tail = tail;
return( event );
}A sample code to invoke ModalDialog
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class WindowEvent06 extends Application {
Stage mainStage;
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("WindowEvent06");
mainStage = stage;
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent e){
ModalDialog dialog = new ModalDialog( mainStage, "Question" );
Button yes = new Button( "Yes" );
Button no = new Button( "No" );
ArrayList<Button> buttons = new ArrayList<>();
buttons.add(yes); buttons.add(no);
Label msg = new Label( "Really Exit ?" );
Group groupInDialog = new Group();
groupInDialog.getChildren().add( msg );
dialog.setContents( groupInDialog, buttons );
int ans = dialog.show( 300, 300 );
System.out.println("returned from a modal dialog");
if( ans == 1 ){
e.consume(); // this blocks window closing
stage.show();
public static void main(String[] args) {
launch(args);
}Hi,
The logic what you follows is some what in the right direction but need to have some changes.
What I would say is, first consume the windowClose event. Then open the dialog box and close the parent accordingly.
So after refactoring your code.
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class ModalDialog extends Stage {
Stage owner;
Stage stage;
BorderPane root;
public ModalDialog( Stage owner, String title){
root = new BorderPane();
stage = this;
this.owner = owner;
initModality( Modality.APPLICATION_MODAL );
initOwner( owner );
initStyle( StageStyle.UTILITY );
setTitle( title );
setContents();
public void setContents(){
Scene scene = new Scene(root,150,150);
setScene(scene);
Group groupInDialog = new Group();
groupInDialog.getChildren().add( new Label("Really Exit ?") );
root.setCenter( groupInDialog );
Button yes = new Button( "Yes" );
yes.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent paramT) {
stage.close(); // Closing the pop up.
owner.close(); // Closing the parent stage also.
Button no = new Button( "No" );
no.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent paramT) {
stage.close(); // Closing the pop up only
HBox buttonPane = new HBox();
buttonPane.setSpacing(10);
buttonPane.getChildren().addAll(yes,no);
root.setBottom(buttonPane);
stage.show();
}And the main class to check this implementation is
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class WindowEvent06 extends Application {
public void start(final Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("WindowEvent06");
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(final WindowEvent e){
e.consume(); // Consuming the event by default.
new ModalDialog( stage, "Question");
stage.show();
public static void main(String[] args) {
launch(args);
}I hope the above code will give you some idea what i mean. :)
Happy Coding !!
Regards,
Sai Pradeep Dandem.
Edited by: Sai Pradeep Dandem on Jan 20, 2012 4:03 AM -
Query in writing a Custom Event class
Hi ,
I am trying to work with the Events for pratic epurposes , when i am copying , pasting the code from web tutorilas they are working finr , but whne i tries myself they aren't working .
Please help me
This is my Custom Event .
I want to pass the VO Object through Event . PLease see this below code and let me know as where i am doing wrong .
package events
import flash.events.Event;
import vo.User;
public class LoginEvent extends Event
public static const LOGIN_EVENT:String = "LoginEvent";
public var user : User;
public function LoginEvent(type:String,user:User)
super(type,user);
this.user = user;
PLease let me know
what are the parameters to be passed inside the Constructor of the Event class , and the Parameters inside the super()
Waiting for your replies .Hi Kiran
Try this
package events
import flash.events.Event;
import vo.User;
public class LoginEvent extends Event
public static const LOGIN_EVENT:String= "loginEvent";
public var userDtl:User;
public function LoginEvent(type:String,userObj:User)
//TODO: implement function
super(type);
this.userDtl = userObj;
override public function clone():Event{
return new LoginEvent(type,userDtl);
Thanks
Ram -
Can you send custom events from one form to another?
I have a compli
cated application, where I about hundred inp
uts organized in several input forms. Some of the forms
require data which has been input in other forms. I have tried to
dispatch custom events from one form to another, but it dispatches the
whole form and I only need one or two items.
Ha anybody else come across such a problem?
SvendOne way is to share data in a static singleton
-
Custom Events and Listeners between classes
I've got a project I've been working on for weeks that I'm
having yet another problem with. I'm trying to learn AS3 which is
why it's taking so long but that's not important for this post.
I wanted to create a custom event class so that I could make
sure the event does not interfere with other "COMPLETE" events that
are being passed between classes. In other words, I have a few
things that need to complete prior to a function being called...
one is some XML being loaded and another is a font loaded. So, I
thought I would create a custom FontLoaded class that extends Event
and make the type something like "FontLoadedEvent.LOADED". That way
I could listen for the XML "Event.COMPLETE" and this font event
also.
Please tell me if I'm going down the wrong path here but I
don't seem to be getting the dispatched event for my new custom
event. Also, how does one detect if it's being dispatched other
than if the eventListener is fired? Any other ways to test
this?You can trace the event to see if it dispatched.
Also, this is not a good case to create a new event. Custom
events are used to store additional information. MouseEvent exists
because Event doesn't have localX, localY, etc. properties. Since
you don't seem to be throwing additional properties, you can use a
regular event.
trace(dispatchEvent(new Event("panelFontsLoaded"));
addEventListener("panelFontsLoaded", onFontsLoaded);
Static consts are used to help debug typos. The event type is
just a string, often stored in a const. -
Problem reading custom property file from custom event handler.
Hi,
My custom event handler needs some bits of information that I have set up in a property file. However, when the event handler runs it throws a FileNotFound exception - actually its because permission was denied.
I have added the code System.getProperty("user.name") to find out the actual user that the event handler is running as. It reports that "oracle" is the user.
That's great. However, the permissions on the file will allow oracle to read/write the file. If I log onto the server where OCDB runs (as oracle), I can vi the file.
The file is owned by another user, but the "oracle" is a member of the group that has read/write (we're running on a unix box). The file is not 777.
The event handler is actually calling a static utility method that returns the Properties. This utility is used elsewhere in other custom apps in conjunction with OCDB (on the same server). It works there, so the utility is functioning correctly.
Is there something going on that I'm missing? Like somehow the event handler is acually runn as somebody else?
Here is the node log.
2007/07/17 12:52:16 [oracle.ifs] [37] 434364 system FINE: Error /opt/csc/sfi/configuration/sfi.properties (Permission
denied) Additional INFO: java.io.FileNotFoundException: /opt/csc/sfi/configuration/sfi.properties (Permission denied)
Thanks in advance for the help.
WinstonMatt,
Sorry to have wasted your time. It was a server reboot issue. The ocdb server hasn't been restarted since early July. We added the users and groups late last week. Although we tested on line, the server wasn't quite up to speed with the new changes.
We bounced the server and all is well.
Thanks
Winston -
Eventhandlers of children of application can not receive custom event dispatched by application
Hello dear Adobe community,
hope you can help me with this issue.
When the application dispatches a custom event, the child uicomponent can only receive the event by using Application.application.addEventListener or systemManager.addEventListener. Simply adding a listener, without application or systemmanager, does not allow the event to be received by the child component.
I want to be able to use the addEventListener and removeEventListener without SystemManager or Application.application, or could you provide a better workaround? How can I use the addEventListener, do I need to overwrite EventDispatcher, which I wouldnt like to do?
Just to clarifiy, if i remove the systemManager in front of addEventListener(CustomEventOne.EventOne,sysManHandleCE,false) it will not add it and will not fire.
The code below is an example for this problem that the event is not getting fired in the right moment. The mainapplication got only a button with the customEventOne that gets dispatched.
public
class MyCanvas extends Canvas{
public function MyCanvas()
super();
width=300;
height=300;
addEventListener(FlexEvent.CREATION_COMPLETE,handleCC,false,0,true);
private function handleCC(event:FlexEvent):void
removeEventListener(FlexEvent.CREATION_COMPLETE,handleCC);
addEventListener(CustomEventOne.EventOne,handleCE,false,0,true);
addEventListener(Event.REMOVED_FROM_STAGE,handleEvt,false,0,true);
systemManager.addeventListener(CustomEventOne.eventOne,sysManHandleCE,false,0,true);
private function handleEvt(event:Event):void
trace("In removed from stage handler");
systemManager.removeEventListener(CustomEventOne.EventOne,sysManHandleCE);
trace(hasEventListener(FlexEvent.CREATION_COMPLETE));
trace(hasEventListener(CustomEventOne.EventOne));
trace(hasEventListener(Event.REMOVED_FROM_STAGE));
private function handleCE(event:CustomEventOne):void
trace("I got it");
private function sysManHandleCE(event:CustomEventOne):void
trace("I got it");
public class CustomEventOne extends Event
public static const EventOne:String = "EventOne";
public function CustomEventOne(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
super(type, bubbles, cancelable);
override public functionclone():Event
return newCustomEventOne(type,bubbles,cancelable);
Thank you in advance,
MichaelI think you need to look at event propogation. The object that dispatches an event will be sitting on the display tree. The event propagates up the tree to the roots. Your canvas should be attached to the application, but even then it sits lower in the tree branches than the event dispatcher, so it won't see the event being dispatched because the event is not propagated to the children of the object that dispatches it but to the parent of the object that dispatches it.
So, your canvas is a child of the application, but dispatching the event from the application means that the canvas doesn't see it because events are notified up the tree using the parent link, not the child links.
You may wish to investigate how the display list and event propagation works and then the MVC pattern.
Paul -
Please Help me with my Custom Event
I am new in java, please help me about my custom event
I have a simple source code about custom event but it doesn't work like I want. This code generate result :
start
end
but I want result :
start
my custom event (from aaa method)
end
Thank you
package TestBean;
class MyEvent extends java.util.EventObject {
public MyEvent(Object source) {
super(source);
interface MyEventListener extends java.util.EventListener {
public void myEventOccurred(MyEvent evt);
class MyClass {
protected javax.swing.event.EventListenerList listenerList =
new javax.swing.event.EventListenerList();
public void addMyEventListener(MyEventListener listener) {
listenerList.add(MyEventListener.class, listener);
public void removeMyEventListener(MyEventListener listener) {
listenerList.remove(MyEventListener.class, listener);
protected void fireMyEvent(MyEvent evt) {
Object[] listeners = listenerList.getListenerList();
for (int i=0; i<listeners.length; i+=2) {
if (listeners==MyEventListener.class) {
((MyEventListener)listeners[i+1]).myEventOccurred(evt);
public class BeanFrame extends javax.swing.JFrame {
public BeanFrame() {
initComponents();
MyClass c = new MyClass();
System.out.println("start");
c.addMyEventListener(new MyEventListener()
public void myEventOccurred(MyEvent evt)
aaa(evt);
System.out.println("end");
private void aaa(MyEvent evt) {
System.out.println("my custom event");
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BeanFrame().setVisible(true);package TestBean;
class MyEvent extends java.util.EventObject {
public MyEvent(Object source) {
super(source);
interface MyEventListener extends java.util.EventListener {
public void myEventOccurred(MyEvent evt);
class MyClass {
protected javax.swing.event.EventListenerList listenerList =
new javax.swing.event.EventListenerList();
public void addMyEventListener(MyEventListener listener) {
listenerList.add(MyEventListener.class, listener);
public void removeMyEventListener(MyEventListener listener) {
listenerList.remove(MyEventListener.class, listener);
protected void fireMyEvent(MyEvent evt) {
Object[] listeners = listenerList.getListenerList();
for (int i=0; i<listeners.length; i+=2) {
if (listeners==MyEventListener.class) {
((MyEventListener)listeners[i+1]).myEventOccurred(evt);
public class BeanFrame extends javax.swing.JFrame {
public BeanFrame() {
initComponents();
MyClass c = new MyClass();
System.out.println("start");
c.addMyEventListener(new MyEventListener(){
public void myEventOccurred(MyEvent evt){
aaa(evt);
System.out.println("end");
private void aaa(MyEvent evt) {
System.out.println("my custom event");
// ><editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BeanFrame().setVisible(true);
}just enclosed it with the code tags.
Maybe you are looking for
-
EOS Solution Disk v28.1 installation problem on Mac.
Yesterday I got the EOS 700D DSLR and when I wanted to install the EOS Solution Disk nothing happened. Nothing seems to happen when I click the setup icon. Has this happened to anyone?
-
Dump in adding a ui element to group dynamically
hi all, I have a group which has a dropdown ,my requirement is when i click a button a dropdown should be created dynamically below the dropdown created at design time. My code in wddomodifyview() cl_wd_dropdown_by_idx=>new_dropdown_by_idx( EXP
-
Custom keyboard shortcuts for Liquify and Vanishing Point filter interfaces in Photoshop CS4?
Is there a way to set custom keyboard shortcuts for Liquify and Vanishing Point filter interfaces in Photoshop CS4? When I change my keyboard shortcuts preferences for Photoshop, they don't change for these filter interfaces. Is there another way?
-
DVD Studio Pro 4 will not open after installing Leopard
I had trouble opening my film project in FCP studio 2 but resolved the problem by trashing the preferences. This did not help other programs like DVD studio pro which will not open at all or crashes as soon as it is open. It also gives me strange mes
-
How do I reset my rescue email when I do not know the answers to my security questions
So I need to answer my security questions which I thought I knew and apparently don't. But when I try to reset them it sends to a rescue email that doesn't exist anymore. How do I go about changing my rescue email to update my security questions?