|
@@ -1,57 +1,51 @@ |
1 |
1 |
|
package org.litesoft.GWT.client.pavsupport; |
2 |
2 |
|
|
3 |
|
- |
import java.util.*; |
4 |
|
- |
|
5 |
3 |
|
import com.google.gwt.place.shared.*; |
6 |
4 |
|
import com.google.gwt.user.client.ui.*; |
7 |
5 |
|
|
8 |
|
- |
public class ActivityFactoryRegistry |
9 |
|
- |
{ |
10 |
|
- |
public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register( ActivityFactory.Synchronous<CommonActivityParam, View, APlace> pFactory ) |
11 |
|
- |
{ |
|
6 |
+ |
import java.util.*; |
|
7 |
+ |
|
|
8 |
+ |
public class ActivityFactoryRegistry { |
|
9 |
+ |
public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register( |
|
10 |
+ |
ActivityFactory.Synchronous<CommonActivityParam, View, APlace> pFactory ) { |
12 |
11 |
|
add( pFactory ); |
13 |
12 |
|
} |
14 |
13 |
|
|
15 |
|
- |
public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register( ActivityFactory.Asynchronous<CommonActivityParam, View, APlace> pFactory ) |
16 |
|
- |
{ |
|
14 |
+ |
public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register( |
|
15 |
+ |
ActivityFactory.Asynchronous<CommonActivityParam, View, APlace> pFactory ) { |
17 |
16 |
|
add( pFactory ); |
18 |
17 |
|
} |
19 |
18 |
|
|
20 |
19 |
|
private static final Map<String, ActivityFactory> PLACEID2ACTIVITYFACTORIES = new HashMap<String, ActivityFactory>(); |
21 |
20 |
|
|
22 |
|
- |
protected static synchronized ActivityFactory get( String pPlaceId ) |
23 |
|
- |
{ |
|
21 |
+ |
protected static synchronized ActivityFactory get( String pPlaceId ) { |
24 |
22 |
|
return PLACEID2ACTIVITYFACTORIES.get( pPlaceId ); |
25 |
23 |
|
} |
26 |
24 |
|
|
27 |
|
- |
protected static synchronized boolean replace( ActivityFactory.Asynchronous pExistingFactory, ActivityFactory pNewSyncFactory ) |
28 |
|
- |
{ |
29 |
|
- |
if ( pNewSyncFactory != null ) |
30 |
|
- |
{ |
|
25 |
+ |
protected static synchronized boolean replace( ActivityFactory.Asynchronous pExistingFactory, ActivityFactory pNewSyncFactory ) { |
|
26 |
+ |
if ( pNewSyncFactory != null ) { |
31 |
27 |
|
String zPlaceId = pNewSyncFactory.getPlaceId(); |
32 |
|
- |
if ( !pExistingFactory.getPlaceId().equals( zPlaceId ) ) |
33 |
|
- |
{ |
|
28 |
+ |
if ( !pExistingFactory.getPlaceId().equals( zPlaceId ) ) { |
34 |
29 |
|
throw new IllegalStateException( "New Sync Factory for '" + zPlaceId + "', not '" + pExistingFactory.getPlaceId() + "'" ); |
35 |
30 |
|
} |
36 |
31 |
|
ActivityFactory zPreviousFactory = PLACEID2ACTIVITYFACTORIES.put( zPlaceId, pNewSyncFactory ); |
37 |
|
- |
if ( pExistingFactory != zPreviousFactory ) |
38 |
|
- |
{ |
39 |
|
- |
throw new IllegalStateException( "Existing Async Factory (" + pExistingFactory.getClass() + ") already replaced by (" + zPreviousFactory.getClass() + ") for: " + zPlaceId ); |
|
32 |
+ |
if ( pExistingFactory != zPreviousFactory ) { |
|
33 |
+ |
throw new IllegalStateException( |
|
34 |
+ |
"Existing Async Factory (" + pExistingFactory.getClass() + ") already replaced by (" + zPreviousFactory.getClass() + ") for: " + |
|
35 |
+ |
zPlaceId ); |
40 |
36 |
|
} |
41 |
37 |
|
return true; |
42 |
38 |
|
} |
43 |
39 |
|
return false; |
44 |
40 |
|
} |
45 |
41 |
|
|
46 |
|
- |
private static synchronized void add( ActivityFactory pFactory ) |
47 |
|
- |
{ |
48 |
|
- |
if ( pFactory != null ) |
49 |
|
- |
{ |
|
42 |
+ |
private static synchronized void add( ActivityFactory pFactory ) { |
|
43 |
+ |
if ( pFactory != null ) { |
50 |
44 |
|
String zPlaceId = pFactory.getPlaceId(); |
51 |
45 |
|
ActivityFactory zPreviousFactory = PLACEID2ACTIVITYFACTORIES.put( zPlaceId, pFactory ); |
52 |
|
- |
if ( (zPreviousFactory != null) && (zPreviousFactory == pFactory) ) |
53 |
|
- |
{ |
54 |
|
- |
throw new IllegalStateException( "Duplicate registration for '" + zPlaceId + "', previous (" + zPreviousFactory.getClass() + "), new (" + pFactory.getClass() + ")" ); |
|
46 |
+ |
if ( (zPreviousFactory != null) && (zPreviousFactory == pFactory) ) { |
|
47 |
+ |
throw new IllegalStateException( |
|
48 |
+ |
"Duplicate registration for '" + zPlaceId + "', previous (" + zPreviousFactory.getClass() + "), new (" + pFactory.getClass() + ")" ); |
55 |
49 |
|
} |
56 |
50 |
|
} |
57 |
51 |
|
} |