1
14
15 package com.liferay.portal.velocity;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19
20 import java.io.InputStream;
21
22 import org.apache.velocity.exception.ResourceNotFoundException;
23
24
30 public class ClassLoaderVelocityResourceListener
31 extends VelocityResourceListener {
32
33 public InputStream getResourceStream(String source)
34 throws ResourceNotFoundException {
35
36 InputStream is = null;
37
38 int pos = source.indexOf(JOURNAL_SEPARATOR);
39
40 if (pos == -1) {
41 pos = source.indexOf(SERVLET_SEPARATOR);
42 }
43
44 if (pos == -1) {
45 pos = source.indexOf(THEME_LOADER_SEPARATOR);
46 }
47
48 if (pos == -1) {
49 ClassLoader classLoader = getClass().getClassLoader();
50
51 if (_log.isDebugEnabled()) {
52 _log.debug("Loading " + source);
53 }
54
55 is = classLoader.getResourceAsStream(source);
56 }
57
58 return is;
59 }
60
61 private static Log _log = LogFactoryUtil.getLog(
62 ClassLoaderVelocityResourceListener.class);
63
64 }