use of org.apache.tapestry5.annotations.Service 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.Service in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method display_block_not_found.
@Test
public void display_block_not_found() {
RequestPageCache cache = mockRequestPageCache();
Collection<BeanBlockContribution> configuration = newList();
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
try {
assertFalse(source.hasDisplayBlock("MyData"));
source.getDisplayBlock("MyData");
unreachable();
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "There is no defined way to display data of type \'MyData\'. Make a contribution to the BeanBlockSource service for this type.");
}
verify();
}
use of org.apache.tapestry5.annotations.Service in project tapestry-5 by apache.
the class PageRenderLinkSourceImplTest method override_passivate_context.
@Test
public void override_passivate_context() {
ComponentClassResolver resolver = mockComponentClassResolver();
LinkSource source = mockLinkSource();
Link link = mockLink();
EventContext eventContext = mockEventContext();
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
expect(source.createPageRenderLink(PAGE_NAME, true, "fred", "barney")).andReturn(link);
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
train_getCount(eventContext, 2);
train_get(eventContext, Object.class, 0, "ted");
train_get(eventContext, Object.class, 1, "barney");
expect(source.createPageRenderLink(PAGE_NAME, true, "ted", "barney")).andReturn(link);
replay();
PageRenderLinkSource service = new PageRenderLinkSourceImpl(source, resolver);
assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, "fred", "barney"), link);
assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, eventContext), link);
verify();
}
use of org.apache.tapestry5.annotations.Service in project tapestry-5 by apache.
the class TranslatorSourceImplTest method name_collision_with_standard_translators.
@Test
public void name_collision_with_standard_translators() {
Translator t1 = mockTranslator("fred", Integer.class);
Translator t2 = mockTranslator("fred", Long.class);
Map<Class, Translator> configuration = CollectionFactory.newMap();
configuration.put(Integer.class, t1);
configuration.put(Long.class, t2);
replay();
try {
new TranslatorSourceImpl(configuration);
unreachable();
} catch (RuntimeException ex) {
assertMessageContains(ex, "Two different Translators contributed to the TranslatorSource service use the same translator name: 'fred'.", "Translator names must be unique.");
}
verify();
}
use of org.apache.tapestry5.annotations.Service in project tapestry-5 by apache.
the class ReloadableServiceImplementationObjectCreator method createInstance.
@Override
protected Object createInstance(Class clazz) {
final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz);
if (constructor == null)
throw new RuntimeException(String.format("Service implementation class %s does not have a suitable public constructor.", clazz.getName()));
ObjectCreator constructorServiceCreator = new ConstructorServiceCreator(resources, constructor.toString(), constructor);
return constructorServiceCreator.createObject();
}
Aggregations