本文整理汇总了Java中org.apache.tomcat.util.scan.Jar.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java Jar.getInputStream方法的具体用法?Java Jar.getInputStream怎么用?Java Jar.getInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.util.scan.Jar
的用法示例。
在下文中一共展示了Jar.getInputStream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputStream
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, Jar jar,
JspCompilationContext ctxt) throws IOException {
InputStream in = null;
if (jar != null) {
String jarEntryName = fname.substring(1, fname.length());
in = jar.getInputStream(jarEntryName);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
throw new FileNotFoundException(Localizer.getMessage(
"jsp.error.file.not.found", fname));
}
return in;
}
示例2: scan
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
@Override
public void scan(JarURLConnection jarConn) throws IOException {
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
try {
jar = JarFactory.newInstance(url);
if (parseRequired || context.getXmlValidation()) {
is = jar.getInputStream(FRAGMENT_LOCATION);
}
if (is == null) {
// If there is no web-fragment.xml to process there is no
// impact on distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource(
"jar:" + resourceURL.toString() + "!/" +
FRAGMENT_LOCATION);
source.setByteStream(is);
parseWebXml(source, fragment, true);
}
} finally {
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}
fragment.setJarName(extractJarFileName(url));
fragments.put(fragment.getName(), fragment);
}
}
示例3: scan
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
@Override
public void scan(JarURLConnection jarConn) throws IOException {
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
try {
jar = JarFactory.newInstance(url);
if (parseRequired || context.getXmlValidation()) {
is = jar.getInputStream(FRAGMENT_LOCATION);
}
if (is == null) {
// If there is no web-fragment.xml to process there is no
// impact on distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource("jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
source.setByteStream(is);
parseWebXml(source, fragment, true);
}
} finally {
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}
fragment.setJarName(extractJarFileName(url));
fragments.put(fragment.getName(), fragment);
}
}
示例4: getInputSource
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
public static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt)
throws IOException {
InputSource source;
if (jar != null) {
String jarEntryName = fname.substring(1, fname.length());
source = new InputSource(jar.getInputStream(jarEntryName));
source.setSystemId(jar.getURL(jarEntryName));
} else {
source = new InputSource(ctxt.getResourceAsStream(fname));
source.setSystemId(ctxt.getResource(fname).toExternalForm());
}
return source;
}
示例5: scan
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
@Override
public void scan(JarURLConnection jarConn, String webappPath, boolean isWebapp)
throws IOException {
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
fragment.setWebappJar(isWebapp);
fragment.setDelegate(delegate);
try {
// Only web application JARs are checked for web-fragment.xml
// files.
// web-fragment.xml files don't need to be parsed if they are never
// going to be used.
if (isWebapp && parseRequired) {
jar = JarFactory.newInstance(url);
is = jar.getInputStream(FRAGMENT_LOCATION);
}
if (is == null) {
// If there is no web.xml, normal JAR no impact on
// distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource(
"jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
source.setByteStream(is);
if (!webXmlParser.parseWebXml(source, fragment, true)) {
ok = false;
}
}
} finally {
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}
fragment.setJarName(extractJarFileName(url));
fragments.put(fragment.getName(), fragment);
}
}
示例6: processServletContainerInitializers
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
/**
* Scan JARs for ServletContainerInitializer implementations.
* Implementations will be added in web-fragment.xml priority order.
*/
protected void processServletContainerInitializers(
Set<WebXml> fragments) {
for (WebXml fragment : fragments) {
URL url = fragment.getURL();
Jar jar = null;
InputStream is = null;
ServletContainerInitializer sci = null;
try {
if ("jar".equals(url.getProtocol())) {
jar = JarFactory.newInstance(url);
is = jar.getInputStream(SCI_LOCATION);
} else if ("file".equals(url.getProtocol())) {
String path = url.getPath();
File file = new File(path, SCI_LOCATION);
if (file.exists()) {
is = new FileInputStream(file);
}
}
if (is != null) {
sci = getServletContainerInitializer(is);
}
} catch (IOException ioe) {
log.error(sm.getString(
"contextConfig.servletContainerInitializerFail", url,
context.getName()));
ok = false;
return;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// Ignore
}
}
if (jar != null) {
jar.close();
}
}
if (sci == null) {
continue;
}
initializerClassMap.put(sci, new HashSet<Class<?>>());
HandlesTypes ht =
sci.getClass().getAnnotation(HandlesTypes.class);
if (ht != null) {
Class<?>[] types = ht.value();
if (types != null) {
for (Class<?> type : types) {
Set<ServletContainerInitializer> scis =
typeInitializerMap.get(type);
if (scis == null) {
scis = new HashSet<ServletContainerInitializer>();
typeInitializerMap.put(type, scis);
}
scis.add(sci);
}
}
}
}
}
示例7: scan
import org.apache.tomcat.util.scan.Jar; //导入方法依赖的package包/类
@Override
public void scan(JarURLConnection jarConn) throws IOException {
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
try {
jar = JarFactory.newInstance(url);
is = jar.getInputStream(FRAGMENT_LOCATION);
if (is == null) {
// If there is no web.xml, normal JAR no impact on
// distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource(
resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
source.setByteStream(is);
parseWebXml(source, fragment, true);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ioe) {
// Ignore
}
}
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}
fragments.put(fragment.getName(), fragment);
}
}