use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class MavenWebInfConfiguration method findClassDirs.
/**
* Add in the classes dirs from test/classes and target/classes
* @see org.eclipse.jetty.webapp.WebInfConfiguration#findClassDirs(org.eclipse.jetty.webapp.WebAppContext)
*/
@Override
protected List<Resource> findClassDirs(WebAppContext context) throws Exception {
List<Resource> list = new ArrayList<Resource>();
JettyWebAppContext jwac = (JettyWebAppContext) context;
if (jwac.getClassPathFiles() != null) {
for (File f : jwac.getClassPathFiles()) {
if (f.exists() && f.isDirectory()) {
try {
list.add(Resource.newResource(f.toURI()));
} catch (Exception e) {
LOG.warn("Bad url ", e);
}
}
}
}
List<Resource> classesDirs = super.findClassDirs(context);
if (classesDirs != null)
list.addAll(classesDirs);
return list;
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class MavenWebInfConfiguration method unpack.
/**
* @see org.eclipse.jetty.webapp.WebInfConfiguration#unpack(org.eclipse.jetty.webapp.WebAppContext)
*/
@Override
public void unpack(WebAppContext context) throws IOException {
//Unpack and find base resource as normal
super.unpack(context);
//Get the base resource for the "virtual" webapp
_originalResourceBase = context.getBaseResource();
JettyWebAppContext jwac = (JettyWebAppContext) context;
//determine sequencing of overlays
_unpackedOverlayResources = new ArrayList<Resource>();
if (jwac.getOverlays() != null && !jwac.getOverlays().isEmpty()) {
List<Resource> resourceBaseCollection = new ArrayList<Resource>();
for (Overlay o : jwac.getOverlays()) {
//can refer to the current project in list of overlays for ordering purposes
if (o.getConfig() != null && o.getConfig().isCurrentProject() && _originalResourceBase.exists()) {
resourceBaseCollection.add(_originalResourceBase);
LOG.debug("Adding virtual project to resource base list");
continue;
}
Resource unpacked = unpackOverlay(jwac, o);
//remember the unpacked overlays for later so we can delete the tmp files
_unpackedOverlayResources.add(unpacked);
//add in the selectively unpacked overlay in the correct order to the webapps resource base
resourceBaseCollection.add(unpacked);
LOG.debug("Adding " + unpacked + " to resource base list");
}
if (!resourceBaseCollection.contains(_originalResourceBase) && _originalResourceBase.exists()) {
if (jwac.getBaseAppFirst()) {
LOG.debug("Adding virtual project first in resource base list");
resourceBaseCollection.add(0, _originalResourceBase);
} else {
LOG.debug("Adding virtual project last in resource base list");
resourceBaseCollection.add(_originalResourceBase);
}
}
jwac.setBaseResource(new ResourceCollection(resourceBaseCollection.toArray(new Resource[resourceBaseCollection.size()])));
}
jwac.setAttribute(RESOURCE_BASES_POST_OVERLAY, jwac.getBaseResource());
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class MavenWebInfConfiguration method findJars.
/**
* Get the jars to examine from the files from which we have
* synthesized the classpath. Note that the classpath is not
* set at this point, so we cannot get them from the classpath.
* @param context the web app context
* @return the list of jars found
*/
@Override
protected List<Resource> findJars(WebAppContext context) throws Exception {
List<Resource> list = new ArrayList<Resource>();
JettyWebAppContext jwac = (JettyWebAppContext) context;
if (jwac.getClassPathFiles() != null) {
for (File f : jwac.getClassPathFiles()) {
if (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
try {
list.add(Resource.newResource(f.toURI()));
} catch (Exception e) {
LOG.warn("Bad url ", e);
}
}
}
}
List<Resource> superList = super.findJars(context);
if (superList != null)
list.addAll(superList);
return list;
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class AnnotationConfiguration method parseBundle.
protected void parseBundle(WebAppContext context, AnnotationParser parser, Bundle webbundle, Bundle bundle) throws Exception {
Resource bundleRes = parser.getResource(bundle);
Set<Handler> handlers = new HashSet<Handler>();
handlers.addAll(_discoverableAnnotationHandlers);
if (_classInheritanceHandler != null)
handlers.add(_classInheritanceHandler);
handlers.addAll(_containerInitializerAnnotationHandlers);
if (_parserTasks != null) {
BundleParserTask task = new BundleParserTask(parser, handlers, bundleRes);
_parserTasks.add(task);
if (LOG.isDebugEnabled())
task.setStatistic(new TimeStatistic());
}
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class AnnotationParser method indexBundle.
/**
* Keep track of a jetty URI Resource and its associated OSGi bundle.
*
* @param bundle the bundle to index
* @return the resource for the bundle
* @throws Exception if unable to create the resource reference
*/
protected Resource indexBundle(Bundle bundle) throws Exception {
File bundleFile = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle);
Resource resource = Resource.newResource(bundleFile.toURI());
URI uri = resource.getURI();
_uriToBundle.putIfAbsent(uri, bundle);
_bundleToUri.putIfAbsent(bundle, uri);
_bundleToResource.putIfAbsent(bundle, resource);
_resourceToBundle.putIfAbsent(resource, bundle);
return resource;
}
Aggregations