Search in sources :

Example 1 with Contribute

use of org.apache.tapestry5.ioc.annotations.Contribute in project flowlogix by flowlogix.

the class ServicesModule method provideClassTransformWorkers.

@Contribute(ComponentClassTransformWorker2.class)
@Primary
public static void provideClassTransformWorkers(OrderedConfiguration<ComponentClassTransformWorker2> configuration) {
    configuration.addInstance("AJAX", AjaxAnnotationWorker.class, "before:Property");
    configuration.add("DisableAfterSubmit", new MixinAdderWorker(Submit.class, AutoDisableAfterSubmit.class), "after:AJAX");
    configuration.add("ZoneColorHighlight", new MixinAdderWorker(Zone.class, AutoZoneColorHighlight.class), "after:AJAX");
}
Also used : MixinAdderWorker(com.flowlogix.web.services.internal.MixinAdderWorker) Zone(org.apache.tapestry5.corelib.components.Zone) AutoZoneColorHighlight(com.flowlogix.web.mixins.AutoZoneColorHighlight) AutoDisableAfterSubmit(com.flowlogix.web.mixins.AutoDisableAfterSubmit) Submit(org.apache.tapestry5.corelib.components.Submit) AutoDisableAfterSubmit(com.flowlogix.web.mixins.AutoDisableAfterSubmit) Primary(org.apache.tapestry5.ioc.annotations.Primary) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 2 with Contribute

use of org.apache.tapestry5.ioc.annotations.Contribute in project tapestry-5 by apache.

the class AppModule method setupCustomBaseURLSource.

@Contribute(ServiceOverride.class)
public void setupCustomBaseURLSource(MappedConfiguration<Class, Object> configuration) {
    BaseURLSource source = new BaseURLSource() {

        public String getBaseURL(boolean secure) {
            String protocol = secure ? "https" : "http";
            // This is all a bit jury-rigged together. This is for running the app
            // interactively; Selenium doesn't seem to handle the transition to https.
            int port = secure ? 8443 : 9090;
            return String.format("%s://localhost:%d", protocol, port);
        }
    };
    configuration.add(BaseURLSource.class, source);
}
Also used : BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 3 with Contribute

use of org.apache.tapestry5.ioc.annotations.Contribute in project tapestry-5 by apache.

the class AppModule method configurePersistenceUnitInfos.

@Contribute(EntityManagerSource.class)
public static void configurePersistenceUnitInfos(final MappedConfiguration<String, PersistenceUnitConfigurer> configuration) {
    final PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {

        @Override
        public void configure(final TapestryPersistenceUnitInfo unitInfo) {
            unitInfo.addManagedClass(User.class);
        }
    };
    configuration.add(AppConstants.TEST_PERSISTENCE_UNIT, configurer);
    final PersistenceUnitConfigurer configurer2 = new PersistenceUnitConfigurer() {

        @Override
        public void configure(final TapestryPersistenceUnitInfo unitInfo) {
            unitInfo.addProperty("javax.persistence.jdbc.driver", "org.h2.Driver").addProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:test").addProperty("eclipselink.ddl-generation", "create-tables").addProperty("eclipselink.logging.level", "fine").addManagedClass(Thang.class);
        }
    };
    configuration.add(AppConstants.TEST_PERSISTENCE_UNIT_2, configurer2);
}
Also used : PersistenceUnitConfigurer(org.apache.tapestry5.jpa.PersistenceUnitConfigurer) TapestryPersistenceUnitInfo(org.apache.tapestry5.jpa.TapestryPersistenceUnitInfo) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 4 with Contribute

use of org.apache.tapestry5.ioc.annotations.Contribute in project tapestry-5 by apache.

the class PageTesterModule method setupTestableOverrides.

