File tree 2 files changed +9
-4
lines changed
ng-appserver/src/main/java/ng/appserver
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 11
11
import org .slf4j .Logger ;
12
12
import org .slf4j .LoggerFactory ;
13
13
14
- import ng .appserver .privates .NGResourceLoader ;
15
14
import ng .appserver .templating .NGDeclarationFormatException ;
16
15
import ng .appserver .templating .NGElementUtils ;
17
16
import ng .appserver .templating .NGHTMLFormatException ;
@@ -201,7 +200,7 @@ private NGElement _loadTemplate() {
201
200
202
201
// If that fails, let's go for the single file html template
203
202
if ( htmlTemplateStringOptional .isEmpty () ) {
204
- final Optional <byte []> htmlTemplate = NGResourceLoader . bytesForComponentResource ( name () + ".html" );
203
+ final Optional <byte []> htmlTemplate = NGApplication . application (). resourceManager (). bytesForComponentResourceNamed ( name () + ".html" );
205
204
206
205
if ( htmlTemplate .isPresent () ) {
207
206
htmlTemplateStringOptional = Optional .of ( new String ( htmlTemplate .get (), StandardCharsets .UTF_8 ) );
@@ -261,7 +260,7 @@ private static Optional<String> loadStringFromTemplateFolder( final String templ
261
260
262
261
final String htmlTemplateFilename = templateName + ".wo/" + templateName + "." + extension ;
263
262
264
- final Optional <byte []> templateBytes = NGResourceLoader . bytesForComponentResource ( htmlTemplateFilename );
263
+ final Optional <byte []> templateBytes = NGApplication . application (). resourceManager (). bytesForComponentResourceNamed ( htmlTemplateFilename );
265
264
266
265
if ( templateBytes .isEmpty () ) {
267
266
return Optional .empty ();
Original file line number Diff line number Diff line change @@ -26,9 +26,10 @@ public class NGResourceManager {
26
26
/**
27
27
* FIXME: Experimental caches. Resource caches should be located centrally.
28
28
*/
29
+ private final Map <String , Optional <byte []>> _appResourceCache = new ConcurrentHashMap <>();
29
30
private final Map <String , Optional <byte []>> _webserverResourceCache = new ConcurrentHashMap <>();
31
+ private final Map <String , Optional <byte []>> _componentResourceCache = new ConcurrentHashMap <>();
30
32
private final Map <String , Optional <byte []>> _publicResourceCache = new ConcurrentHashMap <>();
31
- private final Map <String , Optional <byte []>> _appResourceCache = new ConcurrentHashMap <>();
32
33
33
34
/**
34
35
* Specifies if we want to use the resources cache.
@@ -47,6 +48,11 @@ public Optional<byte[]> bytesForWebserverResourceNamed( final String resourceNam
47
48
return bytesForAnyResource ( resourceName , _webserverResourceCache , NGResourceLoader ::bytesForWebserverResource );
48
49
}
49
50
51
+ public Optional <byte []> bytesForComponentResourceNamed ( final String resourceName ) {
52
+ Objects .requireNonNull ( resourceName );
53
+ return bytesForAnyResource ( resourceName , _componentResourceCache , NGResourceLoader ::bytesForComponentResource );
54
+ }
55
+
50
56
public Optional <byte []> bytesForPublicResourceNamed ( final String resourceName ) {
51
57
Objects .requireNonNull ( resourceName );
52
58
return bytesForAnyResource ( resourceName , _publicResourceCache , NGResourceLoader ::bytesForPublicResource );
You can’t perform that action at this time.
0 commit comments