forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support loading of base64 encoded values from the Environment
- Loading branch information
1 parent
b74d134
commit b7c9c84
Showing
20 changed files
with
458 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../springframework/boot/build/architecture/resources/loads/ResourceUtilsResourceLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.build.architecture.resources.loads; | ||
|
||
import java.io.FileNotFoundException; | ||
|
||
import org.springframework.util.ResourceUtils; | ||
|
||
public class ResourceUtilsResourceLoader { | ||
|
||
void getResource() throws FileNotFoundException { | ||
ResourceUtils.getURL("gradle.properties"); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...pringframework/boot/build/architecture/resources/noloads/ResourceUtilsWithoutLoading.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.build.architecture.resources.noloads; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import org.springframework.util.ResourceUtils; | ||
|
||
public class ResourceUtilsWithoutLoading { | ||
|
||
void inspectResourceLocation() throws MalformedURLException { | ||
ResourceUtils.isUrl("gradle.properties"); | ||
ResourceUtils.isFileURL(new URL("gradle.properties")); | ||
"test".startsWith(ResourceUtils.FILE_URL_PREFIX); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ject/spring-boot/src/main/java/org/springframework/boot/io/ApplicationResourceLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.io; | ||
|
||
import org.springframework.core.io.ContextResource; | ||
import org.springframework.core.io.DefaultResourceLoader; | ||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.core.io.ProtocolResolver; | ||
import org.springframework.core.io.Resource; | ||
|
||
/** | ||
* A {@link DefaultResourceLoader} with any {@link ProtocolResolver}s registered in a | ||
* {@code spring.factories} file applied to it. Plain paths without a qualifier will | ||
* resolve to file system resources. This is different from {@code DefaultResourceLoader}, | ||
* which resolves unqualified paths to classpath resources. | ||
* | ||
* @author Scott Frederick | ||
* @since 3.3.0 | ||
*/ | ||
public class ApplicationResourceLoader extends DefaultResourceLoader { | ||
|
||
/** | ||
* Create a new {@code ApplicationResourceLoader}. | ||
*/ | ||
public ApplicationResourceLoader() { | ||
super(); | ||
ProtocolResolvers.applyTo(this); | ||
} | ||
|
||
/** | ||
* Create a new {@code ApplicationResourceLoader}. | ||
* @param classLoader the {@link ClassLoader} to load class path resources with, or | ||
* {@code null} for using the thread context class loader at the time of actual | ||
* resource access | ||
*/ | ||
public ApplicationResourceLoader(ClassLoader classLoader) { | ||
super(classLoader); | ||
ProtocolResolvers.applyTo(this); | ||
} | ||
|
||
@Override | ||
protected Resource getResourceByPath(String path) { | ||
return new FileSystemContextResource(path); | ||
} | ||
|
||
private static class FileSystemContextResource extends FileSystemResource implements ContextResource { | ||
|
||
FileSystemContextResource(String path) { | ||
super(path); | ||
} | ||
|
||
@Override | ||
public String getPathWithinContext() { | ||
return getPath(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.