KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > impl > config > DummyConfig


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.config;
7
8
9 import java.util.Properties JavaDoc;
10 import org.exoplatform.services.jcr.config.*;
11 import org.exoplatform.services.jcr.impl.storage.filesystem.SimpleFsContainerImpl;
12 import org.exoplatform.services.jcr.impl.storage.inmemory.ContainerImpl;
13 import org.exoplatform.services.jcr.impl.storage.rdb.container.RDBWorkspaceContainerImpl;
14
15 /**
16  * Created by The eXo Platform SARL
17  *
18  * @author <a HREF="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
19  * @version $Id: DummyConfig.java,v 1.12 2004/11/02 18:36:28 geaz Exp $
20  */

21
22 public class DummyConfig implements RepositoryServiceConfig {
23
24   private WorkspaceEntry[] wes = new WorkspaceEntry[9];
25   private ContainerEntry[] ces = new ContainerEntry[5];
26   private RepositoryEntry[] res = new RepositoryEntry[3];
27   private RepositoryManagerEntry[] mes = new RepositoryManagerEntry[3];
28
29   public DummyConfig() {
30     wes[0] = new WorkspaceEntry("ws", "mock", true, "c.inmemory");
31     wes[1] = new WorkspaceEntry("ws2", "mock", "c.inmemory2");
32     wes[2] = new WorkspaceEntry("ws3", "mock", "c.inmemory");
33     wes[3] = new WorkspaceEntry("ws", "fs1", true, "c.fs1");
34     wes[4] = new WorkspaceEntry("ws2", "fs1", "c.fs1");
35     wes[5] = new WorkspaceEntry("ws3", "fs1", "c.fs1");
36     wes[6] = new WorkspaceEntry("ws", "db1", true, "c.db1");
37     wes[7] = new WorkspaceEntry("ws2", "db1", "c.db2");
38     wes[8] = new WorkspaceEntry("ws3", "db1", "c.db1");
39
40     Properties JavaDoc props = new Properties JavaDoc();
41     props.setProperty("rootNodeType", "nt:default");
42     ces[0] = new ContainerEntry("c.inmemory", ContainerImpl.class, props);
43     ces[1] = new ContainerEntry("c.inmemory2", ContainerImpl.class, props);
44
45     props = new Properties JavaDoc();
46     props.setProperty("rootDir", "./temp/fsroot");
47     ces[2] = new ContainerEntry("c.fs1", SimpleFsContainerImpl.class, props);
48
49     props = new Properties JavaDoc();
50     props.setProperty("rootNodeType", "nt:default");
51     props.setProperty("sourceName", "exo.hibernate.service1");
52
53 // props.setProperty("sourceName", "jdbc:hsqldb:mem:exo");
54
// props.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.HSQLDialect");
55

56     ces[3] = new ContainerEntry("c.db1", RDBWorkspaceContainerImpl.class, props);
57     props = new Properties JavaDoc();
58 // props.setProperty("rootNodeType", "nt:default");
59
props.setProperty("sourceName", "exo.hibernate.service2");
60
61 // props.setProperty("sourceName", "jdbc:hsqldb:mem:exo2");
62
// props.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.HSQLDialect");
63

64     ces[4] = new ContainerEntry("c.db2", RDBWorkspaceContainerImpl.class, props);
65
66     props = new Properties JavaDoc();
67     mes[0] = new RepositoryManagerEntry("inmemory", org.exoplatform.services.jcr.impl.storage.inmemory.RepositoryManagerImpl.class, props);
68     mes[1] = new RepositoryManagerEntry("sfs", org.exoplatform.services.jcr.impl.storage.filesystem.SimpleFsRepositoryManagerImpl.class, props);
69     props = new Properties JavaDoc();
70     props.setProperty("sourceName", "exo.hibernate.service1");
71 // props.setProperty("sourceName", "jdbc:hsqldb:mem:exo");
72
// props.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.HSQLDialect");
73
mes[2] = new RepositoryManagerEntry("db", org.exoplatform.services.jcr.impl.storage.rdb.repository.RDBRepositoryManagerImpl.class, props);
74
75
76     res[0] = new RepositoryEntry("mock", "inmemory");
77     res[1] = new RepositoryEntry("fs1", "sfs");
78     res[2] = new RepositoryEntry("db1", "db");
79
80   }
81
82   public String JavaDoc getDefaultRepositoryName() {
83     return "mock";
84   }
85
86   public RepositoryEntry[] getRepositoryEntries() {
87     return res;
88   }
89
90   public WorkspaceEntry[] getWorkspaceEntries() {
91     return wes;
92   }
93
94   public WorkspaceEntry getWorkspaceEntry(String JavaDoc repositoryName, String JavaDoc name) {
95     for (int i = 0; i < wes.length; i++) {
96       if (wes[i].getRepositoryName().equals(repositoryName) && wes[i].getName().equals(name))
97         return wes[i];
98     }
99     return null;
100   }
101
102   public ContainerEntry[] getSupportedContainerEntries() {
103     return ces;
104   }
105
106   public ContainerEntry getContainerEntry(String JavaDoc name) {
107     for (int i = 0; i < ces.length; i++) {
108       if (ces[i].getName().equals(name))
109         return ces[i];
110     }
111     return null;
112   }
113
114   public RepositoryManagerEntry[] getSupportedRepositoryManagerEntries() {
115     return mes;
116   }
117
118   public RepositoryManagerEntry getRepositoryManagerEntry(String JavaDoc name) {
119     for (int i = 0; i < mes.length; i++) {
120       if (mes[i].getName().equals(name))
121         return mes[i];
122     }
123     return null;
124   }
125
126   public RepositoryEntry getRepositoryEntry(String JavaDoc name) {
127     for (int i = 0; i < res.length; i++) {
128       if (res[i].getName().equals(name))
129         return res[i];
130     }
131     return null;
132   }
133
134 }
135
Popular Tags