@Contribute(ServiceOverride.class)
public static void setupTestableOverrides(MappedConfiguration<Class, Object> configuration, @Local TestableRequest request, @Local TestableResponse response, final ObjectLocator locator) {
    configuration.add(Request.class, request);
    configuration.add(Response.class, response);
    TestableCookieSinkSource cookies = new TestableCookieSinkSource();
    configuration.add(CookieSink.class, cookies);
    configuration.add(CookieSource.class, cookies);
    // With the significant changes to the handling of assets in 5.4, we introduced a problem:
    // We were checking at page render time whether to generate URLs for normal or compressed
    // assets and that peeked at the HttpServletRequest global, which isn't set up by PageTester.
    // What we're doing here is using a hacked version of that code to force GZip support
    // on.
    configuration.add(ResponseCompressionAnalyzer.class, new ResponseCompressionAnalyzer() {

        public boolean isGZipEnabled(ContentType contentType) {
            return locator.getObject(CompressionAnalyzer.class, null).isCompressable(contentType.getMimeType());
        }

        public boolean isGZipSupported() {
            return true;
        }
    });
}
Also used : ContentType(org.apache.tapestry5.http.ContentType) ResponseCompressionAnalyzer(org.apache.tapestry5.http.services.ResponseCompressionAnalyzer) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 5 with Contribute

use of org.apache.tapestry5.ioc.annotations.Contribute in project tapestry-5 by apache.

the class SpringModule method reportSpringContextDetailsAtStartup.

@Contribute(ApplicationInitializer.class)
@Primary
public void reportSpringContextDetailsAtStartup(OrderedConfiguration<ApplicationInitializerFilter> configuration, final ApplicationContext springContext) {
    ApplicationInitializerFilter filter = new ApplicationInitializerFilter() {

        @Override
        public void initializeApplication(Context context, ApplicationInitializer initializer) {
            logger.info(String.format("Spring version %s with %,d defined beans.", SpringVersion.getVersion(), springContext.getBeanDefinitionCount()));
            initializer.initializeApplication(context);
        }
    };
    configuration.add("SpringContextInitialization", filter);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) ServletContext(javax.servlet.ServletContext) Context(org.apache.tapestry5.http.services.Context) ApplicationInitializer(org.apache.tapestry5.http.services.ApplicationInitializer) ApplicationInitializerFilter(org.apache.tapestry5.http.services.ApplicationInitializerFilter) Primary(org.apache.tapestry5.ioc.annotations.Primary) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Aggregations

Contribute (org.apache.tapestry5.ioc.annotations.Contribute)28 Primary (org.apache.tapestry5.ioc.annotations.Primary)4 PersistenceUnitConfigurer (org.apache.tapestry5.jpa.PersistenceUnitConfigurer)4 TapestryPersistenceUnitInfo (org.apache.tapestry5.jpa.TapestryPersistenceUnitInfo)4 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 Metamodel (javax.persistence.metamodel.Metamodel)2 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)2 ServletContext (javax.servlet.ServletContext)2 BooleanHook (org.apache.tapestry5.BooleanHook)2 MarkupWriter (org.apache.tapestry5.MarkupWriter)2 Resource (org.apache.tapestry5.commons.Resource)2 DocumentLinker (org.apache.tapestry5.internal.services.DocumentLinker)2 JavaScriptSupportImpl (org.apache.tapestry5.internal.services.ajax.JavaScriptSupportImpl)2 MessageCatalogResource (org.apache.tapestry5.internal.util.MessageCatalogResource)2 JSONObject (org.apache.tapestry5.json.JSONObject)2 PartialMarkupRenderer (org.apache.tapestry5.services.PartialMarkupRenderer)2 PartialMarkupRendererFilter (org.apache.tapestry5.services.PartialMarkupRendererFilter)2 ConfigurableWebApplicationContext (org.springframework.web.context.ConfigurableWebApplicationContext)2 AutoDisableAfterSubmit (com.flowlogix.web.mixins.AutoDisableAfterSubmit)1 AutoZoneColorHighlight (com.flowlogix.web.mixins.AutoZoneColorHighlight)1