bundles/org.eclipse.packagedrone.storage.apm/src/org/eclipse/packagedrone/storage/apm/StorageManager.java
public StorageRegistration registerModel ( final long lockPriority, final MetaKey key, final StorageModelProvider<?, ?> storageProvider ) throws ModelInitializationException
    {
        this.modelLock.writeLock ().lock ();
        try
        {
            testClosed ();

            if ( this.modelKeyMap.containsKey ( key ) )
            {
                throw new IllegalArgumentException ( String.format ( "A provider for '%s' is already registered", key ) );
            }

            try
            {
                storageProvider.start ( this.context );
            }
            catch ( final Exception e )
            {
                throw new ModelInitializationException ( "Failed to start model provider: " + key, e );
            }

            final long id = this.counter++;

            final Entry entry = new Entry ( id, lockPriority, key, storageProvider );

            this.modelIdMap.put ( id, entry );
            this.modelKeyMap.put ( key, entry );

            return new StorageRegistration () {

                @Override
                public void unregister ()
                {
                    unregisterModel ( id );
                }
            };
        }
        finally
        {
            this.modelLock.writeLock ().unlock ();
        }
    }
public StorageRegistration registerModel ( final long lockPriority, final MetaKey key, final StorageModelProvider<?, ?> storageProvider ) throws ModelInitializationException
    {
        this.modelLock.writeLock ().lock ();
        try
        {
            testClosed ();

            if ( this.modelKeyMap.containsKey ( key ) )
            {
                throw new IllegalArgumentException ( String.format ( "A provider for '%s' is already registered", key ) );
            }

            try
            {
                storageProvider.start ( this.context );
            }
            catch ( final Exception e )
            {
                throw new ModelInitializationException ( "Failed to start model provider: " + key, e );
            }

            final long id = this.counter++;

            final Entry entry = new Entry ( id, lockPriority, key, storageProvider );

            this.modelIdMap.put ( id, entry );
            this.modelKeyMap.put ( key, entry );

            return new StorageRegistration () {

                @Override
                public void unregister ()
                {
                    unregisterModel ( id );
                }
            };
        }
        finally
        {
            this.modelLock.writeLock ().unlock ();
        }
    }
Register a new model with the storage manager

@param lockPriority
the priority of the lock, lower numbers must be locked before
higher numbers
@param key
the model key
@param storageProvider
the storage provider
@return a handle for unregistering the model
@throws ModelInitializationException
if the {@link StorageModelProvider#start(StorageContext)}
method fails