|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.mdr.persistence.memoryimpl; import java.util.HashMap; import java.util.Map; import org.netbeans.mdr.persistence.*; /** * * @author pbuzek * @version */ public class StorageFactoryImpl extends Object implements StorageFactory { public static final String STORAGE_ID = "org.netbeans.mdr.persistence.memoryimpl.id"; public static final String STORAGE_NAME = "org.netbeans.mdr.persistence.memoryimpl.fileName"; static final String NULL_STORAGE_ID = "."; private static final MOFID NULL_MOFID = new MOFID(0, NULL_STORAGE_ID); private StorageImpl nullStorage; private static final HashMap storages = new HashMap(); /** Creates new StorageFactoryImpl */ public StorageFactoryImpl() { } /** Creates instance of class that implements Storage interface. * throws StorageException if the name is not valid name of a Storage */ public synchronized Storage createStorage(Map properties) throws StorageException { String name = (String) properties.get(STORAGE_ID); // Not mandatory if (name == null || name.equals(NULL_STORAGE_ID)) { if (nullStorage == null) { nullStorage = new StorageImpl(NULL_STORAGE_ID, null); } return nullStorage; } else { synchronized (storages) { if (storages.containsKey(name)) { throw new RuntimeException("Storage '" + name + "' already created."); } else { Storage result = new StorageImpl(name, (String) properties.get(STORAGE_NAME)); storages.put(name, result); return result; } } } } /** Serializes content of the given storage. Returns false if the storage was not found. */ public static boolean serialize(String storageId) throws StorageException { StorageImpl storage; synchronized (storages) { storage = (StorageImpl) storages.get(storageId); } if (storage == null) { return false; } storage.serialize(); return true; } public org.netbeans.mdr.persistence.MOFID createNullMOFID() throws StorageException { return NULL_MOFID; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.