use of org.apache.tapestry5.annotations.Path in project flowlogix by flowlogix.
the class GwtCachingFilter method service.
@Override
public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler chainHandler) throws IOException {
String path = request.getServletPath();
boolean neverExpire = checkConfig(path, response);
if (neverExpire == false) {
return chainHandler.service(request, response);
}
log.finer("GwtCachingFilter: Processing " + path);
Request rq = new RequestImpl(request, applicationCharset, sessionFactory);
Response rsp = new ResponseImpl(request, response);
rg.storeRequestResponse(rq, rsp);
rsp.setDateHeader("Expires", new Date().getTime() + InternalConstants.TEN_YEARS);
try {
return carh.handleAssetRequest(rq, rsp, pathProcessor.removeAssetPathPart(path));
} catch (Exception e) {
return chainHandler.service(request, response);
}
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class AssetSourceImplTest method get_expanded_asset.
@Test
public void get_expanded_asset() {
AssetFactory factory = mockAssetFactory();
Asset asset = mockAsset();
SymbolSource symbolSource = mockSymbolSource();
Resource expectedResource = baseResource.forFile("SimpleComponent.properties");
train_getRootResource(factory, rootResource);
train_createAsset(factory, expectedResource, asset);
train_expandSymbols(symbolSource, "${path}/SimpleComponent.properties", "org/apache/tapestry5/internal/services/SimpleComponent.properties");
Map<String, AssetFactory> configuration = Collections.singletonMap("classpath", factory);
replay();
AssetSource source = new AssetSourceImpl(null, configuration, symbolSource, null, tracker);
// First try creates it:
assertSame(source.getExpandedAsset("${path}/SimpleComponent.properties"), asset);
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class AssetSourceImplTest method unknown_asset_prefix.
@Test
public void unknown_asset_prefix() {
ThreadLocale threadLocale = mockThreadLocale();
Map<String, AssetFactory> configuration = Collections.emptyMap();
replay();
AssetSource source = new AssetSourceImpl(threadLocale, configuration, null, null, tracker);
try {
source.getAsset(baseResource, "classpath:org/apache/tapestry5/internal/services/SimpleComponent.properties", Locale.UK);
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Unknown prefix for asset path 'classpath:org/apache/tapestry5/internal/services/SimpleComponent.properties'.");
}
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class AbstractAssetFactory method createAsset.
protected Asset createAsset(final Resource resource, final String folder, final String resourcePath) {
assert resource != null;
assert InternalUtils.isNonBlank(folder);
assert InternalUtils.isNonBlank(resourcePath);
return new AbstractAsset(false) {
public String toClientURL() {
try {
// Get the uncompressed version, so that we can identify its content type (and remember, the extension is not enough,
// as some types get translated to new content types by the SRS).
StreamableResource uncompressed = streamableResourceSource.getStreamableResource(resource, StreamableResourceProcessing.COMPRESSION_DISABLED, resourceChangeTracker);
StreamableResource forRequest = isCompressable(uncompressed) ? streamableResourceSource.getStreamableResource(resource, StreamableResourceProcessing.COMPRESSION_ENABLED, resourceChangeTracker) : uncompressed;
return assetPathConstructor.constructAssetPath(folder, resourcePath, forRequest);
} catch (IOException ex) {
throw new RuntimeException(String.format("Unable to construct asset path for %s: %s", resource, ExceptionUtils.toMessage(ex)), ex);
}
}
public Resource getResource() {
return resource;
}
};
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class AssetInjectionProvider method provideInjection.
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) {
Path path = field.getAnnotation(Path.class);
if (path == null) {
return false;
}
final String assetPath = path.value();
final String libraryName = componentModel.getLibraryName();
ComputedValue<Asset> computedAsset = new ComputedValue<Asset>() {
public Asset get(InstanceContext context) {
ComponentResources resources = context.get(ComponentResources.class);
// a different library name than the subclass).
return assetSource.getComponentAsset(resources, assetPath, libraryName);
}
};
field.injectComputed(computedAsset);
return true;
}
Aggregations