id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,100 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerGeneratorImpl.java
|
ClientSideHandlerGeneratorImpl.appendBundle
|
private void appendBundle(JoinableResourceBundle bundle, Map<String, String> variants, StringBuffer buf,
boolean useGzip) {
buf.append("r(").append(JavascriptStringUtil.quote(bundle.getId())).append(",");
String path = bundle.getURLPrefix(variants);
if (useGzip) {
if (path.charAt(0) == '/') {
path = path.substring(1); // remove leading '/'
}
buf.append(JavascriptStringUtil.quote(BundleRenderer.GZIP_PATH_PREFIX + path));
} else {
if (path.charAt(0) != '/') {
path = "/" + path; // Add leading '/'
}
buf.append(JavascriptStringUtil.quote(path));
}
boolean skipItems = false;
if (bundle.getItemPathList().size() == 1 && null == bundle.getExplorerConditionalExpression()) {
skipItems = bundle.getItemPathList().get(0).getPath().equals(bundle.getId());
}
if (!skipItems) {
buf.append(",[");
for (Iterator<BundlePath> it = bundle.getItemPathList(variants).iterator(); it.hasNext();) {
path = it.next().getPath();
if (this.config.getGeneratorRegistry().isPathGenerated(path)) {
path = PathNormalizer.createGenerationPath(path, this.config.getGeneratorRegistry(), null);
}
if ("".equals(this.config.getContextPathOverride()) && path.startsWith("/"))
path = path.substring(1);
buf.append(JavascriptStringUtil.quote(path));
if (it.hasNext())
buf.append(",");
}
buf.append("]");
if (null != bundle.getExplorerConditionalExpression()) {
buf.append(",'").append(bundle.getExplorerConditionalExpression()).append("'");
}
}
if (null != bundle.getAlternateProductionURL()) {
// Complete the parameters if needed, since the alternate param goes
// afterwards
if (skipItems)
buf.append(",null,null");
else if (null == bundle.getExplorerConditionalExpression())
buf.append(",null");
buf.append(",").append(JavascriptStringUtil.quote(bundle.getAlternateProductionURL()));
}
buf.append(")");
}
|
java
|
private void appendBundle(JoinableResourceBundle bundle, Map<String, String> variants, StringBuffer buf,
boolean useGzip) {
buf.append("r(").append(JavascriptStringUtil.quote(bundle.getId())).append(",");
String path = bundle.getURLPrefix(variants);
if (useGzip) {
if (path.charAt(0) == '/') {
path = path.substring(1); // remove leading '/'
}
buf.append(JavascriptStringUtil.quote(BundleRenderer.GZIP_PATH_PREFIX + path));
} else {
if (path.charAt(0) != '/') {
path = "/" + path; // Add leading '/'
}
buf.append(JavascriptStringUtil.quote(path));
}
boolean skipItems = false;
if (bundle.getItemPathList().size() == 1 && null == bundle.getExplorerConditionalExpression()) {
skipItems = bundle.getItemPathList().get(0).getPath().equals(bundle.getId());
}
if (!skipItems) {
buf.append(",[");
for (Iterator<BundlePath> it = bundle.getItemPathList(variants).iterator(); it.hasNext();) {
path = it.next().getPath();
if (this.config.getGeneratorRegistry().isPathGenerated(path)) {
path = PathNormalizer.createGenerationPath(path, this.config.getGeneratorRegistry(), null);
}
if ("".equals(this.config.getContextPathOverride()) && path.startsWith("/"))
path = path.substring(1);
buf.append(JavascriptStringUtil.quote(path));
if (it.hasNext())
buf.append(",");
}
buf.append("]");
if (null != bundle.getExplorerConditionalExpression()) {
buf.append(",'").append(bundle.getExplorerConditionalExpression()).append("'");
}
}
if (null != bundle.getAlternateProductionURL()) {
// Complete the parameters if needed, since the alternate param goes
// afterwards
if (skipItems)
buf.append(",null,null");
else if (null == bundle.getExplorerConditionalExpression())
buf.append(",null");
buf.append(",").append(JavascriptStringUtil.quote(bundle.getAlternateProductionURL()));
}
buf.append(")");
}
|
[
"private",
"void",
"appendBundle",
"(",
"JoinableResourceBundle",
"bundle",
",",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
",",
"StringBuffer",
"buf",
",",
"boolean",
"useGzip",
")",
"{",
"buf",
".",
"append",
"(",
"\"r(\"",
")",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"bundle",
".",
"getId",
"(",
")",
")",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"String",
"path",
"=",
"bundle",
".",
"getURLPrefix",
"(",
"variants",
")",
";",
"if",
"(",
"useGzip",
")",
"{",
"if",
"(",
"path",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"path",
"=",
"path",
".",
"substring",
"(",
"1",
")",
";",
"// remove leading '/'",
"}",
"buf",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"BundleRenderer",
".",
"GZIP_PATH_PREFIX",
"+",
"path",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"path",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"{",
"path",
"=",
"\"/\"",
"+",
"path",
";",
"// Add leading '/'",
"}",
"buf",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"path",
")",
")",
";",
"}",
"boolean",
"skipItems",
"=",
"false",
";",
"if",
"(",
"bundle",
".",
"getItemPathList",
"(",
")",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"null",
"==",
"bundle",
".",
"getExplorerConditionalExpression",
"(",
")",
")",
"{",
"skipItems",
"=",
"bundle",
".",
"getItemPathList",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"bundle",
".",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"skipItems",
")",
"{",
"buf",
".",
"append",
"(",
"\",[\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"BundlePath",
">",
"it",
"=",
"bundle",
".",
"getItemPathList",
"(",
"variants",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"path",
"=",
"it",
".",
"next",
"(",
")",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"this",
".",
"config",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isPathGenerated",
"(",
"path",
")",
")",
"{",
"path",
"=",
"PathNormalizer",
".",
"createGenerationPath",
"(",
"path",
",",
"this",
".",
"config",
".",
"getGeneratorRegistry",
"(",
")",
",",
"null",
")",
";",
"}",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"this",
".",
"config",
".",
"getContextPathOverride",
"(",
")",
")",
"&&",
"path",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"path",
"=",
"path",
".",
"substring",
"(",
"1",
")",
";",
"buf",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"path",
")",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"buf",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\"]\"",
")",
";",
"if",
"(",
"null",
"!=",
"bundle",
".",
"getExplorerConditionalExpression",
"(",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\",'\"",
")",
".",
"append",
"(",
"bundle",
".",
"getExplorerConditionalExpression",
"(",
")",
")",
".",
"append",
"(",
"\"'\"",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"bundle",
".",
"getAlternateProductionURL",
"(",
")",
")",
"{",
"// Complete the parameters if needed, since the alternate param goes",
"// afterwards",
"if",
"(",
"skipItems",
")",
"buf",
".",
"append",
"(",
"\",null,null\"",
")",
";",
"else",
"if",
"(",
"null",
"==",
"bundle",
".",
"getExplorerConditionalExpression",
"(",
")",
")",
"buf",
".",
"append",
"(",
"\",null\"",
")",
";",
"buf",
".",
"append",
"(",
"\",\"",
")",
".",
"append",
"(",
"JavascriptStringUtil",
".",
"quote",
"(",
"bundle",
".",
"getAlternateProductionURL",
"(",
")",
")",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\")\"",
")",
";",
"}"
] |
Creates a javascript object that represents a bundle
@param bundle
the bundle
@param variants
the variant map
@param buf
the buffer
@param useGzip
the flag indicating if we use gzip compression or not.
|
[
"Creates",
"a",
"javascript",
"object",
"that",
"represents",
"a",
"bundle"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/handler/ClientSideHandlerGeneratorImpl.java#L271-L323
|
7,101 |
j-a-w-r/jawr-main-repo
|
jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/message/grails/GrailsBundleMessageSource.java
|
GrailsBundleMessageSource.getAllMessages
|
public Properties getAllMessages(Locale locale) {
Properties props = new Properties();
Properties mergedProps = null;
if (locale == null) {
locale = Locale.getDefault();
}
mergedProps = getMergedProperties(locale).getProperties();
Set<Entry<Object, Object>> entries = mergedProps.entrySet();
for (Entry<Object, Object> entry : entries) {
String key = (String) entry.getKey();
if (LocaleUtils.matchesFilter(key, filters)) {
try {
// Use the property encoding of the file
String msg = getMessage(key, new Object[0], locale);
// When war is deployed, the resource bundle are encoded in ISO 8859-1
// and otherwise in UTF-8
// Check the following link for more detail https://grails.org/Internationalization
if(!warDeployed){
msg = new String(msg.getBytes(CHARSET_ISO_8859_1),
CHARSET_UTF_8);
}
props.put(key, msg);
} catch (NoSuchMessageException e) {
// This is expected, so it's OK to have an empty catch
// block.
if (LOGGER.isDebugEnabled())
LOGGER.debug("Message key [" + key + "] not found.");
} catch (UnsupportedEncodingException e) {
LOGGER.warn("Unable to convert value of message bundle associated to key '"
+ key + "' because the charset is unknown");
}
}
}
return props;
}
|
java
|
public Properties getAllMessages(Locale locale) {
Properties props = new Properties();
Properties mergedProps = null;
if (locale == null) {
locale = Locale.getDefault();
}
mergedProps = getMergedProperties(locale).getProperties();
Set<Entry<Object, Object>> entries = mergedProps.entrySet();
for (Entry<Object, Object> entry : entries) {
String key = (String) entry.getKey();
if (LocaleUtils.matchesFilter(key, filters)) {
try {
// Use the property encoding of the file
String msg = getMessage(key, new Object[0], locale);
// When war is deployed, the resource bundle are encoded in ISO 8859-1
// and otherwise in UTF-8
// Check the following link for more detail https://grails.org/Internationalization
if(!warDeployed){
msg = new String(msg.getBytes(CHARSET_ISO_8859_1),
CHARSET_UTF_8);
}
props.put(key, msg);
} catch (NoSuchMessageException e) {
// This is expected, so it's OK to have an empty catch
// block.
if (LOGGER.isDebugEnabled())
LOGGER.debug("Message key [" + key + "] not found.");
} catch (UnsupportedEncodingException e) {
LOGGER.warn("Unable to convert value of message bundle associated to key '"
+ key + "' because the charset is unknown");
}
}
}
return props;
}
|
[
"public",
"Properties",
"getAllMessages",
"(",
"Locale",
"locale",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"Properties",
"mergedProps",
"=",
"null",
";",
"if",
"(",
"locale",
"==",
"null",
")",
"{",
"locale",
"=",
"Locale",
".",
"getDefault",
"(",
")",
";",
"}",
"mergedProps",
"=",
"getMergedProperties",
"(",
"locale",
")",
".",
"getProperties",
"(",
")",
";",
"Set",
"<",
"Entry",
"<",
"Object",
",",
"Object",
">",
">",
"entries",
"=",
"mergedProps",
".",
"entrySet",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"entries",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"LocaleUtils",
".",
"matchesFilter",
"(",
"key",
",",
"filters",
")",
")",
"{",
"try",
"{",
"// Use the property encoding of the file",
"String",
"msg",
"=",
"getMessage",
"(",
"key",
",",
"new",
"Object",
"[",
"0",
"]",
",",
"locale",
")",
";",
"// When war is deployed, the resource bundle are encoded in ISO 8859-1",
"// and otherwise in UTF-8 ",
"// Check the following link for more detail https://grails.org/Internationalization",
"if",
"(",
"!",
"warDeployed",
")",
"{",
"msg",
"=",
"new",
"String",
"(",
"msg",
".",
"getBytes",
"(",
"CHARSET_ISO_8859_1",
")",
",",
"CHARSET_UTF_8",
")",
";",
"}",
"props",
".",
"put",
"(",
"key",
",",
"msg",
")",
";",
"}",
"catch",
"(",
"NoSuchMessageException",
"e",
")",
"{",
"// This is expected, so it's OK to have an empty catch",
"// block.",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Message key [\"",
"+",
"key",
"+",
"\"] not found.\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to convert value of message bundle associated to key '\"",
"+",
"key",
"+",
"\"' because the charset is unknown\"",
")",
";",
"}",
"}",
"}",
"return",
"props",
";",
"}"
] |
Returns all the messages
@return all the messages
|
[
"Returns",
"all",
"the",
"messages"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-grails/jawr-grails-plugin/src/java/net/jawr/web/resource/bundle/locale/message/grails/GrailsBundleMessageSource.java#L80-L119
|
7,102 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java
|
BundlePathMappingBuilder.build
|
public BundlePathMapping build() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Creating bundle path List for " + this.bundle.getId());
}
BundlePathMapping bundlePathMapping = new BundlePathMapping(this.bundle);
bundlePathMapping.setPathMappings(strPathMappings);
List<PathMapping> pathMappings = bundlePathMapping.getPathMappings();
Map<String, VariantSet> variants = new TreeMap<>();
if (pathMappings != null) {
for (PathMapping pathMapping : pathMappings) {
boolean isGeneratedPath = generatorRegistry.isPathGenerated(pathMapping.getPath());
// Handle generated resources
// path ends in /, the folder is included without subfolders
if (pathMapping.isDirectory()) {
addItemsFromDir(bundlePathMapping, pathMapping, false);
}
// path ends in /, the folder is included with all subfolders
else if (pathMapping.isRecursive()) {
addItemsFromDir(bundlePathMapping, pathMapping, true);
} else if (pathMapping.getPath().endsWith(fileExtension)) {
addPathMapping(bundlePathMapping, asPath(pathMapping.getPath(), isGeneratedPath));
} else if (generatorRegistry.isPathGenerated(pathMapping.getPath())) {
addPathMapping(bundlePathMapping, pathMapping.getPath());
} else if (pathMapping.getPath().endsWith(LICENSES_FILENAME)) {
bundlePathMapping.getLicensesPathList().add(asPath(pathMapping.getPath(), isGeneratedPath));
} else {
throw new BundlingProcessException("Wrong mapping [" + pathMapping + "] for bundle ["
+ this.bundle.getName() + "]. Please check configuration. ");
}
if (isGeneratedPath) {
// Add variants
variants = VariantUtils.concatVariants(variants,
generatorRegistry.getAvailableVariants(pathMapping.getPath()));
}
}
}
bundle.setVariants(variants);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Finished creating bundle path List for " + this.bundle.getId());
}
return bundlePathMapping;
}
|
java
|
public BundlePathMapping build() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Creating bundle path List for " + this.bundle.getId());
}
BundlePathMapping bundlePathMapping = new BundlePathMapping(this.bundle);
bundlePathMapping.setPathMappings(strPathMappings);
List<PathMapping> pathMappings = bundlePathMapping.getPathMappings();
Map<String, VariantSet> variants = new TreeMap<>();
if (pathMappings != null) {
for (PathMapping pathMapping : pathMappings) {
boolean isGeneratedPath = generatorRegistry.isPathGenerated(pathMapping.getPath());
// Handle generated resources
// path ends in /, the folder is included without subfolders
if (pathMapping.isDirectory()) {
addItemsFromDir(bundlePathMapping, pathMapping, false);
}
// path ends in /, the folder is included with all subfolders
else if (pathMapping.isRecursive()) {
addItemsFromDir(bundlePathMapping, pathMapping, true);
} else if (pathMapping.getPath().endsWith(fileExtension)) {
addPathMapping(bundlePathMapping, asPath(pathMapping.getPath(), isGeneratedPath));
} else if (generatorRegistry.isPathGenerated(pathMapping.getPath())) {
addPathMapping(bundlePathMapping, pathMapping.getPath());
} else if (pathMapping.getPath().endsWith(LICENSES_FILENAME)) {
bundlePathMapping.getLicensesPathList().add(asPath(pathMapping.getPath(), isGeneratedPath));
} else {
throw new BundlingProcessException("Wrong mapping [" + pathMapping + "] for bundle ["
+ this.bundle.getName() + "]. Please check configuration. ");
}
if (isGeneratedPath) {
// Add variants
variants = VariantUtils.concatVariants(variants,
generatorRegistry.getAvailableVariants(pathMapping.getPath()));
}
}
}
bundle.setVariants(variants);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Finished creating bundle path List for " + this.bundle.getId());
}
return bundlePathMapping;
}
|
[
"public",
"BundlePathMapping",
"build",
"(",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Creating bundle path List for \"",
"+",
"this",
".",
"bundle",
".",
"getId",
"(",
")",
")",
";",
"}",
"BundlePathMapping",
"bundlePathMapping",
"=",
"new",
"BundlePathMapping",
"(",
"this",
".",
"bundle",
")",
";",
"bundlePathMapping",
".",
"setPathMappings",
"(",
"strPathMappings",
")",
";",
"List",
"<",
"PathMapping",
">",
"pathMappings",
"=",
"bundlePathMapping",
".",
"getPathMappings",
"(",
")",
";",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variants",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"if",
"(",
"pathMappings",
"!=",
"null",
")",
"{",
"for",
"(",
"PathMapping",
"pathMapping",
":",
"pathMappings",
")",
"{",
"boolean",
"isGeneratedPath",
"=",
"generatorRegistry",
".",
"isPathGenerated",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
")",
";",
"// Handle generated resources",
"// path ends in /, the folder is included without subfolders",
"if",
"(",
"pathMapping",
".",
"isDirectory",
"(",
")",
")",
"{",
"addItemsFromDir",
"(",
"bundlePathMapping",
",",
"pathMapping",
",",
"false",
")",
";",
"}",
"// path ends in /, the folder is included with all subfolders",
"else",
"if",
"(",
"pathMapping",
".",
"isRecursive",
"(",
")",
")",
"{",
"addItemsFromDir",
"(",
"bundlePathMapping",
",",
"pathMapping",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
".",
"endsWith",
"(",
"fileExtension",
")",
")",
"{",
"addPathMapping",
"(",
"bundlePathMapping",
",",
"asPath",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
",",
"isGeneratedPath",
")",
")",
";",
"}",
"else",
"if",
"(",
"generatorRegistry",
".",
"isPathGenerated",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
")",
")",
"{",
"addPathMapping",
"(",
"bundlePathMapping",
",",
"pathMapping",
".",
"getPath",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
".",
"endsWith",
"(",
"LICENSES_FILENAME",
")",
")",
"{",
"bundlePathMapping",
".",
"getLicensesPathList",
"(",
")",
".",
"add",
"(",
"asPath",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
",",
"isGeneratedPath",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Wrong mapping [\"",
"+",
"pathMapping",
"+",
"\"] for bundle [\"",
"+",
"this",
".",
"bundle",
".",
"getName",
"(",
")",
"+",
"\"]. Please check configuration. \"",
")",
";",
"}",
"if",
"(",
"isGeneratedPath",
")",
"{",
"// Add variants",
"variants",
"=",
"VariantUtils",
".",
"concatVariants",
"(",
"variants",
",",
"generatorRegistry",
".",
"getAvailableVariants",
"(",
"pathMapping",
".",
"getPath",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"bundle",
".",
"setVariants",
"(",
"variants",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Finished creating bundle path List for \"",
"+",
"this",
".",
"bundle",
".",
"getId",
"(",
")",
")",
";",
"}",
"return",
"bundlePathMapping",
";",
"}"
] |
Detects all files that belong to the bundle and adds them to the bundle
path mapping.
@return the bundlePathMapping
|
[
"Detects",
"all",
"files",
"that",
"belong",
"to",
"the",
"bundle",
"and",
"adds",
"them",
"to",
"the",
"bundle",
"path",
"mapping",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java#L116-L165
|
7,103 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java
|
BundlePathMappingBuilder.addPathMapping
|
private void addPathMapping(BundlePathMapping bundlePathMapping, String pathMapping) {
addFilePathMapping(bundlePathMapping, pathMapping);
if (!bundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
bundlePathMapping.getItemPathList().add(new BundlePath(bundle.getBundlePrefix(), pathMapping));
}
if (!bundle.getInclusionPattern().isExcludeOnDebug()) {
bundlePathMapping.getItemDebugPathList().add(new BundlePath(bundle.getBundlePrefix(), pathMapping));
}
}
|
java
|
private void addPathMapping(BundlePathMapping bundlePathMapping, String pathMapping) {
addFilePathMapping(bundlePathMapping, pathMapping);
if (!bundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
bundlePathMapping.getItemPathList().add(new BundlePath(bundle.getBundlePrefix(), pathMapping));
}
if (!bundle.getInclusionPattern().isExcludeOnDebug()) {
bundlePathMapping.getItemDebugPathList().add(new BundlePath(bundle.getBundlePrefix(), pathMapping));
}
}
|
[
"private",
"void",
"addPathMapping",
"(",
"BundlePathMapping",
"bundlePathMapping",
",",
"String",
"pathMapping",
")",
"{",
"addFilePathMapping",
"(",
"bundlePathMapping",
",",
"pathMapping",
")",
";",
"if",
"(",
"!",
"bundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isIncludeOnlyOnDebug",
"(",
")",
")",
"{",
"bundlePathMapping",
".",
"getItemPathList",
"(",
")",
".",
"add",
"(",
"new",
"BundlePath",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
",",
"pathMapping",
")",
")",
";",
"}",
"if",
"(",
"!",
"bundle",
".",
"getInclusionPattern",
"(",
")",
".",
"isExcludeOnDebug",
"(",
")",
")",
"{",
"bundlePathMapping",
".",
"getItemDebugPathList",
"(",
")",
".",
"add",
"(",
"new",
"BundlePath",
"(",
"bundle",
".",
"getBundlePrefix",
"(",
")",
",",
"pathMapping",
")",
")",
";",
"}",
"}"
] |
Adds a path mapping to the bundle
@param pathMapping
the path mapping to add
|
[
"Adds",
"a",
"path",
"mapping",
"to",
"the",
"bundle"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java#L173-L185
|
7,104 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java
|
BundlePathMappingBuilder.addFilePathMapping
|
protected void addFilePathMapping(BundlePathMapping bundlePathMapping, String pathMapping) {
long timestamp = 0;
String filePath = resourceReaderHandler.getFilePath(pathMapping);
if (filePath != null) {
timestamp = resourceReaderHandler.getLastModified(filePath);
List<FilePathMapping> filePathMappings = bundlePathMapping.getFilePathMappings();
boolean found = false;
for (FilePathMapping filePathMapping : filePathMappings) {
if (filePathMapping.getPath().equals(filePath)) {
found = true;
break;
}
}
if (!found) {
filePathMappings.add(new FilePathMapping(bundle, filePath, timestamp));
}
}
}
|
java
|
protected void addFilePathMapping(BundlePathMapping bundlePathMapping, String pathMapping) {
long timestamp = 0;
String filePath = resourceReaderHandler.getFilePath(pathMapping);
if (filePath != null) {
timestamp = resourceReaderHandler.getLastModified(filePath);
List<FilePathMapping> filePathMappings = bundlePathMapping.getFilePathMappings();
boolean found = false;
for (FilePathMapping filePathMapping : filePathMappings) {
if (filePathMapping.getPath().equals(filePath)) {
found = true;
break;
}
}
if (!found) {
filePathMappings.add(new FilePathMapping(bundle, filePath, timestamp));
}
}
}
|
[
"protected",
"void",
"addFilePathMapping",
"(",
"BundlePathMapping",
"bundlePathMapping",
",",
"String",
"pathMapping",
")",
"{",
"long",
"timestamp",
"=",
"0",
";",
"String",
"filePath",
"=",
"resourceReaderHandler",
".",
"getFilePath",
"(",
"pathMapping",
")",
";",
"if",
"(",
"filePath",
"!=",
"null",
")",
"{",
"timestamp",
"=",
"resourceReaderHandler",
".",
"getLastModified",
"(",
"filePath",
")",
";",
"List",
"<",
"FilePathMapping",
">",
"filePathMappings",
"=",
"bundlePathMapping",
".",
"getFilePathMappings",
"(",
")",
";",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"FilePathMapping",
"filePathMapping",
":",
"filePathMappings",
")",
"{",
"if",
"(",
"filePathMapping",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"filePath",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"filePathMappings",
".",
"add",
"(",
"new",
"FilePathMapping",
"(",
"bundle",
",",
"filePath",
",",
"timestamp",
")",
")",
";",
"}",
"}",
"}"
] |
Adds the path mapping to the file path mapping
@param bundlePathMapping
the bundle path mapping
@param pathMapping
the path mapping to add
|
[
"Adds",
"the",
"path",
"mapping",
"to",
"the",
"file",
"path",
"mapping"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java#L195-L213
|
7,105 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java
|
BundlePathMappingBuilder.asPath
|
private String asPath(String path, boolean generatedResource) {
String result = path;
if (!generatedResource) {
result = PathNormalizer.asPath(path);
}
return result;
}
|
java
|
private String asPath(String path, boolean generatedResource) {
String result = path;
if (!generatedResource) {
result = PathNormalizer.asPath(path);
}
return result;
}
|
[
"private",
"String",
"asPath",
"(",
"String",
"path",
",",
"boolean",
"generatedResource",
")",
"{",
"String",
"result",
"=",
"path",
";",
"if",
"(",
"!",
"generatedResource",
")",
"{",
"result",
"=",
"PathNormalizer",
".",
"asPath",
"(",
"path",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Normalizes a path and adds a separator at its start, if it's not a
generated resource.
@param path
the path
@param generatedResource
the flag indicating if the resource has been generated
@return the normalized path
|
[
"Normalizes",
"a",
"path",
"and",
"adds",
"a",
"separator",
"at",
"its",
"start",
"if",
"it",
"s",
"not",
"a",
"generated",
"resource",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMappingBuilder.java#L313-L320
|
7,106 |
j-a-w-r/jawr-main-repo
|
jawr-tools/jawr-maven-plugin/src/main/java/net/jawr/maven/JawrMojo.java
|
JawrMojo.createBundles
|
public void createBundles() throws Exception {
File tempDir = new File(tempDirPath);
if(!tempDir.exists()){
tempDir.mkdirs();
}else{
FileUtils.cleanDirectory(tempDir);
}
File destDir = new File(destDirPath);
if(!destDir.exists()){
destDir.mkdirs();
}else{
FileUtils.cleanDirectory(destDir);
}
List<String> servlets = new ArrayList<String>();
if(servletsToInitialize != null){
String[] servletNames = servletsToInitialize.split(SERVLET_NAME_SEPARATOR);
for (int i = 0; i < servletNames.length; i++) {
servlets.add(servletNames[i].trim());
}
}
BundleProcessor bundleProcessor = new BundleProcessor();
bundleProcessor.process(rootPath, tempDirPath, destDirPath, springConfigFiles, servlets, generateCDNFiles, keepUrlMapping, servletAPIversion);
}
|
java
|
public void createBundles() throws Exception {
File tempDir = new File(tempDirPath);
if(!tempDir.exists()){
tempDir.mkdirs();
}else{
FileUtils.cleanDirectory(tempDir);
}
File destDir = new File(destDirPath);
if(!destDir.exists()){
destDir.mkdirs();
}else{
FileUtils.cleanDirectory(destDir);
}
List<String> servlets = new ArrayList<String>();
if(servletsToInitialize != null){
String[] servletNames = servletsToInitialize.split(SERVLET_NAME_SEPARATOR);
for (int i = 0; i < servletNames.length; i++) {
servlets.add(servletNames[i].trim());
}
}
BundleProcessor bundleProcessor = new BundleProcessor();
bundleProcessor.process(rootPath, tempDirPath, destDirPath, springConfigFiles, servlets, generateCDNFiles, keepUrlMapping, servletAPIversion);
}
|
[
"public",
"void",
"createBundles",
"(",
")",
"throws",
"Exception",
"{",
"File",
"tempDir",
"=",
"new",
"File",
"(",
"tempDirPath",
")",
";",
"if",
"(",
"!",
"tempDir",
".",
"exists",
"(",
")",
")",
"{",
"tempDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"else",
"{",
"FileUtils",
".",
"cleanDirectory",
"(",
"tempDir",
")",
";",
"}",
"File",
"destDir",
"=",
"new",
"File",
"(",
"destDirPath",
")",
";",
"if",
"(",
"!",
"destDir",
".",
"exists",
"(",
")",
")",
"{",
"destDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"else",
"{",
"FileUtils",
".",
"cleanDirectory",
"(",
"destDir",
")",
";",
"}",
"List",
"<",
"String",
">",
"servlets",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"servletsToInitialize",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"servletNames",
"=",
"servletsToInitialize",
".",
"split",
"(",
"SERVLET_NAME_SEPARATOR",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"servletNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"servlets",
".",
"add",
"(",
"servletNames",
"[",
"i",
"]",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"BundleProcessor",
"bundleProcessor",
"=",
"new",
"BundleProcessor",
"(",
")",
";",
"bundleProcessor",
".",
"process",
"(",
"rootPath",
",",
"tempDirPath",
",",
"destDirPath",
",",
"springConfigFiles",
",",
"servlets",
",",
"generateCDNFiles",
",",
"keepUrlMapping",
",",
"servletAPIversion",
")",
";",
"}"
] |
Create the bundles.
@throws Exception if an exception occurs
|
[
"Create",
"the",
"bundles",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-maven-plugin/src/main/java/net/jawr/maven/JawrMojo.java#L208-L234
|
7,107 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/cli/JettyLauncher.java
|
JettyLauncher.main
|
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
server.setStopAtShutdown(true);
server.setHandler(new WebAppContext("web","/dwr"));
server.start();
server.join();
}
|
java
|
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
server.setStopAtShutdown(true);
server.setHandler(new WebAppContext("web","/dwr"));
server.start();
server.join();
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"Server",
"server",
"=",
"new",
"Server",
"(",
"8080",
")",
";",
"server",
".",
"setStopAtShutdown",
"(",
"true",
")",
";",
"server",
".",
"setHandler",
"(",
"new",
"WebAppContext",
"(",
"\"web\"",
",",
"\"/dwr\"",
")",
")",
";",
"server",
".",
"start",
"(",
")",
";",
"server",
".",
"join",
"(",
")",
";",
"}"
] |
Sets up and runs server.
@param args The command line arguments
@throws Exception Don't care because top level
|
[
"Sets",
"up",
"and",
"runs",
"server",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/cli/JettyLauncher.java#L17-L24
|
7,108 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinVariantResourceProviderStrategy.java
|
CssSkinVariantResourceProviderStrategy.initVariantProviderStrategy
|
@Override
public void initVariantProviderStrategy(GeneratorContext context, Map<String, VariantSet> variantsSetMap) {
List<Map<String, String>> variantMapStrategies = new ArrayList<>();
Map<String, String> ctxVariantMap = context.getVariantMap();
VariantSet skinVariantSet = variantsSetMap.get(JawrConstant.SKIN_VARIANT_TYPE);
String skinVariant = ctxVariantMap.get(JawrConstant.SKIN_VARIANT_TYPE);
VariantSet localeVariantSet = variantsSetMap.get(JawrConstant.LOCALE_VARIANT_TYPE);
String localeVariant = ctxVariantMap.get(JawrConstant.LOCALE_VARIANT_TYPE);
variantMapStrategies.add(getVariantMap(skinVariant, localeVariant));
if (localeVariantSet != null) {
variantMapStrategies.add(getVariantMap(skinVariant, localeVariantSet.getDefaultVariant()));
}
variantMapStrategies.add(getVariantMap(skinVariantSet.getDefaultVariant(), localeVariant));
if (localeVariantSet != null) {
variantMapStrategies
.add(getVariantMap(skinVariantSet.getDefaultVariant(), localeVariantSet.getDefaultVariant()));
}
variantMapStrategyIterator = variantMapStrategies.iterator();
}
|
java
|
@Override
public void initVariantProviderStrategy(GeneratorContext context, Map<String, VariantSet> variantsSetMap) {
List<Map<String, String>> variantMapStrategies = new ArrayList<>();
Map<String, String> ctxVariantMap = context.getVariantMap();
VariantSet skinVariantSet = variantsSetMap.get(JawrConstant.SKIN_VARIANT_TYPE);
String skinVariant = ctxVariantMap.get(JawrConstant.SKIN_VARIANT_TYPE);
VariantSet localeVariantSet = variantsSetMap.get(JawrConstant.LOCALE_VARIANT_TYPE);
String localeVariant = ctxVariantMap.get(JawrConstant.LOCALE_VARIANT_TYPE);
variantMapStrategies.add(getVariantMap(skinVariant, localeVariant));
if (localeVariantSet != null) {
variantMapStrategies.add(getVariantMap(skinVariant, localeVariantSet.getDefaultVariant()));
}
variantMapStrategies.add(getVariantMap(skinVariantSet.getDefaultVariant(), localeVariant));
if (localeVariantSet != null) {
variantMapStrategies
.add(getVariantMap(skinVariantSet.getDefaultVariant(), localeVariantSet.getDefaultVariant()));
}
variantMapStrategyIterator = variantMapStrategies.iterator();
}
|
[
"@",
"Override",
"public",
"void",
"initVariantProviderStrategy",
"(",
"GeneratorContext",
"context",
",",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variantsSetMap",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"variantMapStrategies",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"ctxVariantMap",
"=",
"context",
".",
"getVariantMap",
"(",
")",
";",
"VariantSet",
"skinVariantSet",
"=",
"variantsSetMap",
".",
"get",
"(",
"JawrConstant",
".",
"SKIN_VARIANT_TYPE",
")",
";",
"String",
"skinVariant",
"=",
"ctxVariantMap",
".",
"get",
"(",
"JawrConstant",
".",
"SKIN_VARIANT_TYPE",
")",
";",
"VariantSet",
"localeVariantSet",
"=",
"variantsSetMap",
".",
"get",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
")",
";",
"String",
"localeVariant",
"=",
"ctxVariantMap",
".",
"get",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
")",
";",
"variantMapStrategies",
".",
"add",
"(",
"getVariantMap",
"(",
"skinVariant",
",",
"localeVariant",
")",
")",
";",
"if",
"(",
"localeVariantSet",
"!=",
"null",
")",
"{",
"variantMapStrategies",
".",
"add",
"(",
"getVariantMap",
"(",
"skinVariant",
",",
"localeVariantSet",
".",
"getDefaultVariant",
"(",
")",
")",
")",
";",
"}",
"variantMapStrategies",
".",
"add",
"(",
"getVariantMap",
"(",
"skinVariantSet",
".",
"getDefaultVariant",
"(",
")",
",",
"localeVariant",
")",
")",
";",
"if",
"(",
"localeVariantSet",
"!=",
"null",
")",
"{",
"variantMapStrategies",
".",
"add",
"(",
"getVariantMap",
"(",
"skinVariantSet",
".",
"getDefaultVariant",
"(",
")",
",",
"localeVariantSet",
".",
"getDefaultVariant",
"(",
")",
")",
")",
";",
"}",
"variantMapStrategyIterator",
"=",
"variantMapStrategies",
".",
"iterator",
"(",
")",
";",
"}"
] |
Initialize the variant resource provider strategy
@param context
the generator context
@param variantsSetMap
the variant set map for the current context path
|
[
"Initialize",
"the",
"variant",
"resource",
"provider",
"strategy"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinVariantResourceProviderStrategy.java#L53-L75
|
7,109 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinVariantResourceProviderStrategy.java
|
CssSkinVariantResourceProviderStrategy.getVariantMap
|
private Map<String, String> getVariantMap(String skinVariant, String localeVariant) {
Map<String, String> variantMap = new HashMap<>();
variantMap.put(JawrConstant.SKIN_VARIANT_TYPE, skinVariant);
variantMap.put(JawrConstant.LOCALE_VARIANT_TYPE, localeVariant);
return variantMap;
}
|
java
|
private Map<String, String> getVariantMap(String skinVariant, String localeVariant) {
Map<String, String> variantMap = new HashMap<>();
variantMap.put(JawrConstant.SKIN_VARIANT_TYPE, skinVariant);
variantMap.put(JawrConstant.LOCALE_VARIANT_TYPE, localeVariant);
return variantMap;
}
|
[
"private",
"Map",
"<",
"String",
",",
"String",
">",
"getVariantMap",
"(",
"String",
"skinVariant",
",",
"String",
"localeVariant",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"variantMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"variantMap",
".",
"put",
"(",
"JawrConstant",
".",
"SKIN_VARIANT_TYPE",
",",
"skinVariant",
")",
";",
"variantMap",
".",
"put",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
",",
"localeVariant",
")",
";",
"return",
"variantMap",
";",
"}"
] |
Returns the variant map from the skin and the locale parameters
@param skinVariant
the skin variant
@param localeVariant
the locale variant
@return the variant map
|
[
"Returns",
"the",
"variant",
"map",
"from",
"the",
"skin",
"and",
"the",
"locale",
"parameters"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinVariantResourceProviderStrategy.java#L86-L92
|
7,110 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java
|
AbstractBundleLinkRenderer.init
|
public void init(ResourceBundlesHandler bundler, Boolean useRandomParam) {
this.bundler = bundler;
if (useRandomParam == null) {
this.useRandomParam = bundler.getConfig().isDebugUseRandomParam();
} else {
this.useRandomParam = useRandomParam;
}
}
|
java
|
public void init(ResourceBundlesHandler bundler, Boolean useRandomParam) {
this.bundler = bundler;
if (useRandomParam == null) {
this.useRandomParam = bundler.getConfig().isDebugUseRandomParam();
} else {
this.useRandomParam = useRandomParam;
}
}
|
[
"public",
"void",
"init",
"(",
"ResourceBundlesHandler",
"bundler",
",",
"Boolean",
"useRandomParam",
")",
"{",
"this",
".",
"bundler",
"=",
"bundler",
";",
"if",
"(",
"useRandomParam",
"==",
"null",
")",
"{",
"this",
".",
"useRandomParam",
"=",
"bundler",
".",
"getConfig",
"(",
")",
".",
"isDebugUseRandomParam",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"useRandomParam",
"=",
"useRandomParam",
";",
"}",
"}"
] |
Initializes the bundle link renderer
@param bundler
ResourceBundlesHandler Handles resolving of paths.
@param useRandomParam
|
[
"Initializes",
"the",
"bundle",
"link",
"renderer"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L63-L71
|
7,111 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java
|
AbstractBundleLinkRenderer.renderBundleDependenciesLinks
|
private void renderBundleDependenciesLinks(String requestedPath, BundleRendererContext ctx, Writer out,
boolean debugOn, List<JoinableResourceBundle> dependencies) throws IOException {
if (dependencies != null && !dependencies.isEmpty()) {
for (JoinableResourceBundle dependencyBundle : dependencies) {
if (debugOn) {
addComment("Start adding dependency '" + dependencyBundle.getId() + "'", out);
}
renderBundleLinks(dependencyBundle, requestedPath, ctx, out, debugOn, false);
if (debugOn) {
addComment("Finished adding dependency '" + dependencyBundle.getId() + "'", out);
}
}
}
}
|
java
|
private void renderBundleDependenciesLinks(String requestedPath, BundleRendererContext ctx, Writer out,
boolean debugOn, List<JoinableResourceBundle> dependencies) throws IOException {
if (dependencies != null && !dependencies.isEmpty()) {
for (JoinableResourceBundle dependencyBundle : dependencies) {
if (debugOn) {
addComment("Start adding dependency '" + dependencyBundle.getId() + "'", out);
}
renderBundleLinks(dependencyBundle, requestedPath, ctx, out, debugOn, false);
if (debugOn) {
addComment("Finished adding dependency '" + dependencyBundle.getId() + "'", out);
}
}
}
}
|
[
"private",
"void",
"renderBundleDependenciesLinks",
"(",
"String",
"requestedPath",
",",
"BundleRendererContext",
"ctx",
",",
"Writer",
"out",
",",
"boolean",
"debugOn",
",",
"List",
"<",
"JoinableResourceBundle",
">",
"dependencies",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dependencies",
"!=",
"null",
"&&",
"!",
"dependencies",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"JoinableResourceBundle",
"dependencyBundle",
":",
"dependencies",
")",
"{",
"if",
"(",
"debugOn",
")",
"{",
"addComment",
"(",
"\"Start adding dependency '\"",
"+",
"dependencyBundle",
".",
"getId",
"(",
")",
"+",
"\"'\"",
",",
"out",
")",
";",
"}",
"renderBundleLinks",
"(",
"dependencyBundle",
",",
"requestedPath",
",",
"ctx",
",",
"out",
",",
"debugOn",
",",
"false",
")",
";",
"if",
"(",
"debugOn",
")",
"{",
"addComment",
"(",
"\"Finished adding dependency '\"",
"+",
"dependencyBundle",
".",
"getId",
"(",
")",
"+",
"\"'\"",
",",
"out",
")",
";",
"}",
"}",
"}",
"}"
] |
Renders the bundle links for the bundle dependencies
@param requestedPath
the request path
@param ctx
the context
@param out
the writer
@param debugOn
the debug flag
@param dependencies
the dependencies
@throws IOException
if an IOException occurs.
|
[
"Renders",
"the",
"bundle",
"links",
"for",
"the",
"bundle",
"dependencies"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L256-L270
|
7,112 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java
|
AbstractBundleLinkRenderer.renderBundleLinks
|
protected void renderBundleLinks(ResourceBundlePathsIterator it, BundleRendererContext ctx, boolean debugOn,
Writer out) throws IOException {
String contextPath = ctx.getContextPath();
boolean useGzip = ctx.isUseGzip();
boolean isSslRequest = ctx.isSslRequest();
// Add resources to the page as links.
Random randomSeed = new Random();
while (it.hasNext()) {
BundlePath bundlePath = it.nextPath();
if (bundlePath != null) {
String resourceName = bundlePath.getPath();
if (resourceName != null) {
// Handle external URL
if (bundlePath.isExternalURL()) {
out.write(renderLink(resourceName));
} else if (debugOn && useRandomParam) {
// In debug mode, all the resources are included
// separately
// and
// use a random parameter to avoid caching.
// If useRandomParam is set to false, the links are
// created
// without the random parameter.
int random = randomSeed.nextInt();
if (random < 0) {
random *= -1;
}
out.write(createBundleLink(resourceName, bundlePath.getBundlePrefix(), "d=" + random,
contextPath, isSslRequest));
// } else if (!debugOn && bundlePath.isProductionURL())
// {
// out.write(renderLink(resourceName));
} else if (!debugOn && useGzip) {
out.write(createGzipBundleLink(resourceName, bundlePath.getBundlePrefix(), contextPath,
isSslRequest));
} else {
out.write(createBundleLink(resourceName, bundlePath.getBundlePrefix(), null, contextPath,
isSslRequest));
}
if (debugOn && !ctx.getIncludedResources().add(resourceName)) {
addComment("The resource '" + resourceName + "' is already included in the page.", out);
}
}
}
}
}
|
java
|
protected void renderBundleLinks(ResourceBundlePathsIterator it, BundleRendererContext ctx, boolean debugOn,
Writer out) throws IOException {
String contextPath = ctx.getContextPath();
boolean useGzip = ctx.isUseGzip();
boolean isSslRequest = ctx.isSslRequest();
// Add resources to the page as links.
Random randomSeed = new Random();
while (it.hasNext()) {
BundlePath bundlePath = it.nextPath();
if (bundlePath != null) {
String resourceName = bundlePath.getPath();
if (resourceName != null) {
// Handle external URL
if (bundlePath.isExternalURL()) {
out.write(renderLink(resourceName));
} else if (debugOn && useRandomParam) {
// In debug mode, all the resources are included
// separately
// and
// use a random parameter to avoid caching.
// If useRandomParam is set to false, the links are
// created
// without the random parameter.
int random = randomSeed.nextInt();
if (random < 0) {
random *= -1;
}
out.write(createBundleLink(resourceName, bundlePath.getBundlePrefix(), "d=" + random,
contextPath, isSslRequest));
// } else if (!debugOn && bundlePath.isProductionURL())
// {
// out.write(renderLink(resourceName));
} else if (!debugOn && useGzip) {
out.write(createGzipBundleLink(resourceName, bundlePath.getBundlePrefix(), contextPath,
isSslRequest));
} else {
out.write(createBundleLink(resourceName, bundlePath.getBundlePrefix(), null, contextPath,
isSslRequest));
}
if (debugOn && !ctx.getIncludedResources().add(resourceName)) {
addComment("The resource '" + resourceName + "' is already included in the page.", out);
}
}
}
}
}
|
[
"protected",
"void",
"renderBundleLinks",
"(",
"ResourceBundlePathsIterator",
"it",
",",
"BundleRendererContext",
"ctx",
",",
"boolean",
"debugOn",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"String",
"contextPath",
"=",
"ctx",
".",
"getContextPath",
"(",
")",
";",
"boolean",
"useGzip",
"=",
"ctx",
".",
"isUseGzip",
"(",
")",
";",
"boolean",
"isSslRequest",
"=",
"ctx",
".",
"isSslRequest",
"(",
")",
";",
"// Add resources to the page as links.",
"Random",
"randomSeed",
"=",
"new",
"Random",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"BundlePath",
"bundlePath",
"=",
"it",
".",
"nextPath",
"(",
")",
";",
"if",
"(",
"bundlePath",
"!=",
"null",
")",
"{",
"String",
"resourceName",
"=",
"bundlePath",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"resourceName",
"!=",
"null",
")",
"{",
"// Handle external URL",
"if",
"(",
"bundlePath",
".",
"isExternalURL",
"(",
")",
")",
"{",
"out",
".",
"write",
"(",
"renderLink",
"(",
"resourceName",
")",
")",
";",
"}",
"else",
"if",
"(",
"debugOn",
"&&",
"useRandomParam",
")",
"{",
"// In debug mode, all the resources are included",
"// separately",
"// and",
"// use a random parameter to avoid caching.",
"// If useRandomParam is set to false, the links are",
"// created",
"// without the random parameter.",
"int",
"random",
"=",
"randomSeed",
".",
"nextInt",
"(",
")",
";",
"if",
"(",
"random",
"<",
"0",
")",
"{",
"random",
"*=",
"-",
"1",
";",
"}",
"out",
".",
"write",
"(",
"createBundleLink",
"(",
"resourceName",
",",
"bundlePath",
".",
"getBundlePrefix",
"(",
")",
",",
"\"d=\"",
"+",
"random",
",",
"contextPath",
",",
"isSslRequest",
")",
")",
";",
"// } else if (!debugOn && bundlePath.isProductionURL())",
"// {",
"// out.write(renderLink(resourceName));",
"}",
"else",
"if",
"(",
"!",
"debugOn",
"&&",
"useGzip",
")",
"{",
"out",
".",
"write",
"(",
"createGzipBundleLink",
"(",
"resourceName",
",",
"bundlePath",
".",
"getBundlePrefix",
"(",
")",
",",
"contextPath",
",",
"isSslRequest",
")",
")",
";",
"}",
"else",
"{",
"out",
".",
"write",
"(",
"createBundleLink",
"(",
"resourceName",
",",
"bundlePath",
".",
"getBundlePrefix",
"(",
")",
",",
"null",
",",
"contextPath",
",",
"isSslRequest",
")",
")",
";",
"}",
"if",
"(",
"debugOn",
"&&",
"!",
"ctx",
".",
"getIncludedResources",
"(",
")",
".",
"add",
"(",
"resourceName",
")",
")",
"{",
"addComment",
"(",
"\"The resource '\"",
"+",
"resourceName",
"+",
"\"' is already included in the page.\"",
",",
"out",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Renders the bundle links for the resource iterator passed in parameter
@param it
the iterator on the bundles
@param ctx
the renderer context
@param debugOn
the flag indicating if we are in debug mode or not
@param out
the output writer
@throws IOException
if an IO exception occurs
|
[
"Renders",
"the",
"bundle",
"links",
"for",
"the",
"resource",
"iterator",
"passed",
"in",
"parameter"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L286-L339
|
7,113 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java
|
AbstractBundleLinkRenderer.addComment
|
protected void addComment(String commentText, Writer out) throws IOException {
StringBuilder sb = new StringBuilder("<script type=\"text/javascript\">/* ");
sb.append(commentText).append(" */</script>").append("\n");
out.write(sb.toString());
}
|
java
|
protected void addComment(String commentText, Writer out) throws IOException {
StringBuilder sb = new StringBuilder("<script type=\"text/javascript\">/* ");
sb.append(commentText).append(" */</script>").append("\n");
out.write(sb.toString());
}
|
[
"protected",
"void",
"addComment",
"(",
"String",
"commentText",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"<script type=\\\"text/javascript\\\">/* \"",
")",
";",
"sb",
".",
"append",
"(",
"commentText",
")",
".",
"append",
"(",
"\" */</script>\"",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"out",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Adds an HTML comment to the output stream.
@param commentText
the comment
@param out
Writer
@throws IOException
if an IO exception occurs
|
[
"Adds",
"an",
"HTML",
"comment",
"to",
"the",
"output",
"stream",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L351-L355
|
7,114 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java
|
AbstractBundleLinkRenderer.createGzipBundleLink
|
protected String createGzipBundleLink(String resourceName, String bundlePrefix, String contextPath,
boolean isSslRequest) {
// remove '/' from start of name
String resource = resourceName.substring(1, resourceName.length());
return createBundleLink(BundleRenderer.GZIP_PATH_PREFIX + resource, bundlePrefix, null, contextPath,
isSslRequest);
}
|
java
|
protected String createGzipBundleLink(String resourceName, String bundlePrefix, String contextPath,
boolean isSslRequest) {
// remove '/' from start of name
String resource = resourceName.substring(1, resourceName.length());
return createBundleLink(BundleRenderer.GZIP_PATH_PREFIX + resource, bundlePrefix, null, contextPath,
isSslRequest);
}
|
[
"protected",
"String",
"createGzipBundleLink",
"(",
"String",
"resourceName",
",",
"String",
"bundlePrefix",
",",
"String",
"contextPath",
",",
"boolean",
"isSslRequest",
")",
"{",
"// remove '/' from start of name",
"String",
"resource",
"=",
"resourceName",
".",
"substring",
"(",
"1",
",",
"resourceName",
".",
"length",
"(",
")",
")",
";",
"return",
"createBundleLink",
"(",
"BundleRenderer",
".",
"GZIP_PATH_PREFIX",
"+",
"resource",
",",
"bundlePrefix",
",",
"null",
",",
"contextPath",
",",
"isSslRequest",
")",
";",
"}"
] |
Creates a link to a bundle in the page, prepending the gzip prefix to its
identifier.
@param resourceName
the resource name
@param bundlePrefix
the bundle prefix
@param contextPath
the context path
@param isSslRequest
the flag indicating if it's an SSL request
@return the link to the gzip bundle in the page
|
[
"Creates",
"a",
"link",
"to",
"a",
"bundle",
"in",
"the",
"page",
"prepending",
"the",
"gzip",
"prefix",
"to",
"its",
"identifier",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L371-L377
|
7,115 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractResourceBundleTag.java
|
AbstractResourceBundleTag.getUseRandomParamFlag
|
protected boolean getUseRandomParamFlag(JawrConfig config) {
boolean useRandomParamFlag = config.isDebugUseRandomParam();
if (useRandomParam != null) {
useRandomParamFlag = Boolean.parseBoolean(useRandomParam);
}
return useRandomParamFlag;
}
|
java
|
protected boolean getUseRandomParamFlag(JawrConfig config) {
boolean useRandomParamFlag = config.isDebugUseRandomParam();
if (useRandomParam != null) {
useRandomParamFlag = Boolean.parseBoolean(useRandomParam);
}
return useRandomParamFlag;
}
|
[
"protected",
"boolean",
"getUseRandomParamFlag",
"(",
"JawrConfig",
"config",
")",
"{",
"boolean",
"useRandomParamFlag",
"=",
"config",
".",
"isDebugUseRandomParam",
"(",
")",
";",
"if",
"(",
"useRandomParam",
"!=",
"null",
")",
"{",
"useRandomParamFlag",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"useRandomParam",
")",
";",
"}",
"return",
"useRandomParamFlag",
";",
"}"
] |
Returns the flag for the use of random param in debug mode
@param config
the Jawr config
@return the flag for the use of random param in debug mode
|
[
"Returns",
"the",
"flag",
"for",
"the",
"use",
"of",
"random",
"param",
"in",
"debug",
"mode"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractResourceBundleTag.java#L99-L106
|
7,116 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractResourceBundleTag.java
|
AbstractResourceBundleTag.getResourceBundlesHandler
|
protected ResourceBundlesHandler getResourceBundlesHandler(FacesContext context) {
Object handler = context.getExternalContext().getApplicationMap().get(getResourceBundlesHandlerAttributeName());
if (null == handler)
throw new IllegalStateException(
"ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred.");
ResourceBundlesHandler rsHandler = (ResourceBundlesHandler) handler;
return rsHandler;
}
|
java
|
protected ResourceBundlesHandler getResourceBundlesHandler(FacesContext context) {
Object handler = context.getExternalContext().getApplicationMap().get(getResourceBundlesHandlerAttributeName());
if (null == handler)
throw new IllegalStateException(
"ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred.");
ResourceBundlesHandler rsHandler = (ResourceBundlesHandler) handler;
return rsHandler;
}
|
[
"protected",
"ResourceBundlesHandler",
"getResourceBundlesHandler",
"(",
"FacesContext",
"context",
")",
"{",
"Object",
"handler",
"=",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getApplicationMap",
"(",
")",
".",
"get",
"(",
"getResourceBundlesHandlerAttributeName",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"handler",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred.\"",
")",
";",
"ResourceBundlesHandler",
"rsHandler",
"=",
"(",
"ResourceBundlesHandler",
")",
"handler",
";",
"return",
"rsHandler",
";",
"}"
] |
Returns the resource handler
@param context
the FacesContext
@return the resource handler
|
[
"Returns",
"the",
"resource",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractResourceBundleTag.java#L124-L132
|
7,117 |
j-a-w-r/jawr-main-repo
|
jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/renderer/DWRParamWriter.java
|
DWRParamWriter.buildRequestSpecificParams
|
public static StringBuffer buildRequestSpecificParams(String contextPath,
String dwrPath) {
StringBuffer sb = new StringBuffer(
"<script type=\"text/javascript\">if(!JAWR){var JAWR = {};};");
sb.append(buildDWRJSParams(contextPath, dwrPath));
sb.append("</script>").append("\n");
return sb;
}
|
java
|
public static StringBuffer buildRequestSpecificParams(String contextPath,
String dwrPath) {
StringBuffer sb = new StringBuffer(
"<script type=\"text/javascript\">if(!JAWR){var JAWR = {};};");
sb.append(buildDWRJSParams(contextPath, dwrPath));
sb.append("</script>").append("\n");
return sb;
}
|
[
"public",
"static",
"StringBuffer",
"buildRequestSpecificParams",
"(",
"String",
"contextPath",
",",
"String",
"dwrPath",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"\"<script type=\\\"text/javascript\\\">if(!JAWR){var JAWR = {};};\"",
")",
";",
"sb",
".",
"append",
"(",
"buildDWRJSParams",
"(",
"contextPath",
",",
"dwrPath",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"</script>\"",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"return",
"sb",
";",
"}"
] |
Adds a script with DWR needed params, including a generated ID that DWR
needs.
@param contextPath
@param dwrPath
@return
|
[
"Adds",
"a",
"script",
"with",
"DWR",
"needed",
"params",
"including",
"a",
"generated",
"ID",
"that",
"DWR",
"needs",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr3.x/jawr-dwr3.x-extension/src/main/java/net/jawr/web/resource/bundle/renderer/DWRParamWriter.java#L39-L47
|
7,118 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/OrphanResourceBundlesMapper.java
|
OrphanResourceBundlesMapper.getOrphansList
|
public List<String> getOrphansList() throws DuplicateBundlePathException {
// Create a mapping for every resource available
JoinableResourceBundleImpl tempBundle = new JoinableResourceOrphanBundleImpl("orphansTemp", "orphansTemp",
this.resourceExtension, new InclusionPattern(), Collections.singletonList(this.baseDir), rsHandler,
generatorRegistry);
// Add licenses
Set<String> licensesPathList = tempBundle.getLicensesPathList();
for (Iterator<String> it = licensesPathList.iterator(); it.hasNext();) {
addFileIfNotMapped(it.next());
}
// Add resources
List<BundlePath> allPaths = tempBundle.getItemPathList();
for (Iterator<BundlePath> it = allPaths.iterator(); it.hasNext();) {
addFileIfNotMapped(it.next().getPath());
}
return this.bundleMapping;
}
|
java
|
public List<String> getOrphansList() throws DuplicateBundlePathException {
// Create a mapping for every resource available
JoinableResourceBundleImpl tempBundle = new JoinableResourceOrphanBundleImpl("orphansTemp", "orphansTemp",
this.resourceExtension, new InclusionPattern(), Collections.singletonList(this.baseDir), rsHandler,
generatorRegistry);
// Add licenses
Set<String> licensesPathList = tempBundle.getLicensesPathList();
for (Iterator<String> it = licensesPathList.iterator(); it.hasNext();) {
addFileIfNotMapped(it.next());
}
// Add resources
List<BundlePath> allPaths = tempBundle.getItemPathList();
for (Iterator<BundlePath> it = allPaths.iterator(); it.hasNext();) {
addFileIfNotMapped(it.next().getPath());
}
return this.bundleMapping;
}
|
[
"public",
"List",
"<",
"String",
">",
"getOrphansList",
"(",
")",
"throws",
"DuplicateBundlePathException",
"{",
"// Create a mapping for every resource available",
"JoinableResourceBundleImpl",
"tempBundle",
"=",
"new",
"JoinableResourceOrphanBundleImpl",
"(",
"\"orphansTemp\"",
",",
"\"orphansTemp\"",
",",
"this",
".",
"resourceExtension",
",",
"new",
"InclusionPattern",
"(",
")",
",",
"Collections",
".",
"singletonList",
"(",
"this",
".",
"baseDir",
")",
",",
"rsHandler",
",",
"generatorRegistry",
")",
";",
"// Add licenses",
"Set",
"<",
"String",
">",
"licensesPathList",
"=",
"tempBundle",
".",
"getLicensesPathList",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"it",
"=",
"licensesPathList",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"addFileIfNotMapped",
"(",
"it",
".",
"next",
"(",
")",
")",
";",
"}",
"// Add resources",
"List",
"<",
"BundlePath",
">",
"allPaths",
"=",
"tempBundle",
".",
"getItemPathList",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"BundlePath",
">",
"it",
"=",
"allPaths",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"addFileIfNotMapped",
"(",
"it",
".",
"next",
"(",
")",
".",
"getPath",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"bundleMapping",
";",
"}"
] |
Scan all dirs starting at baseDir, and add each orphan resource to the
resources map.
@return the list of orphan resources
@throws DuplicateBundlePathException
if a duplicate path is found in the bundle
|
[
"Scan",
"all",
"dirs",
"starting",
"at",
"baseDir",
"and",
"add",
"each",
"orphan",
"resource",
"to",
"the",
"resources",
"map",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/OrphanResourceBundlesMapper.java#L113-L132
|
7,119 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/OrphanResourceBundlesMapper.java
|
OrphanResourceBundlesMapper.addFileIfNotMapped
|
private void addFileIfNotMapped(String filePath) throws DuplicateBundlePathException {
for (JoinableResourceBundle bundle : currentBundles) {
List<BundlePath> items = bundle.getItemPathList();
List<BundlePath> itemsDebug = bundle.getItemDebugPathList();
Set<String> licenses = bundle.getLicensesPathList();
for (BundlePath path : items) {
if (path.getPath().equals(filePath)) {
return;
}
}
for (BundlePath path : itemsDebug) {
if (path.getPath().equals(filePath)) {
return;
}
}
if (licenses.contains(filePath))
return;
else if (filePath.equals(bundle.getId())) {
Marker fatal = MarkerFactory.getMarker("FATAL");
LOGGER.error(fatal, "Duplicate bundle id resulted from orphan mapping of:" + filePath);
throw new DuplicateBundlePathException(filePath);
}
}
if (!filePath.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)
&& !filePath.startsWith(JawrConstant.META_INF_DIR_PREFIX)) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("Adding orphan resource: " + filePath);
// If we got here, the resource belongs to no other bundle.
bundleMapping.add(filePath);
}
}
|
java
|
private void addFileIfNotMapped(String filePath) throws DuplicateBundlePathException {
for (JoinableResourceBundle bundle : currentBundles) {
List<BundlePath> items = bundle.getItemPathList();
List<BundlePath> itemsDebug = bundle.getItemDebugPathList();
Set<String> licenses = bundle.getLicensesPathList();
for (BundlePath path : items) {
if (path.getPath().equals(filePath)) {
return;
}
}
for (BundlePath path : itemsDebug) {
if (path.getPath().equals(filePath)) {
return;
}
}
if (licenses.contains(filePath))
return;
else if (filePath.equals(bundle.getId())) {
Marker fatal = MarkerFactory.getMarker("FATAL");
LOGGER.error(fatal, "Duplicate bundle id resulted from orphan mapping of:" + filePath);
throw new DuplicateBundlePathException(filePath);
}
}
if (!filePath.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)
&& !filePath.startsWith(JawrConstant.META_INF_DIR_PREFIX)) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("Adding orphan resource: " + filePath);
// If we got here, the resource belongs to no other bundle.
bundleMapping.add(filePath);
}
}
|
[
"private",
"void",
"addFileIfNotMapped",
"(",
"String",
"filePath",
")",
"throws",
"DuplicateBundlePathException",
"{",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"currentBundles",
")",
"{",
"List",
"<",
"BundlePath",
">",
"items",
"=",
"bundle",
".",
"getItemPathList",
"(",
")",
";",
"List",
"<",
"BundlePath",
">",
"itemsDebug",
"=",
"bundle",
".",
"getItemDebugPathList",
"(",
")",
";",
"Set",
"<",
"String",
">",
"licenses",
"=",
"bundle",
".",
"getLicensesPathList",
"(",
")",
";",
"for",
"(",
"BundlePath",
"path",
":",
"items",
")",
"{",
"if",
"(",
"path",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"filePath",
")",
")",
"{",
"return",
";",
"}",
"}",
"for",
"(",
"BundlePath",
"path",
":",
"itemsDebug",
")",
"{",
"if",
"(",
"path",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"filePath",
")",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"licenses",
".",
"contains",
"(",
"filePath",
")",
")",
"return",
";",
"else",
"if",
"(",
"filePath",
".",
"equals",
"(",
"bundle",
".",
"getId",
"(",
")",
")",
")",
"{",
"Marker",
"fatal",
"=",
"MarkerFactory",
".",
"getMarker",
"(",
"\"FATAL\"",
")",
";",
"LOGGER",
".",
"error",
"(",
"fatal",
",",
"\"Duplicate bundle id resulted from orphan mapping of:\"",
"+",
"filePath",
")",
";",
"throw",
"new",
"DuplicateBundlePathException",
"(",
"filePath",
")",
";",
"}",
"}",
"if",
"(",
"!",
"filePath",
".",
"startsWith",
"(",
"JawrConstant",
".",
"WEB_INF_DIR_PREFIX",
")",
"&&",
"!",
"filePath",
".",
"startsWith",
"(",
"JawrConstant",
".",
"META_INF_DIR_PREFIX",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"Adding orphan resource: \"",
"+",
"filePath",
")",
";",
"// If we got here, the resource belongs to no other bundle.",
"bundleMapping",
".",
"add",
"(",
"filePath",
")",
";",
"}",
"}"
] |
Determine whether a resource is already added to some bundle, add it to
the list if it is not.
@param filePath
@param currentMappedResources
|
[
"Determine",
"whether",
"a",
"resource",
"is",
"already",
"added",
"to",
"some",
"bundle",
"add",
"it",
"to",
"the",
"list",
"if",
"it",
"is",
"not",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/OrphanResourceBundlesMapper.java#L141-L177
|
7,120 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/MultipleFileConfigSource.java
|
MultipleFileConfigSource.initAdditionalPropertyBaseNames
|
protected void initAdditionalPropertyBaseNames(ServletContext context) {
String propertyNames = context.getInitParameter(SERVLET_CONTEXT_ADDITIONAL_CONFIG_PARAM);
propertyBaseNames = new ArrayList<>();
if (null != propertyNames) {
StringTokenizer tk = new StringTokenizer(propertyNames, ",");
while (tk.hasMoreTokens())
propertyBaseNames.add(tk.nextToken());
}
}
|
java
|
protected void initAdditionalPropertyBaseNames(ServletContext context) {
String propertyNames = context.getInitParameter(SERVLET_CONTEXT_ADDITIONAL_CONFIG_PARAM);
propertyBaseNames = new ArrayList<>();
if (null != propertyNames) {
StringTokenizer tk = new StringTokenizer(propertyNames, ",");
while (tk.hasMoreTokens())
propertyBaseNames.add(tk.nextToken());
}
}
|
[
"protected",
"void",
"initAdditionalPropertyBaseNames",
"(",
"ServletContext",
"context",
")",
"{",
"String",
"propertyNames",
"=",
"context",
".",
"getInitParameter",
"(",
"SERVLET_CONTEXT_ADDITIONAL_CONFIG_PARAM",
")",
";",
"propertyBaseNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"propertyNames",
")",
"{",
"StringTokenizer",
"tk",
"=",
"new",
"StringTokenizer",
"(",
"propertyNames",
",",
"\",\"",
")",
";",
"while",
"(",
"tk",
".",
"hasMoreTokens",
"(",
")",
")",
"propertyBaseNames",
".",
"add",
"(",
"tk",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"}"
] |
Initializes the propertyBaseNames list by reading the jawr.config.sources
servlet context param. Subclasses may override this method to use a
different strategy.
@param context
|
[
"Initializes",
"the",
"propertyBaseNames",
"list",
"by",
"reading",
"the",
"jawr",
".",
"config",
".",
"sources",
"servlet",
"context",
"param",
".",
"Subclasses",
"may",
"override",
"this",
"method",
"to",
"use",
"a",
"different",
"strategy",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/MultipleFileConfigSource.java#L76-L84
|
7,121 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/image/ImgHTMLRenderer.java
|
ImgHTMLRenderer.renderImage
|
@Override
public void renderImage(String imgSource, Map<String, Object> attributes, final Writer writer) throws IOException {
StringBuilder sb = new StringBuilder(tagStart);
sb.append("src=\"").append(imgSource).append("\" ");
for (Entry<String, Object> mapEntry : attributes.entrySet()) {
sb.append(mapEntry.getKey()).append("=\"").append(mapEntry.getValue()).append("\" ");
}
sb.append("/>");
writer.write(sb.toString());
}
|
java
|
@Override
public void renderImage(String imgSource, Map<String, Object> attributes, final Writer writer) throws IOException {
StringBuilder sb = new StringBuilder(tagStart);
sb.append("src=\"").append(imgSource).append("\" ");
for (Entry<String, Object> mapEntry : attributes.entrySet()) {
sb.append(mapEntry.getKey()).append("=\"").append(mapEntry.getValue()).append("\" ");
}
sb.append("/>");
writer.write(sb.toString());
}
|
[
"@",
"Override",
"public",
"void",
"renderImage",
"(",
"String",
"imgSource",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"tagStart",
")",
";",
"sb",
".",
"append",
"(",
"\"src=\\\"\"",
")",
".",
"append",
"(",
"imgSource",
")",
".",
"append",
"(",
"\"\\\" \"",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"mapEntry",
":",
"attributes",
".",
"entrySet",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"mapEntry",
".",
"getKey",
"(",
")",
")",
".",
"append",
"(",
"\"=\\\"\"",
")",
".",
"append",
"(",
"mapEntry",
".",
"getValue",
"(",
")",
")",
".",
"append",
"(",
"\"\\\" \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"/>\"",
")",
";",
"writer",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Render the actual tag
@param imgSource
Source of the image
@param attributes
Attributes for the tag.
@param writer
Writer to render the HTML into. Will NOT be closed or flushed.
@throws IOException
if an exception occurs
|
[
"Render",
"the",
"actual",
"tag"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/image/ImgHTMLRenderer.java#L72-L83
|
7,122 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/util/StringUtils.java
|
StringUtils.split
|
public static String[] split(String str, String separator){
return Pattern.compile(separator).split(str, -1);
}
|
java
|
public static String[] split(String str, String separator){
return Pattern.compile(separator).split(str, -1);
}
|
[
"public",
"static",
"String",
"[",
"]",
"split",
"(",
"String",
"str",
",",
"String",
"separator",
")",
"{",
"return",
"Pattern",
".",
"compile",
"(",
"separator",
")",
".",
"split",
"(",
"str",
",",
"-",
"1",
")",
";",
"}"
] |
Split the String passed in parameter, the trailing empty string are kept.
@param str the string to split
@param separator the separator
@return the splitted string
|
[
"Split",
"the",
"String",
"passed",
"in",
"parameter",
"the",
"trailing",
"empty",
"string",
"are",
"kept",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/StringUtils.java#L294-L297
|
7,123 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java
|
JoinableResourceBundlePropertySerializer.serializeVariantSets
|
private static String serializeVariantSets(Map<String, VariantSet> map) {
StringBuilder result = new StringBuilder();
for (Entry<String, VariantSet> entry : map.entrySet()) {
result.append(entry.getKey()).append(":");
VariantSet variantSet = (VariantSet) entry.getValue();
result.append(variantSet.getDefaultVariant()).append(":");
result.append(getCommaSeparatedString(variantSet));
result.append(";");
}
return result.toString();
}
|
java
|
private static String serializeVariantSets(Map<String, VariantSet> map) {
StringBuilder result = new StringBuilder();
for (Entry<String, VariantSet> entry : map.entrySet()) {
result.append(entry.getKey()).append(":");
VariantSet variantSet = (VariantSet) entry.getValue();
result.append(variantSet.getDefaultVariant()).append(":");
result.append(getCommaSeparatedString(variantSet));
result.append(";");
}
return result.toString();
}
|
[
"private",
"static",
"String",
"serializeVariantSets",
"(",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"map",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"VariantSet",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"append",
"(",
"\":\"",
")",
";",
"VariantSet",
"variantSet",
"=",
"(",
"VariantSet",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"result",
".",
"append",
"(",
"variantSet",
".",
"getDefaultVariant",
"(",
")",
")",
".",
"append",
"(",
"\":\"",
")",
";",
"result",
".",
"append",
"(",
"getCommaSeparatedString",
"(",
"variantSet",
")",
")",
";",
"result",
".",
"append",
"(",
"\";\"",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Serialize the variant sets.
@param map
the map to serialize
@return the serialized variant sets
|
[
"Serialize",
"the",
"variant",
"sets",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java#L198-L210
|
7,124 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java
|
JoinableResourceBundlePropertySerializer.getBundleNames
|
private static List<String> getBundleNames(List<JoinableResourceBundle> bundles) {
List<String> bundleNames = new ArrayList<>();
for (Iterator<JoinableResourceBundle> iterator = bundles.iterator(); iterator.hasNext();) {
bundleNames.add(iterator.next().getName());
}
return bundleNames;
}
|
java
|
private static List<String> getBundleNames(List<JoinableResourceBundle> bundles) {
List<String> bundleNames = new ArrayList<>();
for (Iterator<JoinableResourceBundle> iterator = bundles.iterator(); iterator.hasNext();) {
bundleNames.add(iterator.next().getName());
}
return bundleNames;
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"getBundleNames",
"(",
"List",
"<",
"JoinableResourceBundle",
">",
"bundles",
")",
"{",
"List",
"<",
"String",
">",
"bundleNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"JoinableResourceBundle",
">",
"iterator",
"=",
"bundles",
".",
"iterator",
"(",
")",
";",
"iterator",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"bundleNames",
".",
"add",
"(",
"iterator",
".",
"next",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"bundleNames",
";",
"}"
] |
Returns the list of bundle names
@param bundles
the bundles
@return the list of bundle names
|
[
"Returns",
"the",
"list",
"of",
"bundle",
"names"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java#L219-L226
|
7,125 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java
|
JoinableResourceBundlePropertySerializer.getBundlePostProcessorsName
|
private static String getBundlePostProcessorsName(ChainedResourceBundlePostProcessor processor) {
String bundlePostProcessor = "";
if (processor != null) {
bundlePostProcessor = processor.getId();
}
return bundlePostProcessor;
}
|
java
|
private static String getBundlePostProcessorsName(ChainedResourceBundlePostProcessor processor) {
String bundlePostProcessor = "";
if (processor != null) {
bundlePostProcessor = processor.getId();
}
return bundlePostProcessor;
}
|
[
"private",
"static",
"String",
"getBundlePostProcessorsName",
"(",
"ChainedResourceBundlePostProcessor",
"processor",
")",
"{",
"String",
"bundlePostProcessor",
"=",
"\"\"",
";",
"if",
"(",
"processor",
"!=",
"null",
")",
"{",
"bundlePostProcessor",
"=",
"processor",
".",
"getId",
"(",
")",
";",
"}",
"return",
"bundlePostProcessor",
";",
"}"
] |
Returns the bundle post processor name separated by a comma character
@param processor
the post processor
@return the bundle post processor name separated by a comma character
|
[
"Returns",
"the",
"bundle",
"post",
"processor",
"name",
"separated",
"by",
"a",
"comma",
"character"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java#L298-L306
|
7,126 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java
|
LiveHelp.notifyTyping
|
public void notifyTyping(String id, String value)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.setValue(id, Security.replaceXmlCharacters(value));
}
|
java
|
public void notifyTyping(String id, String value)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.setValue(id, Security.replaceXmlCharacters(value));
}
|
[
"public",
"void",
"notifyTyping",
"(",
"String",
"id",
",",
"String",
"value",
")",
"{",
"Util",
"utilAll",
"=",
"new",
"Util",
"(",
"getUsersToAffect",
"(",
")",
")",
";",
"utilAll",
".",
"setValue",
"(",
"id",
",",
"Security",
".",
"replaceXmlCharacters",
"(",
"value",
")",
")",
";",
"}"
] |
Something has changed
@param id The id of the field that changed
@param value The new value
|
[
"Something",
"has",
"changed"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java#L38-L43
|
7,127 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java
|
LiveHelp.notifyFocus
|
public void notifyFocus(String id)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.addClassName(id, "disabled");
String addr = WebContextFactory.get().getHttpServletRequest().getRemoteAddr();
utilAll.setValue(id + "Tip", addr);
//utilAll.addScript("$('" + id + "').disabled = true;");
}
|
java
|
public void notifyFocus(String id)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.addClassName(id, "disabled");
String addr = WebContextFactory.get().getHttpServletRequest().getRemoteAddr();
utilAll.setValue(id + "Tip", addr);
//utilAll.addScript("$('" + id + "').disabled = true;");
}
|
[
"public",
"void",
"notifyFocus",
"(",
"String",
"id",
")",
"{",
"Util",
"utilAll",
"=",
"new",
"Util",
"(",
"getUsersToAffect",
"(",
")",
")",
";",
"utilAll",
".",
"addClassName",
"(",
"id",
",",
"\"disabled\"",
")",
";",
"String",
"addr",
"=",
"WebContextFactory",
".",
"get",
"(",
")",
".",
"getHttpServletRequest",
"(",
")",
".",
"getRemoteAddr",
"(",
")",
";",
"utilAll",
".",
"setValue",
"(",
"id",
"+",
"\"Tip\"",
",",
"addr",
")",
";",
"//utilAll.addScript(\"$('\" + id + \"').disabled = true;\");",
"}"
] |
The user has tabbed in
@param id The id of the field that changed
|
[
"The",
"user",
"has",
"tabbed",
"in"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java#L49-L58
|
7,128 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java
|
LiveHelp.notifyBlur
|
public void notifyBlur(String id)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.removeClassName(id, "disabled");
utilAll.setValue(id + "Tip", "");
//utilAll.addScript("$('" + id + "').disabled = false;");
}
|
java
|
public void notifyBlur(String id)
{
Util utilAll = new Util(getUsersToAffect());
utilAll.removeClassName(id, "disabled");
utilAll.setValue(id + "Tip", "");
//utilAll.addScript("$('" + id + "').disabled = false;");
}
|
[
"public",
"void",
"notifyBlur",
"(",
"String",
"id",
")",
"{",
"Util",
"utilAll",
"=",
"new",
"Util",
"(",
"getUsersToAffect",
"(",
")",
")",
";",
"utilAll",
".",
"removeClassName",
"(",
"id",
",",
"\"disabled\"",
")",
";",
"utilAll",
".",
"setValue",
"(",
"id",
"+",
"\"Tip\"",
",",
"\"\"",
")",
";",
"//utilAll.addScript(\"$('\" + id + \"').disabled = false;\");",
"}"
] |
The user has tabbed out
@param id The id of the field that changed
|
[
"The",
"user",
"has",
"tabbed",
"out"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/livehelp/LiveHelp.java#L64-L72
|
7,129 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initRequestHandler
|
private void initRequestHandler(ServletContext context, Properties configProps) throws ServletException {
long initialTime = System.currentTimeMillis();
if (LOGGER.isInfoEnabled())
LOGGER.info("Initializing jawr config for request handler named " + getInitParameter("handlerName"));
this.servletContext = context;
this.overrideProperties = configProps;
resourceType = getInitParameter("type");
resourceType = null == resourceType ? "js" : resourceType;
if (resourceType.equals("img")) {
throw new BundlingProcessException(
"The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead.");
}
// Check if the resource type is a valid one
if (!(resourceType.equals(JawrConstant.JS_TYPE) || resourceType.equals(JawrConstant.CSS_TYPE)
|| resourceType.equals(JawrConstant.BINARY_TYPE))) {
throw new BundlingProcessException("Unknown resource Type:" + resourceType);
}
// Initialize the config properties source that will provide with all
// configuration options.
ConfigPropertiesSource propsSrc = initConfigPropertiesSource(context, configProps);
// Read properties from properties source
Properties props = propsSrc.getConfigProperties();
// override the properties if needed
if (this.overrideProperties != null) {
props.putAll(overrideProperties);
}
// hang onto the propertiesSource for manual reloads
this.propertiesSource = propsSrc;
// Initialize the ConfigPropertyResolver
initConfigPropertyResolver(context);
initializeJawrContext(props);
// Initialize the properties reloading checker daemon if specified
if (!ThreadLocalJawrContext.isBundleProcessingAtBuildTime()
&& null != props.getProperty(CONFIG_RELOAD_INTERVAL)) {
int interval = Integer.parseInt(props.getProperty(CONFIG_RELOAD_INTERVAL));
LOGGER.warn("Jawr started with configuration auto reloading on. "
+ "Be aware that a daemon thread will be checking for changes to configuration every " + interval
+ " seconds.");
this.configChangeListenerThread = new ConfigChangeListenerThread(this.resourceType, propsSrc,
this.overrideProperties, this, this.bundlesHandler, interval);
configChangeListenerThread.start();
}
if (this.bundlesHandler != null && jawrConfig.getUseSmartBundling()) {
this.watcher = new ResourceWatcher(this.bundlesHandler, this.rsReaderHandler);
this.bundlesHandler.setResourceWatcher(watcher);
try {
this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getGlobalBundles());
this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getContextBundles());
} catch (IOException e) {
throw new BundlingProcessException("Impossible to initialize Jawr Resource Watcher", e);
}
this.watcher.start();
}
if (LOGGER.isInfoEnabled()) {
long totaltime = System.currentTimeMillis() - initialTime;
LOGGER.info("Init method successful. jawr started in " + (totaltime / 1000) + " seconds....");
}
// Reset ThreadLocalJawrContext
ThreadLocalJawrContext.reset();
}
|
java
|
private void initRequestHandler(ServletContext context, Properties configProps) throws ServletException {
long initialTime = System.currentTimeMillis();
if (LOGGER.isInfoEnabled())
LOGGER.info("Initializing jawr config for request handler named " + getInitParameter("handlerName"));
this.servletContext = context;
this.overrideProperties = configProps;
resourceType = getInitParameter("type");
resourceType = null == resourceType ? "js" : resourceType;
if (resourceType.equals("img")) {
throw new BundlingProcessException(
"The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead.");
}
// Check if the resource type is a valid one
if (!(resourceType.equals(JawrConstant.JS_TYPE) || resourceType.equals(JawrConstant.CSS_TYPE)
|| resourceType.equals(JawrConstant.BINARY_TYPE))) {
throw new BundlingProcessException("Unknown resource Type:" + resourceType);
}
// Initialize the config properties source that will provide with all
// configuration options.
ConfigPropertiesSource propsSrc = initConfigPropertiesSource(context, configProps);
// Read properties from properties source
Properties props = propsSrc.getConfigProperties();
// override the properties if needed
if (this.overrideProperties != null) {
props.putAll(overrideProperties);
}
// hang onto the propertiesSource for manual reloads
this.propertiesSource = propsSrc;
// Initialize the ConfigPropertyResolver
initConfigPropertyResolver(context);
initializeJawrContext(props);
// Initialize the properties reloading checker daemon if specified
if (!ThreadLocalJawrContext.isBundleProcessingAtBuildTime()
&& null != props.getProperty(CONFIG_RELOAD_INTERVAL)) {
int interval = Integer.parseInt(props.getProperty(CONFIG_RELOAD_INTERVAL));
LOGGER.warn("Jawr started with configuration auto reloading on. "
+ "Be aware that a daemon thread will be checking for changes to configuration every " + interval
+ " seconds.");
this.configChangeListenerThread = new ConfigChangeListenerThread(this.resourceType, propsSrc,
this.overrideProperties, this, this.bundlesHandler, interval);
configChangeListenerThread.start();
}
if (this.bundlesHandler != null && jawrConfig.getUseSmartBundling()) {
this.watcher = new ResourceWatcher(this.bundlesHandler, this.rsReaderHandler);
this.bundlesHandler.setResourceWatcher(watcher);
try {
this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getGlobalBundles());
this.watcher.initPathToResourceBundleMap(this.bundlesHandler.getContextBundles());
} catch (IOException e) {
throw new BundlingProcessException("Impossible to initialize Jawr Resource Watcher", e);
}
this.watcher.start();
}
if (LOGGER.isInfoEnabled()) {
long totaltime = System.currentTimeMillis() - initialTime;
LOGGER.info("Init method successful. jawr started in " + (totaltime / 1000) + " seconds....");
}
// Reset ThreadLocalJawrContext
ThreadLocalJawrContext.reset();
}
|
[
"private",
"void",
"initRequestHandler",
"(",
"ServletContext",
"context",
",",
"Properties",
"configProps",
")",
"throws",
"ServletException",
"{",
"long",
"initialTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"LOGGER",
".",
"info",
"(",
"\"Initializing jawr config for request handler named \"",
"+",
"getInitParameter",
"(",
"\"handlerName\"",
")",
")",
";",
"this",
".",
"servletContext",
"=",
"context",
";",
"this",
".",
"overrideProperties",
"=",
"configProps",
";",
"resourceType",
"=",
"getInitParameter",
"(",
"\"type\"",
")",
";",
"resourceType",
"=",
"null",
"==",
"resourceType",
"?",
"\"js\"",
":",
"resourceType",
";",
"if",
"(",
"resourceType",
".",
"equals",
"(",
"\"img\"",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead.\"",
")",
";",
"}",
"// Check if the resource type is a valid one",
"if",
"(",
"!",
"(",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"JS_TYPE",
")",
"||",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"CSS_TYPE",
")",
"||",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"BINARY_TYPE",
")",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unknown resource Type:\"",
"+",
"resourceType",
")",
";",
"}",
"// Initialize the config properties source that will provide with all",
"// configuration options.",
"ConfigPropertiesSource",
"propsSrc",
"=",
"initConfigPropertiesSource",
"(",
"context",
",",
"configProps",
")",
";",
"// Read properties from properties source",
"Properties",
"props",
"=",
"propsSrc",
".",
"getConfigProperties",
"(",
")",
";",
"// override the properties if needed",
"if",
"(",
"this",
".",
"overrideProperties",
"!=",
"null",
")",
"{",
"props",
".",
"putAll",
"(",
"overrideProperties",
")",
";",
"}",
"// hang onto the propertiesSource for manual reloads",
"this",
".",
"propertiesSource",
"=",
"propsSrc",
";",
"// Initialize the ConfigPropertyResolver",
"initConfigPropertyResolver",
"(",
"context",
")",
";",
"initializeJawrContext",
"(",
"props",
")",
";",
"// Initialize the properties reloading checker daemon if specified",
"if",
"(",
"!",
"ThreadLocalJawrContext",
".",
"isBundleProcessingAtBuildTime",
"(",
")",
"&&",
"null",
"!=",
"props",
".",
"getProperty",
"(",
"CONFIG_RELOAD_INTERVAL",
")",
")",
"{",
"int",
"interval",
"=",
"Integer",
".",
"parseInt",
"(",
"props",
".",
"getProperty",
"(",
"CONFIG_RELOAD_INTERVAL",
")",
")",
";",
"LOGGER",
".",
"warn",
"(",
"\"Jawr started with configuration auto reloading on. \"",
"+",
"\"Be aware that a daemon thread will be checking for changes to configuration every \"",
"+",
"interval",
"+",
"\" seconds.\"",
")",
";",
"this",
".",
"configChangeListenerThread",
"=",
"new",
"ConfigChangeListenerThread",
"(",
"this",
".",
"resourceType",
",",
"propsSrc",
",",
"this",
".",
"overrideProperties",
",",
"this",
",",
"this",
".",
"bundlesHandler",
",",
"interval",
")",
";",
"configChangeListenerThread",
".",
"start",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"bundlesHandler",
"!=",
"null",
"&&",
"jawrConfig",
".",
"getUseSmartBundling",
"(",
")",
")",
"{",
"this",
".",
"watcher",
"=",
"new",
"ResourceWatcher",
"(",
"this",
".",
"bundlesHandler",
",",
"this",
".",
"rsReaderHandler",
")",
";",
"this",
".",
"bundlesHandler",
".",
"setResourceWatcher",
"(",
"watcher",
")",
";",
"try",
"{",
"this",
".",
"watcher",
".",
"initPathToResourceBundleMap",
"(",
"this",
".",
"bundlesHandler",
".",
"getGlobalBundles",
"(",
")",
")",
";",
"this",
".",
"watcher",
".",
"initPathToResourceBundleMap",
"(",
"this",
".",
"bundlesHandler",
".",
"getContextBundles",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Impossible to initialize Jawr Resource Watcher\"",
",",
"e",
")",
";",
"}",
"this",
".",
"watcher",
".",
"start",
"(",
")",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"long",
"totaltime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"initialTime",
";",
"LOGGER",
".",
"info",
"(",
"\"Init method successful. jawr started in \"",
"+",
"(",
"totaltime",
"/",
"1000",
")",
"+",
"\" seconds....\"",
")",
";",
"}",
"// Reset ThreadLocalJawrContext",
"ThreadLocalJawrContext",
".",
"reset",
"(",
")",
";",
"}"
] |
Initialize the request handler
@param context
the servlet context
@param configProps
the configuration properties
@throws ServletException
if an exception occurs
|
[
"Initialize",
"the",
"request",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L252-L327
|
7,130 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initApplicationConfigManager
|
private JawrApplicationConfigManager initApplicationConfigManager() {
JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) servletContext
.getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER);
if (appConfigMgr == null) {
appConfigMgr = new JawrApplicationConfigManager();
servletContext.setAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER, appConfigMgr);
}
// Create the config manager for the current Request Handler
JawrConfigManager configMgr = new JawrConfigManager(this, jawrConfig.getConfigProperties());
// Initialize the jawrApplicationConfigManager
if (resourceType.equals(JawrConstant.JS_TYPE)) {
appConfigMgr.setJsMBean(configMgr);
} else if (resourceType.equals(JawrConstant.CSS_TYPE)) {
appConfigMgr.setCssMBean(configMgr);
} else {
appConfigMgr.setBinaryMBean(configMgr);
}
return appConfigMgr;
}
|
java
|
private JawrApplicationConfigManager initApplicationConfigManager() {
JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) servletContext
.getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER);
if (appConfigMgr == null) {
appConfigMgr = new JawrApplicationConfigManager();
servletContext.setAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER, appConfigMgr);
}
// Create the config manager for the current Request Handler
JawrConfigManager configMgr = new JawrConfigManager(this, jawrConfig.getConfigProperties());
// Initialize the jawrApplicationConfigManager
if (resourceType.equals(JawrConstant.JS_TYPE)) {
appConfigMgr.setJsMBean(configMgr);
} else if (resourceType.equals(JawrConstant.CSS_TYPE)) {
appConfigMgr.setCssMBean(configMgr);
} else {
appConfigMgr.setBinaryMBean(configMgr);
}
return appConfigMgr;
}
|
[
"private",
"JawrApplicationConfigManager",
"initApplicationConfigManager",
"(",
")",
"{",
"JawrApplicationConfigManager",
"appConfigMgr",
"=",
"(",
"JawrApplicationConfigManager",
")",
"servletContext",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"JAWR_APPLICATION_CONFIG_MANAGER",
")",
";",
"if",
"(",
"appConfigMgr",
"==",
"null",
")",
"{",
"appConfigMgr",
"=",
"new",
"JawrApplicationConfigManager",
"(",
")",
";",
"servletContext",
".",
"setAttribute",
"(",
"JawrConstant",
".",
"JAWR_APPLICATION_CONFIG_MANAGER",
",",
"appConfigMgr",
")",
";",
"}",
"// Create the config manager for the current Request Handler",
"JawrConfigManager",
"configMgr",
"=",
"new",
"JawrConfigManager",
"(",
"this",
",",
"jawrConfig",
".",
"getConfigProperties",
"(",
")",
")",
";",
"// Initialize the jawrApplicationConfigManager",
"if",
"(",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"JS_TYPE",
")",
")",
"{",
"appConfigMgr",
".",
"setJsMBean",
"(",
"configMgr",
")",
";",
"}",
"else",
"if",
"(",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"CSS_TYPE",
")",
")",
"{",
"appConfigMgr",
".",
"setCssMBean",
"(",
"configMgr",
")",
";",
"}",
"else",
"{",
"appConfigMgr",
".",
"setBinaryMBean",
"(",
"configMgr",
")",
";",
"}",
"return",
"appConfigMgr",
";",
"}"
] |
Initialize the application config manager
@return the application config manager
|
[
"Initialize",
"the",
"application",
"config",
"manager"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L367-L388
|
7,131 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initConfigPropertyResolver
|
private void initConfigPropertyResolver(ServletContext context) {
String configPropertyResolverClass = getInitParameter("configPropertyResolverClass");
// Load a custom class to set configPropertyResolver
configPropResolver = null;
if (null != configPropertyResolverClass) {
configPropResolver = (ConfigPropertyResolver) ClassLoaderResourceUtils
.buildObjectInstance(configPropertyResolverClass);
if (configPropResolver instanceof ServletContextAware) {
((ServletContextAware) configPropResolver).setServletContext(context);
}
}
}
|
java
|
private void initConfigPropertyResolver(ServletContext context) {
String configPropertyResolverClass = getInitParameter("configPropertyResolverClass");
// Load a custom class to set configPropertyResolver
configPropResolver = null;
if (null != configPropertyResolverClass) {
configPropResolver = (ConfigPropertyResolver) ClassLoaderResourceUtils
.buildObjectInstance(configPropertyResolverClass);
if (configPropResolver instanceof ServletContextAware) {
((ServletContextAware) configPropResolver).setServletContext(context);
}
}
}
|
[
"private",
"void",
"initConfigPropertyResolver",
"(",
"ServletContext",
"context",
")",
"{",
"String",
"configPropertyResolverClass",
"=",
"getInitParameter",
"(",
"\"configPropertyResolverClass\"",
")",
";",
"// Load a custom class to set configPropertyResolver",
"configPropResolver",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"configPropertyResolverClass",
")",
"{",
"configPropResolver",
"=",
"(",
"ConfigPropertyResolver",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"configPropertyResolverClass",
")",
";",
"if",
"(",
"configPropResolver",
"instanceof",
"ServletContextAware",
")",
"{",
"(",
"(",
"ServletContextAware",
")",
"configPropResolver",
")",
".",
"setServletContext",
"(",
"context",
")",
";",
"}",
"}",
"}"
] |
Initialize the config property resolver
@param context
the servlet context
|
[
"Initialize",
"the",
"config",
"property",
"resolver"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L396-L407
|
7,132 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initConfigPropertiesSource
|
private ConfigPropertiesSource initConfigPropertiesSource(ServletContext context, Properties configProps)
throws ServletException {
String configLocation = getInitParameter("configLocation");
String configPropsSourceClass = getInitParameter("configPropertiesSourceClass");
if (null == configProps && null == configLocation && null == configPropsSourceClass)
throw new ServletException("Neither configLocation nor configPropertiesSourceClass init params were set."
+ " You must set at least the configLocation param. Please check your web.xml file");
// Initialize the config properties source that will provide with all
// configuration options.
ConfigPropertiesSource propsSrc = null;
// Load a custom class to set config properties
if (null != configPropsSourceClass) {
propsSrc = (ConfigPropertiesSource) ClassLoaderResourceUtils.buildObjectInstance(configPropsSourceClass);
if (propsSrc instanceof ServletContextAware) {
((ServletContextAware) propsSrc).setServletContext(context);
}
} else if (configLocation == null && configProps != null) {
// configuration retrieved from the in memory configuration
// properties
propsSrc = new PropsConfigPropertiesSource(configProps);
} else {
// Default config properties source, reads from a .properties file
// in the classpath.
propsSrc = new PropsFilePropertiesSource();
}
// If a custom properties source is a subclass of
// PropsFilePropertiesSource, we hand it the configLocation param.
// This affects the standard one as well.
if (propsSrc instanceof PropsFilePropertiesSource)
((PropsFilePropertiesSource) propsSrc).setConfigLocation(configLocation);
return propsSrc;
}
|
java
|
private ConfigPropertiesSource initConfigPropertiesSource(ServletContext context, Properties configProps)
throws ServletException {
String configLocation = getInitParameter("configLocation");
String configPropsSourceClass = getInitParameter("configPropertiesSourceClass");
if (null == configProps && null == configLocation && null == configPropsSourceClass)
throw new ServletException("Neither configLocation nor configPropertiesSourceClass init params were set."
+ " You must set at least the configLocation param. Please check your web.xml file");
// Initialize the config properties source that will provide with all
// configuration options.
ConfigPropertiesSource propsSrc = null;
// Load a custom class to set config properties
if (null != configPropsSourceClass) {
propsSrc = (ConfigPropertiesSource) ClassLoaderResourceUtils.buildObjectInstance(configPropsSourceClass);
if (propsSrc instanceof ServletContextAware) {
((ServletContextAware) propsSrc).setServletContext(context);
}
} else if (configLocation == null && configProps != null) {
// configuration retrieved from the in memory configuration
// properties
propsSrc = new PropsConfigPropertiesSource(configProps);
} else {
// Default config properties source, reads from a .properties file
// in the classpath.
propsSrc = new PropsFilePropertiesSource();
}
// If a custom properties source is a subclass of
// PropsFilePropertiesSource, we hand it the configLocation param.
// This affects the standard one as well.
if (propsSrc instanceof PropsFilePropertiesSource)
((PropsFilePropertiesSource) propsSrc).setConfigLocation(configLocation);
return propsSrc;
}
|
[
"private",
"ConfigPropertiesSource",
"initConfigPropertiesSource",
"(",
"ServletContext",
"context",
",",
"Properties",
"configProps",
")",
"throws",
"ServletException",
"{",
"String",
"configLocation",
"=",
"getInitParameter",
"(",
"\"configLocation\"",
")",
";",
"String",
"configPropsSourceClass",
"=",
"getInitParameter",
"(",
"\"configPropertiesSourceClass\"",
")",
";",
"if",
"(",
"null",
"==",
"configProps",
"&&",
"null",
"==",
"configLocation",
"&&",
"null",
"==",
"configPropsSourceClass",
")",
"throw",
"new",
"ServletException",
"(",
"\"Neither configLocation nor configPropertiesSourceClass init params were set.\"",
"+",
"\" You must set at least the configLocation param. Please check your web.xml file\"",
")",
";",
"// Initialize the config properties source that will provide with all",
"// configuration options.",
"ConfigPropertiesSource",
"propsSrc",
"=",
"null",
";",
"// Load a custom class to set config properties",
"if",
"(",
"null",
"!=",
"configPropsSourceClass",
")",
"{",
"propsSrc",
"=",
"(",
"ConfigPropertiesSource",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"configPropsSourceClass",
")",
";",
"if",
"(",
"propsSrc",
"instanceof",
"ServletContextAware",
")",
"{",
"(",
"(",
"ServletContextAware",
")",
"propsSrc",
")",
".",
"setServletContext",
"(",
"context",
")",
";",
"}",
"}",
"else",
"if",
"(",
"configLocation",
"==",
"null",
"&&",
"configProps",
"!=",
"null",
")",
"{",
"// configuration retrieved from the in memory configuration",
"// properties",
"propsSrc",
"=",
"new",
"PropsConfigPropertiesSource",
"(",
"configProps",
")",
";",
"}",
"else",
"{",
"// Default config properties source, reads from a .properties file",
"// in the classpath.",
"propsSrc",
"=",
"new",
"PropsFilePropertiesSource",
"(",
")",
";",
"}",
"// If a custom properties source is a subclass of",
"// PropsFilePropertiesSource, we hand it the configLocation param.",
"// This affects the standard one as well.",
"if",
"(",
"propsSrc",
"instanceof",
"PropsFilePropertiesSource",
")",
"(",
"(",
"PropsFilePropertiesSource",
")",
"propsSrc",
")",
".",
"setConfigLocation",
"(",
"configLocation",
")",
";",
"return",
"propsSrc",
";",
"}"
] |
Initialize the config properties source that will provide with all
configuration options.
@param context
the servlet context
@param configProps
the config properties
@return the config properties source
@throws ServletException
if an exception occurs
|
[
"Initialize",
"the",
"config",
"properties",
"source",
"that",
"will",
"provide",
"with",
"all",
"configuration",
"options",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L421-L458
|
7,133 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initIllegalBundleRequestHandler
|
protected void initIllegalBundleRequestHandler() {
String illegalBundleRequestandlerClassName = jawrConfig
.getProperty(JawrConstant.ILLEGAL_BUNDLE_REQUEST_HANDLER);
if (illegalBundleRequestandlerClassName != null) {
illegalBundleRequestHandler = (IllegalBundleRequestHandler) ClassLoaderResourceUtils
.buildObjectInstance(illegalBundleRequestandlerClassName);
} else {
illegalBundleRequestHandler = new IllegalBundleRequestHandlerImpl();
}
}
|
java
|
protected void initIllegalBundleRequestHandler() {
String illegalBundleRequestandlerClassName = jawrConfig
.getProperty(JawrConstant.ILLEGAL_BUNDLE_REQUEST_HANDLER);
if (illegalBundleRequestandlerClassName != null) {
illegalBundleRequestHandler = (IllegalBundleRequestHandler) ClassLoaderResourceUtils
.buildObjectInstance(illegalBundleRequestandlerClassName);
} else {
illegalBundleRequestHandler = new IllegalBundleRequestHandlerImpl();
}
}
|
[
"protected",
"void",
"initIllegalBundleRequestHandler",
"(",
")",
"{",
"String",
"illegalBundleRequestandlerClassName",
"=",
"jawrConfig",
".",
"getProperty",
"(",
"JawrConstant",
".",
"ILLEGAL_BUNDLE_REQUEST_HANDLER",
")",
";",
"if",
"(",
"illegalBundleRequestandlerClassName",
"!=",
"null",
")",
"{",
"illegalBundleRequestHandler",
"=",
"(",
"IllegalBundleRequestHandler",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"illegalBundleRequestandlerClassName",
")",
";",
"}",
"else",
"{",
"illegalBundleRequestHandler",
"=",
"new",
"IllegalBundleRequestHandlerImpl",
"(",
")",
";",
"}",
"}"
] |
Initialize the illegal bundle request handler
|
[
"Initialize",
"the",
"illegal",
"bundle",
"request",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L566-L575
|
7,134 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initResourceReaderHandler
|
protected ResourceReaderHandler initResourceReaderHandler() {
ResourceReaderHandler rsHandler = null;
if (servletContext != null) {
try {
rsHandler = new ServletContextResourceReaderHandler(servletContext, jawrConfig, generatorRegistry);
} catch (IOException e) {
throw new BundlingProcessException(e);
}
}
return rsHandler;
}
|
java
|
protected ResourceReaderHandler initResourceReaderHandler() {
ResourceReaderHandler rsHandler = null;
if (servletContext != null) {
try {
rsHandler = new ServletContextResourceReaderHandler(servletContext, jawrConfig, generatorRegistry);
} catch (IOException e) {
throw new BundlingProcessException(e);
}
}
return rsHandler;
}
|
[
"protected",
"ResourceReaderHandler",
"initResourceReaderHandler",
"(",
")",
"{",
"ResourceReaderHandler",
"rsHandler",
"=",
"null",
";",
"if",
"(",
"servletContext",
"!=",
"null",
")",
"{",
"try",
"{",
"rsHandler",
"=",
"new",
"ServletContextResourceReaderHandler",
"(",
"servletContext",
",",
"jawrConfig",
",",
"generatorRegistry",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"rsHandler",
";",
"}"
] |
Initialize the resource reader handler
@return the resource reader handler
|
[
"Initialize",
"the",
"resource",
"reader",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L582-L593
|
7,135 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initResourceBundleHandler
|
protected ResourceBundleHandler initResourceBundleHandler() {
ResourceBundleHandler rsHandler = null;
if (jawrConfig.getUseBundleMapping() && StringUtils.isNotEmpty(jawrConfig.getJawrWorkingDirectory())) {
rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getJawrWorkingDirectory(),
jawrConfig.getResourceCharset(), jawrConfig.getGeneratorRegistry(), resourceType);
} else {
rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getResourceCharset(),
jawrConfig.getGeneratorRegistry(), resourceType);
}
return rsHandler;
}
|
java
|
protected ResourceBundleHandler initResourceBundleHandler() {
ResourceBundleHandler rsHandler = null;
if (jawrConfig.getUseBundleMapping() && StringUtils.isNotEmpty(jawrConfig.getJawrWorkingDirectory())) {
rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getJawrWorkingDirectory(),
jawrConfig.getResourceCharset(), jawrConfig.getGeneratorRegistry(), resourceType);
} else {
rsHandler = new ServletContextResourceBundleHandler(servletContext, jawrConfig.getResourceCharset(),
jawrConfig.getGeneratorRegistry(), resourceType);
}
return rsHandler;
}
|
[
"protected",
"ResourceBundleHandler",
"initResourceBundleHandler",
"(",
")",
"{",
"ResourceBundleHandler",
"rsHandler",
"=",
"null",
";",
"if",
"(",
"jawrConfig",
".",
"getUseBundleMapping",
"(",
")",
"&&",
"StringUtils",
".",
"isNotEmpty",
"(",
"jawrConfig",
".",
"getJawrWorkingDirectory",
"(",
")",
")",
")",
"{",
"rsHandler",
"=",
"new",
"ServletContextResourceBundleHandler",
"(",
"servletContext",
",",
"jawrConfig",
".",
"getJawrWorkingDirectory",
"(",
")",
",",
"jawrConfig",
".",
"getResourceCharset",
"(",
")",
",",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
",",
"resourceType",
")",
";",
"}",
"else",
"{",
"rsHandler",
"=",
"new",
"ServletContextResourceBundleHandler",
"(",
"servletContext",
",",
"jawrConfig",
".",
"getResourceCharset",
"(",
")",
",",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
",",
"resourceType",
")",
";",
"}",
"return",
"rsHandler",
";",
"}"
] |
Initialize the resource bundle handler
@return the resource bundle handler
|
[
"Initialize",
"the",
"resource",
"bundle",
"handler"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L600-L610
|
7,136 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.createJawrConfig
|
protected JawrConfig createJawrConfig(Properties props) {
jawrConfig = new JawrConfig(resourceType, props, configPropResolver);
// Override properties which are incompatible with the build time bundle
// processing
if (ThreadLocalJawrContext.isBundleProcessingAtBuildTime()) {
jawrConfig.setUseBundleMapping(true);
// Use the standard working directory
jawrConfig.setJawrWorkingDirectory(null);
}
return jawrConfig;
}
|
java
|
protected JawrConfig createJawrConfig(Properties props) {
jawrConfig = new JawrConfig(resourceType, props, configPropResolver);
// Override properties which are incompatible with the build time bundle
// processing
if (ThreadLocalJawrContext.isBundleProcessingAtBuildTime()) {
jawrConfig.setUseBundleMapping(true);
// Use the standard working directory
jawrConfig.setJawrWorkingDirectory(null);
}
return jawrConfig;
}
|
[
"protected",
"JawrConfig",
"createJawrConfig",
"(",
"Properties",
"props",
")",
"{",
"jawrConfig",
"=",
"new",
"JawrConfig",
"(",
"resourceType",
",",
"props",
",",
"configPropResolver",
")",
";",
"// Override properties which are incompatible with the build time bundle",
"// processing",
"if",
"(",
"ThreadLocalJawrContext",
".",
"isBundleProcessingAtBuildTime",
"(",
")",
")",
"{",
"jawrConfig",
".",
"setUseBundleMapping",
"(",
"true",
")",
";",
"// Use the standard working directory",
"jawrConfig",
".",
"setJawrWorkingDirectory",
"(",
"null",
")",
";",
"}",
"return",
"jawrConfig",
";",
"}"
] |
Create the Jawr config from the properties
@param props
the properties
@return the Jawr config
|
[
"Create",
"the",
"Jawr",
"config",
"from",
"the",
"properties"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L619-L632
|
7,137 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.doGet
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String requestedPath = "".equals(jawrConfig.getServletMapping()) ? request.getServletPath()
: request.getPathInfo();
processRequest(requestedPath, request, response);
} catch (Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("ServletException : ", e);
}
throw new ServletException(e);
}
}
|
java
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String requestedPath = "".equals(jawrConfig.getServletMapping()) ? request.getServletPath()
: request.getPathInfo();
processRequest(requestedPath, request, response);
} catch (Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("ServletException : ", e);
}
throw new ServletException(e);
}
}
|
[
"public",
"void",
"doGet",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"try",
"{",
"String",
"requestedPath",
"=",
"\"\"",
".",
"equals",
"(",
"jawrConfig",
".",
"getServletMapping",
"(",
")",
")",
"?",
"request",
".",
"getServletPath",
"(",
")",
":",
"request",
".",
"getPathInfo",
"(",
")",
";",
"processRequest",
"(",
"requestedPath",
",",
"request",
",",
"response",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"ServletException : \"",
",",
"e",
")",
";",
"}",
"throw",
"new",
"ServletException",
"(",
"e",
")",
";",
"}",
"}"
] |
Handles a resource request by getting the requested path from the request
object and invoking processRequest.
@param request
the request
@param response
the response
@throws ServletException
if a servlet exception occurs
@throws IOException
if an IO exception occurs.
|
[
"Handles",
"a",
"resource",
"request",
"by",
"getting",
"the",
"requested",
"path",
"from",
"the",
"request",
"object",
"and",
"invoking",
"processRequest",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L647-L663
|
7,138 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.initThreadLocalJawrContext
|
protected void initThreadLocalJawrContext(HttpServletRequest request) {
ThreadLocalJawrContext.setJawrConfigMgrObjectName(JmxUtils.getJawrConfigMBeanObjectName(
request.getContextPath(), resourceType, jawrConfig.getProperty(JawrConstant.JAWR_JMX_MBEAN_PREFIX)));
ThreadLocalJawrContext.setRequest(request.getRequestURL().toString());
RendererRequestUtils.setRequestDebuggable(request, jawrConfig);
}
|
java
|
protected void initThreadLocalJawrContext(HttpServletRequest request) {
ThreadLocalJawrContext.setJawrConfigMgrObjectName(JmxUtils.getJawrConfigMBeanObjectName(
request.getContextPath(), resourceType, jawrConfig.getProperty(JawrConstant.JAWR_JMX_MBEAN_PREFIX)));
ThreadLocalJawrContext.setRequest(request.getRequestURL().toString());
RendererRequestUtils.setRequestDebuggable(request, jawrConfig);
}
|
[
"protected",
"void",
"initThreadLocalJawrContext",
"(",
"HttpServletRequest",
"request",
")",
"{",
"ThreadLocalJawrContext",
".",
"setJawrConfigMgrObjectName",
"(",
"JmxUtils",
".",
"getJawrConfigMBeanObjectName",
"(",
"request",
".",
"getContextPath",
"(",
")",
",",
"resourceType",
",",
"jawrConfig",
".",
"getProperty",
"(",
"JawrConstant",
".",
"JAWR_JMX_MBEAN_PREFIX",
")",
")",
")",
";",
"ThreadLocalJawrContext",
".",
"setRequest",
"(",
"request",
".",
"getRequestURL",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"RendererRequestUtils",
".",
"setRequestDebuggable",
"(",
"request",
",",
"jawrConfig",
")",
";",
"}"
] |
Initialize the ThreadLocalJawrContext
@param request
the HTTP request
|
[
"Initialize",
"the",
"ThreadLocalJawrContext"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L761-L768
|
7,139 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.copyRequestedContentToResponse
|
protected boolean copyRequestedContentToResponse(String requestedPath, HttpServletResponse response,
String contentType) throws IOException {
boolean copyDone = false;
if (isValidRequestedPath(requestedPath)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Path '" + requestedPath + "' does not belong to a bundle. Forwarding request to the server. ");
}
try (InputStream is = servletContext.getResourceAsStream(requestedPath)) {
if (is != null) {
response.setContentType(contentType);
IOUtils.copy(is, response.getOutputStream());
copyDone = true;
}
}
}
return copyDone;
}
|
java
|
protected boolean copyRequestedContentToResponse(String requestedPath, HttpServletResponse response,
String contentType) throws IOException {
boolean copyDone = false;
if (isValidRequestedPath(requestedPath)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Path '" + requestedPath + "' does not belong to a bundle. Forwarding request to the server. ");
}
try (InputStream is = servletContext.getResourceAsStream(requestedPath)) {
if (is != null) {
response.setContentType(contentType);
IOUtils.copy(is, response.getOutputStream());
copyDone = true;
}
}
}
return copyDone;
}
|
[
"protected",
"boolean",
"copyRequestedContentToResponse",
"(",
"String",
"requestedPath",
",",
"HttpServletResponse",
"response",
",",
"String",
"contentType",
")",
"throws",
"IOException",
"{",
"boolean",
"copyDone",
"=",
"false",
";",
"if",
"(",
"isValidRequestedPath",
"(",
"requestedPath",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Path '\"",
"+",
"requestedPath",
"+",
"\"' does not belong to a bundle. Forwarding request to the server. \"",
")",
";",
"}",
"try",
"(",
"InputStream",
"is",
"=",
"servletContext",
".",
"getResourceAsStream",
"(",
"requestedPath",
")",
")",
"{",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"response",
".",
"setContentType",
"(",
"contentType",
")",
";",
"IOUtils",
".",
"copy",
"(",
"is",
",",
"response",
".",
"getOutputStream",
"(",
")",
")",
";",
"copyDone",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"copyDone",
";",
"}"
] |
Copy the requested content to the response
@param requestedPath
the requested path
@param response
the response
@param contentType
the content type
@return true if the resource exists and has been copied in the response
@throws IOException
if an IO exception occurs
|
[
"Copy",
"the",
"requested",
"content",
"to",
"the",
"response"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L783-L804
|
7,140 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.handleSpecificRequest
|
protected boolean handleSpecificRequest(String requestedPath, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
boolean processed = false;
if (CLIENTSIDE_HANDLER_REQ_PATH.equals(requestedPath)) {
this.clientSideScriptRequestHandler.handleClientSideHandlerRequest(request, response);
processed = true;
} else {
// CSS images would be requested through this handler in case
// servletMapping is used
if (JawrConstant.CSS_TYPE.equals(resourceType)
&& !JawrConstant.CSS_TYPE.equals(getExtension(requestedPath))) {
if (null == bundlesHandler.resolveBundleForPath(requestedPath) && isValidRequestedPath(requestedPath)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Path '" + requestedPath
+ "' does not belong to a bundle. Forwarding request to the server. ");
}
request.getRequestDispatcher(requestedPath).forward(request, response);
processed = true;
}
}
}
return processed;
}
|
java
|
protected boolean handleSpecificRequest(String requestedPath, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
boolean processed = false;
if (CLIENTSIDE_HANDLER_REQ_PATH.equals(requestedPath)) {
this.clientSideScriptRequestHandler.handleClientSideHandlerRequest(request, response);
processed = true;
} else {
// CSS images would be requested through this handler in case
// servletMapping is used
if (JawrConstant.CSS_TYPE.equals(resourceType)
&& !JawrConstant.CSS_TYPE.equals(getExtension(requestedPath))) {
if (null == bundlesHandler.resolveBundleForPath(requestedPath) && isValidRequestedPath(requestedPath)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Path '" + requestedPath
+ "' does not belong to a bundle. Forwarding request to the server. ");
}
request.getRequestDispatcher(requestedPath).forward(request, response);
processed = true;
}
}
}
return processed;
}
|
[
"protected",
"boolean",
"handleSpecificRequest",
"(",
"String",
"requestedPath",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"boolean",
"processed",
"=",
"false",
";",
"if",
"(",
"CLIENTSIDE_HANDLER_REQ_PATH",
".",
"equals",
"(",
"requestedPath",
")",
")",
"{",
"this",
".",
"clientSideScriptRequestHandler",
".",
"handleClientSideHandlerRequest",
"(",
"request",
",",
"response",
")",
";",
"processed",
"=",
"true",
";",
"}",
"else",
"{",
"// CSS images would be requested through this handler in case",
"// servletMapping is used",
"if",
"(",
"JawrConstant",
".",
"CSS_TYPE",
".",
"equals",
"(",
"resourceType",
")",
"&&",
"!",
"JawrConstant",
".",
"CSS_TYPE",
".",
"equals",
"(",
"getExtension",
"(",
"requestedPath",
")",
")",
")",
"{",
"if",
"(",
"null",
"==",
"bundlesHandler",
".",
"resolveBundleForPath",
"(",
"requestedPath",
")",
"&&",
"isValidRequestedPath",
"(",
"requestedPath",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Path '\"",
"+",
"requestedPath",
"+",
"\"' does not belong to a bundle. Forwarding request to the server. \"",
")",
";",
"}",
"request",
".",
"getRequestDispatcher",
"(",
"requestedPath",
")",
".",
"forward",
"(",
"request",
",",
"response",
")",
";",
"processed",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"processed",
";",
"}"
] |
Handle the specific requests
@param requestedPath
the requested path
@param request
the request
@param response
the response
@return true if the request has been processed
@throws ServletException
if a servlet exception occurs
@throws IOException
if an IO exception occurs
|
[
"Handle",
"the",
"specific",
"requests"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L821-L847
|
7,141 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.isValidBundle
|
protected BundleHashcodeType isValidBundle(String requestedPath) {
BundleHashcodeType bundleHashcodeType = BundleHashcodeType.VALID_HASHCODE;
if (!jawrConfig.isDebugModeOn()) {
bundleHashcodeType = bundlesHandler.getBundleHashcodeType(requestedPath);
}
return bundleHashcodeType;
}
|
java
|
protected BundleHashcodeType isValidBundle(String requestedPath) {
BundleHashcodeType bundleHashcodeType = BundleHashcodeType.VALID_HASHCODE;
if (!jawrConfig.isDebugModeOn()) {
bundleHashcodeType = bundlesHandler.getBundleHashcodeType(requestedPath);
}
return bundleHashcodeType;
}
|
[
"protected",
"BundleHashcodeType",
"isValidBundle",
"(",
"String",
"requestedPath",
")",
"{",
"BundleHashcodeType",
"bundleHashcodeType",
"=",
"BundleHashcodeType",
".",
"VALID_HASHCODE",
";",
"if",
"(",
"!",
"jawrConfig",
".",
"isDebugModeOn",
"(",
")",
")",
"{",
"bundleHashcodeType",
"=",
"bundlesHandler",
".",
"getBundleHashcodeType",
"(",
"requestedPath",
")",
";",
"}",
"return",
"bundleHashcodeType",
";",
"}"
] |
Returns true if the bundle is a valid bundle
@param requestedPath
the requested path
@return true if the bundle is a valid bundle
|
[
"Returns",
"true",
"if",
"the",
"bundle",
"is",
"a",
"valid",
"bundle"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L856-L862
|
7,142 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.writeContent
|
protected void writeContent(String requestedPath, HttpServletRequest request, HttpServletResponse response)
throws IOException, ResourceNotFoundException {
// Send gzipped resource if user agent supports it.
int idx = requestedPath.indexOf(BundleRenderer.GZIP_PATH_PREFIX);
if (idx != -1) {
requestedPath = JawrConstant.URL_SEPARATOR
+ requestedPath.substring(idx + BundleRenderer.GZIP_PATH_PREFIX.length(), requestedPath.length());
if (isValidRequestedPath(requestedPath)) {
response.setHeader(CONTENT_ENCODING, GZIP);
bundlesHandler.streamBundleTo(requestedPath, response.getOutputStream());
} else {
throw new ResourceNotFoundException(requestedPath);
}
} else {
// In debug mode, we take in account the image generated from a
// StreamGenerator like classpath Image generator
// The following code will rewrite the URL path for the generated
// images,
// because in debug mode, we are retrieving the CSS resources
// directly from the webapp
// and if the CSS contains generated images, we should rewrite the
// URL.
BinaryResourcesHandler imgRsHandler = (BinaryResourcesHandler) servletContext
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (imgRsHandler != null && this.jawrConfig.isDebugModeOn() && resourceType.equals(JawrConstant.CSS_TYPE)) {
handleGeneratedCssInDebugMode(requestedPath, request, response, imgRsHandler);
} else {
if (isValidRequestedPath(requestedPath)) {
Writer out = response.getWriter();
bundlesHandler.writeBundleTo(requestedPath, out);
} else {
throw new ResourceNotFoundException(requestedPath);
}
}
}
}
|
java
|
protected void writeContent(String requestedPath, HttpServletRequest request, HttpServletResponse response)
throws IOException, ResourceNotFoundException {
// Send gzipped resource if user agent supports it.
int idx = requestedPath.indexOf(BundleRenderer.GZIP_PATH_PREFIX);
if (idx != -1) {
requestedPath = JawrConstant.URL_SEPARATOR
+ requestedPath.substring(idx + BundleRenderer.GZIP_PATH_PREFIX.length(), requestedPath.length());
if (isValidRequestedPath(requestedPath)) {
response.setHeader(CONTENT_ENCODING, GZIP);
bundlesHandler.streamBundleTo(requestedPath, response.getOutputStream());
} else {
throw new ResourceNotFoundException(requestedPath);
}
} else {
// In debug mode, we take in account the image generated from a
// StreamGenerator like classpath Image generator
// The following code will rewrite the URL path for the generated
// images,
// because in debug mode, we are retrieving the CSS resources
// directly from the webapp
// and if the CSS contains generated images, we should rewrite the
// URL.
BinaryResourcesHandler imgRsHandler = (BinaryResourcesHandler) servletContext
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (imgRsHandler != null && this.jawrConfig.isDebugModeOn() && resourceType.equals(JawrConstant.CSS_TYPE)) {
handleGeneratedCssInDebugMode(requestedPath, request, response, imgRsHandler);
} else {
if (isValidRequestedPath(requestedPath)) {
Writer out = response.getWriter();
bundlesHandler.writeBundleTo(requestedPath, out);
} else {
throw new ResourceNotFoundException(requestedPath);
}
}
}
}
|
[
"protected",
"void",
"writeContent",
"(",
"String",
"requestedPath",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
",",
"ResourceNotFoundException",
"{",
"// Send gzipped resource if user agent supports it.",
"int",
"idx",
"=",
"requestedPath",
".",
"indexOf",
"(",
"BundleRenderer",
".",
"GZIP_PATH_PREFIX",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"requestedPath",
"=",
"JawrConstant",
".",
"URL_SEPARATOR",
"+",
"requestedPath",
".",
"substring",
"(",
"idx",
"+",
"BundleRenderer",
".",
"GZIP_PATH_PREFIX",
".",
"length",
"(",
")",
",",
"requestedPath",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"isValidRequestedPath",
"(",
"requestedPath",
")",
")",
"{",
"response",
".",
"setHeader",
"(",
"CONTENT_ENCODING",
",",
"GZIP",
")",
";",
"bundlesHandler",
".",
"streamBundleTo",
"(",
"requestedPath",
",",
"response",
".",
"getOutputStream",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"requestedPath",
")",
";",
"}",
"}",
"else",
"{",
"// In debug mode, we take in account the image generated from a",
"// StreamGenerator like classpath Image generator",
"// The following code will rewrite the URL path for the generated",
"// images,",
"// because in debug mode, we are retrieving the CSS resources",
"// directly from the webapp",
"// and if the CSS contains generated images, we should rewrite the",
"// URL.",
"BinaryResourcesHandler",
"imgRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"servletContext",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"imgRsHandler",
"!=",
"null",
"&&",
"this",
".",
"jawrConfig",
".",
"isDebugModeOn",
"(",
")",
"&&",
"resourceType",
".",
"equals",
"(",
"JawrConstant",
".",
"CSS_TYPE",
")",
")",
"{",
"handleGeneratedCssInDebugMode",
"(",
"requestedPath",
",",
"request",
",",
"response",
",",
"imgRsHandler",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isValidRequestedPath",
"(",
"requestedPath",
")",
")",
"{",
"Writer",
"out",
"=",
"response",
".",
"getWriter",
"(",
")",
";",
"bundlesHandler",
".",
"writeBundleTo",
"(",
"requestedPath",
",",
"out",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"requestedPath",
")",
";",
"}",
"}",
"}",
"}"
] |
Writes the content to the output stream
@param requestedPath
the requested path
@param request
the request
@param response
the response
@throws IOException
if an IOException occurs
@throws ResourceNotFoundException
if the resource is not found
|
[
"Writes",
"the",
"content",
"to",
"the",
"output",
"stream"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L983-L1024
|
7,143 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.handleGeneratedCssInDebugMode
|
private void handleGeneratedCssInDebugMode(String requestedPath, HttpServletRequest request,
HttpServletResponse response, BinaryResourcesHandler binaryRsHandler)
throws ResourceNotFoundException, IOException {
// Retrieves the content of the CSS
Reader rd = rsReaderHandler.getResource(null, requestedPath);
if (rd == null) {
throw new ResourceNotFoundException(requestedPath);
}
String content = IOUtils.toString(rd);
String requestPath = getRequestPath(request);
// Rewrite the generated binary resources
String result = CssDebugUrlRewriter.rewriteGeneratedBinaryResourceDebugUrl(requestPath, content,
binaryRsHandler.getConfig().getServletMapping());
Writer out = response.getWriter();
out.write(result);
}
|
java
|
private void handleGeneratedCssInDebugMode(String requestedPath, HttpServletRequest request,
HttpServletResponse response, BinaryResourcesHandler binaryRsHandler)
throws ResourceNotFoundException, IOException {
// Retrieves the content of the CSS
Reader rd = rsReaderHandler.getResource(null, requestedPath);
if (rd == null) {
throw new ResourceNotFoundException(requestedPath);
}
String content = IOUtils.toString(rd);
String requestPath = getRequestPath(request);
// Rewrite the generated binary resources
String result = CssDebugUrlRewriter.rewriteGeneratedBinaryResourceDebugUrl(requestPath, content,
binaryRsHandler.getConfig().getServletMapping());
Writer out = response.getWriter();
out.write(result);
}
|
[
"private",
"void",
"handleGeneratedCssInDebugMode",
"(",
"String",
"requestedPath",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"BinaryResourcesHandler",
"binaryRsHandler",
")",
"throws",
"ResourceNotFoundException",
",",
"IOException",
"{",
"// Retrieves the content of the CSS",
"Reader",
"rd",
"=",
"rsReaderHandler",
".",
"getResource",
"(",
"null",
",",
"requestedPath",
")",
";",
"if",
"(",
"rd",
"==",
"null",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"requestedPath",
")",
";",
"}",
"String",
"content",
"=",
"IOUtils",
".",
"toString",
"(",
"rd",
")",
";",
"String",
"requestPath",
"=",
"getRequestPath",
"(",
"request",
")",
";",
"// Rewrite the generated binary resources",
"String",
"result",
"=",
"CssDebugUrlRewriter",
".",
"rewriteGeneratedBinaryResourceDebugUrl",
"(",
"requestPath",
",",
"content",
",",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
".",
"getServletMapping",
"(",
")",
")",
";",
"Writer",
"out",
"=",
"response",
".",
"getWriter",
"(",
")",
";",
"out",
".",
"write",
"(",
"result",
")",
";",
"}"
] |
Handle the generated CSS content in debug mode.
@param requestedPath
the request path
@param request
the request
@param response
the response
@param binaryRsHandler
the image resource handler
@throws ResourceNotFoundException
if the resource is not found
@throws IOException
if an IO exception occurs
|
[
"Handle",
"the",
"generated",
"CSS",
"content",
"in",
"debug",
"mode",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L1042-L1060
|
7,144 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.getRequestPath
|
private String getRequestPath(HttpServletRequest request) {
String finalUrl = null;
String servletPath = request.getServletPath();
if ("".equals(jawrConfig.getServletMapping())) {
finalUrl = PathNormalizer.asPath(servletPath);
} else {
finalUrl = PathNormalizer.asPath(servletPath + request.getPathInfo());
}
return finalUrl;
}
|
java
|
private String getRequestPath(HttpServletRequest request) {
String finalUrl = null;
String servletPath = request.getServletPath();
if ("".equals(jawrConfig.getServletMapping())) {
finalUrl = PathNormalizer.asPath(servletPath);
} else {
finalUrl = PathNormalizer.asPath(servletPath + request.getPathInfo());
}
return finalUrl;
}
|
[
"private",
"String",
"getRequestPath",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"finalUrl",
"=",
"null",
";",
"String",
"servletPath",
"=",
"request",
".",
"getServletPath",
"(",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"jawrConfig",
".",
"getServletMapping",
"(",
")",
")",
")",
"{",
"finalUrl",
"=",
"PathNormalizer",
".",
"asPath",
"(",
"servletPath",
")",
";",
"}",
"else",
"{",
"finalUrl",
"=",
"PathNormalizer",
".",
"asPath",
"(",
"servletPath",
"+",
"request",
".",
"getPathInfo",
"(",
")",
")",
";",
"}",
"return",
"finalUrl",
";",
"}"
] |
Returns the request path
@param request
the request
@return the request path
|
[
"Returns",
"the",
"request",
"path"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L1107-L1117
|
7,145 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.setResponseHeaders
|
protected void setResponseHeaders(HttpServletResponse resp) {
// Force resource caching as best as possible
resp.setHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE);
resp.setHeader(LAST_MODIFIED_HEADER, LAST_MODIFIED_VALUE);
resp.setHeader(ETAG_HEADER, ETAG_VALUE);
Calendar cal = Calendar.getInstance();
cal.roll(Calendar.YEAR, 10);
resp.setDateHeader(EXPIRES_HEADER, cal.getTimeInMillis());
}
|
java
|
protected void setResponseHeaders(HttpServletResponse resp) {
// Force resource caching as best as possible
resp.setHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE);
resp.setHeader(LAST_MODIFIED_HEADER, LAST_MODIFIED_VALUE);
resp.setHeader(ETAG_HEADER, ETAG_VALUE);
Calendar cal = Calendar.getInstance();
cal.roll(Calendar.YEAR, 10);
resp.setDateHeader(EXPIRES_HEADER, cal.getTimeInMillis());
}
|
[
"protected",
"void",
"setResponseHeaders",
"(",
"HttpServletResponse",
"resp",
")",
"{",
"// Force resource caching as best as possible",
"resp",
".",
"setHeader",
"(",
"CACHE_CONTROL_HEADER",
",",
"CACHE_CONTROL_VALUE",
")",
";",
"resp",
".",
"setHeader",
"(",
"LAST_MODIFIED_HEADER",
",",
"LAST_MODIFIED_VALUE",
")",
";",
"resp",
".",
"setHeader",
"(",
"ETAG_HEADER",
",",
"ETAG_VALUE",
")",
";",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"roll",
"(",
"Calendar",
".",
"YEAR",
",",
"10",
")",
";",
"resp",
".",
"setDateHeader",
"(",
"EXPIRES_HEADER",
",",
"cal",
".",
"getTimeInMillis",
"(",
")",
")",
";",
"}"
] |
Adds aggressive caching headers to the response in order to prevent
browsers requesting the same file twice.
@param resp
the response
|
[
"Adds",
"aggressive",
"caching",
"headers",
"to",
"the",
"response",
"in",
"order",
"to",
"prevent",
"browsers",
"requesting",
"the",
"same",
"file",
"twice",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L1126-L1134
|
7,146 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.getDirtyBundleNames
|
public List<String> getDirtyBundleNames() {
List<String> bundleNames = new ArrayList<>();
if (bundlesHandler != null) {
bundleNames = bundlesHandler.getDirtyBundleNames();
}
return bundleNames;
}
|
java
|
public List<String> getDirtyBundleNames() {
List<String> bundleNames = new ArrayList<>();
if (bundlesHandler != null) {
bundleNames = bundlesHandler.getDirtyBundleNames();
}
return bundleNames;
}
|
[
"public",
"List",
"<",
"String",
">",
"getDirtyBundleNames",
"(",
")",
"{",
"List",
"<",
"String",
">",
"bundleNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"bundlesHandler",
"!=",
"null",
")",
"{",
"bundleNames",
"=",
"bundlesHandler",
".",
"getDirtyBundleNames",
"(",
")",
";",
"}",
"return",
"bundleNames",
";",
"}"
] |
Returns the names of the dirty bundles
@return the names of the dirty bundles
|
[
"Returns",
"the",
"names",
"of",
"the",
"dirty",
"bundles"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L1177-L1185
|
7,147 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java
|
JawrRequestHandler.rebuildDirtyBundles
|
@Override
public synchronized void rebuildDirtyBundles() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Rebuild dirty bundles");
}
StopWatch stopWatch = new StopWatch();
ThreadLocalJawrContext.setStopWatch(stopWatch);
// Initialize the Thread local for the Jawr context
ThreadLocalJawrContext.setJawrConfigMgrObjectName(JmxUtils.getMBeanObjectName(servletContext, resourceType,
jawrConfig.getProperty(JawrConstant.JAWR_JMX_MBEAN_PREFIX)));
try {
if (bundlesHandler != null) {
bundlesHandler.rebuildModifiedBundles();
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Jawr configuration successfully reloaded. ");
}
if (PERF_PROCESSING_LOGGER.isDebugEnabled()) {
PERF_PROCESSING_LOGGER.debug(stopWatch.prettyPrint());
}
} catch (InterruptBundlingProcessException e) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Bundling processed stopped");
}
} catch (Exception e) {
throw new BundlingProcessException("Error while rebuilding dirty bundles : " + e.getMessage(), e);
} finally {
// Reset the Thread local for the Jawr context
ThreadLocalJawrContext.reset();
}
}
|
java
|
@Override
public synchronized void rebuildDirtyBundles() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Rebuild dirty bundles");
}
StopWatch stopWatch = new StopWatch();
ThreadLocalJawrContext.setStopWatch(stopWatch);
// Initialize the Thread local for the Jawr context
ThreadLocalJawrContext.setJawrConfigMgrObjectName(JmxUtils.getMBeanObjectName(servletContext, resourceType,
jawrConfig.getProperty(JawrConstant.JAWR_JMX_MBEAN_PREFIX)));
try {
if (bundlesHandler != null) {
bundlesHandler.rebuildModifiedBundles();
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Jawr configuration successfully reloaded. ");
}
if (PERF_PROCESSING_LOGGER.isDebugEnabled()) {
PERF_PROCESSING_LOGGER.debug(stopWatch.prettyPrint());
}
} catch (InterruptBundlingProcessException e) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Bundling processed stopped");
}
} catch (Exception e) {
throw new BundlingProcessException("Error while rebuilding dirty bundles : " + e.getMessage(), e);
} finally {
// Reset the Thread local for the Jawr context
ThreadLocalJawrContext.reset();
}
}
|
[
"@",
"Override",
"public",
"synchronized",
"void",
"rebuildDirtyBundles",
"(",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Rebuild dirty bundles\"",
")",
";",
"}",
"StopWatch",
"stopWatch",
"=",
"new",
"StopWatch",
"(",
")",
";",
"ThreadLocalJawrContext",
".",
"setStopWatch",
"(",
"stopWatch",
")",
";",
"// Initialize the Thread local for the Jawr context",
"ThreadLocalJawrContext",
".",
"setJawrConfigMgrObjectName",
"(",
"JmxUtils",
".",
"getMBeanObjectName",
"(",
"servletContext",
",",
"resourceType",
",",
"jawrConfig",
".",
"getProperty",
"(",
"JawrConstant",
".",
"JAWR_JMX_MBEAN_PREFIX",
")",
")",
")",
";",
"try",
"{",
"if",
"(",
"bundlesHandler",
"!=",
"null",
")",
"{",
"bundlesHandler",
".",
"rebuildModifiedBundles",
"(",
")",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Jawr configuration successfully reloaded. \"",
")",
";",
"}",
"if",
"(",
"PERF_PROCESSING_LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"PERF_PROCESSING_LOGGER",
".",
"debug",
"(",
"stopWatch",
".",
"prettyPrint",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptBundlingProcessException",
"e",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Bundling processed stopped\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Error while rebuilding dirty bundles : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"// Reset the Thread local for the Jawr context",
"ThreadLocalJawrContext",
".",
"reset",
"(",
")",
";",
"}",
"}"
] |
Refresh the dirty bundles
|
[
"Refresh",
"the",
"dirty",
"bundles"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/JawrRequestHandler.java#L1190-L1228
|
7,148 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java
|
People.setPerson
|
public void setPerson(Person person) {
log.debug("Adding person: " + person);
if (person.getId() == -1) {
person.setId(getNextId());
}
people.remove(person);
people.add(person);
}
|
java
|
public void setPerson(Person person) {
log.debug("Adding person: " + person);
if (person.getId() == -1) {
person.setId(getNextId());
}
people.remove(person);
people.add(person);
}
|
[
"public",
"void",
"setPerson",
"(",
"Person",
"person",
")",
"{",
"log",
".",
"debug",
"(",
"\"Adding person: \"",
"+",
"person",
")",
";",
"if",
"(",
"person",
".",
"getId",
"(",
")",
"==",
"-",
"1",
")",
"{",
"person",
".",
"setId",
"(",
"getNextId",
"(",
")",
")",
";",
"}",
"people",
".",
"remove",
"(",
"person",
")",
";",
"people",
".",
"add",
"(",
"person",
")",
";",
"}"
] |
Insert a person into the set of people
@param person
The person to add or update
|
[
"Insert",
"a",
"person",
"into",
"the",
"set",
"of",
"people"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java#L55-L63
|
7,149 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java
|
People.deletePerson
|
public void deletePerson(Person person) {
log.debug("Removing person: " + person);
people.remove(person);
debug();
}
|
java
|
public void deletePerson(Person person) {
log.debug("Removing person: " + person);
people.remove(person);
debug();
}
|
[
"public",
"void",
"deletePerson",
"(",
"Person",
"person",
")",
"{",
"log",
".",
"debug",
"(",
"\"Removing person: \"",
"+",
"person",
")",
";",
"people",
".",
"remove",
"(",
"person",
")",
";",
"debug",
"(",
")",
";",
"}"
] |
Delete a person from the set of people
@param person
The person to delete
|
[
"Delete",
"a",
"person",
"from",
"the",
"set",
"of",
"people"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java#L71-L75
|
7,150 |
j-a-w-r/jawr-main-repo
|
jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java
|
People.getRandomPerson
|
private Person getRandomPerson() {
Person person = new Person();
person.setId(getNextId());
String firstname = FIRSTNAMES[random.nextInt(FIRSTNAMES.length)];
String surname = SURNAMES[random.nextInt(SURNAMES.length)];
person.setName(firstname + " " + surname);
String housenum = (random.nextInt(99) + 1) + " ";
String road1 = ROADS1[random.nextInt(ROADS1.length)];
String road2 = ROADS2[random.nextInt(ROADS2.length)];
String town = TOWNS[random.nextInt(TOWNS.length)];
String address = housenum + road1 + " " + road2 + ", " + town;
person.setAddress(address);
float salary = Math.round(10 + 90 * random.nextFloat()) * 1000;
person.setSalary(salary);
return person;
}
|
java
|
private Person getRandomPerson() {
Person person = new Person();
person.setId(getNextId());
String firstname = FIRSTNAMES[random.nextInt(FIRSTNAMES.length)];
String surname = SURNAMES[random.nextInt(SURNAMES.length)];
person.setName(firstname + " " + surname);
String housenum = (random.nextInt(99) + 1) + " ";
String road1 = ROADS1[random.nextInt(ROADS1.length)];
String road2 = ROADS2[random.nextInt(ROADS2.length)];
String town = TOWNS[random.nextInt(TOWNS.length)];
String address = housenum + road1 + " " + road2 + ", " + town;
person.setAddress(address);
float salary = Math.round(10 + 90 * random.nextFloat()) * 1000;
person.setSalary(salary);
return person;
}
|
[
"private",
"Person",
"getRandomPerson",
"(",
")",
"{",
"Person",
"person",
"=",
"new",
"Person",
"(",
")",
";",
"person",
".",
"setId",
"(",
"getNextId",
"(",
")",
")",
";",
"String",
"firstname",
"=",
"FIRSTNAMES",
"[",
"random",
".",
"nextInt",
"(",
"FIRSTNAMES",
".",
"length",
")",
"]",
";",
"String",
"surname",
"=",
"SURNAMES",
"[",
"random",
".",
"nextInt",
"(",
"SURNAMES",
".",
"length",
")",
"]",
";",
"person",
".",
"setName",
"(",
"firstname",
"+",
"\" \"",
"+",
"surname",
")",
";",
"String",
"housenum",
"=",
"(",
"random",
".",
"nextInt",
"(",
"99",
")",
"+",
"1",
")",
"+",
"\" \"",
";",
"String",
"road1",
"=",
"ROADS1",
"[",
"random",
".",
"nextInt",
"(",
"ROADS1",
".",
"length",
")",
"]",
";",
"String",
"road2",
"=",
"ROADS2",
"[",
"random",
".",
"nextInt",
"(",
"ROADS2",
".",
"length",
")",
"]",
";",
"String",
"town",
"=",
"TOWNS",
"[",
"random",
".",
"nextInt",
"(",
"TOWNS",
".",
"length",
")",
"]",
";",
"String",
"address",
"=",
"housenum",
"+",
"road1",
"+",
"\" \"",
"+",
"road2",
"+",
"\", \"",
"+",
"town",
";",
"person",
".",
"setAddress",
"(",
"address",
")",
";",
"float",
"salary",
"=",
"Math",
".",
"round",
"(",
"10",
"+",
"90",
"*",
"random",
".",
"nextFloat",
"(",
")",
")",
"*",
"1000",
";",
"person",
".",
"setSalary",
"(",
"salary",
")",
";",
"return",
"person",
";",
"}"
] |
Create a random person
@return a random person
|
[
"Create",
"a",
"random",
"person"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-webapp-sample/src/main/java/org/getahead/dwrdemo/people/People.java#L87-L106
|
7,151 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java
|
JawrSassResolver.getPath
|
public String getPath(String base, String uri) throws ResourceNotFoundException, IOException {
String fileName = uri;
if (!fileName.endsWith(".scss")) {
fileName += ".scss";
}
String parentPath = base.replace('\\', '/');
fileName = fileName.replace('\\', '/');
return PathNormalizer.concatWebPath(parentPath, fileName);
}
|
java
|
public String getPath(String base, String uri) throws ResourceNotFoundException, IOException {
String fileName = uri;
if (!fileName.endsWith(".scss")) {
fileName += ".scss";
}
String parentPath = base.replace('\\', '/');
fileName = fileName.replace('\\', '/');
return PathNormalizer.concatWebPath(parentPath, fileName);
}
|
[
"public",
"String",
"getPath",
"(",
"String",
"base",
",",
"String",
"uri",
")",
"throws",
"ResourceNotFoundException",
",",
"IOException",
"{",
"String",
"fileName",
"=",
"uri",
";",
"if",
"(",
"!",
"fileName",
".",
"endsWith",
"(",
"\".scss\"",
")",
")",
"{",
"fileName",
"+=",
"\".scss\"",
";",
"}",
"String",
"parentPath",
"=",
"base",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"fileName",
"=",
"fileName",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"return",
"PathNormalizer",
".",
"concatWebPath",
"(",
"parentPath",
",",
"fileName",
")",
";",
"}"
] |
Returns the path of the resource
@param base
the base path
@param uri
the relative URI
@return the resource path
@throws ResourceNotFoundException
if the resource is not found
@throws IOException
if an IOException occurs
|
[
"Returns",
"the",
"path",
"of",
"the",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java#L97-L108
|
7,152 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java
|
JawrSassResolver.findRelative
|
public String findRelative(String base, String uri) throws ResourceNotFoundException, IOException {
String path = getPath(base, uri);
String source = resolveAndNormalize(path);
if (source != null) {
return source;
}
// Try to find partial import (_identifier.scss)
path = PathNormalizer.getParentPath(path) + "_" + PathNormalizer.getPathName(path);
source = resolveAndNormalize(path);
if (source != null) {
return source;
}
return resolveAndNormalize(uri);
}
|
java
|
public String findRelative(String base, String uri) throws ResourceNotFoundException, IOException {
String path = getPath(base, uri);
String source = resolveAndNormalize(path);
if (source != null) {
return source;
}
// Try to find partial import (_identifier.scss)
path = PathNormalizer.getParentPath(path) + "_" + PathNormalizer.getPathName(path);
source = resolveAndNormalize(path);
if (source != null) {
return source;
}
return resolveAndNormalize(uri);
}
|
[
"public",
"String",
"findRelative",
"(",
"String",
"base",
",",
"String",
"uri",
")",
"throws",
"ResourceNotFoundException",
",",
"IOException",
"{",
"String",
"path",
"=",
"getPath",
"(",
"base",
",",
"uri",
")",
";",
"String",
"source",
"=",
"resolveAndNormalize",
"(",
"path",
")",
";",
"if",
"(",
"source",
"!=",
"null",
")",
"{",
"return",
"source",
";",
"}",
"// Try to find partial import (_identifier.scss)",
"path",
"=",
"PathNormalizer",
".",
"getParentPath",
"(",
"path",
")",
"+",
"\"_\"",
"+",
"PathNormalizer",
".",
"getPathName",
"(",
"path",
")",
";",
"source",
"=",
"resolveAndNormalize",
"(",
"path",
")",
";",
"if",
"(",
"source",
"!=",
"null",
")",
"{",
"return",
"source",
";",
"}",
"return",
"resolveAndNormalize",
"(",
"uri",
")",
";",
"}"
] |
Return the content of the resource using the base path and the relative
URI
@param base
the base path
@param uri
the relative URI
@return the content of the resource using the base path and the relative
URI
@throws ResourceNotFoundException
if the resource is not found
@throws IOException
if an IOException occurs
|
[
"Return",
"the",
"content",
"of",
"the",
"resource",
"using",
"the",
"base",
"path",
"and",
"the",
"relative",
"URI"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java#L125-L146
|
7,153 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java
|
JawrSassResolver.resolveAndNormalize
|
protected String resolveAndNormalize(String path) throws ResourceNotFoundException, IOException {
List<Class<?>> excluded = new ArrayList<>();
excluded.add(ISassResourceGenerator.class);
Reader rd = null;
try {
rd = rsHandler.getResource(bundle, path, false, excluded);
addLinkedResource(path);
} catch (ResourceNotFoundException e) {
// Do nothing
}
String content = null;
if (rd != null) {
content = IOUtils.toString(rd);
if (!useAbsoluteUrl) {
CssImageUrlRewriter rewriter = new CssImageUrlRewriter();
content = rewriter.rewriteUrl(path, this.scssPath, content).toString();
}
content = SassRubyUtils.normalizeMultiByteString(content);
}
return content;
}
|
java
|
protected String resolveAndNormalize(String path) throws ResourceNotFoundException, IOException {
List<Class<?>> excluded = new ArrayList<>();
excluded.add(ISassResourceGenerator.class);
Reader rd = null;
try {
rd = rsHandler.getResource(bundle, path, false, excluded);
addLinkedResource(path);
} catch (ResourceNotFoundException e) {
// Do nothing
}
String content = null;
if (rd != null) {
content = IOUtils.toString(rd);
if (!useAbsoluteUrl) {
CssImageUrlRewriter rewriter = new CssImageUrlRewriter();
content = rewriter.rewriteUrl(path, this.scssPath, content).toString();
}
content = SassRubyUtils.normalizeMultiByteString(content);
}
return content;
}
|
[
"protected",
"String",
"resolveAndNormalize",
"(",
"String",
"path",
")",
"throws",
"ResourceNotFoundException",
",",
"IOException",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"excluded",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"excluded",
".",
"add",
"(",
"ISassResourceGenerator",
".",
"class",
")",
";",
"Reader",
"rd",
"=",
"null",
";",
"try",
"{",
"rd",
"=",
"rsHandler",
".",
"getResource",
"(",
"bundle",
",",
"path",
",",
"false",
",",
"excluded",
")",
";",
"addLinkedResource",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"// Do nothing",
"}",
"String",
"content",
"=",
"null",
";",
"if",
"(",
"rd",
"!=",
"null",
")",
"{",
"content",
"=",
"IOUtils",
".",
"toString",
"(",
"rd",
")",
";",
"if",
"(",
"!",
"useAbsoluteUrl",
")",
"{",
"CssImageUrlRewriter",
"rewriter",
"=",
"new",
"CssImageUrlRewriter",
"(",
")",
";",
"content",
"=",
"rewriter",
".",
"rewriteUrl",
"(",
"path",
",",
"this",
".",
"scssPath",
",",
"content",
")",
".",
"toString",
"(",
")",
";",
"}",
"content",
"=",
"SassRubyUtils",
".",
"normalizeMultiByteString",
"(",
"content",
")",
";",
"}",
"return",
"content",
";",
"}"
] |
Finds and and normalized the content of the resource
@param path
the resource path
@return the normalized resource content
@throws ResourceNotFoundException
if the resource is not found
@throws IOException
if an IOException occurs
|
[
"Finds",
"and",
"and",
"normalized",
"the",
"content",
"of",
"the",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java#L159-L181
|
7,154 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java
|
JawrSassResolver.addLinkedResource
|
protected void addLinkedResource(String path) {
FilePathMapping linkedResource = getFilePathMapping(path);
if (linkedResource != null) {
addLinkedResource(linkedResource);
if (bundle != null) {
bundle.getLinkedFilePathMappings()
.add(new FilePathMapping(bundle, linkedResource.getPath(), linkedResource.getLastModified()));
}
}
}
|
java
|
protected void addLinkedResource(String path) {
FilePathMapping linkedResource = getFilePathMapping(path);
if (linkedResource != null) {
addLinkedResource(linkedResource);
if (bundle != null) {
bundle.getLinkedFilePathMappings()
.add(new FilePathMapping(bundle, linkedResource.getPath(), linkedResource.getLastModified()));
}
}
}
|
[
"protected",
"void",
"addLinkedResource",
"(",
"String",
"path",
")",
"{",
"FilePathMapping",
"linkedResource",
"=",
"getFilePathMapping",
"(",
"path",
")",
";",
"if",
"(",
"linkedResource",
"!=",
"null",
")",
"{",
"addLinkedResource",
"(",
"linkedResource",
")",
";",
"if",
"(",
"bundle",
"!=",
"null",
")",
"{",
"bundle",
".",
"getLinkedFilePathMappings",
"(",
")",
".",
"add",
"(",
"new",
"FilePathMapping",
"(",
"bundle",
",",
"linkedResource",
".",
"getPath",
"(",
")",
",",
"linkedResource",
".",
"getLastModified",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Adds a path to the linked resource
@param path
the resource path
|
[
"Adds",
"a",
"path",
"to",
"the",
"linked",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/sass/ruby/JawrSassResolver.java#L189-L198
|
7,155 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/postprocessor/AbstractPostProcessorChainFactory.java
|
AbstractPostProcessorChainFactory.addOrCreateChain
|
private AbstractChainedResourceBundlePostProcessor addOrCreateChain(
AbstractChainedResourceBundlePostProcessor chain, String key) {
AbstractChainedResourceBundlePostProcessor toAdd;
if (customPostProcessors.get(key) == null) {
toAdd = buildProcessorByKey(key);
if (toAdd instanceof BundlingProcessLifeCycleListener && !listeners.contains(toAdd)) {
listeners.add((BundlingProcessLifeCycleListener) toAdd);
}
} else {
toAdd = (AbstractChainedResourceBundlePostProcessor) customPostProcessors.get(key);
}
AbstractChainedResourceBundlePostProcessor newChainResult = null;
if (chain == null) {
newChainResult = toAdd;
} else {
chain.addNextProcessor(toAdd);
newChainResult = chain;
}
return newChainResult;
}
|
java
|
private AbstractChainedResourceBundlePostProcessor addOrCreateChain(
AbstractChainedResourceBundlePostProcessor chain, String key) {
AbstractChainedResourceBundlePostProcessor toAdd;
if (customPostProcessors.get(key) == null) {
toAdd = buildProcessorByKey(key);
if (toAdd instanceof BundlingProcessLifeCycleListener && !listeners.contains(toAdd)) {
listeners.add((BundlingProcessLifeCycleListener) toAdd);
}
} else {
toAdd = (AbstractChainedResourceBundlePostProcessor) customPostProcessors.get(key);
}
AbstractChainedResourceBundlePostProcessor newChainResult = null;
if (chain == null) {
newChainResult = toAdd;
} else {
chain.addNextProcessor(toAdd);
newChainResult = chain;
}
return newChainResult;
}
|
[
"private",
"AbstractChainedResourceBundlePostProcessor",
"addOrCreateChain",
"(",
"AbstractChainedResourceBundlePostProcessor",
"chain",
",",
"String",
"key",
")",
"{",
"AbstractChainedResourceBundlePostProcessor",
"toAdd",
";",
"if",
"(",
"customPostProcessors",
".",
"get",
"(",
"key",
")",
"==",
"null",
")",
"{",
"toAdd",
"=",
"buildProcessorByKey",
"(",
"key",
")",
";",
"if",
"(",
"toAdd",
"instanceof",
"BundlingProcessLifeCycleListener",
"&&",
"!",
"listeners",
".",
"contains",
"(",
"toAdd",
")",
")",
"{",
"listeners",
".",
"add",
"(",
"(",
"BundlingProcessLifeCycleListener",
")",
"toAdd",
")",
";",
"}",
"}",
"else",
"{",
"toAdd",
"=",
"(",
"AbstractChainedResourceBundlePostProcessor",
")",
"customPostProcessors",
".",
"get",
"(",
"key",
")",
";",
"}",
"AbstractChainedResourceBundlePostProcessor",
"newChainResult",
"=",
"null",
";",
"if",
"(",
"chain",
"==",
"null",
")",
"{",
"newChainResult",
"=",
"toAdd",
";",
"}",
"else",
"{",
"chain",
".",
"addNextProcessor",
"(",
"toAdd",
")",
";",
"newChainResult",
"=",
"chain",
";",
"}",
"return",
"newChainResult",
";",
"}"
] |
Creates an AbstractChainedResourceBundlePostProcessor. If the supplied
chain is null, the new chain is returned. Otherwise it is added to the
existing chain.
@param chain
the chained post processor
@param key
the id of the post processor
@return the chained post processor, with the new post processor.
|
[
"Creates",
"an",
"AbstractChainedResourceBundlePostProcessor",
".",
"If",
"the",
"supplied",
"chain",
"is",
"null",
"the",
"new",
"chain",
"is",
"returned",
".",
"Otherwise",
"it",
"is",
"added",
"to",
"the",
"existing",
"chain",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/postprocessor/AbstractPostProcessorChainFactory.java#L112-L135
|
7,156 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/postprocessor/AbstractPostProcessorChainFactory.java
|
AbstractPostProcessorChainFactory.getCustomProcessorWrapper
|
protected ChainedResourceBundlePostProcessor getCustomProcessorWrapper(ResourceBundlePostProcessor customProcessor,
String key, boolean isVariantPostProcessor) {
return new CustomPostProcessorChainWrapper(key, customProcessor, isVariantPostProcessor);
}
|
java
|
protected ChainedResourceBundlePostProcessor getCustomProcessorWrapper(ResourceBundlePostProcessor customProcessor,
String key, boolean isVariantPostProcessor) {
return new CustomPostProcessorChainWrapper(key, customProcessor, isVariantPostProcessor);
}
|
[
"protected",
"ChainedResourceBundlePostProcessor",
"getCustomProcessorWrapper",
"(",
"ResourceBundlePostProcessor",
"customProcessor",
",",
"String",
"key",
",",
"boolean",
"isVariantPostProcessor",
")",
"{",
"return",
"new",
"CustomPostProcessorChainWrapper",
"(",
"key",
",",
"customProcessor",
",",
"isVariantPostProcessor",
")",
";",
"}"
] |
Returns the custom processor wrapper
@param customProcessor
the custom processor
@param key
the id of the custom processor
@param isVariantPostProcessor
the flag indicating if it's a variant postprocessor
@return the custom processor wrapper
|
[
"Returns",
"the",
"custom",
"processor",
"wrapper"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/postprocessor/AbstractPostProcessorChainFactory.java#L191-L194
|
7,157 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java
|
JoinableResourceBundleImpl.setVariants
|
@Override
public void setVariants(Map<String, VariantSet> variantSets) {
if (variantSets != null) {
this.variants = new TreeMap<>(variantSets);
variantKeys = VariantUtils.getAllVariantKeys(this.variants);
}
}
|
java
|
@Override
public void setVariants(Map<String, VariantSet> variantSets) {
if (variantSets != null) {
this.variants = new TreeMap<>(variantSets);
variantKeys = VariantUtils.getAllVariantKeys(this.variants);
}
}
|
[
"@",
"Override",
"public",
"void",
"setVariants",
"(",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variantSets",
")",
"{",
"if",
"(",
"variantSets",
"!=",
"null",
")",
"{",
"this",
".",
"variants",
"=",
"new",
"TreeMap",
"<>",
"(",
"variantSets",
")",
";",
"variantKeys",
"=",
"VariantUtils",
".",
"getAllVariantKeys",
"(",
"this",
".",
"variants",
")",
";",
"}",
"}"
] |
Set the list of variants for variant resources
@param variantSets
|
[
"Set",
"the",
"list",
"of",
"variants",
"for",
"variant",
"resources"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java#L318-L325
|
7,158 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java
|
JoinableResourceBundleImpl.getItemPathList
|
private List<BundlePath> getItemPathList(List<BundlePath> itemList, Map<String, String> variants) {
if (variants == null || variants.isEmpty()) {
return itemList;
}
List<BundlePath> rets = new ArrayList<>();
for (BundlePath bundlePath : itemList) {
String path = bundlePath.getPath();
if (generatorRegistry.isPathGenerated(path)) {
Set<String> variantTypes = generatorRegistry.getGeneratedResourceVariantTypes(path);
String variantKey = VariantUtils.getVariantKey(variants, variantTypes);
if (StringUtils.isNotEmpty(variantKey)) {
rets.add(new BundlePath(bundlePath.getBundlePrefix(),
VariantUtils.getVariantBundleName(path, variantKey, true)));
} else {
rets.add(bundlePath);
}
} else {
rets.add(bundlePath);
}
}
return rets;
}
|
java
|
private List<BundlePath> getItemPathList(List<BundlePath> itemList, Map<String, String> variants) {
if (variants == null || variants.isEmpty()) {
return itemList;
}
List<BundlePath> rets = new ArrayList<>();
for (BundlePath bundlePath : itemList) {
String path = bundlePath.getPath();
if (generatorRegistry.isPathGenerated(path)) {
Set<String> variantTypes = generatorRegistry.getGeneratedResourceVariantTypes(path);
String variantKey = VariantUtils.getVariantKey(variants, variantTypes);
if (StringUtils.isNotEmpty(variantKey)) {
rets.add(new BundlePath(bundlePath.getBundlePrefix(),
VariantUtils.getVariantBundleName(path, variantKey, true)));
} else {
rets.add(bundlePath);
}
} else {
rets.add(bundlePath);
}
}
return rets;
}
|
[
"private",
"List",
"<",
"BundlePath",
">",
"getItemPathList",
"(",
"List",
"<",
"BundlePath",
">",
"itemList",
",",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
")",
"{",
"if",
"(",
"variants",
"==",
"null",
"||",
"variants",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"itemList",
";",
"}",
"List",
"<",
"BundlePath",
">",
"rets",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"BundlePath",
"bundlePath",
":",
"itemList",
")",
"{",
"String",
"path",
"=",
"bundlePath",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"generatorRegistry",
".",
"isPathGenerated",
"(",
"path",
")",
")",
"{",
"Set",
"<",
"String",
">",
"variantTypes",
"=",
"generatorRegistry",
".",
"getGeneratedResourceVariantTypes",
"(",
"path",
")",
";",
"String",
"variantKey",
"=",
"VariantUtils",
".",
"getVariantKey",
"(",
"variants",
",",
"variantTypes",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"variantKey",
")",
")",
"{",
"rets",
".",
"add",
"(",
"new",
"BundlePath",
"(",
"bundlePath",
".",
"getBundlePrefix",
"(",
")",
",",
"VariantUtils",
".",
"getVariantBundleName",
"(",
"path",
",",
"variantKey",
",",
"true",
")",
")",
")",
";",
"}",
"else",
"{",
"rets",
".",
"add",
"(",
"bundlePath",
")",
";",
"}",
"}",
"else",
"{",
"rets",
".",
"add",
"(",
"bundlePath",
")",
";",
"}",
"}",
"return",
"rets",
";",
"}"
] |
Filters the bundlePath list given in parameter using the specified
variants
@param itemList
the list of bundlePath
@param variants
the variants
@return the filtered list of bundlePath
|
[
"Filters",
"the",
"bundlePath",
"list",
"given",
"in",
"parameter",
"using",
"the",
"specified",
"variants"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java#L551-L574
|
7,159 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java
|
JoinableResourceBundleImpl.getAvailableVariant
|
private String getAvailableVariant(Map<String, String> curVariants) {
String variantKey = null;
if (variants != null) {
Map<String, String> availableVariants = generatorRegistry.getAvailableVariantMap(variants, curVariants);
variantKey = VariantUtils.getVariantKey(availableVariants);
}
return variantKey;
}
|
java
|
private String getAvailableVariant(Map<String, String> curVariants) {
String variantKey = null;
if (variants != null) {
Map<String, String> availableVariants = generatorRegistry.getAvailableVariantMap(variants, curVariants);
variantKey = VariantUtils.getVariantKey(availableVariants);
}
return variantKey;
}
|
[
"private",
"String",
"getAvailableVariant",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"curVariants",
")",
"{",
"String",
"variantKey",
"=",
"null",
";",
"if",
"(",
"variants",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"availableVariants",
"=",
"generatorRegistry",
".",
"getAvailableVariantMap",
"(",
"variants",
",",
"curVariants",
")",
";",
"variantKey",
"=",
"VariantUtils",
".",
"getVariantKey",
"(",
"availableVariants",
")",
";",
"}",
"return",
"variantKey",
";",
"}"
] |
Resolves a registered path from a variant key.
@param variantKey
the requested variant key
@return the variant key to use
|
[
"Resolves",
"a",
"registered",
"path",
"from",
"a",
"variant",
"key",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundleImpl.java#L683-L692
|
7,160 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/JsonPropertiesSource.java
|
JsonPropertiesSource.generateProperties
|
private void generateProperties(JsonNode node, String parentPrefix,
Properties props) {
Iterator<Entry<String, JsonNode>> fields = node.fields();
while (fields.hasNext()) {
Entry<String, JsonNode> entry = fields.next();
String fieldName = entry.getKey();
JsonNode jsonNode = entry.getValue();
String nodePrefix = parentPrefix == null ? fieldName : parentPrefix
+ FIELD_NAME_SEPARATOR + fieldName;
if (jsonNode.isTextual() || jsonNode.isBoolean()) {
props.put(nodePrefix, jsonNode.asText());
} else if (jsonNode.isNumber()) {
props.put(nodePrefix, Integer.toString(jsonNode.asInt()));
} else if (jsonNode.isArray()) {
String arrayValue = convertToString(jsonNode);
props.put(nodePrefix, arrayValue);
}
generateProperties(jsonNode, nodePrefix, props);
}
}
|
java
|
private void generateProperties(JsonNode node, String parentPrefix,
Properties props) {
Iterator<Entry<String, JsonNode>> fields = node.fields();
while (fields.hasNext()) {
Entry<String, JsonNode> entry = fields.next();
String fieldName = entry.getKey();
JsonNode jsonNode = entry.getValue();
String nodePrefix = parentPrefix == null ? fieldName : parentPrefix
+ FIELD_NAME_SEPARATOR + fieldName;
if (jsonNode.isTextual() || jsonNode.isBoolean()) {
props.put(nodePrefix, jsonNode.asText());
} else if (jsonNode.isNumber()) {
props.put(nodePrefix, Integer.toString(jsonNode.asInt()));
} else if (jsonNode.isArray()) {
String arrayValue = convertToString(jsonNode);
props.put(nodePrefix, arrayValue);
}
generateProperties(jsonNode, nodePrefix, props);
}
}
|
[
"private",
"void",
"generateProperties",
"(",
"JsonNode",
"node",
",",
"String",
"parentPrefix",
",",
"Properties",
"props",
")",
"{",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"JsonNode",
">",
">",
"fields",
"=",
"node",
".",
"fields",
"(",
")",
";",
"while",
"(",
"fields",
".",
"hasNext",
"(",
")",
")",
"{",
"Entry",
"<",
"String",
",",
"JsonNode",
">",
"entry",
"=",
"fields",
".",
"next",
"(",
")",
";",
"String",
"fieldName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"JsonNode",
"jsonNode",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"String",
"nodePrefix",
"=",
"parentPrefix",
"==",
"null",
"?",
"fieldName",
":",
"parentPrefix",
"+",
"FIELD_NAME_SEPARATOR",
"+",
"fieldName",
";",
"if",
"(",
"jsonNode",
".",
"isTextual",
"(",
")",
"||",
"jsonNode",
".",
"isBoolean",
"(",
")",
")",
"{",
"props",
".",
"put",
"(",
"nodePrefix",
",",
"jsonNode",
".",
"asText",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"jsonNode",
".",
"isNumber",
"(",
")",
")",
"{",
"props",
".",
"put",
"(",
"nodePrefix",
",",
"Integer",
".",
"toString",
"(",
"jsonNode",
".",
"asInt",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"jsonNode",
".",
"isArray",
"(",
")",
")",
"{",
"String",
"arrayValue",
"=",
"convertToString",
"(",
"jsonNode",
")",
";",
"props",
".",
"put",
"(",
"nodePrefix",
",",
"arrayValue",
")",
";",
"}",
"generateProperties",
"(",
"jsonNode",
",",
"nodePrefix",
",",
"props",
")",
";",
"}",
"}"
] |
Generates the properties from a JSON node
@param node
the JSON node
@param props
the properties to populate
|
[
"Generates",
"the",
"properties",
"from",
"a",
"JSON",
"node"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/JsonPropertiesSource.java#L77-L97
|
7,161 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/JsonPropertiesSource.java
|
JsonPropertiesSource.convertToString
|
private String convertToString(JsonNode jsonArrayNode) {
StringBuilder strBuilder = new StringBuilder();
Iterator<JsonNode> nodeIterator = jsonArrayNode.iterator();
while (nodeIterator.hasNext()) {
JsonNode jsonNode = (JsonNode) nodeIterator.next();
strBuilder.append(jsonNode.asText());
if (nodeIterator.hasNext()) {
strBuilder.append(ARRAY_VALUE_SEPARATOR);
}
}
return strBuilder.toString();
}
|
java
|
private String convertToString(JsonNode jsonArrayNode) {
StringBuilder strBuilder = new StringBuilder();
Iterator<JsonNode> nodeIterator = jsonArrayNode.iterator();
while (nodeIterator.hasNext()) {
JsonNode jsonNode = (JsonNode) nodeIterator.next();
strBuilder.append(jsonNode.asText());
if (nodeIterator.hasNext()) {
strBuilder.append(ARRAY_VALUE_SEPARATOR);
}
}
return strBuilder.toString();
}
|
[
"private",
"String",
"convertToString",
"(",
"JsonNode",
"jsonArrayNode",
")",
"{",
"StringBuilder",
"strBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Iterator",
"<",
"JsonNode",
">",
"nodeIterator",
"=",
"jsonArrayNode",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"nodeIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"JsonNode",
"jsonNode",
"=",
"(",
"JsonNode",
")",
"nodeIterator",
".",
"next",
"(",
")",
";",
"strBuilder",
".",
"append",
"(",
"jsonNode",
".",
"asText",
"(",
")",
")",
";",
"if",
"(",
"nodeIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"strBuilder",
".",
"append",
"(",
"ARRAY_VALUE_SEPARATOR",
")",
";",
"}",
"}",
"return",
"strBuilder",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts the json array node to a String
@param jsonArrayNode
the json array node to convert
@return a string corresponding to the json array node
|
[
"Converts",
"the",
"json",
"array",
"node",
"to",
"a",
"String"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/JsonPropertiesSource.java#L135-L147
|
7,162 |
j-a-w-r/jawr-main-repo
|
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/servlet/mock/MockServletRequest.java
|
MockServletRequest.setRequestPath
|
public void setRequestPath(String mapping, String path) {
this.requestPath = path;
int paramStartIdx = requestPath.indexOf("?");
if(StringUtils.isEmpty(mapping)){
if(paramStartIdx != -1){
this.servletPath = requestPath.substring(0, paramStartIdx);
}else{
this.servletPath = requestPath;
}
}else{
this.servletPath = PathNormalizer.asPath(mapping);
String pathInfo = removeServletMappingFromPath(path, mapping);
this.pathInfo = pathInfo;
}
// Sets the request URI
if(paramStartIdx == -1){
this.requestURI = requestPath;
}else{
this.requestURI = requestPath.substring(0, paramStartIdx);
}
initParameters();
}
|
java
|
public void setRequestPath(String mapping, String path) {
this.requestPath = path;
int paramStartIdx = requestPath.indexOf("?");
if(StringUtils.isEmpty(mapping)){
if(paramStartIdx != -1){
this.servletPath = requestPath.substring(0, paramStartIdx);
}else{
this.servletPath = requestPath;
}
}else{
this.servletPath = PathNormalizer.asPath(mapping);
String pathInfo = removeServletMappingFromPath(path, mapping);
this.pathInfo = pathInfo;
}
// Sets the request URI
if(paramStartIdx == -1){
this.requestURI = requestPath;
}else{
this.requestURI = requestPath.substring(0, paramStartIdx);
}
initParameters();
}
|
[
"public",
"void",
"setRequestPath",
"(",
"String",
"mapping",
",",
"String",
"path",
")",
"{",
"this",
".",
"requestPath",
"=",
"path",
";",
"int",
"paramStartIdx",
"=",
"requestPath",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"mapping",
")",
")",
"{",
"if",
"(",
"paramStartIdx",
"!=",
"-",
"1",
")",
"{",
"this",
".",
"servletPath",
"=",
"requestPath",
".",
"substring",
"(",
"0",
",",
"paramStartIdx",
")",
";",
"}",
"else",
"{",
"this",
".",
"servletPath",
"=",
"requestPath",
";",
"}",
"}",
"else",
"{",
"this",
".",
"servletPath",
"=",
"PathNormalizer",
".",
"asPath",
"(",
"mapping",
")",
";",
"String",
"pathInfo",
"=",
"removeServletMappingFromPath",
"(",
"path",
",",
"mapping",
")",
";",
"this",
".",
"pathInfo",
"=",
"pathInfo",
";",
"}",
"// Sets the request URI",
"if",
"(",
"paramStartIdx",
"==",
"-",
"1",
")",
"{",
"this",
".",
"requestURI",
"=",
"requestPath",
";",
"}",
"else",
"{",
"this",
".",
"requestURI",
"=",
"requestPath",
".",
"substring",
"(",
"0",
",",
"paramStartIdx",
")",
";",
"}",
"initParameters",
"(",
")",
";",
"}"
] |
Sets the requested path
@param path the requested path
|
[
"Sets",
"the",
"requested",
"path"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/servlet/mock/MockServletRequest.java#L82-L106
|
7,163 |
j-a-w-r/jawr-main-repo
|
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/servlet/mock/MockServletRequest.java
|
MockServletRequest.initParameters
|
private void initParameters() {
int idx = requestPath.indexOf("?");
if(idx != -1){
String strParams = null;
try {
strParams = URLDecoder.decode(requestPath.substring(idx+1), "UTF-8");
} catch (UnsupportedEncodingException neverHappens) {
/*URLEncoder:how not to use checked exceptions...*/
throw new RuntimeException("Something went unexpectedly wrong while decoding a URL for a generator. ",
neverHappens);
}
String[] params = strParams.split("&");
for (int i = 0; i < params.length; i++) {
String[] param = params[i].split("=");
parameters.put(param[0], param[1]);
}
}else{ // No parameters
parameters.clear();
}
}
|
java
|
private void initParameters() {
int idx = requestPath.indexOf("?");
if(idx != -1){
String strParams = null;
try {
strParams = URLDecoder.decode(requestPath.substring(idx+1), "UTF-8");
} catch (UnsupportedEncodingException neverHappens) {
/*URLEncoder:how not to use checked exceptions...*/
throw new RuntimeException("Something went unexpectedly wrong while decoding a URL for a generator. ",
neverHappens);
}
String[] params = strParams.split("&");
for (int i = 0; i < params.length; i++) {
String[] param = params[i].split("=");
parameters.put(param[0], param[1]);
}
}else{ // No parameters
parameters.clear();
}
}
|
[
"private",
"void",
"initParameters",
"(",
")",
"{",
"int",
"idx",
"=",
"requestPath",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"String",
"strParams",
"=",
"null",
";",
"try",
"{",
"strParams",
"=",
"URLDecoder",
".",
"decode",
"(",
"requestPath",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"neverHappens",
")",
"{",
"/*URLEncoder:how not to use checked exceptions...*/",
"throw",
"new",
"RuntimeException",
"(",
"\"Something went unexpectedly wrong while decoding a URL for a generator. \"",
",",
"neverHappens",
")",
";",
"}",
"String",
"[",
"]",
"params",
"=",
"strParams",
".",
"split",
"(",
"\"&\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"[",
"]",
"param",
"=",
"params",
"[",
"i",
"]",
".",
"split",
"(",
"\"=\"",
")",
";",
"parameters",
".",
"put",
"(",
"param",
"[",
"0",
"]",
",",
"param",
"[",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"// No parameters",
"parameters",
".",
"clear",
"(",
")",
";",
"}",
"}"
] |
Initialize the parameters from the request path
This is a naive implementation which serves only the purpose of bundle generation.
It don't even handle multiple parameters value...
|
[
"Initialize",
"the",
"parameters",
"from",
"the",
"request",
"path",
"This",
"is",
"a",
"naive",
"implementation",
"which",
"serves",
"only",
"the",
"purpose",
"of",
"bundle",
"generation",
".",
"It",
"don",
"t",
"even",
"handle",
"multiple",
"parameters",
"value",
"..."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/servlet/mock/MockServletRequest.java#L131-L153
|
7,164 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/css/base64/Base64PostProcessorCssImageUrlRewriter.java
|
Base64PostProcessorCssImageUrlRewriter.getBooleanValue
|
private boolean getBooleanValue(String strVal, boolean defaultValue) {
boolean result = defaultValue;
if (strVal != null) {
result = Boolean.parseBoolean(strVal);
}
return result;
}
|
java
|
private boolean getBooleanValue(String strVal, boolean defaultValue) {
boolean result = defaultValue;
if (strVal != null) {
result = Boolean.parseBoolean(strVal);
}
return result;
}
|
[
"private",
"boolean",
"getBooleanValue",
"(",
"String",
"strVal",
",",
"boolean",
"defaultValue",
")",
"{",
"boolean",
"result",
"=",
"defaultValue",
";",
"if",
"(",
"strVal",
"!=",
"null",
")",
"{",
"result",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"strVal",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns the boolean value of the string passed in parameter or the
default value if the string is null
@param strVal
the string value
@param defaultValue
the default value
@return the boolean value of the string passed in parameter or the
default value if the string is null
|
[
"Returns",
"the",
"boolean",
"value",
"of",
"the",
"string",
"passed",
"in",
"parameter",
"or",
"the",
"default",
"value",
"if",
"the",
"string",
"is",
"null"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/css/base64/Base64PostProcessorCssImageUrlRewriter.java#L147-L155
|
7,165 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMapping.java
|
BundlePathMapping.setPathMappings
|
public void setPathMappings(List<String> pathMappings) {
this.pathMappings.clear();
if (pathMappings != null) {
for (String mapping : pathMappings) {
this.pathMappings.add(new PathMapping(bundle, mapping));
}
}
}
|
java
|
public void setPathMappings(List<String> pathMappings) {
this.pathMappings.clear();
if (pathMappings != null) {
for (String mapping : pathMappings) {
this.pathMappings.add(new PathMapping(bundle, mapping));
}
}
}
|
[
"public",
"void",
"setPathMappings",
"(",
"List",
"<",
"String",
">",
"pathMappings",
")",
"{",
"this",
".",
"pathMappings",
".",
"clear",
"(",
")",
";",
"if",
"(",
"pathMappings",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"mapping",
":",
"pathMappings",
")",
"{",
"this",
".",
"pathMappings",
".",
"add",
"(",
"new",
"PathMapping",
"(",
"bundle",
",",
"mapping",
")",
")",
";",
"}",
"}",
"}"
] |
Sets the path mapping
@param pathMappings
the pathMappings to set
|
[
"Sets",
"the",
"path",
"mapping"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/BundlePathMapping.java#L99-L108
|
7,166 |
j-a-w-r/jawr-main-repo
|
jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java
|
JawrWicketLinkTagHandler.analyzeAutolinkCondition
|
protected boolean analyzeAutolinkCondition(final ComponentTag tag) {
if (tag.getId() == null) {
if (checkRef(tag)) {
return true;
}
}
return false;
}
|
java
|
protected boolean analyzeAutolinkCondition(final ComponentTag tag) {
if (tag.getId() == null) {
if (checkRef(tag)) {
return true;
}
}
return false;
}
|
[
"protected",
"boolean",
"analyzeAutolinkCondition",
"(",
"final",
"ComponentTag",
"tag",
")",
"{",
"if",
"(",
"tag",
".",
"getId",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"checkRef",
"(",
"tag",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Analyze the tag. If return value == true, a jawr component will be
created.
@param tag
The current tag being parsed
@return If true, tag will become auto-component
|
[
"Analyze",
"the",
"tag",
".",
"If",
"return",
"value",
"==",
"true",
"a",
"jawr",
"component",
"will",
"be",
"created",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java#L92-L100
|
7,167 |
j-a-w-r/jawr-main-repo
|
jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java
|
JawrWicketLinkTagHandler.checkRef
|
private final boolean checkRef(ComponentTag tag) {
boolean ok = false;
if (!tag.getName().equals("a")) {
IValueMap attributes = tag.getAttributes();
String ref = attributes.getString("href");
if (ref == null) {
ref = attributes.getString("src");
}
if ((ref != null)
&& (isJawrImageTag(tag) || (ref.indexOf(":") == -1))) {
ok = true;
}
}
return ok;
}
|
java
|
private final boolean checkRef(ComponentTag tag) {
boolean ok = false;
if (!tag.getName().equals("a")) {
IValueMap attributes = tag.getAttributes();
String ref = attributes.getString("href");
if (ref == null) {
ref = attributes.getString("src");
}
if ((ref != null)
&& (isJawrImageTag(tag) || (ref.indexOf(":") == -1))) {
ok = true;
}
}
return ok;
}
|
[
"private",
"final",
"boolean",
"checkRef",
"(",
"ComponentTag",
"tag",
")",
"{",
"boolean",
"ok",
"=",
"false",
";",
"if",
"(",
"!",
"tag",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"a\"",
")",
")",
"{",
"IValueMap",
"attributes",
"=",
"tag",
".",
"getAttributes",
"(",
")",
";",
"String",
"ref",
"=",
"attributes",
".",
"getString",
"(",
"\"href\"",
")",
";",
"if",
"(",
"ref",
"==",
"null",
")",
"{",
"ref",
"=",
"attributes",
".",
"getString",
"(",
"\"src\"",
")",
";",
"}",
"if",
"(",
"(",
"ref",
"!=",
"null",
")",
"&&",
"(",
"isJawrImageTag",
"(",
"tag",
")",
"||",
"(",
"ref",
".",
"indexOf",
"(",
"\":\"",
")",
"==",
"-",
"1",
")",
")",
")",
"{",
"ok",
"=",
"true",
";",
"}",
"}",
"return",
"ok",
";",
"}"
] |
Checks if if tag ref is a correct one or not
@param tag
the component tag
@return true if if tag ref is a correct one or not and that a component
should be created
|
[
"Checks",
"if",
"if",
"tag",
"ref",
"is",
"a",
"correct",
"one",
"or",
"not"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java#L110-L127
|
7,168 |
j-a-w-r/jawr-main-repo
|
jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java
|
JawrWicketLinkTagHandler.isJawrImageTag
|
private boolean isJawrImageTag(ComponentTag tag) {
String tagName = tag.getName();
return (tagName.equalsIgnoreCase("img") || (tagName
.equalsIgnoreCase("input") && tag.getAttribute("type").equals(
"image")));
}
|
java
|
private boolean isJawrImageTag(ComponentTag tag) {
String tagName = tag.getName();
return (tagName.equalsIgnoreCase("img") || (tagName
.equalsIgnoreCase("input") && tag.getAttribute("type").equals(
"image")));
}
|
[
"private",
"boolean",
"isJawrImageTag",
"(",
"ComponentTag",
"tag",
")",
"{",
"String",
"tagName",
"=",
"tag",
".",
"getName",
"(",
")",
";",
"return",
"(",
"tagName",
".",
"equalsIgnoreCase",
"(",
"\"img\"",
")",
"||",
"(",
"tagName",
".",
"equalsIgnoreCase",
"(",
"\"input\"",
")",
"&&",
"tag",
".",
"getAttribute",
"(",
"\"type\"",
")",
".",
"equals",
"(",
"\"image\"",
")",
")",
")",
";",
"}"
] |
Checks if it's a Jawr image tag or not
@param tag
the Component tag
@return true if it's a Jawr image tag or not
|
[
"Checks",
"if",
"it",
"s",
"a",
"Jawr",
"image",
"tag",
"or",
"not"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/JawrWicketLinkTagHandler.java#L136-L141
|
7,169 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropsFilePropertiesSource.java
|
PropsFilePropertiesSource.loadConfig
|
protected void loadConfig(Properties props, String path, InputStream is) {
// load properties into a Properties object
try {
props.load(is);
} catch (IOException e) {
throw new BundlingProcessException("Unable to load jawr configuration at " + path + ".", e);
}
}
|
java
|
protected void loadConfig(Properties props, String path, InputStream is) {
// load properties into a Properties object
try {
props.load(is);
} catch (IOException e) {
throw new BundlingProcessException("Unable to load jawr configuration at " + path + ".", e);
}
}
|
[
"protected",
"void",
"loadConfig",
"(",
"Properties",
"props",
",",
"String",
"path",
",",
"InputStream",
"is",
")",
"{",
"// load properties into a Properties object",
"try",
"{",
"props",
".",
"load",
"(",
"is",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unable to load jawr configuration at \"",
"+",
"path",
"+",
"\".\"",
",",
"e",
")",
";",
"}",
"}"
] |
Loads the configuration from the stream
@param props
the properties to update
@param path
The configuration path
@param is
the input stream
|
[
"Loads",
"the",
"configuration",
"from",
"the",
"stream"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropsFilePropertiesSource.java#L119-L126
|
7,170 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/BinaryResourcesHandler.java
|
BinaryResourcesHandler.getBundleHashcodeType
|
public BundleHashcodeType getBundleHashcodeType(String requestedPath) {
if (binaryResourcePathMap.containsValue(requestedPath)) {
return BundleHashcodeType.VALID_HASHCODE;
}
BundleHashcodeType bundleHashcodeType = BundleHashcodeType.UNKNOW_BUNDLE;
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(requestedPath);
String binaryRequest = resourceInfo[0];
if (resourceInfo[1] != null) { // an hashcode is defined in the path
try {
String cacheBustedPath = CheckSumUtils.getCacheBustedUrl(binaryRequest, getRsReaderHandler(),
jawrConfig);
addMapping(binaryRequest, cacheBustedPath);
if (requestedPath.equals(cacheBustedPath)) {
bundleHashcodeType = BundleHashcodeType.VALID_HASHCODE;
} else {
bundleHashcodeType = BundleHashcodeType.INVALID_HASHCODE;
}
} catch (IOException | ResourceNotFoundException e) {
// Nothing to do
}
}
return bundleHashcodeType;
}
|
java
|
public BundleHashcodeType getBundleHashcodeType(String requestedPath) {
if (binaryResourcePathMap.containsValue(requestedPath)) {
return BundleHashcodeType.VALID_HASHCODE;
}
BundleHashcodeType bundleHashcodeType = BundleHashcodeType.UNKNOW_BUNDLE;
String[] resourceInfo = PathNormalizer.extractBinaryResourceInfo(requestedPath);
String binaryRequest = resourceInfo[0];
if (resourceInfo[1] != null) { // an hashcode is defined in the path
try {
String cacheBustedPath = CheckSumUtils.getCacheBustedUrl(binaryRequest, getRsReaderHandler(),
jawrConfig);
addMapping(binaryRequest, cacheBustedPath);
if (requestedPath.equals(cacheBustedPath)) {
bundleHashcodeType = BundleHashcodeType.VALID_HASHCODE;
} else {
bundleHashcodeType = BundleHashcodeType.INVALID_HASHCODE;
}
} catch (IOException | ResourceNotFoundException e) {
// Nothing to do
}
}
return bundleHashcodeType;
}
|
[
"public",
"BundleHashcodeType",
"getBundleHashcodeType",
"(",
"String",
"requestedPath",
")",
"{",
"if",
"(",
"binaryResourcePathMap",
".",
"containsValue",
"(",
"requestedPath",
")",
")",
"{",
"return",
"BundleHashcodeType",
".",
"VALID_HASHCODE",
";",
"}",
"BundleHashcodeType",
"bundleHashcodeType",
"=",
"BundleHashcodeType",
".",
"UNKNOW_BUNDLE",
";",
"String",
"[",
"]",
"resourceInfo",
"=",
"PathNormalizer",
".",
"extractBinaryResourceInfo",
"(",
"requestedPath",
")",
";",
"String",
"binaryRequest",
"=",
"resourceInfo",
"[",
"0",
"]",
";",
"if",
"(",
"resourceInfo",
"[",
"1",
"]",
"!=",
"null",
")",
"{",
"// an hashcode is defined in the path",
"try",
"{",
"String",
"cacheBustedPath",
"=",
"CheckSumUtils",
".",
"getCacheBustedUrl",
"(",
"binaryRequest",
",",
"getRsReaderHandler",
"(",
")",
",",
"jawrConfig",
")",
";",
"addMapping",
"(",
"binaryRequest",
",",
"cacheBustedPath",
")",
";",
"if",
"(",
"requestedPath",
".",
"equals",
"(",
"cacheBustedPath",
")",
")",
"{",
"bundleHashcodeType",
"=",
"BundleHashcodeType",
".",
"VALID_HASHCODE",
";",
"}",
"else",
"{",
"bundleHashcodeType",
"=",
"BundleHashcodeType",
".",
"INVALID_HASHCODE",
";",
"}",
"}",
"catch",
"(",
"IOException",
"|",
"ResourceNotFoundException",
"e",
")",
"{",
"// Nothing to do",
"}",
"}",
"return",
"bundleHashcodeType",
";",
"}"
] |
Checks the bundle hashcode type of the requested binary resource
@param requestedPath
the requested path
@return true if the requested image is a valid one or not
|
[
"Checks",
"the",
"bundle",
"hashcode",
"type",
"of",
"the",
"requested",
"binary",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/BinaryResourcesHandler.java#L137-L163
|
7,171 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.getResourceAsStream
|
public static InputStream getResourceAsStream(String resourcePath, Object source) throws FileNotFoundException {
// Try the current classloader
InputStream is = source.getClass().getResourceAsStream(resourcePath);
// Weblogic 10 likes this one better..
if (null == is) {
ClassLoader cl = source.getClass().getClassLoader();
if (null != cl) {
is = cl.getResourceAsStream(resourcePath);
}
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == is) {
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
}
if (null == is) {
// Try to use the classloader of the current Jawr Config Manager
// MBean
// This will be used when a refresh is done in the configuration
// using the JMX MBean
MBeanServer mbs = JmxUtils.getMBeanServer();
if (mbs != null) {
ObjectName name = ThreadLocalJawrContext.getJawrConfigMgrObjectName();
if (name != null) {
try {
ClassLoader cl = mbs.getClassLoaderFor(name);
is = cl.getResourceAsStream(resourcePath);
} catch (Exception e) {
LOGGER.error("Unable to instanciate the Jawr MBean '" + name.getCanonicalName() + "'", e);
}
}
}
}
// Try to retrieve by URL
if (null == is) {
try {
URL url = getResourceURL(resourcePath, source);
is = new FileInputStream(new File(url.getFile()));
} catch (ResourceNotFoundException | IOException e) {
throw new FileNotFoundException(resourcePath + " could not be found. ");
}
}
return is;
}
|
java
|
public static InputStream getResourceAsStream(String resourcePath, Object source) throws FileNotFoundException {
// Try the current classloader
InputStream is = source.getClass().getResourceAsStream(resourcePath);
// Weblogic 10 likes this one better..
if (null == is) {
ClassLoader cl = source.getClass().getClassLoader();
if (null != cl) {
is = cl.getResourceAsStream(resourcePath);
}
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == is) {
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
}
if (null == is) {
// Try to use the classloader of the current Jawr Config Manager
// MBean
// This will be used when a refresh is done in the configuration
// using the JMX MBean
MBeanServer mbs = JmxUtils.getMBeanServer();
if (mbs != null) {
ObjectName name = ThreadLocalJawrContext.getJawrConfigMgrObjectName();
if (name != null) {
try {
ClassLoader cl = mbs.getClassLoaderFor(name);
is = cl.getResourceAsStream(resourcePath);
} catch (Exception e) {
LOGGER.error("Unable to instanciate the Jawr MBean '" + name.getCanonicalName() + "'", e);
}
}
}
}
// Try to retrieve by URL
if (null == is) {
try {
URL url = getResourceURL(resourcePath, source);
is = new FileInputStream(new File(url.getFile()));
} catch (ResourceNotFoundException | IOException e) {
throw new FileNotFoundException(resourcePath + " could not be found. ");
}
}
return is;
}
|
[
"public",
"static",
"InputStream",
"getResourceAsStream",
"(",
"String",
"resourcePath",
",",
"Object",
"source",
")",
"throws",
"FileNotFoundException",
"{",
"// Try the current classloader",
"InputStream",
"is",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"resourcePath",
")",
";",
"// Weblogic 10 likes this one better..",
"if",
"(",
"null",
"==",
"is",
")",
"{",
"ClassLoader",
"cl",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"cl",
")",
"{",
"is",
"=",
"cl",
".",
"getResourceAsStream",
"(",
"resourcePath",
")",
";",
"}",
"}",
"// If current classloader failed, try with the Threads context",
"// classloader. If that fails ott, the resource is either not on the",
"// classpath or inaccessible from the current context.",
"if",
"(",
"null",
"==",
"is",
")",
"{",
"is",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"resourcePath",
")",
";",
"}",
"if",
"(",
"null",
"==",
"is",
")",
"{",
"// Try to use the classloader of the current Jawr Config Manager",
"// MBean",
"// This will be used when a refresh is done in the configuration",
"// using the JMX MBean",
"MBeanServer",
"mbs",
"=",
"JmxUtils",
".",
"getMBeanServer",
"(",
")",
";",
"if",
"(",
"mbs",
"!=",
"null",
")",
"{",
"ObjectName",
"name",
"=",
"ThreadLocalJawrContext",
".",
"getJawrConfigMgrObjectName",
"(",
")",
";",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"try",
"{",
"ClassLoader",
"cl",
"=",
"mbs",
".",
"getClassLoaderFor",
"(",
"name",
")",
";",
"is",
"=",
"cl",
".",
"getResourceAsStream",
"(",
"resourcePath",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Unable to instanciate the Jawr MBean '\"",
"+",
"name",
".",
"getCanonicalName",
"(",
")",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"}",
"// Try to retrieve by URL",
"if",
"(",
"null",
"==",
"is",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"getResourceURL",
"(",
"resourcePath",
",",
"source",
")",
";",
"is",
"=",
"new",
"FileInputStream",
"(",
"new",
"File",
"(",
"url",
".",
"getFile",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"|",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"resourcePath",
"+",
"\" could not be found. \"",
")",
";",
"}",
"}",
"return",
"is",
";",
"}"
] |
Attempots to load a resource from the classpath, either usinf the
caller's class loader or the current thread's context classloader.
@param resourcePath
@param source
@return
@throws FileNotFoundException
|
[
"Attempots",
"to",
"load",
"a",
"resource",
"from",
"the",
"classpath",
"either",
"usinf",
"the",
"caller",
"s",
"class",
"loader",
"or",
"the",
"current",
"thread",
"s",
"context",
"classloader",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L55-L111
|
7,172 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.getResourceURL
|
public static URL getResourceURL(String resourcePath, Object source) throws ResourceNotFoundException {
// Try the current classloader
URL url = source.getClass().getResource(resourcePath);
// Weblogic 10 likes this one better..
if (null == url) {
ClassLoader cl = source.getClass().getClassLoader();
if (null != cl)
url = cl.getResource(resourcePath);
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == url) {
url = Thread.currentThread().getContextClassLoader().getResource(resourcePath);
// Last chance, hack in the classloader
if (null == url) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(source.getClass().getClassLoader());
if (Thread.currentThread().getContextClassLoader() != null) {
url = Thread.currentThread().getContextClassLoader().getResource(resourcePath);
}
} finally {
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
if (null == url) {
throw new ResourceNotFoundException(resourcePath + " could not be found. ");
}
}
return url;
}
|
java
|
public static URL getResourceURL(String resourcePath, Object source) throws ResourceNotFoundException {
// Try the current classloader
URL url = source.getClass().getResource(resourcePath);
// Weblogic 10 likes this one better..
if (null == url) {
ClassLoader cl = source.getClass().getClassLoader();
if (null != cl)
url = cl.getResource(resourcePath);
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == url) {
url = Thread.currentThread().getContextClassLoader().getResource(resourcePath);
// Last chance, hack in the classloader
if (null == url) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(source.getClass().getClassLoader());
if (Thread.currentThread().getContextClassLoader() != null) {
url = Thread.currentThread().getContextClassLoader().getResource(resourcePath);
}
} finally {
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
if (null == url) {
throw new ResourceNotFoundException(resourcePath + " could not be found. ");
}
}
return url;
}
|
[
"public",
"static",
"URL",
"getResourceURL",
"(",
"String",
"resourcePath",
",",
"Object",
"source",
")",
"throws",
"ResourceNotFoundException",
"{",
"// Try the current classloader",
"URL",
"url",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getResource",
"(",
"resourcePath",
")",
";",
"// Weblogic 10 likes this one better..",
"if",
"(",
"null",
"==",
"url",
")",
"{",
"ClassLoader",
"cl",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"cl",
")",
"url",
"=",
"cl",
".",
"getResource",
"(",
"resourcePath",
")",
";",
"}",
"// If current classloader failed, try with the Threads context",
"// classloader. If that fails ott, the resource is either not on the",
"// classpath or inaccessible from the current context.",
"if",
"(",
"null",
"==",
"url",
")",
"{",
"url",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"resourcePath",
")",
";",
"// Last chance, hack in the classloader",
"if",
"(",
"null",
"==",
"url",
")",
"{",
"ClassLoader",
"threadClassLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"try",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"source",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"if",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
"!=",
"null",
")",
"{",
"url",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"resourcePath",
")",
";",
"}",
"}",
"finally",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"threadClassLoader",
")",
";",
"}",
"}",
"if",
"(",
"null",
"==",
"url",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"resourcePath",
"+",
"\" could not be found. \"",
")",
";",
"}",
"}",
"return",
"url",
";",
"}"
] |
Attempts to find the URL of a resource from the classpath, either usinf
the caller's class loader or the current thread's context classloader.
@param resourcePath
the resource path
@param source
the object
@return the URL.
@throws ResourceNotFoundException
if the resource is not found
|
[
"Attempts",
"to",
"find",
"the",
"URL",
"of",
"a",
"resource",
"from",
"the",
"classpath",
"either",
"usinf",
"the",
"caller",
"s",
"class",
"loader",
"or",
"the",
"current",
"thread",
"s",
"context",
"classloader",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L125-L162
|
7,173 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.getResources
|
public static Enumeration<URL> getResources(String resourcePath, Object source) {
// Try the current classloader
Enumeration<URL> urls = null;
ClassLoader cl = source.getClass().getClassLoader();
try {
if (null != cl) {
urls = cl.getResources(resourcePath);
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == urls) {
urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
}
// Last chance, hack in the classloader
if (null == urls) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(source.getClass().getClassLoader());
if (Thread.currentThread().getContextClassLoader() != null) {
urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
}
} finally {
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
} catch (IOException e) {
LOGGER.warn("Unable to load " + resourcePath, e);
}
return urls;
}
|
java
|
public static Enumeration<URL> getResources(String resourcePath, Object source) {
// Try the current classloader
Enumeration<URL> urls = null;
ClassLoader cl = source.getClass().getClassLoader();
try {
if (null != cl) {
urls = cl.getResources(resourcePath);
}
// If current classloader failed, try with the Threads context
// classloader. If that fails ott, the resource is either not on the
// classpath or inaccessible from the current context.
if (null == urls) {
urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
}
// Last chance, hack in the classloader
if (null == urls) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(source.getClass().getClassLoader());
if (Thread.currentThread().getContextClassLoader() != null) {
urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
}
} finally {
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
} catch (IOException e) {
LOGGER.warn("Unable to load " + resourcePath, e);
}
return urls;
}
|
[
"public",
"static",
"Enumeration",
"<",
"URL",
">",
"getResources",
"(",
"String",
"resourcePath",
",",
"Object",
"source",
")",
"{",
"// Try the current classloader",
"Enumeration",
"<",
"URL",
">",
"urls",
"=",
"null",
";",
"ClassLoader",
"cl",
"=",
"source",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
";",
"try",
"{",
"if",
"(",
"null",
"!=",
"cl",
")",
"{",
"urls",
"=",
"cl",
".",
"getResources",
"(",
"resourcePath",
")",
";",
"}",
"// If current classloader failed, try with the Threads context",
"// classloader. If that fails ott, the resource is either not on the",
"// classpath or inaccessible from the current context.",
"if",
"(",
"null",
"==",
"urls",
")",
"{",
"urls",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResources",
"(",
"resourcePath",
")",
";",
"}",
"// Last chance, hack in the classloader",
"if",
"(",
"null",
"==",
"urls",
")",
"{",
"ClassLoader",
"threadClassLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"try",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"source",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"if",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
"!=",
"null",
")",
"{",
"urls",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResources",
"(",
"resourcePath",
")",
";",
"}",
"}",
"finally",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"threadClassLoader",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to load \"",
"+",
"resourcePath",
",",
"e",
")",
";",
"}",
"return",
"urls",
";",
"}"
] |
Attempts to find the URLs of a resource from the classpath, either using
the caller's class loader or the current thread's context classloader.
@param resourcePath
the resource path
@param source
the object
@return the URL or null if not found
|
[
"Attempts",
"to",
"find",
"the",
"URLs",
"of",
"a",
"resource",
"from",
"the",
"classpath",
"either",
"using",
"the",
"caller",
"s",
"class",
"loader",
"or",
"the",
"current",
"thread",
"s",
"context",
"classloader",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L174-L211
|
7,174 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.buildObjectInstance
|
public static Object buildObjectInstance(Class<?> clazz) {
Object rets = null;
try {
rets = clazz.newInstance();
} catch (Exception e) {
throw new BundlingProcessException(e.getMessage() + " [The custom class " + clazz.getName()
+ " could not be instantiated, check whether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ e.getClass().getName() + ":" + e.getMessage(), e);
}
return rets;
}
|
java
|
public static Object buildObjectInstance(Class<?> clazz) {
Object rets = null;
try {
rets = clazz.newInstance();
} catch (Exception e) {
throw new BundlingProcessException(e.getMessage() + " [The custom class " + clazz.getName()
+ " could not be instantiated, check whether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ e.getClass().getName() + ":" + e.getMessage(), e);
}
return rets;
}
|
[
"public",
"static",
"Object",
"buildObjectInstance",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Object",
"rets",
"=",
"null",
";",
"try",
"{",
"rets",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" [The custom class \"",
"+",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" could not be instantiated, check whether it is available on the classpath and\"",
"+",
"\" verify that it has a zero-arg constructor].\\n\"",
"+",
"\" The specific error message is: \"",
"+",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\":\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"rets",
";",
"}"
] |
Builds a class instance using reflection, by using its class. The class
must have a zero-arg constructor.
@param clazz
the class to build an instance of.
@return
|
[
"Builds",
"a",
"class",
"instance",
"using",
"reflection",
"by",
"using",
"its",
"class",
".",
"The",
"class",
"must",
"have",
"a",
"zero",
"-",
"arg",
"constructor",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L235-L246
|
7,175 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.isClassPresent
|
public static boolean isClassPresent(String classname) {
try {
Class.forName(classname);
return true;
} catch (ClassNotFoundException e) {
}
return false;
}
|
java
|
public static boolean isClassPresent(String classname) {
try {
Class.forName(classname);
return true;
} catch (ClassNotFoundException e) {
}
return false;
}
|
[
"public",
"static",
"boolean",
"isClassPresent",
"(",
"String",
"classname",
")",
"{",
"try",
"{",
"Class",
".",
"forName",
"(",
"classname",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"}",
"return",
"false",
";",
"}"
] |
Checks whether the class is present.
@param classname
the name of class to be checked
@return true if the class is present.
|
[
"Checks",
"whether",
"the",
"class",
"is",
"present",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L255-L263
|
7,176 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/context/JawrContext.java
|
JawrContext.reset
|
public void reset() {
this.jawrConfigMgrObjectName = null;
this.debugOverriden = false;
this.bundleProcessingAtBuildTime = false;
this.requestURL = null;
this.stopWatch = null;
this.interruptProcessingBundle.set(false);
}
|
java
|
public void reset() {
this.jawrConfigMgrObjectName = null;
this.debugOverriden = false;
this.bundleProcessingAtBuildTime = false;
this.requestURL = null;
this.stopWatch = null;
this.interruptProcessingBundle.set(false);
}
|
[
"public",
"void",
"reset",
"(",
")",
"{",
"this",
".",
"jawrConfigMgrObjectName",
"=",
"null",
";",
"this",
".",
"debugOverriden",
"=",
"false",
";",
"this",
".",
"bundleProcessingAtBuildTime",
"=",
"false",
";",
"this",
".",
"requestURL",
"=",
"null",
";",
"this",
".",
"stopWatch",
"=",
"null",
";",
"this",
".",
"interruptProcessingBundle",
".",
"set",
"(",
"false",
")",
";",
"}"
] |
Reset the context.
|
[
"Reset",
"the",
"context",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/context/JawrContext.java#L180-L188
|
7,177 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSImportPostProcessor.java
|
CSSImportPostProcessor.getCssPathContent
|
private String getCssPathContent(String cssPathToImport, String media, BundleProcessingStatus status)
throws IOException {
String currentCssPath = status.getLastPathAdded();
String path = cssPathToImport;
JawrConfig jawrConfig = status.getJawrConfig();
if (jawrConfig.getGeneratorRegistry().isPathGenerated(path)) {
ResourceGenerator generator = jawrConfig.getGeneratorRegistry().getResourceGenerator(path);
if (generator != null && generator.getResolver() instanceof SuffixedPathResolver) {
path = PathNormalizer.concatWebPath(currentCssPath, cssPathToImport);
}
} else if (!cssPathToImport.startsWith("/")) { // relative URL
path = PathNormalizer.concatWebPath(currentCssPath, cssPathToImport);
}
FilePathMappingUtils.buildFilePathMapping(status.getCurrentBundle(), path, status.getRsReader());
Reader reader = null;
try {
reader = status.getRsReader().getResource(status.getCurrentBundle(), path, true);
} catch (ResourceNotFoundException e) {
throw new IOException("Css to import '" + path + "' was not found", e);
}
StringWriter content = new StringWriter();
IOUtils.copy(reader, content, true);
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) jawrConfig.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
jawrConfig = binaryRsHandler.getConfig();
}
// Rewrite image URL
CssImportedUrlRewriter urlRewriter = new CssImportedUrlRewriter(jawrConfig);
StringBuilder result = new StringBuilder();
boolean isMediaAttributeSet = StringUtils.isNotEmpty(media);
if (isMediaAttributeSet) {
result.append("@media ").append(media).append(" {\n");
}
result.append(urlRewriter.rewriteUrl(path, currentCssPath, content.getBuffer().toString()));
if (isMediaAttributeSet) {
result.append("\n}\n");
}
return result.toString();
}
|
java
|
private String getCssPathContent(String cssPathToImport, String media, BundleProcessingStatus status)
throws IOException {
String currentCssPath = status.getLastPathAdded();
String path = cssPathToImport;
JawrConfig jawrConfig = status.getJawrConfig();
if (jawrConfig.getGeneratorRegistry().isPathGenerated(path)) {
ResourceGenerator generator = jawrConfig.getGeneratorRegistry().getResourceGenerator(path);
if (generator != null && generator.getResolver() instanceof SuffixedPathResolver) {
path = PathNormalizer.concatWebPath(currentCssPath, cssPathToImport);
}
} else if (!cssPathToImport.startsWith("/")) { // relative URL
path = PathNormalizer.concatWebPath(currentCssPath, cssPathToImport);
}
FilePathMappingUtils.buildFilePathMapping(status.getCurrentBundle(), path, status.getRsReader());
Reader reader = null;
try {
reader = status.getRsReader().getResource(status.getCurrentBundle(), path, true);
} catch (ResourceNotFoundException e) {
throw new IOException("Css to import '" + path + "' was not found", e);
}
StringWriter content = new StringWriter();
IOUtils.copy(reader, content, true);
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) jawrConfig.getContext()
.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler != null) {
jawrConfig = binaryRsHandler.getConfig();
}
// Rewrite image URL
CssImportedUrlRewriter urlRewriter = new CssImportedUrlRewriter(jawrConfig);
StringBuilder result = new StringBuilder();
boolean isMediaAttributeSet = StringUtils.isNotEmpty(media);
if (isMediaAttributeSet) {
result.append("@media ").append(media).append(" {\n");
}
result.append(urlRewriter.rewriteUrl(path, currentCssPath, content.getBuffer().toString()));
if (isMediaAttributeSet) {
result.append("\n}\n");
}
return result.toString();
}
|
[
"private",
"String",
"getCssPathContent",
"(",
"String",
"cssPathToImport",
",",
"String",
"media",
",",
"BundleProcessingStatus",
"status",
")",
"throws",
"IOException",
"{",
"String",
"currentCssPath",
"=",
"status",
".",
"getLastPathAdded",
"(",
")",
";",
"String",
"path",
"=",
"cssPathToImport",
";",
"JawrConfig",
"jawrConfig",
"=",
"status",
".",
"getJawrConfig",
"(",
")",
";",
"if",
"(",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isPathGenerated",
"(",
"path",
")",
")",
"{",
"ResourceGenerator",
"generator",
"=",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
".",
"getResourceGenerator",
"(",
"path",
")",
";",
"if",
"(",
"generator",
"!=",
"null",
"&&",
"generator",
".",
"getResolver",
"(",
")",
"instanceof",
"SuffixedPathResolver",
")",
"{",
"path",
"=",
"PathNormalizer",
".",
"concatWebPath",
"(",
"currentCssPath",
",",
"cssPathToImport",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"cssPathToImport",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"// relative URL",
"path",
"=",
"PathNormalizer",
".",
"concatWebPath",
"(",
"currentCssPath",
",",
"cssPathToImport",
")",
";",
"}",
"FilePathMappingUtils",
".",
"buildFilePathMapping",
"(",
"status",
".",
"getCurrentBundle",
"(",
")",
",",
"path",
",",
"status",
".",
"getRsReader",
"(",
")",
")",
";",
"Reader",
"reader",
"=",
"null",
";",
"try",
"{",
"reader",
"=",
"status",
".",
"getRsReader",
"(",
")",
".",
"getResource",
"(",
"status",
".",
"getCurrentBundle",
"(",
")",
",",
"path",
",",
"true",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Css to import '\"",
"+",
"path",
"+",
"\"' was not found\"",
",",
"e",
")",
";",
"}",
"StringWriter",
"content",
"=",
"new",
"StringWriter",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"reader",
",",
"content",
",",
"true",
")",
";",
"BinaryResourcesHandler",
"binaryRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"jawrConfig",
".",
"getContext",
"(",
")",
".",
"getAttribute",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"binaryRsHandler",
"!=",
"null",
")",
"{",
"jawrConfig",
"=",
"binaryRsHandler",
".",
"getConfig",
"(",
")",
";",
"}",
"// Rewrite image URL",
"CssImportedUrlRewriter",
"urlRewriter",
"=",
"new",
"CssImportedUrlRewriter",
"(",
"jawrConfig",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"isMediaAttributeSet",
"=",
"StringUtils",
".",
"isNotEmpty",
"(",
"media",
")",
";",
"if",
"(",
"isMediaAttributeSet",
")",
"{",
"result",
".",
"append",
"(",
"\"@media \"",
")",
".",
"append",
"(",
"media",
")",
".",
"append",
"(",
"\" {\\n\"",
")",
";",
"}",
"result",
".",
"append",
"(",
"urlRewriter",
".",
"rewriteUrl",
"(",
"path",
",",
"currentCssPath",
",",
"content",
".",
"getBuffer",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"if",
"(",
"isMediaAttributeSet",
")",
"{",
"result",
".",
"append",
"(",
"\"\\n}\\n\"",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Retrieve the content of the css to import
@param cssPathToImport
the path of the css to import
@param media
the media
@param status
the bundle processing status
@return the content of the css to import
@throws IOException
if an IOException occurs
|
[
"Retrieve",
"the",
"content",
"of",
"the",
"css",
"to",
"import"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSImportPostProcessor.java#L108-L156
|
7,178 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java
|
MessageBundleScriptCreator.createScript
|
public Reader createScript(Charset charset) {
String[] names = configParam.split("\\|");
Properties props = new Properties();
Locale currentLocale = getLocaleToApply();
for (int x = 0; x < names.length; x++) {
ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle(names[x], currentLocale, control);
} catch (MissingResourceException ex) {
// Fixes problems with some servers, e.g. WLS 10
try {
bundle = ResourceBundle.getBundle(names[x], currentLocale, getClass().getClassLoader(), control);
} catch (Exception e) {
bundle = ResourceBundle.getBundle(names[x], currentLocale,
Thread.currentThread().getContextClassLoader(), control);
}
}
updateProperties(bundle, props, charset);
}
return doCreateScript(props);
}
|
java
|
public Reader createScript(Charset charset) {
String[] names = configParam.split("\\|");
Properties props = new Properties();
Locale currentLocale = getLocaleToApply();
for (int x = 0; x < names.length; x++) {
ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle(names[x], currentLocale, control);
} catch (MissingResourceException ex) {
// Fixes problems with some servers, e.g. WLS 10
try {
bundle = ResourceBundle.getBundle(names[x], currentLocale, getClass().getClassLoader(), control);
} catch (Exception e) {
bundle = ResourceBundle.getBundle(names[x], currentLocale,
Thread.currentThread().getContextClassLoader(), control);
}
}
updateProperties(bundle, props, charset);
}
return doCreateScript(props);
}
|
[
"public",
"Reader",
"createScript",
"(",
"Charset",
"charset",
")",
"{",
"String",
"[",
"]",
"names",
"=",
"configParam",
".",
"split",
"(",
"\"\\\\|\"",
")",
";",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"Locale",
"currentLocale",
"=",
"getLocaleToApply",
"(",
")",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"names",
".",
"length",
";",
"x",
"++",
")",
"{",
"ResourceBundle",
"bundle",
";",
"try",
"{",
"bundle",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"names",
"[",
"x",
"]",
",",
"currentLocale",
",",
"control",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"ex",
")",
"{",
"// Fixes problems with some servers, e.g. WLS 10",
"try",
"{",
"bundle",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"names",
"[",
"x",
"]",
",",
"currentLocale",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
",",
"control",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"bundle",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"names",
"[",
"x",
"]",
",",
"currentLocale",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
",",
"control",
")",
";",
"}",
"}",
"updateProperties",
"(",
"bundle",
",",
"props",
",",
"charset",
")",
";",
"}",
"return",
"doCreateScript",
"(",
"props",
")",
";",
"}"
] |
Create the message resource bundles specified and uses a
BundleStringJsonifier to generate the properties.
@param charset
the charset
@return the script
|
[
"Create",
"the",
"message",
"resource",
"bundles",
"specified",
"and",
"uses",
"a",
"BundleStringJsonifier",
"to",
"generate",
"the",
"properties",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java#L164-L190
|
7,179 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java
|
MessageBundleScriptCreator.getLocaleToApply
|
protected Locale getLocaleToApply() {
Locale currentLocale = locale;
if (currentLocale == null) {
currentLocale = control.getFallbackLocale();
}
return currentLocale;
}
|
java
|
protected Locale getLocaleToApply() {
Locale currentLocale = locale;
if (currentLocale == null) {
currentLocale = control.getFallbackLocale();
}
return currentLocale;
}
|
[
"protected",
"Locale",
"getLocaleToApply",
"(",
")",
"{",
"Locale",
"currentLocale",
"=",
"locale",
";",
"if",
"(",
"currentLocale",
"==",
"null",
")",
"{",
"currentLocale",
"=",
"control",
".",
"getFallbackLocale",
"(",
")",
";",
"}",
"return",
"currentLocale",
";",
"}"
] |
Returns the locale to use to retrieve the ResourceBundle
@return the locale to use to retrieve the ResourceBundle
|
[
"Returns",
"the",
"locale",
"to",
"use",
"to",
"retrieve",
"the",
"ResourceBundle"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java#L197-L204
|
7,180 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java
|
MessageBundleScriptCreator.doCreateScript
|
protected Reader doCreateScript(Properties props) {
BundleStringJsonifier bsj = new BundleStringJsonifier(props, addQuoteToMessageKey);
String script = template.toString();
String messages = bsj.serializeBundles().toString();
script = script.replaceFirst("@namespace", RegexUtil.adaptReplacementToMatcher(namespace));
script = script.replaceFirst("@messages", RegexUtil.adaptReplacementToMatcher(messages));
return new StringReader(script);
}
|
java
|
protected Reader doCreateScript(Properties props) {
BundleStringJsonifier bsj = new BundleStringJsonifier(props, addQuoteToMessageKey);
String script = template.toString();
String messages = bsj.serializeBundles().toString();
script = script.replaceFirst("@namespace", RegexUtil.adaptReplacementToMatcher(namespace));
script = script.replaceFirst("@messages", RegexUtil.adaptReplacementToMatcher(messages));
return new StringReader(script);
}
|
[
"protected",
"Reader",
"doCreateScript",
"(",
"Properties",
"props",
")",
"{",
"BundleStringJsonifier",
"bsj",
"=",
"new",
"BundleStringJsonifier",
"(",
"props",
",",
"addQuoteToMessageKey",
")",
";",
"String",
"script",
"=",
"template",
".",
"toString",
"(",
")",
";",
"String",
"messages",
"=",
"bsj",
".",
"serializeBundles",
"(",
")",
".",
"toString",
"(",
")",
";",
"script",
"=",
"script",
".",
"replaceFirst",
"(",
"\"@namespace\"",
",",
"RegexUtil",
".",
"adaptReplacementToMatcher",
"(",
"namespace",
")",
")",
";",
"script",
"=",
"script",
".",
"replaceFirst",
"(",
"\"@messages\"",
",",
"RegexUtil",
".",
"adaptReplacementToMatcher",
"(",
"messages",
")",
")",
";",
"return",
"new",
"StringReader",
"(",
"script",
")",
";",
"}"
] |
Returns the JS script from the message properties
@param props
the message properties
@return the JS script from the message properties
|
[
"Returns",
"the",
"JS",
"script",
"from",
"the",
"message",
"properties"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/message/MessageBundleScriptCreator.java#L255-L263
|
7,181 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java
|
ResourceBundleMessagesGenerator.addLinkedResources
|
protected void addLinkedResources(String path, GeneratorContext context) {
List<Locale> locales = new ArrayList<>();
Locale currentLocale = context.getLocale();
if (currentLocale != null) {
locales.add(currentLocale);
if (StringUtils.isNotEmpty(currentLocale.getVariant())) {
locales.add(new Locale(currentLocale.getCountry(), currentLocale.getLanguage()));
}
if (StringUtils.isNotEmpty(currentLocale.getLanguage())) {
locales.add(new Locale(currentLocale.getCountry()));
}
}
// Adds fallback locale
locales.add(control.getFallbackLocale());
Locale baseLocale = new Locale("", "");
if (!locales.contains(baseLocale)) {
locales.add(baseLocale);
}
List<FilePathMapping> fMappings = getFileMappings(path, context, locales);
addLinkedResources(path, context, fMappings);
}
|
java
|
protected void addLinkedResources(String path, GeneratorContext context) {
List<Locale> locales = new ArrayList<>();
Locale currentLocale = context.getLocale();
if (currentLocale != null) {
locales.add(currentLocale);
if (StringUtils.isNotEmpty(currentLocale.getVariant())) {
locales.add(new Locale(currentLocale.getCountry(), currentLocale.getLanguage()));
}
if (StringUtils.isNotEmpty(currentLocale.getLanguage())) {
locales.add(new Locale(currentLocale.getCountry()));
}
}
// Adds fallback locale
locales.add(control.getFallbackLocale());
Locale baseLocale = new Locale("", "");
if (!locales.contains(baseLocale)) {
locales.add(baseLocale);
}
List<FilePathMapping> fMappings = getFileMappings(path, context, locales);
addLinkedResources(path, context, fMappings);
}
|
[
"protected",
"void",
"addLinkedResources",
"(",
"String",
"path",
",",
"GeneratorContext",
"context",
")",
"{",
"List",
"<",
"Locale",
">",
"locales",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Locale",
"currentLocale",
"=",
"context",
".",
"getLocale",
"(",
")",
";",
"if",
"(",
"currentLocale",
"!=",
"null",
")",
"{",
"locales",
".",
"add",
"(",
"currentLocale",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentLocale",
".",
"getVariant",
"(",
")",
")",
")",
"{",
"locales",
".",
"add",
"(",
"new",
"Locale",
"(",
"currentLocale",
".",
"getCountry",
"(",
")",
",",
"currentLocale",
".",
"getLanguage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentLocale",
".",
"getLanguage",
"(",
")",
")",
")",
"{",
"locales",
".",
"add",
"(",
"new",
"Locale",
"(",
"currentLocale",
".",
"getCountry",
"(",
")",
")",
")",
";",
"}",
"}",
"// Adds fallback locale",
"locales",
".",
"add",
"(",
"control",
".",
"getFallbackLocale",
"(",
")",
")",
";",
"Locale",
"baseLocale",
"=",
"new",
"Locale",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"if",
"(",
"!",
"locales",
".",
"contains",
"(",
"baseLocale",
")",
")",
"{",
"locales",
".",
"add",
"(",
"baseLocale",
")",
";",
"}",
"List",
"<",
"FilePathMapping",
">",
"fMappings",
"=",
"getFileMappings",
"(",
"path",
",",
"context",
",",
"locales",
")",
";",
"addLinkedResources",
"(",
"path",
",",
"context",
",",
"fMappings",
")",
";",
"}"
] |
Adds the linked resources
@param path
the resource path
@param context
the generator context
|
[
"Adds",
"the",
"linked",
"resources"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java#L172-L195
|
7,182 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java
|
ResourceBundleMessagesGenerator.getFileMappings
|
protected List<FilePathMapping> getFileMappings(String path, GeneratorContext context, List<Locale> locales) {
List<FilePathMapping> fMappings = new ArrayList<>();
String fileSuffix = PROPERTIES_FILE_SUFFIX;
String[] names = path.split(RESOURCE_BUNDLE_SEPARATOR);
for (String resourcePath : names) {
resourcePath = resourcePath.replace('.', JawrConstant.URL_SEPARATOR_CHAR);
for (Locale locale : locales) {
String resourceBundlePath = control.toBundleName(resourcePath, locale) + fileSuffix;
URL rbURL = LocaleUtils.getResourceBundleURL(resourceBundlePath, context.getServletContext());
if (rbURL != null) {
File f = FileUtils.urlToFile(rbURL);
String fileName = f.getAbsolutePath();
if (StringUtils.isNotEmpty(fileName)) {
long lastModified = rsHandler.getLastModified(fileName);
FilePathMapping fMapping = new FilePathMapping(fileName, lastModified);
fMappings.add(fMapping);
}
}
}
}
return fMappings;
}
|
java
|
protected List<FilePathMapping> getFileMappings(String path, GeneratorContext context, List<Locale> locales) {
List<FilePathMapping> fMappings = new ArrayList<>();
String fileSuffix = PROPERTIES_FILE_SUFFIX;
String[] names = path.split(RESOURCE_BUNDLE_SEPARATOR);
for (String resourcePath : names) {
resourcePath = resourcePath.replace('.', JawrConstant.URL_SEPARATOR_CHAR);
for (Locale locale : locales) {
String resourceBundlePath = control.toBundleName(resourcePath, locale) + fileSuffix;
URL rbURL = LocaleUtils.getResourceBundleURL(resourceBundlePath, context.getServletContext());
if (rbURL != null) {
File f = FileUtils.urlToFile(rbURL);
String fileName = f.getAbsolutePath();
if (StringUtils.isNotEmpty(fileName)) {
long lastModified = rsHandler.getLastModified(fileName);
FilePathMapping fMapping = new FilePathMapping(fileName, lastModified);
fMappings.add(fMapping);
}
}
}
}
return fMappings;
}
|
[
"protected",
"List",
"<",
"FilePathMapping",
">",
"getFileMappings",
"(",
"String",
"path",
",",
"GeneratorContext",
"context",
",",
"List",
"<",
"Locale",
">",
"locales",
")",
"{",
"List",
"<",
"FilePathMapping",
">",
"fMappings",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"fileSuffix",
"=",
"PROPERTIES_FILE_SUFFIX",
";",
"String",
"[",
"]",
"names",
"=",
"path",
".",
"split",
"(",
"RESOURCE_BUNDLE_SEPARATOR",
")",
";",
"for",
"(",
"String",
"resourcePath",
":",
"names",
")",
"{",
"resourcePath",
"=",
"resourcePath",
".",
"replace",
"(",
"'",
"'",
",",
"JawrConstant",
".",
"URL_SEPARATOR_CHAR",
")",
";",
"for",
"(",
"Locale",
"locale",
":",
"locales",
")",
"{",
"String",
"resourceBundlePath",
"=",
"control",
".",
"toBundleName",
"(",
"resourcePath",
",",
"locale",
")",
"+",
"fileSuffix",
";",
"URL",
"rbURL",
"=",
"LocaleUtils",
".",
"getResourceBundleURL",
"(",
"resourceBundlePath",
",",
"context",
".",
"getServletContext",
"(",
")",
")",
";",
"if",
"(",
"rbURL",
"!=",
"null",
")",
"{",
"File",
"f",
"=",
"FileUtils",
".",
"urlToFile",
"(",
"rbURL",
")",
";",
"String",
"fileName",
"=",
"f",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"fileName",
")",
")",
"{",
"long",
"lastModified",
"=",
"rsHandler",
".",
"getLastModified",
"(",
"fileName",
")",
";",
"FilePathMapping",
"fMapping",
"=",
"new",
"FilePathMapping",
"(",
"fileName",
",",
"lastModified",
")",
";",
"fMappings",
".",
"add",
"(",
"fMapping",
")",
";",
"}",
"}",
"}",
"}",
"return",
"fMappings",
";",
"}"
] |
Returns the list of file path mapping associate to the resource bundles
locales
@param path
the resource path
@param context
the generator context
@param locales
the list of locales
@return the list of file path mapping associate to the resource bundles
locales
|
[
"Returns",
"the",
"list",
"of",
"file",
"path",
"mapping",
"associate",
"to",
"the",
"resource",
"bundles",
"locales"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java#L210-L237
|
7,183 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java
|
ResourceBundleMessagesGenerator.findAvailableLocales
|
protected List<String> findAvailableLocales(String resource) {
List<String> availableLocales = cachedAvailableLocalePerResource.get(resource);
if (availableLocales == null) {
availableLocales = LocaleUtils.getAvailableLocaleSuffixesForBundle(resource);
cachedAvailableLocalePerResource.put(resource, availableLocales);
}
return availableLocales;
}
|
java
|
protected List<String> findAvailableLocales(String resource) {
List<String> availableLocales = cachedAvailableLocalePerResource.get(resource);
if (availableLocales == null) {
availableLocales = LocaleUtils.getAvailableLocaleSuffixesForBundle(resource);
cachedAvailableLocalePerResource.put(resource, availableLocales);
}
return availableLocales;
}
|
[
"protected",
"List",
"<",
"String",
">",
"findAvailableLocales",
"(",
"String",
"resource",
")",
"{",
"List",
"<",
"String",
">",
"availableLocales",
"=",
"cachedAvailableLocalePerResource",
".",
"get",
"(",
"resource",
")",
";",
"if",
"(",
"availableLocales",
"==",
"null",
")",
"{",
"availableLocales",
"=",
"LocaleUtils",
".",
"getAvailableLocaleSuffixesForBundle",
"(",
"resource",
")",
";",
"cachedAvailableLocalePerResource",
".",
"put",
"(",
"resource",
",",
"availableLocales",
")",
";",
"}",
"return",
"availableLocales",
";",
"}"
] |
Finds the available locales
@param resource
the resource
@return the available locales for the resource
|
[
"Finds",
"the",
"available",
"locales"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java#L318-L326
|
7,184 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesResourceReader.java
|
CssSmartSpritesResourceReader.getCssPath
|
protected String getCssPath(String resourceName) {
String path = resourceName;
if (jawrConfig.getGeneratorRegistry().isPathGenerated(path)) {
path = path.replace(':', '/');
path = JawrConstant.SPRITE_GENERATED_CSS_DIR + path;
}
return path;
}
|
java
|
protected String getCssPath(String resourceName) {
String path = resourceName;
if (jawrConfig.getGeneratorRegistry().isPathGenerated(path)) {
path = path.replace(':', '/');
path = JawrConstant.SPRITE_GENERATED_CSS_DIR + path;
}
return path;
}
|
[
"protected",
"String",
"getCssPath",
"(",
"String",
"resourceName",
")",
"{",
"String",
"path",
"=",
"resourceName",
";",
"if",
"(",
"jawrConfig",
".",
"getGeneratorRegistry",
"(",
")",
".",
"isPathGenerated",
"(",
"path",
")",
")",
"{",
"path",
"=",
"path",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"path",
"=",
"JawrConstant",
".",
"SPRITE_GENERATED_CSS_DIR",
"+",
"path",
";",
"}",
"return",
"path",
";",
"}"
] |
Returns the Css path from the resource name
@param resourceName
the resource name
@return the Css path
|
[
"Returns",
"the",
"Css",
"path",
"from",
"the",
"resource",
"name"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/global/preprocessor/css/smartsprites/CssSmartSpritesResourceReader.java#L115-L122
|
7,185 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.loadCommonGenerator
|
private ResourceGenerator loadCommonGenerator(String resourcePath) {
ResourceGenerator generator = null;
for (Entry<ResourceGeneratorResolver, Class<?>> entry : commonGenerators.entrySet()) {
ResourceGeneratorResolver resolver = entry.getKey();
if (resolver.matchPath(resourcePath)) {
generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(entry.getValue());
if (!generator.getResolver().isSameAs(resolver)) {
throw new BundlingProcessException("The resolver defined for " + generator.getClass().getName()
+ " is different from the one expected by Jawr.");
}
if (resolver.getType().equals(ResolverType.PREFIXED)) {
loadGeneratorIfNeeded(resolver.getResourcePath(resourcePath));
}
}
}
if (generator != null) {
initGenerator(generator);
}
return generator;
}
|
java
|
private ResourceGenerator loadCommonGenerator(String resourcePath) {
ResourceGenerator generator = null;
for (Entry<ResourceGeneratorResolver, Class<?>> entry : commonGenerators.entrySet()) {
ResourceGeneratorResolver resolver = entry.getKey();
if (resolver.matchPath(resourcePath)) {
generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(entry.getValue());
if (!generator.getResolver().isSameAs(resolver)) {
throw new BundlingProcessException("The resolver defined for " + generator.getClass().getName()
+ " is different from the one expected by Jawr.");
}
if (resolver.getType().equals(ResolverType.PREFIXED)) {
loadGeneratorIfNeeded(resolver.getResourcePath(resourcePath));
}
}
}
if (generator != null) {
initGenerator(generator);
}
return generator;
}
|
[
"private",
"ResourceGenerator",
"loadCommonGenerator",
"(",
"String",
"resourcePath",
")",
"{",
"ResourceGenerator",
"generator",
"=",
"null",
";",
"for",
"(",
"Entry",
"<",
"ResourceGeneratorResolver",
",",
"Class",
"<",
"?",
">",
">",
"entry",
":",
"commonGenerators",
".",
"entrySet",
"(",
")",
")",
"{",
"ResourceGeneratorResolver",
"resolver",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"resolver",
".",
"matchPath",
"(",
"resourcePath",
")",
")",
"{",
"generator",
"=",
"(",
"ResourceGenerator",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"!",
"generator",
".",
"getResolver",
"(",
")",
".",
"isSameAs",
"(",
"resolver",
")",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"The resolver defined for \"",
"+",
"generator",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" is different from the one expected by Jawr.\"",
")",
";",
"}",
"if",
"(",
"resolver",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"ResolverType",
".",
"PREFIXED",
")",
")",
"{",
"loadGeneratorIfNeeded",
"(",
"resolver",
".",
"getResourcePath",
"(",
"resourcePath",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"generator",
"!=",
"null",
")",
"{",
"initGenerator",
"(",
"generator",
")",
";",
"}",
"return",
"generator",
";",
"}"
] |
Lazy loads generators, to avoid the need for undesired dependencies.
@param generatorKey
the generator key
@return the resource generator
|
[
"Lazy",
"loads",
"generators",
"to",
"avoid",
"the",
"need",
"for",
"undesired",
"dependencies",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L286-L310
|
7,186 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.initGenerator
|
private void initGenerator(ResourceGenerator generator) {
initializeGeneratorProperties(generator);
updateRegistries(generator);
ResourceReader proxy = ResourceGeneratorReaderProxyFactory.getResourceReaderProxy(generator, rsHandler, config);
rsHandler.addResourceReader(proxy);
}
|
java
|
private void initGenerator(ResourceGenerator generator) {
initializeGeneratorProperties(generator);
updateRegistries(generator);
ResourceReader proxy = ResourceGeneratorReaderProxyFactory.getResourceReaderProxy(generator, rsHandler, config);
rsHandler.addResourceReader(proxy);
}
|
[
"private",
"void",
"initGenerator",
"(",
"ResourceGenerator",
"generator",
")",
"{",
"initializeGeneratorProperties",
"(",
"generator",
")",
";",
"updateRegistries",
"(",
"generator",
")",
";",
"ResourceReader",
"proxy",
"=",
"ResourceGeneratorReaderProxyFactory",
".",
"getResourceReaderProxy",
"(",
"generator",
",",
"rsHandler",
",",
"config",
")",
";",
"rsHandler",
".",
"addResourceReader",
"(",
"proxy",
")",
";",
"}"
] |
Initialize the generator
@param generator
the generator to initialize
|
[
"Initialize",
"the",
"generator"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L318-L324
|
7,187 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.updateRegistries
|
private void updateRegistries(ResourceGenerator generator) {
resolverRegistry.add(new ResourceGeneratorResolverWrapper(generator, generator.getResolver()));
GeneratorComparator genComparator = new GeneratorComparator();
Collections.sort(resolverRegistry);
if (generator instanceof StreamResourceGenerator) {
binaryResourceGeneratorRegistry.add(generator);
Collections.sort(binaryResourceGeneratorRegistry, genComparator);
}
if (generator instanceof CssResourceGenerator) {
if (((CssResourceGenerator) generator).isHandlingCssImage()) {
cssImageResourceGeneratorRegistry.add(generator);
Collections.sort(cssImageResourceGeneratorRegistry, genComparator);
}
}
if (generator instanceof BundlingProcessLifeCycleListener) {
bundlingProcesslifeCycleListeners.add((BundlingProcessLifeCycleListener) generator);
}
}
|
java
|
private void updateRegistries(ResourceGenerator generator) {
resolverRegistry.add(new ResourceGeneratorResolverWrapper(generator, generator.getResolver()));
GeneratorComparator genComparator = new GeneratorComparator();
Collections.sort(resolverRegistry);
if (generator instanceof StreamResourceGenerator) {
binaryResourceGeneratorRegistry.add(generator);
Collections.sort(binaryResourceGeneratorRegistry, genComparator);
}
if (generator instanceof CssResourceGenerator) {
if (((CssResourceGenerator) generator).isHandlingCssImage()) {
cssImageResourceGeneratorRegistry.add(generator);
Collections.sort(cssImageResourceGeneratorRegistry, genComparator);
}
}
if (generator instanceof BundlingProcessLifeCycleListener) {
bundlingProcesslifeCycleListeners.add((BundlingProcessLifeCycleListener) generator);
}
}
|
[
"private",
"void",
"updateRegistries",
"(",
"ResourceGenerator",
"generator",
")",
"{",
"resolverRegistry",
".",
"add",
"(",
"new",
"ResourceGeneratorResolverWrapper",
"(",
"generator",
",",
"generator",
".",
"getResolver",
"(",
")",
")",
")",
";",
"GeneratorComparator",
"genComparator",
"=",
"new",
"GeneratorComparator",
"(",
")",
";",
"Collections",
".",
"sort",
"(",
"resolverRegistry",
")",
";",
"if",
"(",
"generator",
"instanceof",
"StreamResourceGenerator",
")",
"{",
"binaryResourceGeneratorRegistry",
".",
"add",
"(",
"generator",
")",
";",
"Collections",
".",
"sort",
"(",
"binaryResourceGeneratorRegistry",
",",
"genComparator",
")",
";",
"}",
"if",
"(",
"generator",
"instanceof",
"CssResourceGenerator",
")",
"{",
"if",
"(",
"(",
"(",
"CssResourceGenerator",
")",
"generator",
")",
".",
"isHandlingCssImage",
"(",
")",
")",
"{",
"cssImageResourceGeneratorRegistry",
".",
"add",
"(",
"generator",
")",
";",
"Collections",
".",
"sort",
"(",
"cssImageResourceGeneratorRegistry",
",",
"genComparator",
")",
";",
"}",
"}",
"if",
"(",
"generator",
"instanceof",
"BundlingProcessLifeCycleListener",
")",
"{",
"bundlingProcesslifeCycleListeners",
".",
"add",
"(",
"(",
"BundlingProcessLifeCycleListener",
")",
"generator",
")",
";",
"}",
"}"
] |
Update the registries with the generator given in parameter
@param generator
the generator
|
[
"Update",
"the",
"registries",
"with",
"the",
"generator",
"given",
"in",
"parameter"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L332-L350
|
7,188 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.registerGenerator
|
public void registerGenerator(String clazz) {
ResourceGenerator generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(clazz);
if (null == generator.getResolver()) {
throw new IllegalStateException("The getResolver() method must return something at " + clazz);
}
ResourceGeneratorResolver resolver = generator.getResolver();
// Checks if another generator is already define with the same resolver
for (ResourceGeneratorResolver resourceGeneratorResolver : resolverRegistry) {
if (resourceGeneratorResolver.isSameAs(resolver)) {
String generatorName = generator.getClass().getName();
if (!clazz.equals(generatorName)) {
String errorMsg = "Cannot register the generator of class " + generator.getClass().getName()
+ " since the same resolver is being used by " + generatorName
+ ". Please specify a different resolver in the getResolver() method.";
throw new IllegalStateException(errorMsg);
}
}
}
// Warns the user about if the generator override a built-in generator
Set<ResourceGeneratorResolver> commonResolvers = commonGenerators.keySet();
for (ResourceGeneratorResolver commonGeneratorResolver : commonResolvers) {
if (commonGeneratorResolver.isSameAs(resolver)) {
String generatorName = generator.getClass().getName();
LOGGER.warn("The custom generator '" + generatorName + "' override a built-in generator");
}
}
initGenerator(generator);
}
|
java
|
public void registerGenerator(String clazz) {
ResourceGenerator generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(clazz);
if (null == generator.getResolver()) {
throw new IllegalStateException("The getResolver() method must return something at " + clazz);
}
ResourceGeneratorResolver resolver = generator.getResolver();
// Checks if another generator is already define with the same resolver
for (ResourceGeneratorResolver resourceGeneratorResolver : resolverRegistry) {
if (resourceGeneratorResolver.isSameAs(resolver)) {
String generatorName = generator.getClass().getName();
if (!clazz.equals(generatorName)) {
String errorMsg = "Cannot register the generator of class " + generator.getClass().getName()
+ " since the same resolver is being used by " + generatorName
+ ". Please specify a different resolver in the getResolver() method.";
throw new IllegalStateException(errorMsg);
}
}
}
// Warns the user about if the generator override a built-in generator
Set<ResourceGeneratorResolver> commonResolvers = commonGenerators.keySet();
for (ResourceGeneratorResolver commonGeneratorResolver : commonResolvers) {
if (commonGeneratorResolver.isSameAs(resolver)) {
String generatorName = generator.getClass().getName();
LOGGER.warn("The custom generator '" + generatorName + "' override a built-in generator");
}
}
initGenerator(generator);
}
|
[
"public",
"void",
"registerGenerator",
"(",
"String",
"clazz",
")",
"{",
"ResourceGenerator",
"generator",
"=",
"(",
"ResourceGenerator",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"clazz",
")",
";",
"if",
"(",
"null",
"==",
"generator",
".",
"getResolver",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The getResolver() method must return something at \"",
"+",
"clazz",
")",
";",
"}",
"ResourceGeneratorResolver",
"resolver",
"=",
"generator",
".",
"getResolver",
"(",
")",
";",
"// Checks if another generator is already define with the same resolver",
"for",
"(",
"ResourceGeneratorResolver",
"resourceGeneratorResolver",
":",
"resolverRegistry",
")",
"{",
"if",
"(",
"resourceGeneratorResolver",
".",
"isSameAs",
"(",
"resolver",
")",
")",
"{",
"String",
"generatorName",
"=",
"generator",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"clazz",
".",
"equals",
"(",
"generatorName",
")",
")",
"{",
"String",
"errorMsg",
"=",
"\"Cannot register the generator of class \"",
"+",
"generator",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" since the same resolver is being used by \"",
"+",
"generatorName",
"+",
"\". Please specify a different resolver in the getResolver() method.\"",
";",
"throw",
"new",
"IllegalStateException",
"(",
"errorMsg",
")",
";",
"}",
"}",
"}",
"// Warns the user about if the generator override a built-in generator",
"Set",
"<",
"ResourceGeneratorResolver",
">",
"commonResolvers",
"=",
"commonGenerators",
".",
"keySet",
"(",
")",
";",
"for",
"(",
"ResourceGeneratorResolver",
"commonGeneratorResolver",
":",
"commonResolvers",
")",
"{",
"if",
"(",
"commonGeneratorResolver",
".",
"isSameAs",
"(",
"resolver",
")",
")",
"{",
"String",
"generatorName",
"=",
"generator",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"LOGGER",
".",
"warn",
"(",
"\"The custom generator '\"",
"+",
"generatorName",
"+",
"\"' override a built-in generator\"",
")",
";",
"}",
"}",
"initGenerator",
"(",
"generator",
")",
";",
"}"
] |
Register a generator mapping it to the specified prefix.
@param clazz
the classname of the generator
|
[
"Register",
"a",
"generator",
"mapping",
"it",
"to",
"the",
"specified",
"prefix",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L404-L437
|
7,189 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.initializeGeneratorProperties
|
private void initializeGeneratorProperties(ResourceGenerator generator) {
// Initialize the generator
if (generator instanceof InitializingResourceGenerator) {
if (generator instanceof ConfigurationAwareResourceGenerator) {
((ConfigurationAwareResourceGenerator) generator).setConfig(config);
}
if (generator instanceof TypeAwareResourceGenerator) {
((TypeAwareResourceGenerator) generator).setResourceType(resourceType);
}
if (generator instanceof ResourceReaderHandlerAwareResourceGenerator) {
((ResourceReaderHandlerAwareResourceGenerator) generator).setResourceReaderHandler(rsHandler);
}
if (generator instanceof WorkingDirectoryLocationAware) {
((WorkingDirectoryLocationAware) generator).setWorkingDirectory(rsHandler.getWorkingDirectory());
}
if (generator instanceof PostInitializationAwareResourceGenerator) {
((PostInitializationAwareResourceGenerator) generator).afterPropertiesSet();
}
}
}
|
java
|
private void initializeGeneratorProperties(ResourceGenerator generator) {
// Initialize the generator
if (generator instanceof InitializingResourceGenerator) {
if (generator instanceof ConfigurationAwareResourceGenerator) {
((ConfigurationAwareResourceGenerator) generator).setConfig(config);
}
if (generator instanceof TypeAwareResourceGenerator) {
((TypeAwareResourceGenerator) generator).setResourceType(resourceType);
}
if (generator instanceof ResourceReaderHandlerAwareResourceGenerator) {
((ResourceReaderHandlerAwareResourceGenerator) generator).setResourceReaderHandler(rsHandler);
}
if (generator instanceof WorkingDirectoryLocationAware) {
((WorkingDirectoryLocationAware) generator).setWorkingDirectory(rsHandler.getWorkingDirectory());
}
if (generator instanceof PostInitializationAwareResourceGenerator) {
((PostInitializationAwareResourceGenerator) generator).afterPropertiesSet();
}
}
}
|
[
"private",
"void",
"initializeGeneratorProperties",
"(",
"ResourceGenerator",
"generator",
")",
"{",
"// Initialize the generator",
"if",
"(",
"generator",
"instanceof",
"InitializingResourceGenerator",
")",
"{",
"if",
"(",
"generator",
"instanceof",
"ConfigurationAwareResourceGenerator",
")",
"{",
"(",
"(",
"ConfigurationAwareResourceGenerator",
")",
"generator",
")",
".",
"setConfig",
"(",
"config",
")",
";",
"}",
"if",
"(",
"generator",
"instanceof",
"TypeAwareResourceGenerator",
")",
"{",
"(",
"(",
"TypeAwareResourceGenerator",
")",
"generator",
")",
".",
"setResourceType",
"(",
"resourceType",
")",
";",
"}",
"if",
"(",
"generator",
"instanceof",
"ResourceReaderHandlerAwareResourceGenerator",
")",
"{",
"(",
"(",
"ResourceReaderHandlerAwareResourceGenerator",
")",
"generator",
")",
".",
"setResourceReaderHandler",
"(",
"rsHandler",
")",
";",
"}",
"if",
"(",
"generator",
"instanceof",
"WorkingDirectoryLocationAware",
")",
"{",
"(",
"(",
"WorkingDirectoryLocationAware",
")",
"generator",
")",
".",
"setWorkingDirectory",
"(",
"rsHandler",
".",
"getWorkingDirectory",
"(",
")",
")",
";",
"}",
"if",
"(",
"generator",
"instanceof",
"PostInitializationAwareResourceGenerator",
")",
"{",
"(",
"(",
"PostInitializationAwareResourceGenerator",
")",
"generator",
")",
".",
"afterPropertiesSet",
"(",
")",
";",
"}",
"}",
"}"
] |
Initializes the generator properties.
@param generator
the generator
|
[
"Initializes",
"the",
"generator",
"properties",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L445-L464
|
7,190 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getDebugModeGenerationPath
|
public String getDebugModeGenerationPath(String path) {
ResourceGenerator resourceGenerator = resolveResourceGenerator(path);
return resourceGenerator.getDebugModeRequestPath();
}
|
java
|
public String getDebugModeGenerationPath(String path) {
ResourceGenerator resourceGenerator = resolveResourceGenerator(path);
return resourceGenerator.getDebugModeRequestPath();
}
|
[
"public",
"String",
"getDebugModeGenerationPath",
"(",
"String",
"path",
")",
"{",
"ResourceGenerator",
"resourceGenerator",
"=",
"resolveResourceGenerator",
"(",
"path",
")",
";",
"return",
"resourceGenerator",
".",
"getDebugModeRequestPath",
"(",
")",
";",
"}"
] |
Returns the path to use in the generation URL for debug mode.
@param path
the resource path
@return the path to use in the generation URL for debug mode.
|
[
"Returns",
"the",
"path",
"to",
"use",
"in",
"the",
"generation",
"URL",
"for",
"debug",
"mode",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L484-L488
|
7,191 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getDebugModeBuildTimeGenerationPath
|
public String getDebugModeBuildTimeGenerationPath(String path) {
int idx = path.indexOf("?");
String debugModeGeneratorPath = path.substring(0, idx);
debugModeGeneratorPath = debugModeGeneratorPath.replaceAll("\\.", "/");
int jawrGenerationParamIdx = path.indexOf(JawrRequestHandler.GENERATION_PARAM);
String parameter = path.substring(jawrGenerationParamIdx + JawrRequestHandler.GENERATION_PARAM.length() + 1); // Add
// 1
// for
// the
// '='
// character
ResourceGenerator resourceGenerator = resolveResourceGenerator(parameter);
String suffixPath = null;
if (resourceGenerator instanceof SpecificCDNDebugPathResourceGenerator) {
suffixPath = ((SpecificCDNDebugPathResourceGenerator) resourceGenerator)
.getDebugModeBuildTimeGenerationPath(parameter);
} else {
suffixPath = parameter.replaceFirst(GeneratorRegistry.PREFIX_SEPARATOR, JawrConstant.URL_SEPARATOR);
}
return debugModeGeneratorPath + "/" + suffixPath;
}
|
java
|
public String getDebugModeBuildTimeGenerationPath(String path) {
int idx = path.indexOf("?");
String debugModeGeneratorPath = path.substring(0, idx);
debugModeGeneratorPath = debugModeGeneratorPath.replaceAll("\\.", "/");
int jawrGenerationParamIdx = path.indexOf(JawrRequestHandler.GENERATION_PARAM);
String parameter = path.substring(jawrGenerationParamIdx + JawrRequestHandler.GENERATION_PARAM.length() + 1); // Add
// 1
// for
// the
// '='
// character
ResourceGenerator resourceGenerator = resolveResourceGenerator(parameter);
String suffixPath = null;
if (resourceGenerator instanceof SpecificCDNDebugPathResourceGenerator) {
suffixPath = ((SpecificCDNDebugPathResourceGenerator) resourceGenerator)
.getDebugModeBuildTimeGenerationPath(parameter);
} else {
suffixPath = parameter.replaceFirst(GeneratorRegistry.PREFIX_SEPARATOR, JawrConstant.URL_SEPARATOR);
}
return debugModeGeneratorPath + "/" + suffixPath;
}
|
[
"public",
"String",
"getDebugModeBuildTimeGenerationPath",
"(",
"String",
"path",
")",
"{",
"int",
"idx",
"=",
"path",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"String",
"debugModeGeneratorPath",
"=",
"path",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"debugModeGeneratorPath",
"=",
"debugModeGeneratorPath",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"/\"",
")",
";",
"int",
"jawrGenerationParamIdx",
"=",
"path",
".",
"indexOf",
"(",
"JawrRequestHandler",
".",
"GENERATION_PARAM",
")",
";",
"String",
"parameter",
"=",
"path",
".",
"substring",
"(",
"jawrGenerationParamIdx",
"+",
"JawrRequestHandler",
".",
"GENERATION_PARAM",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"// Add",
"// 1",
"// for",
"// the",
"// '='",
"// character",
"ResourceGenerator",
"resourceGenerator",
"=",
"resolveResourceGenerator",
"(",
"parameter",
")",
";",
"String",
"suffixPath",
"=",
"null",
";",
"if",
"(",
"resourceGenerator",
"instanceof",
"SpecificCDNDebugPathResourceGenerator",
")",
"{",
"suffixPath",
"=",
"(",
"(",
"SpecificCDNDebugPathResourceGenerator",
")",
"resourceGenerator",
")",
".",
"getDebugModeBuildTimeGenerationPath",
"(",
"parameter",
")",
";",
"}",
"else",
"{",
"suffixPath",
"=",
"parameter",
".",
"replaceFirst",
"(",
"GeneratorRegistry",
".",
"PREFIX_SEPARATOR",
",",
"JawrConstant",
".",
"URL_SEPARATOR",
")",
";",
"}",
"return",
"debugModeGeneratorPath",
"+",
"\"/\"",
"+",
"suffixPath",
";",
"}"
] |
Returns the path to use in the "build time process" to generate the
resource path for debug mode.
@param path
the resource path
@return the path to use in the "build time process" to generate the
resource path for debug mode.
|
[
"Returns",
"the",
"path",
"to",
"use",
"in",
"the",
"build",
"time",
"process",
"to",
"generate",
"the",
"resource",
"path",
"for",
"debug",
"mode",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L499-L521
|
7,192 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.resolveResourceGenerator
|
private ResourceGenerator resolveResourceGenerator(String path) {
ResourceGenerator resourceGenerator = null;
for (ResourceGeneratorResolverWrapper resolver : resolverRegistry) {
if (resolver.matchPath(path)) {
resourceGenerator = resolver.getResourceGenerator();
if (resolver.getType().equals(ResolverType.PREFIXED)) {
loadGeneratorIfNeeded(resolver.getResourcePath(path));
}
break;
}
}
// Lazy load generator
if (resourceGenerator == null) {
resourceGenerator = loadCommonGenerator(path);
}
return resourceGenerator;
}
|
java
|
private ResourceGenerator resolveResourceGenerator(String path) {
ResourceGenerator resourceGenerator = null;
for (ResourceGeneratorResolverWrapper resolver : resolverRegistry) {
if (resolver.matchPath(path)) {
resourceGenerator = resolver.getResourceGenerator();
if (resolver.getType().equals(ResolverType.PREFIXED)) {
loadGeneratorIfNeeded(resolver.getResourcePath(path));
}
break;
}
}
// Lazy load generator
if (resourceGenerator == null) {
resourceGenerator = loadCommonGenerator(path);
}
return resourceGenerator;
}
|
[
"private",
"ResourceGenerator",
"resolveResourceGenerator",
"(",
"String",
"path",
")",
"{",
"ResourceGenerator",
"resourceGenerator",
"=",
"null",
";",
"for",
"(",
"ResourceGeneratorResolverWrapper",
"resolver",
":",
"resolverRegistry",
")",
"{",
"if",
"(",
"resolver",
".",
"matchPath",
"(",
"path",
")",
")",
"{",
"resourceGenerator",
"=",
"resolver",
".",
"getResourceGenerator",
"(",
")",
";",
"if",
"(",
"resolver",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"ResolverType",
".",
"PREFIXED",
")",
")",
"{",
"loadGeneratorIfNeeded",
"(",
"resolver",
".",
"getResourcePath",
"(",
"path",
")",
")",
";",
"}",
"break",
";",
"}",
"}",
"// Lazy load generator",
"if",
"(",
"resourceGenerator",
"==",
"null",
")",
"{",
"resourceGenerator",
"=",
"loadCommonGenerator",
"(",
"path",
")",
";",
"}",
"return",
"resourceGenerator",
";",
"}"
] |
Finds the resource generator which will handle the resource, whose the
path is given in parameter
@param path
the resource path
@return the resource generator
|
[
"Finds",
"the",
"resource",
"generator",
"which",
"will",
"handle",
"the",
"resource",
"whose",
"the",
"path",
"is",
"given",
"in",
"parameter"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L531-L550
|
7,193 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getAvailableVariants
|
public Map<String, VariantSet> getAvailableVariants(String path) {
Map<String, VariantSet> availableVariants = new TreeMap<>();
ResourceGenerator generator = resolveResourceGenerator(path);
if (generator != null) {
if (generator instanceof VariantResourceGenerator) {
Map<String, VariantSet> tempResult = ((VariantResourceGenerator) generator)
.getAvailableVariants(generator.getResolver().getResourcePath(path));
if (tempResult != null) {
availableVariants = tempResult;
}
} else if (generator instanceof LocaleAwareResourceGenerator) {
List<String> availableLocales = ((LocaleAwareResourceGenerator) generator)
.getAvailableLocales(generator.getResolver().getResourcePath(path));
if (availableLocales != null) {
VariantSet variantSet = new VariantSet(JawrConstant.LOCALE_VARIANT_TYPE, "", availableLocales);
availableVariants.put(JawrConstant.LOCALE_VARIANT_TYPE, variantSet);
}
}
}
return availableVariants;
}
|
java
|
public Map<String, VariantSet> getAvailableVariants(String path) {
Map<String, VariantSet> availableVariants = new TreeMap<>();
ResourceGenerator generator = resolveResourceGenerator(path);
if (generator != null) {
if (generator instanceof VariantResourceGenerator) {
Map<String, VariantSet> tempResult = ((VariantResourceGenerator) generator)
.getAvailableVariants(generator.getResolver().getResourcePath(path));
if (tempResult != null) {
availableVariants = tempResult;
}
} else if (generator instanceof LocaleAwareResourceGenerator) {
List<String> availableLocales = ((LocaleAwareResourceGenerator) generator)
.getAvailableLocales(generator.getResolver().getResourcePath(path));
if (availableLocales != null) {
VariantSet variantSet = new VariantSet(JawrConstant.LOCALE_VARIANT_TYPE, "", availableLocales);
availableVariants.put(JawrConstant.LOCALE_VARIANT_TYPE, variantSet);
}
}
}
return availableVariants;
}
|
[
"public",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"getAvailableVariants",
"(",
"String",
"path",
")",
"{",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"availableVariants",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"ResourceGenerator",
"generator",
"=",
"resolveResourceGenerator",
"(",
"path",
")",
";",
"if",
"(",
"generator",
"!=",
"null",
")",
"{",
"if",
"(",
"generator",
"instanceof",
"VariantResourceGenerator",
")",
"{",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"tempResult",
"=",
"(",
"(",
"VariantResourceGenerator",
")",
"generator",
")",
".",
"getAvailableVariants",
"(",
"generator",
".",
"getResolver",
"(",
")",
".",
"getResourcePath",
"(",
"path",
")",
")",
";",
"if",
"(",
"tempResult",
"!=",
"null",
")",
"{",
"availableVariants",
"=",
"tempResult",
";",
"}",
"}",
"else",
"if",
"(",
"generator",
"instanceof",
"LocaleAwareResourceGenerator",
")",
"{",
"List",
"<",
"String",
">",
"availableLocales",
"=",
"(",
"(",
"LocaleAwareResourceGenerator",
")",
"generator",
")",
".",
"getAvailableLocales",
"(",
"generator",
".",
"getResolver",
"(",
")",
".",
"getResourcePath",
"(",
"path",
")",
")",
";",
"if",
"(",
"availableLocales",
"!=",
"null",
")",
"{",
"VariantSet",
"variantSet",
"=",
"new",
"VariantSet",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
",",
"\"\"",
",",
"availableLocales",
")",
";",
"availableVariants",
".",
"put",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
",",
"variantSet",
")",
";",
"}",
"}",
"}",
"return",
"availableVariants",
";",
"}"
] |
Returns the available variant for a path
@param path
the path
@return the available variant for a path
|
[
"Returns",
"the",
"available",
"variant",
"for",
"a",
"path"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L595-L618
|
7,194 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getGeneratedResourceVariantTypes
|
public Set<String> getGeneratedResourceVariantTypes(String path) {
Set<String> variantTypes = new HashSet<>();
ResourceGenerator generator = resolveResourceGenerator(path);
if (generator != null) {
if (generator instanceof VariantResourceGenerator) {
Set<String> tempResult = ((VariantResourceGenerator) generator)
.getAvailableVariants(generator.getResolver().getResourcePath(path)).keySet();
if (tempResult != null) {
variantTypes = tempResult;
}
} else if (generator instanceof LocaleAwareResourceGenerator) {
variantTypes = new HashSet<>();
variantTypes.add(JawrConstant.LOCALE_VARIANT_TYPE);
}
}
return variantTypes;
}
|
java
|
public Set<String> getGeneratedResourceVariantTypes(String path) {
Set<String> variantTypes = new HashSet<>();
ResourceGenerator generator = resolveResourceGenerator(path);
if (generator != null) {
if (generator instanceof VariantResourceGenerator) {
Set<String> tempResult = ((VariantResourceGenerator) generator)
.getAvailableVariants(generator.getResolver().getResourcePath(path)).keySet();
if (tempResult != null) {
variantTypes = tempResult;
}
} else if (generator instanceof LocaleAwareResourceGenerator) {
variantTypes = new HashSet<>();
variantTypes.add(JawrConstant.LOCALE_VARIANT_TYPE);
}
}
return variantTypes;
}
|
[
"public",
"Set",
"<",
"String",
">",
"getGeneratedResourceVariantTypes",
"(",
"String",
"path",
")",
"{",
"Set",
"<",
"String",
">",
"variantTypes",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"ResourceGenerator",
"generator",
"=",
"resolveResourceGenerator",
"(",
"path",
")",
";",
"if",
"(",
"generator",
"!=",
"null",
")",
"{",
"if",
"(",
"generator",
"instanceof",
"VariantResourceGenerator",
")",
"{",
"Set",
"<",
"String",
">",
"tempResult",
"=",
"(",
"(",
"VariantResourceGenerator",
")",
"generator",
")",
".",
"getAvailableVariants",
"(",
"generator",
".",
"getResolver",
"(",
")",
".",
"getResourcePath",
"(",
"path",
")",
")",
".",
"keySet",
"(",
")",
";",
"if",
"(",
"tempResult",
"!=",
"null",
")",
"{",
"variantTypes",
"=",
"tempResult",
";",
"}",
"}",
"else",
"if",
"(",
"generator",
"instanceof",
"LocaleAwareResourceGenerator",
")",
"{",
"variantTypes",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"variantTypes",
".",
"add",
"(",
"JawrConstant",
".",
"LOCALE_VARIANT_TYPE",
")",
";",
"}",
"}",
"return",
"variantTypes",
";",
"}"
] |
Returns the variant types for a generated resource
@param path
the path
@return he variant types for a generated resource
|
[
"Returns",
"the",
"variant",
"types",
"for",
"a",
"generated",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L627-L646
|
7,195 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.isHandlingCssImage
|
public boolean isHandlingCssImage(String cssResourcePath) {
boolean isHandlingCssImage = false;
ResourceGenerator generator = resolveResourceGenerator(cssResourcePath);
if (generator != null && cssImageResourceGeneratorRegistry.contains(generator)) {
isHandlingCssImage = true;
}
return isHandlingCssImage;
}
|
java
|
public boolean isHandlingCssImage(String cssResourcePath) {
boolean isHandlingCssImage = false;
ResourceGenerator generator = resolveResourceGenerator(cssResourcePath);
if (generator != null && cssImageResourceGeneratorRegistry.contains(generator)) {
isHandlingCssImage = true;
}
return isHandlingCssImage;
}
|
[
"public",
"boolean",
"isHandlingCssImage",
"(",
"String",
"cssResourcePath",
")",
"{",
"boolean",
"isHandlingCssImage",
"=",
"false",
";",
"ResourceGenerator",
"generator",
"=",
"resolveResourceGenerator",
"(",
"cssResourcePath",
")",
";",
"if",
"(",
"generator",
"!=",
"null",
"&&",
"cssImageResourceGeneratorRegistry",
".",
"contains",
"(",
"generator",
")",
")",
"{",
"isHandlingCssImage",
"=",
"true",
";",
"}",
"return",
"isHandlingCssImage",
";",
"}"
] |
Returns true if the generator associated to the css resource path handle
also CSS image.
@param cssResourcePath
the Css resource path
@return true if the generator associated to the css resource path handle
also CSS image.
|
[
"Returns",
"true",
"if",
"the",
"generator",
"associated",
"to",
"the",
"css",
"resource",
"path",
"handle",
"also",
"CSS",
"image",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L657-L667
|
7,196 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.isGeneratedBinaryResource
|
public boolean isGeneratedBinaryResource(String resourcePath) {
boolean isGeneratedImage = false;
ResourceGenerator generator = resolveResourceGenerator(resourcePath);
if (generator != null && binaryResourceGeneratorRegistry.contains(generator)) {
isGeneratedImage = true;
}
return isGeneratedImage;
}
|
java
|
public boolean isGeneratedBinaryResource(String resourcePath) {
boolean isGeneratedImage = false;
ResourceGenerator generator = resolveResourceGenerator(resourcePath);
if (generator != null && binaryResourceGeneratorRegistry.contains(generator)) {
isGeneratedImage = true;
}
return isGeneratedImage;
}
|
[
"public",
"boolean",
"isGeneratedBinaryResource",
"(",
"String",
"resourcePath",
")",
"{",
"boolean",
"isGeneratedImage",
"=",
"false",
";",
"ResourceGenerator",
"generator",
"=",
"resolveResourceGenerator",
"(",
"resourcePath",
")",
";",
"if",
"(",
"generator",
"!=",
"null",
"&&",
"binaryResourceGeneratorRegistry",
".",
"contains",
"(",
"generator",
")",
")",
"{",
"isGeneratedImage",
"=",
"true",
";",
"}",
"return",
"isGeneratedImage",
";",
"}"
] |
Returns true if the generator associated to the binary resource path is
an Image generator.
@param resourcePath
the binary resource path
@return true if the generator associated to the binary resource path is
an Image generator.
|
[
"Returns",
"true",
"if",
"the",
"generator",
"associated",
"to",
"the",
"binary",
"resource",
"path",
"is",
"an",
"Image",
"generator",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L678-L688
|
7,197 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.resolveVariants
|
public Map<String, String> resolveVariants(HttpServletRequest request) {
Map<String, String> variants = new TreeMap<>();
for (VariantResolver resolver : variantResolvers.values()) {
String value = resolver.resolveVariant(request);
if (value != null) {
variants.put(resolver.getVariantType(), value);
}
}
return variants;
}
|
java
|
public Map<String, String> resolveVariants(HttpServletRequest request) {
Map<String, String> variants = new TreeMap<>();
for (VariantResolver resolver : variantResolvers.values()) {
String value = resolver.resolveVariant(request);
if (value != null) {
variants.put(resolver.getVariantType(), value);
}
}
return variants;
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"resolveVariants",
"(",
"HttpServletRequest",
"request",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"variants",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"for",
"(",
"VariantResolver",
"resolver",
":",
"variantResolvers",
".",
"values",
"(",
")",
")",
"{",
"String",
"value",
"=",
"resolver",
".",
"resolveVariant",
"(",
"request",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"variants",
".",
"put",
"(",
"resolver",
".",
"getVariantType",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"return",
"variants",
";",
"}"
] |
Resolve the variants for the request passed in parameter
@param request
the request
@return the map of variants defined in the request
|
[
"Resolve",
"the",
"variants",
"for",
"the",
"request",
"passed",
"in",
"parameter"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L697-L708
|
7,198 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getAvailableVariantMap
|
public Map<String, String> getAvailableVariantMap(Map<String, VariantSet> variants,
Map<String, String> curVariants) {
Map<String, String> availableVariantMap = new HashMap<>();
for (Entry<String, VariantSet> entry : variants.entrySet()) {
String variantType = entry.getKey();
VariantSet variantSet = entry.getValue();
String variant = variantSet.getDefaultVariant();
if (curVariants.containsKey(variantType)) {
String curVariant = curVariants.get(variantType);
VariantResolver resolver = variantResolvers.get(variantType);
if (resolver != null) {
variant = resolver.getAvailableVariant(curVariant, variants.get(variantType));
if (variant == null) {
variant = variants.get(variantType).getDefaultVariant();
}
} else {
throw new BundlingProcessException(
"Unable to find variant resolver for variant type '" + variantType + "'");
}
}
availableVariantMap.put(variantType, variant);
}
return availableVariantMap;
}
|
java
|
public Map<String, String> getAvailableVariantMap(Map<String, VariantSet> variants,
Map<String, String> curVariants) {
Map<String, String> availableVariantMap = new HashMap<>();
for (Entry<String, VariantSet> entry : variants.entrySet()) {
String variantType = entry.getKey();
VariantSet variantSet = entry.getValue();
String variant = variantSet.getDefaultVariant();
if (curVariants.containsKey(variantType)) {
String curVariant = curVariants.get(variantType);
VariantResolver resolver = variantResolvers.get(variantType);
if (resolver != null) {
variant = resolver.getAvailableVariant(curVariant, variants.get(variantType));
if (variant == null) {
variant = variants.get(variantType).getDefaultVariant();
}
} else {
throw new BundlingProcessException(
"Unable to find variant resolver for variant type '" + variantType + "'");
}
}
availableVariantMap.put(variantType, variant);
}
return availableVariantMap;
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getAvailableVariantMap",
"(",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"variants",
",",
"Map",
"<",
"String",
",",
"String",
">",
"curVariants",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"availableVariantMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"VariantSet",
">",
"entry",
":",
"variants",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"variantType",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"VariantSet",
"variantSet",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"String",
"variant",
"=",
"variantSet",
".",
"getDefaultVariant",
"(",
")",
";",
"if",
"(",
"curVariants",
".",
"containsKey",
"(",
"variantType",
")",
")",
"{",
"String",
"curVariant",
"=",
"curVariants",
".",
"get",
"(",
"variantType",
")",
";",
"VariantResolver",
"resolver",
"=",
"variantResolvers",
".",
"get",
"(",
"variantType",
")",
";",
"if",
"(",
"resolver",
"!=",
"null",
")",
"{",
"variant",
"=",
"resolver",
".",
"getAvailableVariant",
"(",
"curVariant",
",",
"variants",
".",
"get",
"(",
"variantType",
")",
")",
";",
"if",
"(",
"variant",
"==",
"null",
")",
"{",
"variant",
"=",
"variants",
".",
"get",
"(",
"variantType",
")",
".",
"getDefaultVariant",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Unable to find variant resolver for variant type '\"",
"+",
"variantType",
"+",
"\"'\"",
")",
";",
"}",
"}",
"availableVariantMap",
".",
"put",
"(",
"variantType",
",",
"variant",
")",
";",
"}",
"return",
"availableVariantMap",
";",
"}"
] |
Returns the available variants.
@param variants
the current bundle variants
@param curVariants
the current variant
@return the available variants
|
[
"Returns",
"the",
"available",
"variants",
"."
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L719-L743
|
7,199 |
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java
|
GeneratorRegistry.getGeneratedPathMappings
|
public List<PathMapping> getGeneratedPathMappings(JoinableResourceBundle bundle, String path,
ResourceReaderHandler rsReader) {
List<PathMapping> pathMappings = null;
ResourceGenerator resourceGenerator = getResourceGenerator(path);
if (resourceGenerator instanceof PathMappingProvider) {
pathMappings = ((PathMappingProvider) resourceGenerator).getPathMappings(bundle, path, rsReader);
}
return pathMappings;
}
|
java
|
public List<PathMapping> getGeneratedPathMappings(JoinableResourceBundle bundle, String path,
ResourceReaderHandler rsReader) {
List<PathMapping> pathMappings = null;
ResourceGenerator resourceGenerator = getResourceGenerator(path);
if (resourceGenerator instanceof PathMappingProvider) {
pathMappings = ((PathMappingProvider) resourceGenerator).getPathMappings(bundle, path, rsReader);
}
return pathMappings;
}
|
[
"public",
"List",
"<",
"PathMapping",
">",
"getGeneratedPathMappings",
"(",
"JoinableResourceBundle",
"bundle",
",",
"String",
"path",
",",
"ResourceReaderHandler",
"rsReader",
")",
"{",
"List",
"<",
"PathMapping",
">",
"pathMappings",
"=",
"null",
";",
"ResourceGenerator",
"resourceGenerator",
"=",
"getResourceGenerator",
"(",
"path",
")",
";",
"if",
"(",
"resourceGenerator",
"instanceof",
"PathMappingProvider",
")",
"{",
"pathMappings",
"=",
"(",
"(",
"PathMappingProvider",
")",
"resourceGenerator",
")",
".",
"getPathMappings",
"(",
"bundle",
",",
"path",
",",
"rsReader",
")",
";",
"}",
"return",
"pathMappings",
";",
"}"
] |
Returns the PathMapping for the generated resource
@param bundle
the bundle
@param path
the generated path
@param rsReader
the resource reader handler
@return the PathMapping for the generated resource
|
[
"Returns",
"the",
"PathMapping",
"for",
"the",
"generated",
"resource"
] |
5381f6acf461cd2502593c67a77bd6ef9eab848d
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/GeneratorRegistry.java#L766-L776
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.