Search in sources :

Example 1 with Service

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);
    }
}
Also used : Response(org.apache.tapestry5.services.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.services.Request) RequestImpl(org.apache.tapestry5.internal.services.RequestImpl) ResponseImpl(org.apache.tapestry5.internal.services.ResponseImpl) Date(java.util.Date) IOException(java.io.IOException)

Example 2 with Service

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();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) Test(org.testng.annotations.Test)

Example 3 with Service

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();
}
Also used : EventContext(org.apache.tapestry5.EventContext) PageRenderLinkSource(org.apache.tapestry5.services.PageRenderLinkSource) PageRenderLinkSource(org.apache.tapestry5.services.PageRenderLinkSource) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 4 with Service

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();
}
Also used : Translator(org.apache.tapestry5.Translator) BeforeClass(org.testng.annotations.BeforeClass) Test(org.testng.annotations.Test)

Example 5 with Service

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();
}
Also used : Constructor(java.lang.reflect.Constructor) ObjectCreator(org.apache.tapestry5.commons.ObjectCreator)

Aggregations

Service (org.jvnet.hk2.annotations.Service)11 Test (org.testng.annotations.Test)7 List (java.util.List)4 Config (com.sun.enterprise.config.serverbeans.Config)2 PropertyVetoException (java.beans.PropertyVetoException)2 IOException (java.io.IOException)2 Annotation (java.lang.annotation.Annotation)2 Type (java.lang.reflect.Type)2 HashMap (java.util.HashMap)2 Level (java.util.logging.Level)2 Logger (java.util.logging.Logger)2 Inject (javax.inject.Inject)2 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)2 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)2 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)2 AdminCommand (org.glassfish.api.admin.AdminCommand)2 RestEndpoint (org.glassfish.api.admin.RestEndpoint)2 RestEndpoints (org.glassfish.api.admin.RestEndpoints)2 ServerEnvironment (org.glassfish.api.admin.ServerEnvironment)2 DescriptorType (org.glassfish.hk2.api.DescriptorType)2