org.spincast.plugins.routing.StaticResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-plugins-routing Show documentation
Show all versions of spincast-plugins-routing Show documentation
The default Spincast Routing plugin
The newest version!
package org.spincast.plugins.routing;
import javax.annotation.Nullable;
import org.spincast.core.exchange.IRequestContext;
import org.spincast.core.routing.IHandler;
import org.spincast.core.routing.IStaticResource;
import org.spincast.core.routing.IStaticResourceCorsConfig;
import org.spincast.core.routing.StaticResourceType;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
/**
* Represents a static resource.
*/
public class StaticResource> implements IStaticResource {
private final StaticResourceType staticResourceType;
private final String urlPath;
private final String resourcePath;
private final IHandler generator;
private final IStaticResourceCorsConfig corsConfig;
@AssistedInject
public StaticResource(@Assisted StaticResourceType staticResourceType,
@Assisted("url") String urlPath,
@Assisted("path") String resourcePath,
@Assisted @Nullable IHandler generator,
@Assisted @Nullable IStaticResourceCorsConfig corsConfig) {
this.staticResourceType = staticResourceType;
this.urlPath = urlPath;
this.resourcePath = resourcePath;
this.generator = generator;
this.corsConfig = corsConfig;
}
@Override
public StaticResourceType getStaticResourceType() {
return this.staticResourceType;
}
@Override
public String getUrlPath() {
return this.urlPath;
}
@Override
public String getResourcePath() {
return this.resourcePath;
}
@Override
public boolean isCanBeGenerated() {
return getGenerator() != null;
}
@Override
public IHandler getGenerator() {
return this.generator;
}
@Override
public IStaticResourceCorsConfig getCorsConfig() {
return this.corsConfig;
}
@Override
public boolean isFileResource() {
return getStaticResourceType() == StaticResourceType.FILE ||
getStaticResourceType() == StaticResourceType.FILE_FROM_CLASSPATH;
}
@Override
public boolean isDirResource() {
return !isFileResource();
}
@Override
public boolean isClasspath() {
return getStaticResourceType() == StaticResourceType.FILE_FROM_CLASSPATH ||
getStaticResourceType() == StaticResourceType.DIRECTORY_FROM_CLASSPATH;
}
@Override
public boolean isFileSytem() {
return !isClasspath();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy