OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / packages / apps / Email / src / org / apache / james / mime4j / util / TempStorage.java
1 /****************************************************************\r
2  * Licensed to the Apache Software Foundation (ASF) under one   *\r
3  * or more contributor license agreements.  See the NOTICE file *\r
4  * distributed with this work for additional information        *\r
5  * regarding copyright ownership.  The ASF licenses this file   *\r
6  * to you under the Apache License, Version 2.0 (the            *\r
7  * "License"); you may not use this file except in compliance   *\r
8  * with the License.  You may obtain a copy of the License at   *\r
9  *                                                              *\r
10  *   http://www.apache.org/licenses/LICENSE-2.0                 *\r
11  *                                                              *\r
12  * Unless required by applicable law or agreed to in writing,   *\r
13  * software distributed under the License is distributed on an  *\r
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\r
15  * KIND, either express or implied.  See the License for the    *\r
16  * specific language governing permissions and limitations      *\r
17  * under the License.                                           *\r
18  ****************************************************************/\r
19 \r
20 package org.apache.james.mime4j.util;\r
21 \r
22 //BEGIN android-changed: Stubbing out logging\r
23 import org.apache.james.mime4j.Log;\r
24 import org.apache.james.mime4j.LogFactory;\r
25 //END android-changed\r
26 \r
27 /**\r
28  * \r
29  * @version $Id: TempStorage.java,v 1.2 2004/10/02 12:41:11 ntherning Exp $\r
30  */\r
31 public abstract class TempStorage {\r
32     private static Log log = LogFactory.getLog(TempStorage.class);\r
33     private static TempStorage inst = null;\r
34     \r
35     static {\r
36         \r
37         String clazz = System.getProperty("org.apache.james.mime4j.tempStorage");\r
38         try {\r
39             \r
40             if (inst != null) {\r
41                 inst = (TempStorage) Class.forName(clazz).newInstance();\r
42             }\r
43             \r
44         } catch (Throwable t) {\r
45             log.warn("Unable to create or instantiate TempStorage class '" \r
46                       + clazz + "' using SimpleTempStorage instead", t);\r
47         }\r
48 \r
49         if (inst == null) {\r
50             inst = new SimpleTempStorage();            \r
51         }\r
52     }\r
53     \r
54     /**\r
55      * Gets the root temporary path which should be used to \r
56      * create new temporary paths or files.\r
57      * \r
58      * @return the root temporary path.\r
59      */\r
60     public abstract TempPath getRootTempPath();\r
61     \r
62     public static TempStorage getInstance() {\r
63         return inst;\r
64     }\r
65     \r
66     public static void setInstance(TempStorage inst) {\r
67         if (inst == null) {\r
68             throw new NullPointerException("inst");\r
69         }\r
70         TempStorage.inst = inst;\r
71     }\r
72 }\r