1 14 package org.wings.resource; 15 16 import org.apache.commons.logging.Log; 17 import org.apache.commons.logging.LogFactory; 18 import org.wings.Resource; 19 import org.wings.externalizer.ExternalizeManager; 20 import org.wings.session.SessionManager; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 25 34 public class ClassPathStylesheetResource 35 extends ClasspathResource { 36 private final transient static Log log = LogFactory.getLog(ClassPathStylesheetResource.class); 37 42 private static final int MAX_BUFFER_SIZE = 24 * 1024; 44 private ExternalizeManager extManager; 45 46 49 public ClassPathStylesheetResource(String resourceFileName) { 50 this(Resource.class.getClassLoader(), resourceFileName, "unkonwn"); 51 } 52 53 56 public ClassPathStylesheetResource(String resourceFileName, String mimeType) { 57 this(Resource.class.getClassLoader(), resourceFileName, mimeType); 58 } 59 60 66 public ClassPathStylesheetResource(ClassLoader classLoader, String resourceFileName) { 67 this(classLoader, resourceFileName, "unknown"); 68 } 69 70 77 public ClassPathStylesheetResource(ClassLoader classLoader, String resourceFileName, String mimeType) { 78 this(classLoader, resourceFileName, mimeType, MAX_BUFFER_SIZE); 79 } 80 81 90 public ClassPathStylesheetResource(ClassLoader classLoader, String resourceFileName, String mimeType, int maxBufferSize) { 91 super(classLoader, resourceFileName, mimeType); 92 extManager = SessionManager.getSession().getExternalizeManager(); 94 setMaxBufferSize(maxBufferSize); 96 } 97 98 101 protected final InputStream getResourceStream() { 102 InputStream in = classLoader.getResourceAsStream(resourceFileName); 103 CssUrlFilterInputStream stream = new CssUrlFilterInputStream(in, extManager); 104 return stream; 105 } 106 107 111 112 119 public boolean equals(Object o) { 120 if (o instanceof ClassPathStylesheetResource) { 121 if (super.equals(o)) { 122 return true; 123 } 124 } 125 return false; 126 } 127 128 131 protected LimitedBuffer bufferResource() throws IOException { 132 try { 133 return super.bufferResource(); 134 } catch (IOException e) { 135 log.error("Unable to retrieve css file from classpath: '"+resourceFileName); 136 throw e; 137 } 138 } 139 } 140 141 142 | Popular Tags |