Subversion Repository Public Repository

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
package com.temp.client.foundation.pavment;

import com.google.gwt.place.shared.*;

import java.util.*;

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() + ")" );
            }
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/pavment/ActivityFactoryRegistry.java

Diff revisions: vs.
Revision Author Commited Message
948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

626 GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000