Path segment to get all the matching resources in the class loader hierarchy,Īnd then off each resource the same PathMatcher resolution strategy described In this case, the resolution strategy is fairly simple: aĬlassLoader.getResources() call is used on the last non-wildcard The rest of the location path, for example "classpath*:META-INF/*-beans.xml". The "classpath*:" prefix can also be combined with a PathMatcher pattern in Internally, this happens via aĬlassLoader.getResources() call, and is completely portable. This is particularly useful for autodetecting config files of the same nameĪt the same location within each jar file. " classpath*:META-INF/beans.xml" will find all "beans.xml"įiles in the class path, be it in "classes" directories or in JAR files. The same name, via the " classpath*:" prefix. There is special support for retrieving multiple class path resources with Specific environment before you rely on it. Resolution of resources coming from jars be thoroughly tested in your This will work in most environments, but willįail in others, and it is strongly recommended that the wildcard Manually parse the jar URL, to be able to walk the contents of the jar,Īnd resolve the wildcard. If a jar URL is obtained for the last non-wildcard segment, the resolver Still, there is a portability concern on this operation. Location, or a jar URL of some sort, where the classpath resource resolves The directory, where the classpath resource resolves to a filesystem In practice, it is usually a java.io.File representing (in the ClassLoader Javadocs) exactly what sort of URL is returned in Node of the path (not the file at the end) it is actually undefined Obtain the last non-wildcard path segment URL via aĬlassloader.getResource() call. If the specified path is a classpath location, then the resolver must Then wildcarding is guaranteed to work in a completely portable fashion. Implicitly because the base ResourceLoader is a filesystem one), If the specified path is already a file URL (either explicitly, or The jar URL, and then traverses the contents of the jar file, to resolve the In the case of a jar URL, the resolverĮither gets a from it, or manually parses Then a java.io.File is obtained from it, and used to resolve the " zip:" in WebLogic, " wsjar" in WebSphere", etc.), Not a " jar:" URL or container-specific variant (e.g. Non-wildcard segment and obtains a URL from it. It produces a Resource for the path up to the last The resolver follows a more complex but defined procedure to try to resolve When the path location contains an Ant-style pattern, e.g.:Ĭlasspath:com/mycompany/**/applicationContext.xml ServletContextResource for a WebApplicationContext). The latter will resolve in aįashion specific to the underlying ResourceLoader (e.g. Such as " classpath:/context.xml", and simple unprefixed paths GetResource() call on the underlying ResourceLoader.Įxamples are real URLs such as " file:C:/context.xml", pseudo-URLs This resolver will simply return a single resource via a "classpath*:" prefix, and does not contain a PathMatcher pattern, In the simple case, if the specified location path does not start with the Internal Ant-style regular expressions (matched using Spring'sīoth of the latter are effectively wildcards. May contain the special " classpath*:" prefix and/or The source path may be a simple path which has a one-to-one mapping to a Specified resource location path into one or more matching Resources. A ResourcePatternResolver implementation that is able to resolve a
0 Comments
Leave a Reply. |