|
@@ -1,100 +1,100 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.eventbus.client.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.eventbus.client.*; |
5 |
|
- |
import org.litesoft.core.delayed.*; |
6 |
|
- |
import org.litesoft.logger.*; |
7 |
|
- |
|
8 |
|
- |
public abstract class AbstractPeerSupportingEventBus extends EventBus implements PeerSupportingEventBus, |
9 |
|
- |
EventConstrictor { |
10 |
|
- |
private IStatePeerSupportingEventBus mStatePeerSupportingEventBus = |
11 |
|
- |
NullStatePeerSupportingEventBus.INSTANCE; |
12 |
|
- |
|
13 |
|
- |
protected AbstractPeerSupportingEventBus( String pForm, int pClientIdNumber, // |
14 |
|
- |
TimedRunner pTimedRunner, |
15 |
|
- |
UnexpectedEventPackageHandler pUnexpectedHandler ) { |
16 |
|
- |
super( pForm, pClientIdNumber, pTimedRunner, pUnexpectedHandler ); |
17 |
|
- |
} |
18 |
|
- |
|
19 |
|
- |
protected void LLdisposing( String pWhy ) { |
20 |
|
- |
getStatePeerSupportingEventBus().disposing(); |
21 |
|
- |
super.LLdisposing( pWhy ); |
22 |
|
- |
} |
23 |
|
- |
|
24 |
|
- |
protected void LLdispose( String pWhy ) { |
25 |
|
- |
IStatePeerSupportingEventBus peer = getStatePeerSupportingEventBus(); |
26 |
|
- |
mStatePeerSupportingEventBus = NullStatePeerSupportingEventBus.INSTANCE; |
27 |
|
- |
peer.dispose(); |
28 |
|
- |
super.LLdispose( pWhy ); |
29 |
|
- |
} |
30 |
|
- |
|
31 |
|
- |
/** |
32 |
|
- |
* @noinspection NonJREEmulationClassesInClientCode |
33 |
|
- |
*/ |
34 |
|
- |
protected synchronized void initialize( Logger pLogger, |
35 |
|
- |
IStatePeerSupportingEventBus pStatePeerSupportingEventBus ) { |
36 |
|
- |
if ( pLogger != null ) { |
37 |
|
- |
mLogger = pLogger; |
38 |
|
- |
} |
39 |
|
- |
mStatePeerSupportingEventBus = pStatePeerSupportingEventBus; |
40 |
|
- |
} |
41 |
|
- |
|
42 |
|
- |
protected synchronized IStatePeerSupportingEventBus getStatePeerSupportingEventBus() { |
43 |
|
- |
return mStatePeerSupportingEventBus; |
44 |
|
- |
} |
45 |
|
- |
|
46 |
|
- |
protected IStatePeerSupportingEventBus switchFromSuspendedToRegular() { |
47 |
|
- |
IStatePeerSupportingEventBus suspended; |
48 |
|
- |
synchronized ( this ) { |
49 |
|
- |
suspended = mStatePeerSupportingEventBus; |
50 |
|
- |
mStatePeerSupportingEventBus = suspended.suspendedToRegular( this, this ); |
51 |
|
- |
} |
52 |
|
- |
suspended.dispose(); |
53 |
|
- |
return mStatePeerSupportingEventBus; |
54 |
|
- |
} |
55 |
|
- |
|
56 |
|
- |
/** |
57 |
|
- |
* @noinspection NonJREEmulationClassesInClientCode |
58 |
|
- |
*/ |
59 |
|
- |
protected Logger createLogger() { |
60 |
|
- |
Logger logger = LoggerFactory.getLogger( getForm() + "EB" ); |
61 |
|
- |
return PrefixingLogger.decorate( "(" + getClientIdNumber() + ")", logger ); |
62 |
|
- |
} |
63 |
|
- |
|
64 |
|
- |
public String isLocalDistributionFromPeerOK( EventPackage pPackage ) { |
65 |
|
- |
return null; |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
protected void LLpublishNonNullNotDisposedExpectingResponse( EventPackage pPackage ) { |
69 |
|
- |
getStatePeerSupportingEventBus().publishExpectingResponse( pPackage ); |
70 |
|
- |
} |
71 |
|
- |
|
72 |
|
- |
protected void LLsubscribeAndPublish( EventSubscriptionStructure[] pSubscriptions, |
73 |
|
- |
EventPackage[] pPackages ) { |
74 |
|
- |
if ( (pSubscriptions.length != 0) || (pPackages.length != 0) ) { |
75 |
|
- |
getStatePeerSupportingEventBus().subscribeAndPublish( pSubscriptions, pPackages ); |
76 |
|
- |
} |
77 |
|
- |
} |
78 |
|
- |
|
79 |
|
- |
protected void LLunsubscribe( EventSubscriptionStructure[] pSubscriptions ) { |
80 |
|
- |
if ( pSubscriptions.length != 0 ) { |
81 |
|
- |
getStatePeerSupportingEventBus().unsubscribe( pSubscriptions ); |
82 |
|
- |
} |
83 |
|
- |
} |
84 |
|
- |
|
85 |
|
- |
public void problemFromRemotePeerService( EventPackage pProblem ) { |
86 |
|
- |
getStatePeerSupportingEventBus().problemFromRemotePeerService( pProblem ); |
87 |
|
- |
} |
88 |
|
- |
|
89 |
|
- |
public boolean propagateFromRemotePeerService( ChannelServicePackage pFromPeer ) { |
90 |
|
- |
return getStatePeerSupportingEventBus().propagateFromRemotePeerService( pFromPeer ); |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
public boolean ping() { |
94 |
|
- |
return getStatePeerSupportingEventBus().ping(); |
95 |
|
- |
} |
96 |
|
- |
|
97 |
|
- |
public String toString() { |
98 |
|
- |
return getForm() + "EventBus(" + getClientIdNumber() + ")"; |
99 |
|
- |
} |
100 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.eventbus.client.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.eventbus.client.*; |
|
5 |
+ |
import org.litesoft.core.delayed.*; |
|
6 |
+ |
import org.litesoft.logger.*; |
|
7 |
+ |
|
|
8 |
+ |
public abstract class AbstractPeerSupportingEventBus extends EventBus implements PeerSupportingEventBus, |
|
9 |
+ |
EventConstrictor { |
|
10 |
+ |
private IStatePeerSupportingEventBus mStatePeerSupportingEventBus = |
|
11 |
+ |
NullStatePeerSupportingEventBus.INSTANCE; |
|
12 |
+ |
|
|
13 |
+ |
protected AbstractPeerSupportingEventBus( String pForm, int pClientIdNumber, // |
|
14 |
+ |
TimedRunner pTimedRunner, |
|
15 |
+ |
UnexpectedEventPackageHandler pUnexpectedHandler ) { |
|
16 |
+ |
super( pForm, pClientIdNumber, pTimedRunner, pUnexpectedHandler ); |
|
17 |
+ |
} |
|
18 |
+ |
|
|
19 |
+ |
protected void LLdisposing( String pWhy ) { |
|
20 |
+ |
getStatePeerSupportingEventBus().disposing(); |
|
21 |
+ |
super.LLdisposing( pWhy ); |
|
22 |
+ |
} |
|
23 |
+ |
|
|
24 |
+ |
protected void LLdispose( String pWhy ) { |
|
25 |
+ |
IStatePeerSupportingEventBus peer = getStatePeerSupportingEventBus(); |
|
26 |
+ |
mStatePeerSupportingEventBus = NullStatePeerSupportingEventBus.INSTANCE; |
|
27 |
+ |
peer.dispose(); |
|
28 |
+ |
super.LLdispose( pWhy ); |
|
29 |
+ |
} |
|
30 |
+ |
|
|
31 |
+ |
/** |
|
32 |
+ |
* @noinspection NonJREEmulationClassesInClientCode |
|
33 |
+ |
*/ |
|
34 |
+ |
protected synchronized void initialize( Logger pLogger, |
|
35 |
+ |
IStatePeerSupportingEventBus pStatePeerSupportingEventBus ) { |
|
36 |
+ |
if ( pLogger != null ) { |
|
37 |
+ |
mLogger = pLogger; |
|
38 |
+ |
} |
|
39 |
+ |
mStatePeerSupportingEventBus = pStatePeerSupportingEventBus; |
|
40 |
+ |
} |
|
41 |
+ |
|
|
42 |
+ |
protected synchronized IStatePeerSupportingEventBus getStatePeerSupportingEventBus() { |
|
43 |
+ |
return mStatePeerSupportingEventBus; |
|
44 |
+ |
} |
|
45 |
+ |
|
|
46 |
+ |
protected IStatePeerSupportingEventBus switchFromSuspendedToRegular() { |
|
47 |
+ |
IStatePeerSupportingEventBus suspended; |
|
48 |
+ |
synchronized ( this ) { |
|
49 |
+ |
suspended = mStatePeerSupportingEventBus; |
|
50 |
+ |
mStatePeerSupportingEventBus = suspended.suspendedToRegular( this, this ); |
|
51 |
+ |
} |
|
52 |
+ |
suspended.dispose(); |
|
53 |
+ |
return mStatePeerSupportingEventBus; |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
/** |
|
57 |
+ |
* @noinspection NonJREEmulationClassesInClientCode |
|
58 |
+ |
*/ |
|
59 |
+ |
protected Logger createLogger() { |
|
60 |
+ |
Logger logger = LoggerFactory.getLogger( getForm() + "EB" ); |
|
61 |
+ |
return PrefixingLogger.decorate( "(" + getClientIdNumber() + ")", logger ); |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
public String isLocalDistributionFromPeerOK( EventPackage pPackage ) { |
|
65 |
+ |
return null; |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
protected void LLpublishNonNullNotDisposedExpectingResponse( EventPackage pPackage ) { |
|
69 |
+ |
getStatePeerSupportingEventBus().publishExpectingResponse( pPackage ); |
|
70 |
+ |
} |
|
71 |
+ |
|
|
72 |
+ |
protected void LLsubscribeAndPublish( EventSubscriptionStructure[] pSubscriptions, |
|
73 |
+ |
EventPackage[] pPackages ) { |
|
74 |
+ |
if ( (pSubscriptions.length != 0) || (pPackages.length != 0) ) { |
|
75 |
+ |
getStatePeerSupportingEventBus().subscribeAndPublish( pSubscriptions, pPackages ); |
|
76 |
+ |
} |
|
77 |
+ |
} |
|
78 |
+ |
|
|
79 |
+ |
protected void LLunsubscribe( EventSubscriptionStructure[] pSubscriptions ) { |
|
80 |
+ |
if ( pSubscriptions.length != 0 ) { |
|
81 |
+ |
getStatePeerSupportingEventBus().unsubscribe( pSubscriptions ); |
|
82 |
+ |
} |
|
83 |
+ |
} |
|
84 |
+ |
|
|
85 |
+ |
public void problemFromRemotePeerService( EventPackage pProblem ) { |
|
86 |
+ |
getStatePeerSupportingEventBus().problemFromRemotePeerService( pProblem ); |
|
87 |
+ |
} |
|
88 |
+ |
|
|
89 |
+ |
public boolean propagateFromRemotePeerService( ChannelServicePackage pFromPeer ) { |
|
90 |
+ |
return getStatePeerSupportingEventBus().propagateFromRemotePeerService( pFromPeer ); |
|
91 |
+ |
} |
|
92 |
+ |
|
|
93 |
+ |
public boolean ping() { |
|
94 |
+ |
return getStatePeerSupportingEventBus().ping(); |
|
95 |
+ |
} |
|
96 |
+ |
|
|
97 |
+ |
public String toString() { |
|
98 |
+ |
return getForm() + "EventBus(" + getClientIdNumber() + ")"; |
|
99 |
+ |
} |
|
100 |
+ |
} |