![JAR search and dependency download from the Maven repository](/logo.png)
org.omnifaces.resourcehandler.OmniVersionResourceHandler Maven / Gradle / Ivy
/*
* Copyright OmniFaces
*
* 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.omnifaces.resourcehandler;
import static org.omnifaces.config.OmniFaces.OMNIFACES_LIBRARY_NAME;
import jakarta.faces.application.Resource;
import jakarta.faces.application.ResourceHandler;
import org.omnifaces.config.OmniFaces;
/**
* Appends OmniFaces version to resources with library name omnifaces
.
*
* @author Bauke Scholtz
* @since 2.2
*/
public class OmniVersionResourceHandler extends DefaultResourceHandler {
private final String version;
/**
* Creates a new instance of this OmniFaces version resource handler which wraps the given resource handler.
* @param wrapped The resource handler to be wrapped.
*/
public OmniVersionResourceHandler(ResourceHandler wrapped) {
super(wrapped);
version = "&v=" + (OmniFaces.isSnapshot() ? OmniFaces.getStartupTime() : OmniFaces.getVersion());
}
@Override
public Resource decorateResource(Resource resource) {
if (resource == null || !OMNIFACES_LIBRARY_NAME.equals(resource.getLibraryName())) {
return resource;
}
return new RemappedResource(resource, resource.getRequestPath() + version);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy