KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > configuration > MockConfigurationManagerImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.configuration;
6
7 import java.io.File JavaDoc;
8 import java.net.URL JavaDoc;
9 import javax.servlet.ServletContext JavaDoc;
10 /**
11  * Jul 19, 2004
12  * @author: Tuan Nguyen
13  * @email: tuan08@users.sourceforge.net
14  * @version: $Id: MockConfigurationServiceImpl.java,v 1.11 2004/10/29 01:55:23 tuan08 Exp $
15  */

16 public class MockConfigurationManagerImpl extends ConfigurationManagerImpl {
17   private String JavaDoc confDir_ ;
18   
19   public MockConfigurationManagerImpl(ServletContext JavaDoc context) throws Exception JavaDoc {
20     super(context) ;
21     File JavaDoc currentDir = new File JavaDoc("") ;
22     String JavaDoc path = currentDir.getAbsolutePath() ;
23     int idx = path.indexOf("exoplatform") ;
24     if(idx < 0) {
25       path = System.getProperty("maven.exoplatform.dir") + "/" ;
26       confDir_ = path + "/web/portal/src/webapp/WEB-INF" ;
27     } else {
28       path = path.substring(0, idx) ;
29       path = path.replace('\\', '/') ;
30       confDir_ = path + "exoplatform/web/portal/src/webapp/WEB-INF" ;
31     }
32   }
33   
34   protected URL JavaDoc getURL(String JavaDoc uri) throws Exception JavaDoc {
35     if(uri.startsWith("jar:")) {
36       String JavaDoc path = removePrefix("jar:/", uri) ;
37       ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader() ;
38       return cl.getResource(path) ;
39     } else if(uri.startsWith("war:")) {
40       String JavaDoc path = removePrefix("war:", uri) ;
41       URL JavaDoc url = new URL JavaDoc("file:" + confDir_ + path) ;
42       return url ;
43     } else if(uri.startsWith("file:")) {
44       return new URL JavaDoc(uri) ;
45     }
46     return null ;
47   }
48 }
Popular Tags