本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.getExtraClasspath()
方法的一些代码示例,展示了WebAppContext.getExtraClasspath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.getExtraClasspath()
方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:getExtraClasspath
暂无
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
/**
* Get jars from WebAppContext.getExtraClasspath as resources
*
* @param context the context to find extra classpath jars in
* @return the list of Resources with the extra classpath, or null if not found
* @throws Exception if unable to find the extra classpath jars
*/
protected List<Resource> findExtraClasspathJars(WebAppContext context)
throws Exception
{
if (context == null || context.getExtraClasspath() == null)
return null;
List<Resource> jarResources = new ArrayList<Resource>();
StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;");
while (tokenizer.hasMoreTokens())
{
Resource resource = context.newResource(tokenizer.nextToken().trim());
String fnlc = resource.getName().toLowerCase(Locale.ENGLISH);
int dot = fnlc.lastIndexOf('.');
String extension = (dot < 0 ? null : fnlc.substring(dot));
if (extension != null && (extension.equals(".jar") || extension.equals(".zip")))
{
jarResources.add(resource);
}
}
return jarResources;
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
/**
* Get class dirs from WebAppContext.getExtraClasspath as resources
*
* @param context the context to look for extra classpaths in
* @return the list of Resources to the extra classpath
* @throws Exception if unable to find the extra classpaths
*/
protected List<Resource> findExtraClasspathDirs(WebAppContext context)
throws Exception
{
if (context == null || context.getExtraClasspath() == null)
return null;
List<Resource> dirResources = new ArrayList<Resource>();
StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;");
while (tokenizer.hasMoreTokens())
{
Resource resource = context.newResource(tokenizer.nextToken().trim());
if (resource.exists() && resource.isDirectory())
dirResources.add(resource);
}
return dirResources;
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldAddExtraJarsIntoClassPath() throws Exception {
jetty9Server.configure();
jetty9Server.addExtraJarsToClasspath("test-addons/some-addon-dir/addon-1.JAR,test-addons/some-addon-dir/addon-2.jar");
jetty9Server.startHandlers();
WebAppContext webAppContext = (WebAppContext) getLoadedHandlers().get(WebAppContext.class);
assertThat(webAppContext.getExtraClasspath(), is("test-addons/some-addon-dir/addon-1.JAR,test-addons/some-addon-dir/addon-2.jar," + configDir));
}
代码示例来源:origin: jenkinsci/winstone
/**
* Get jars from WebAppContext.getExtraClasspath as resources
*
* @param context the context to find extra classpath jars in
* @return the list of Resources with the extra classpath, or null if not found
* @throws Exception if unable to find the extra classpath jars
*/
protected List<Resource> findExtraClasspathJars(WebAppContext context)
throws Exception
{
if (context == null || context.getExtraClasspath() == null)
return null;
List<Resource> jarResources = new ArrayList<Resource>();
StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;");
while (tokenizer.hasMoreTokens())
{
Resource resource = context.newResource(tokenizer.nextToken().trim());
String fnlc = resource.getName().toLowerCase(Locale.ENGLISH);
int dot = fnlc.lastIndexOf('.');
String extension = (dot < 0 ? null : fnlc.substring(dot));
if (extension != null && (extension.equals(".jar") || extension.equals(".zip")))
{
jarResources.add(resource);
}
}
return jarResources;
}
代码示例来源:origin: jenkinsci/winstone
/**
* Get class dirs from WebAppContext.getExtraClasspath as resources
*
* @param context the context to look for extra classpaths in
* @return the list of Resources to the extra classpath
* @throws Exception if unable to find the extra classpaths
*/
protected List<Resource> findExtraClasspathDirs(WebAppContext context)
throws Exception
{
if (context == null || context.getExtraClasspath() == null)
return null;
List<Resource> dirResources = new ArrayList<Resource>();
StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;");
while (tokenizer.hasMoreTokens())
{
Resource resource = context.newResource(tokenizer.nextToken().trim());
if (resource.exists() && resource.isDirectory())
dirResources.add(resource);
}
return dirResources;
}
代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot
/**
* In the case of the generation of a webapp via a jetty context file we
* need a proper classloader to setup the app before we have the
* WebappContext So we place a fake one there to start with. We replace it
* with the actual webapp context with this method. We also apply the
* extraclasspath there at the same time.
* @param webappContext the web app context
*/
public void setWebappContext(WebAppContext webappContext)
{
try
{
if (_contextField == null)
{
_contextField = WebAppClassLoader.class.getDeclaredField("_context");
_contextField.setAccessible(true);
}
_contextField.set(this, webappContext);
if (webappContext.getExtraClasspath() != null)
{
addClassPath(webappContext.getExtraClasspath());
}
}
catch (Throwable t)
{
// humf that will hurt if it does not work.
__logger.warn("Unable to set webappcontext", t);
}
}
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
protected Collection<String> getClassPathDescription(Collection<String> classPath, Handler... handlers)
{
if (handlers != null)
{
for (Handler handler : handlers)
{
if (handler instanceof HandlerCollection)
{
getClassPathDescription(classPath, ((HandlerCollection) handler).getHandlers());
}
else if (handler instanceof WebAppContext)
{
String extraClasspath = ((WebAppContext) handler).getExtraClasspath();
if (extraClasspath != null)
{
// Collections.addAll(classPath, extraClasspath.split(File.pathSeparator)); // it seems, Jetty was built for Windows
Collections.addAll(classPath, extraClasspath.split(";"));
}
}
}
}
return classPath;
}
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
protected Collection<String> getClassPathDescription(Collection<String> classPath, Handler... handlers)
{
if (handlers != null)
{
for (Handler handler : handlers)
{
if (handler instanceof HandlerCollection)
{
getClassPathDescription(classPath, ((HandlerCollection) handler).getHandlers());
}
else if (handler instanceof WebAppContext)
{
String extraClasspath = ((WebAppContext) handler).getExtraClasspath();
if (extraClasspath != null)
{
// Collections.addAll(classPath, extraClasspath.split(File.pathSeparator)); // it seems, Jetty was built for Windows
Collections.addAll(classPath, extraClasspath.split(";"));
}
}
}
}
return classPath;
}
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
protected Collection<String> getClassPathDescription(Collection<String> classPath, Handler... handlers)
{
if (handlers != null)
{
for (Handler handler : handlers)
{
if (handler instanceof HandlerCollection)
{
getClassPathDescription(classPath, ((HandlerCollection) handler).getHandlers());
}
else if (handler instanceof WebAppContext)
{
String extraClasspath = ((WebAppContext) handler).getExtraClasspath();
if (extraClasspath != null)
{
// Collections.addAll(classPath, extraClasspath.split(File.pathSeparator)); // it seems, Jetty was built for Windows
Collections.addAll(classPath, extraClasspath.split(";"));
}
}
}
}
return classPath;
}
}
代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin
protected Collection<String> getClassPathDescription(Collection<String> classPath, Handler... handlers)
{
if (handlers != null)
{
for (Handler handler : handlers)
{
if (handler instanceof HandlerCollection)
{
getClassPathDescription(classPath, ((HandlerCollection) handler).getHandlers());
}
else if (handler instanceof WebAppContext)
{
String extraClasspath = ((WebAppContext) handler).getExtraClasspath();
if (extraClasspath != null)
{
// Collections.addAll(classPath, extraClasspath.split(File.pathSeparator)); // it seems, Jetty was built for Windows
Collections.addAll(classPath, extraClasspath.split(";"));
}
}
}
}
return classPath;
}
}
内容来源于网络,如有侵权,请联系作者删除!