Top Description Fields Constructors Methods
org.webjars

public Class WebJarExtractor

extends Object
Class Inheritance
Static Imports
java.util.Objects.requireNonNull, org.webjars.WebJarAssetLocator.WEBJARS_PATH_PREFIX

Utility for extracting WebJars onto the filesystem. The extractor also recognises the node_modules convention used by WebJars. node_modules are a special place within a WebJar that contain the assets required in an environment conforming to the Node API for require.

Field Summary

Modifier and TypeField and Description
public static final String
BOWER_JSON

The bower.json file name.

private final ClassLoader
private static final String
private static final Logger
public static final String
PACKAGE_JSON

The node_modules directory prefix as a convenience.

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
extractAllBowerComponentsTo(File
The location to extract it to. All WebJars will be merged into this location.
to
)

Extract the bower_components of all WebJars and merge them into the same folder.

public void
extractAllNodeModulesTo(File
The location to extract it to. All WebJars will be merged into this location.
to
)

Extract the node_modules of all WebJars and merge them into the same folder.

public void
extractAllWebJarsTo(File
The directory to extract to
to
)

Extract all WebJars.

private static void
extractResource(String webJarName, WebJarAssetLocator.WebJarInfo webJarInfo, File to, String webJarId, Resource resource, InputStream inputStream)

private void
extractResourcesTo(final String webJarName, final WebJarAssetLocator.WebJarInfo webJarInfo, final String moduleFilePath, final ResourceList webJarResources, final File to)

private void
extractWebJarsTo(final String
If null then all WebJars are extracted, otherwise the name of a single WebJars.
name
,
final String
The file to get module name from, can be null, artifactId will be used in this case.
moduleNameFile
,
final File
The location to extract it to. All WebJars will be merged into this location.
to
)

A generalised form for extracting WebJars.

public void
extractWebJarTo(String
The name of the WebJar to extract.
name
,
File
The location to extract it to. All WebJars will be merged into this location.
to
)

Extract the given WebJar to the given location.

protected static String
getJsonModuleId(String packageJson)

private String
getModuleId(final String moduleNameFile)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOWER_JSONback to summary
public static final String BOWER_JSON

The bower.json file name.

classLoaderback to summary
private final ClassLoader classLoader
JAR_PATH_DELIMITERback to summary
private static final String JAR_PATH_DELIMITER
logback to summary
private static final Logger log
PACKAGE_JSONback to summary
public static final String PACKAGE_JSON

The node_modules directory prefix as a convenience.

Constructor Detail

WebJarExtractorback to summary
public WebJarExtractor()
WebJarExtractorback to summary
public WebJarExtractor(ClassLoader classLoader)

Method Detail

extractAllBowerComponentsToback to summary
public void extractAllBowerComponentsTo(File to) throws IOException

Extract the bower_components of all WebJars and merge them into the same folder.

Parameters
to:File

The location to extract it to. All WebJars will be merged into this location.

Exceptions
IOException:
There was a problem extracting the WebJars
extractAllNodeModulesToback to summary
public void extractAllNodeModulesTo(File to) throws IOException

Extract the node_modules of all WebJars and merge them into the same folder.

Parameters
to:File

The location to extract it to. All WebJars will be merged into this location.

Exceptions
IOException:
There was a problem extracting the WebJars
extractAllWebJarsToback to summary
public void extractAllWebJarsTo(File to) throws IOException

Extract all WebJars.

Parameters
to:File

The directory to extract to

Exceptions
IOException:
There was a problem extracting the WebJars
extractResourceback to summary
private static void extractResource(String webJarName, WebJarAssetLocator.WebJarInfo webJarInfo, File to, String webJarId, Resource resource, InputStream inputStream)
extractResourcesToback to summary
private void extractResourcesTo(final String webJarName, final WebJarAssetLocator.WebJarInfo webJarInfo, final String moduleFilePath, final ResourceList webJarResources, final File to)
extractWebJarsToback to summary
private void extractWebJarsTo(final String name, final String moduleNameFile, final File to)

A generalised form for extracting WebJars.

Parameters
name:String

If null then all WebJars are extracted, otherwise the name of a single WebJars.

moduleNameFile:String

The file to get module name from, can be null, artifactId will be used in this case.

to:File

The location to extract it to. All WebJars will be merged into this location.

extractWebJarToback to summary
public void extractWebJarTo(String name, File to) throws IOException

Extract the given WebJar to the given location. The WebJar will be extracted, without its version in the path, to the given directory.

Parameters
name:String

The name of the WebJar to extract.

to:File

The location to extract it to. All WebJars will be merged into this location.

Exceptions
IOException:
There was a problem extracting the WebJars
getJsonModuleIdback to summary
protected static String getJsonModuleId(String packageJson) throws IOException
Annotations
@Nullable
getModuleIdback to summary
private String getModuleId(final String moduleNameFile)
Annotations
@Nullable