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