Changeset 49

Show
Ignore:
Timestamp:
02/21/10 20:06:48 (2 years ago)
Author:
ke
Message:

DbDataManager? now stores non-lightweight Kahina objects in memory by default.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • kahina/trunk/src/org/kahina/core/data/DbDataManager.java

    r17 r49  
    1010 
    1111/** 
    12  * A {@link DataManager} implementation using a database for storage, and 
    13  * {@link LightweightKahinaObjectDbDataStore}s as default data stores. 
     12 * A {@link DataManager} implementation using a database for storage, 
     13 * {@link LightweightKahinaObjectDbDataStore}s as default data stores for 
     14 * {@link LightweightKahinaObject}s, and {@link KahinaObjectMemDataStore}s as 
     15 * default data stores for other {@link KahinaObject}s. 
    1416 *  
    1517 * @author ke 
     
    3638 
    3739        @Override 
    38         public void registerDataType(Class<? extends KahinaObject> type, DataStore store) 
     40        public void registerDataType(Class<? extends KahinaObject> type, 
     41                        DataStore store) 
    3942        { 
    4043                if (typeIDByType.containsKey(type)) 
    4144                { 
    42                         throw new KahinaException("A data store for type " + type + " is already registered."); 
     45                        throw new KahinaException("A data store for type " + type 
     46                                        + " is already registered."); 
    4347                } 
    4448                typeIDByType.put(type, storeByTypeID.size()); 
     
    4953         * Registers a new data type with a 
    5054         * {@link LightweightKahinaObjectDbDataStore}. 
     55         *  
    5156         * @param type 
    5257         *            Must be a subclass of {@link LightweightKahinaObject}. 
     
    5560        public void registerDataType(Class<? extends KahinaObject> type) 
    5661        { 
    57                 if (!LightweightKahinaObject.class.isAssignableFrom(type)) 
     62                if (LightweightKahinaObject.class.isAssignableFrom(type)) 
    5863                { 
    59                         throw new KahinaException("Cannot auto-create a suitable data store for " + type + "."); 
     64                        registerDataType(type, new LightweightKahinaObjectDbDataStore(type, 
     65                                        this, db)); 
     66                } else 
     67                { 
     68                        registerDataType(type, new KahinaObjectMemDataStore()); 
    6069                } 
    61                 registerDataType(type, new LightweightKahinaObjectDbDataStore(type, this, db)); 
    6270        } 
    6371 
    6472        /** 
    6573         * Returns the internal numeric ID given to a data type by this manager. 
     74         *  
    6675         * @param type 
    6776         * @return 
     
    7483        /** 
    7584         * Retrieves an object by the internal numeric ID given to its type by this 
    76          * manager, and its object ID.  
     85         * manager, and its object ID. 
     86         *  
    7787         * @param typeID 
    7888         * @param objectID