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 org.litesoft.GWT.client.pavsupport;

import com.google.gwt.place.shared.*;
import com.google.gwt.user.client.ui.*;

import java.util.*;

public class ActivityFactoryRegistry {
    public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register(
            ActivityFactory.Synchronous<CommonActivityParam, View, APlace> pFactory ) {
        add( pFactory );
    }

    public static <CommonActivityParam extends CommonActivityParameter, View extends IsWidget, APlace extends Place> void register(
            ActivityFactory.Asynchronous<CommonActivityParam, View, 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 );
    }

    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/Java/GWT/Client/src/org/litesoft/GWT/client/pavsupport/ActivityFactoryRegistry.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

720 Diff Diff GeorgeS picture GeorgeS Sun 10 Jun, 2012 16:20:42 +0000
712 GeorgeS picture GeorgeS Sat 09 Jun, 2012 22:46:04 +0000

Move PAV stuff into LiteSoft