View Javadoc

1   /*
2    * Copyright 2004 Charles Blaxland
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package mnemosyne.system;
17  
18  import mnemosyne.core.VersionManager;
19  import mnemosyne.core.DefaultPersistentObjectFactory;
20  import mnemosyne.guid.RmiUidGuidGenerator;
21  import mnemosyne.aop.aspectwerkz.AspectwerkzAopSystem;
22  import mnemosyne.archiver.FileSystemArchiver;
23  import org.picocontainer.MutablePicoContainer;
24  import org.picocontainer.Parameter;
25  import org.picocontainer.defaults.DefaultPicoContainer;
26  import org.picocontainer.defaults.ComponentParameter;
27  import org.picocontainer.defaults.ConstantParameter;
28  
29  /***
30   * @version $Id: PersistentSystemFactory.java,v 1.1 2004/08/12 14:01:06 charlesblaxland Exp $
31   */
32  public class PersistentSystemFactory
33  {
34      public static final String DEFAULT_DATA_DIR = "data";
35  
36      public PersistentSystem createPersistentSystem()
37      {
38          return createPersistentSystem(DEFAULT_DATA_DIR);
39      }
40  
41      public PersistentSystem createPersistentSystem(String dataDirectory)
42      {
43          MutablePicoContainer pico = new DefaultPicoContainer();
44          pico.registerComponentImplementation(VersionManager.class);
45          pico.registerComponentImplementation(RmiUidGuidGenerator.class);
46          pico.registerComponentImplementation(AspectwerkzAopSystem.class);
47          pico.registerComponentImplementation(DefaultPersistentObjectFactory.class);
48          pico.registerComponentImplementation(FileSystemArchiver.class, FileSystemArchiver.class, new Parameter[] {
49              new ComponentParameter(), new ComponentParameter(),
50              new ConstantParameter(dataDirectory)
51          });
52          pico.registerComponentImplementation(LocalPersistentSystem.class);
53          return (LocalPersistentSystem) pico.getComponentInstanceOfType(LocalPersistentSystem.class);
54      }
55  }