@@ -150,13 +150,6 @@ public PackageResourceBlockedException(String message)
150
150
*/
151
151
private boolean cachingEnabled = true ;
152
152
153
- /**
154
- * controls whether
155
- * {@link org.apache.wicket.core.util.resource.locator.caching.CachingResourceStreamLocator}
156
- * should update the cache
157
- */
158
- private boolean serverResourceStreamReferenceCacheUpdate = true ;
159
-
160
153
/**
161
154
* text encoding (may be null) - only makes sense for character-based resources
162
155
*/
@@ -248,27 +241,6 @@ public void setCachingEnabled(final boolean enabled)
248
241
this .cachingEnabled = enabled ;
249
242
}
250
243
251
- /**
252
- * Returns true if the cache should be updated for this resource
253
- *
254
- * @return if the cache update is enabled
255
- */
256
- public boolean isServerResourceStreamReferenceCacheUpdate ()
257
- {
258
- return serverResourceStreamReferenceCacheUpdate ;
259
- }
260
-
261
- /**
262
- * Sets the cache update for this resource to be enabled
263
- *
264
- * @param enabled
265
- * if the cache update should be enabled
266
- */
267
- public void setServerResourceStreamReferenceCacheUpdate (final boolean enabled )
268
- {
269
- this .serverResourceStreamReferenceCacheUpdate = enabled ;
270
- }
271
-
272
244
/**
273
245
* get text encoding (intended for character-based resources)
274
246
*
@@ -560,8 +532,8 @@ private ResourceResponse sendResourceError(ResourceResponse resourceResponse, in
560
532
@ Override
561
533
public IResourceStream getResourceStream ()
562
534
{
563
- return internalGetResourceStream (getCurrentStyle (), getCurrentLocale (), isServerResourceStreamReferenceCacheUpdate () );
564
- }
535
+ return internalGetResourceStream (getCurrentStyle (), getCurrentLocale ());
536
+ }
565
537
566
538
/**
567
539
* @return whether {@link org.apache.wicket.resource.ITextResourceCompressor} can be used to
@@ -581,23 +553,13 @@ public void setCompress(boolean compress)
581
553
this .compress = compress ;
582
554
}
583
555
584
- private IResourceStream internalGetResourceStream (final String style , final Locale locale , boolean updateCache )
556
+ private IResourceStream internalGetResourceStream (final String style , final Locale locale )
585
557
{
586
558
IResourceStreamLocator resourceStreamLocator = Application .get ()
587
559
.getResourceSettings ()
588
560
.getResourceStreamLocator ();
589
- IResourceStream resourceStream = null ;
590
-
591
- if (resourceStreamLocator instanceof CachingResourceStreamLocator cache )
592
- {
593
- resourceStream = cache .locate (getScope (), absolutePath , style , variation , locale , null ,
594
- false , updateCache );
595
- }
596
- else
597
- {
598
- resourceStream = resourceStreamLocator .locate (getScope (), absolutePath , style ,
599
- variation , locale , null , false );
600
- }
561
+ IResourceStream resourceStream = resourceStreamLocator .locate (getScope (), absolutePath ,
562
+ style , variation , locale , null , false );
601
563
602
564
String realPath = absolutePath ;
603
565
if (resourceStream instanceof IFixedLocationResourceStream )
@@ -737,49 +699,26 @@ public static boolean exists(final ResourceReference.Key key)
737
699
* @param variation
738
700
* The component's variation (of the style)
739
701
* @return {@code true} if a resource could be loaded, {@code false} otherwise
740
- *
741
- * @deprecated use {@link PackageResource#exists(Class, String, Locale, String, String, boolean)}
742
702
*/
743
703
public static boolean exists (final Class <?> scope , final String path , final Locale locale ,
744
704
final String style , final String variation )
745
705
{
746
- return exists (scope , path , locale , style , variation , true );
706
+ return getResourceStream (scope , path , locale , style , variation , true ) != null ;
747
707
}
748
708
749
- /**
750
- * Checks whether a resource for a given set of criteria exists.
751
- *
752
- * @param scope
753
- * This argument will be used to get the class loader for loading the package
754
- * resource, and to determine what package it is in. Typically this is the class in
755
- * which you call this method
756
- * @param path
757
- * The path to the resource
758
- * @param locale
759
- * The locale of the resource
760
- * @param style
761
- * The style of the resource (see {@link org.apache.wicket.Session})
762
- * @param variation
763
- * The component's variation (of the style)
764
- * @param updateCache
765
- * if the server resource stream reference cache should be updated
766
- * @return {@code true} if a resource could be loaded, {@code false} otherwise
767
- */
768
- public static boolean exists (final Class <?> scope , final String path , final Locale locale ,
709
+ private static IResourceStream getResourceStream (final Class <?> scope , final String path , final Locale locale ,
769
710
final String style , final String variation , final boolean updateCache )
770
711
{
771
712
String absolutePath = Packages .absolutePath (scope , path );
772
713
IResourceStreamLocator resourceStreamLocator = Application .get ().getResourceSettings ()
773
714
.getResourceStreamLocator ();
774
715
if (resourceStreamLocator instanceof CachingResourceStreamLocator cache )
775
716
{
776
- return cache .locate (scope , absolutePath , style , variation , locale , null , false ,
777
- updateCache ) != null ;
717
+ return cache .locate (scope , absolutePath , style , variation , locale , null , false , updateCache );
778
718
}
779
719
else
780
720
{
781
- return resourceStreamLocator .locate (scope , absolutePath , style , variation , locale , null ,
782
- false ) != null ;
721
+ return resourceStreamLocator .locate (scope , absolutePath , style , variation , locale , null , false );
783
722
}
784
723
}
785
724
@@ -933,10 +872,13 @@ public PackageResource readBuffered(boolean readBuffered)
933
872
public static ResourceReference .UrlAttributes sanitize (
934
873
ResourceReference .UrlAttributes urlAttributes , Class <?> scope , String name )
935
874
{
936
- PackageResource urlResource = new PackageResource (scope , name , urlAttributes .getLocale (),
937
- urlAttributes .getStyle (), urlAttributes .getVariation ());
938
- urlResource .setServerResourceStreamReferenceCacheUpdate (false );
939
- IResourceStream filesystemMatch = urlResource .getResourceStream ();
875
+ IResourceStream filesystemMatch = getResourceStream (scope , name , urlAttributes .getLocale (),
876
+ urlAttributes .getStyle (), urlAttributes .getVariation (), false );
877
+
878
+ if (filesystemMatch == null )
879
+ {
880
+ return urlAttributes ;
881
+ }
940
882
941
883
ResourceReference .Key urlKey = new ResourceReference .Key (scope .getName (), name ,
942
884
urlAttributes .getLocale (), urlAttributes .getStyle (), urlAttributes .getVariation ());
0 commit comments