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