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
20 package org.apache.james.services;
21
22 import java.io.File;
23 import java.io.FileNotFoundException;
24 import java.io.InputStream;
25 import java.io.IOException;
26
27 /**
28 * This service is used by components that wants to lookup a File resource
29 * from the application folder.
30 *
31 * @since James 2.4
32 */
33 public interface FileSystem {
34
35 String ROLE = "org.apache.james.services.FileSystem";
36
37 /**
38 * to retrieve a resource. this is typically a file resource,
39 * but depending on the implementation, this could also be from classpath or
40 * from another source.
41 *
42 * @param url the url of the resource
43 * @return the resource as an input stream
44 * @throws IOException if the resource could not be accessed
45 */
46 public InputStream getResource(String url) throws IOException;
47
48 /**
49 * Used to retrieve a specific file in the application context
50 *
51 * @param fileURL file
52 * @return the File found
53 * @throws FileNotFoundException if the file cannot be found/read
54 */
55 public File getFile(String fileURL) throws FileNotFoundException;
56
57 /**
58 * Return the base folder used by the application
59 */
60 public File getBasedir() throws FileNotFoundException;
61
62 }