View Javadoc

1   /**
2    *  MicroEmulator
3    *  Copyright (C) 2006-2007 Bartek Teodorczyk <barteo@barteo.net>
4    *  Copyright (C) 2006-2007 Vlad Skarzhevskyy
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or (at your option) any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   *  @version $Id: FileSystem.java 1593 2008-02-21 03:12:10Z vlads $
21   */
22  package org.microemu.cldc.file;
23  
24  import java.util.Map;
25  
26  import org.microemu.app.util.MIDletSystemProperties;
27  import org.microemu.microedition.ImplFactory;
28  import org.microemu.microedition.ImplementationInitialization;
29  
30  /**
31   * @author vlads
32   * 
33   * config2.xml example
34   * 
35   * <pre>
36   *  &lt;extensions&gt;
37   *  &lt;extension&gt;
38   *  &lt;className&gt;org.microemu.cldc.file.FileSystem&lt;/className&gt;
39   *  &lt;properties&gt;
40   *  &lt;property NAME=&quot;fsRoot&quot; VALUE=&quot;C:&quot;/&gt;
41   *  &lt;/properties&gt;
42   *  &lt;/extension&gt;
43   *  &lt;/extensions&gt;
44   * </pre>
45   * 
46   */
47  
48  public class FileSystem implements ImplementationInitialization {
49  
50  	public static final String detectionProperty = "microedition.io.file.FileConnection.version";
51  
52  	public static final String fsRootConfigProperty = "fsRoot";
53  
54  	private FileSystemConnectorImpl impl;
55  
56  	/*
57  	 * (non-Javadoc)
58  	 * 
59  	 * @see org.microemu.microedition.ImplementationInitialization#registerImplementation()
60  	 */
61  	public void registerImplementation(Map parameters) {
62  		String fsRoot = (String) parameters.get(fsRootConfigProperty);
63  		this.impl = new FileSystemConnectorImpl(fsRoot);
64  		ImplFactory.registerGCF("file", this.impl);
65  		ImplFactory.register(FileSystemRegistryDelegate.class, new FileSystemRegistryImpl(fsRoot));
66  		MIDletSystemProperties.setProperty(detectionProperty, "1.0");
67  	}
68  
69  	protected static void unregisterImplementation(FileSystemConnectorImpl impl) {
70  		MIDletSystemProperties.clearProperty(detectionProperty);
71  		ImplFactory.unregistedGCF("file", impl);
72  		ImplFactory.unregister(FileSystemRegistryDelegate.class, FileSystemRegistryImpl.class);
73  	}
74  
75  	/*
76  	 * (non-Javadoc)
77  	 * 
78  	 * @see org.microemu.microedition.ImplementationInitialization#notifyMIDletStart()
79  	 */
80  	public void notifyMIDletStart() {
81  	}
82  
83  	/*
84  	 * (non-Javadoc)
85  	 * 
86  	 * @see org.microemu.microedition.ImplementationInitialization#notifyMIDletDestroyed()
87  	 */
88  	public void notifyMIDletDestroyed() {
89  		this.impl.notifyMIDletDestroyed();
90  	}
91  
92  }