/*
 * Copyright (C) 2009 eXo Platform SAS.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.exoplatform.services.jcr.impl.storage.inmemory;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by The eXo Platform SAS.
 * 
 * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
 * @version $Id: WorkspaceContainerRegistry.java 11907 2008-03-13 15:36:21Z ksm $
 */
public class WorkspaceContainerRegistry
{

   /* # private WorkspaceContainerRegistry _workspaceRegistry; */
   private static WorkspaceContainerRegistry instance = null;

   // map that contain a map of items
   private Map workspaces;

   private String defaultWorkspace;

   protected WorkspaceContainerRegistry()
   {
      workspaces = new HashMap();
   }

   public static WorkspaceContainerRegistry getInstance()
   {
      if (instance == null)
      {
         instance = new WorkspaceContainerRegistry();
      }
      return instance;
   }

   public TreeMap getWorkspaceContainer(String name)
   {

      if (workspaces.get(name) == null)
         initWorkspaceContainer(name);

      return (TreeMap)workspaces.get(name);
   }

   private void initWorkspaceContainer(String name)
   {

      TreeMap workspace = new TreeMap();
      workspaces.put(name, workspace);

   }

}
