KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > impl > storage > inmemory > WorkspaceContainerRegistry


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5
6 package org.exoplatform.services.jcr.impl.storage.inmemory;
7
8 import java.util.Map JavaDoc;
9 import java.util.HashMap JavaDoc;
10 import javax.jcr.Node;
11 import org.exoplatform.services.jcr.impl.core.NodeImpl;
12
13 /**
14  * Created by The eXo Platform SARL .
15  *
16  * @author <a HREF="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
17  * @version $Id: WorkspaceContainerRegistry.java,v 1.1 2004/08/23 10:31:39 geaz Exp $
18  */

19 public class WorkspaceContainerRegistry {
20
21     /*# private WorkspaceContainerRegistry _workspaceRegistry; */
22     private static WorkspaceContainerRegistry instance = null;
23
24   //map that contain a map of items
25
private Map JavaDoc workspaces;
26     private String JavaDoc defaultWorkspace;
27
28     protected WorkspaceContainerRegistry() {
29
30        workspaces = new HashMap JavaDoc();
31     }
32
33     public static WorkspaceContainerRegistry getInstance() {
34         if (instance == null) {
35             instance = new WorkspaceContainerRegistry ();
36         }
37         return instance;
38     }
39
40
41     public Map JavaDoc getWorkspaceContainer(String JavaDoc name, String JavaDoc rootNodeType) {
42
43         if(workspaces.get(name) == null)
44             initWorkspaceContainer(name, rootNodeType);
45
46         return (Map JavaDoc)workspaces.get(name);
47     }
48
49      private void initWorkspaceContainer(String JavaDoc name, String JavaDoc rootNodeType) {
50
51         Map JavaDoc workspace = new HashMap JavaDoc();
52         try {
53            workspace.put("/", new NodeImpl("/",rootNodeType));
54         } catch (Exception JavaDoc e) {
55             // unreal
56
}
57         workspaces.put(name, workspace);
58
59 // if(isBase)
60
// defaultWorkspace = name;
61
}
62
63 }
64
Popular Tags