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