com.github.dynamicextensionsalfresco.blueprint.BundleScriptContent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blueprint-integration-spring-3 Show documentation
Show all versions of blueprint-integration-spring-3 Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.blueprint;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import org.springframework.extensions.webscripts.ScriptContent;
import org.springframework.util.Assert;
class BundleScriptContent implements ScriptContent {
private final URL url;
private final String path;
private final boolean secure;
private final String encoding;
BundleScriptContent(final URL url, final String path, final boolean secure, final String encoding) {
Assert.notNull(url, "URL cannot be null.");
Assert.hasText(encoding, "Encoding cannot be empty.");
this.url = url;
this.path = path;
this.secure = secure;
this.encoding = encoding;
}
protected URL getUrl() {
return url;
}
protected String getEncoding() {
return encoding;
}
@Override
public InputStream getInputStream() {
try {
return getUrl().openStream();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
@Override
public Reader getReader() {
try {
return new InputStreamReader(getUrl().openStream(), getEncoding());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
@Override
public String getPath() {
return path;
}
@Override
public String getPathDescription() {
return path;
}
@Override
public boolean isCachable() {
return true;
}
@Override
public boolean isSecure() {
return secure;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy