KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > bean > Resources


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.bean;
28
29 import java.io.File JavaDoc;
30 import java.io.FileInputStream JavaDoc;
31 import java.util.Vector JavaDoc;
32 import javax.servlet.http.HttpServlet JavaDoc;
33
34 import org.nextime.ion.common.ResourceServlet;
35
36 public class Resources {
37
38     private static ResourceXmlBean bean;
39
40     public static ResourceXmlBean getResourceXmlBean(
41         HttpServlet JavaDoc servlet,
42         String JavaDoc id)
43         throws Exception JavaDoc {
44         if (bean == null) {
45             FileInputStream JavaDoc fis =
46                 new FileInputStream JavaDoc(
47                     new File JavaDoc(
48                         servlet.getServletContext().getRealPath(
49                             ResourceServlet.configPath)));
50             bean = ResourceXmlBean.parse(fis);
51             fis.close();
52         }
53         return bean.getResource(id);
54     }
55
56     public static Vector JavaDoc getResourceXmlBeans(HttpServlet JavaDoc servlet)
57         throws Exception JavaDoc {
58         if (bean == null) {
59             FileInputStream JavaDoc fis =
60                 new FileInputStream JavaDoc(
61                     new File JavaDoc(
62                         servlet.getServletContext().getRealPath(
63                             ResourceServlet.configPath)));
64             bean = ResourceXmlBean.parse(fis);
65             fis.close();
66         }
67         return bean.getItems();
68     }
69
70 }
71
Popular Tags