Search in sources :

Example 26 with Contribute

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

the class JSONModule method provideCoercions.

/**
 * <ul>
 * <li>{@link String} to {@link org.apache.tapestry5.json.JSONObject}</li>
 * <li>{@link String} to {@link org.apache.tapestry5.json.JSONArray}</li>
 * </ul>
 * @param configuration the configuration to provide the type coercer to
 */
@Contribute(TypeCoercer.class)
public static void provideCoercions(MappedConfiguration<CoercionTuple.Key, CoercionTuple> configuration) {
    CoercionTuple<String, JSONObject> stringToJsonObject = CoercionTuple.create(String.class, JSONObject.class, new StringToJSONObject());
    configuration.add(stringToJsonObject.getKey(), stringToJsonObject);
    CoercionTuple<String, JSONArray> stringToJsonArray = CoercionTuple.create(String.class, JSONArray.class, new StringToJSONArray());
    configuration.add(stringToJsonArray.getKey(), stringToJsonArray);
}
Also used : StringToJSONObject(org.apache.tapestry5.internal.json.StringToJSONObject) StringToJSONObject(org.apache.tapestry5.internal.json.StringToJSONObject) JSONObject(org.apache.tapestry5.json.JSONObject) StringToJSONArray(org.apache.tapestry5.internal.json.StringToJSONArray) JSONArray(org.apache.tapestry5.json.JSONArray) StringToJSONArray(org.apache.tapestry5.internal.json.StringToJSONArray) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 27 with Contribute

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

the class AssetsModule method provideBuiltinAssetDispatchers.

/**
 * Contributes an handler for each mapped classpath alias, as well handlers for context assets
 * and stack assets (combined {@link org.apache.tapestry5.services.javascript.JavaScriptStack} files).
 */
@Contribute(Dispatcher.class)
@AssetRequestDispatcher
public static void provideBuiltinAssetDispatchers(MappedConfiguration<String, AssetRequestHandler> configuration, @ContextProvider AssetFactory contextAssetFactory, @Autobuild StackAssetRequestHandler stackAssetRequestHandler, ClasspathAssetAliasManager classpathAssetAliasManager, ResourceStreamer streamer, AssetSource assetSource, ClasspathAssetProtectionRule classpathAssetProtectionRule) {
    Map<String, String> mappings = classpathAssetAliasManager.getMappings();
    for (String folder : mappings.keySet()) {
        String path = mappings.get(folder);
        configuration.add(folder, new ClasspathAssetRequestHandler(streamer, assetSource, path, classpathAssetProtectionRule));
    }
    configuration.add(RequestConstants.CONTEXT_FOLDER, new ContextAssetRequestHandler(streamer, contextAssetFactory.getRootResource()));
    configuration.add(RequestConstants.STACK_FOLDER, stackAssetRequestHandler);
}
Also used : ContextAssetRequestHandler(org.apache.tapestry5.internal.services.assets.ContextAssetRequestHandler) ClasspathAssetRequestHandler(org.apache.tapestry5.internal.services.assets.ClasspathAssetRequestHandler) Contribute(org.apache.tapestry5.ioc.annotations.Contribute) AssetRequestDispatcher(org.apache.tapestry5.services.AssetRequestDispatcher)

Example 28 with Contribute

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

the class AssetsModule method configureStandardAssetFactories.

@Contribute(AssetSource.class)
public void configureStandardAssetFactories(MappedConfiguration<String, AssetFactory> configuration, @ContextProvider AssetFactory contextAssetFactory, @ClasspathProvider AssetFactory classpathAssetFactory) {
    configuration.add(AssetConstants.CONTEXT, contextAssetFactory);
    configuration.add(AssetConstants.CLASSPATH, classpathAssetFactory);
    configuration.add(AssetConstants.HTTP, new ExternalUrlAssetFactory(AssetConstants.HTTP));
    configuration.add(AssetConstants.HTTPS, new ExternalUrlAssetFactory(AssetConstants.HTTPS));
    configuration.add(AssetConstants.FTP, new ExternalUrlAssetFactory(AssetConstants.FTP));
    configuration.add(AssetConstants.PROTOCOL_RELATIVE, new ExternalUrlAssetFactory(AssetConstants.PROTOCOL_RELATIVE));
}
Also used : ExternalUrlAssetFactory(org.apache.tapestry5.internal.services.ExternalUrlAssetFactory) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 29 with Contribute

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

the class JpaModule method provideApplicationStateContributions.

@Contribute(ApplicationStateManager.class)
public static void provideApplicationStateContributions(final MappedConfiguration<Class, ApplicationStateContribution> configuration, final EntityManagerSource entityManagerSource, @Symbol(JpaSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED) final boolean entitySessionStatePersistenceStrategyEnabled) {
    if (!entitySessionStatePersistenceStrategyEnabled)
        return;
    for (final PersistenceUnitInfo info : entityManagerSource.getPersistenceUnitInfos()) {
        final EntityManagerFactory emf = entityManagerSource.getEntityManagerFactory(info.getPersistenceUnitName());
        final Metamodel metamodel = emf.getMetamodel();
        for (EntityType<?> entity : metamodel.getEntities()) {
            configuration.add(entity.getJavaType(), new ApplicationStateContribution(JpaPersistenceConstants.ENTITY));
        }
    }
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) PersistenceUnitInfo(javax.persistence.spi.PersistenceUnitInfo) Metamodel(javax.persistence.metamodel.Metamodel) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 30 with Contribute

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

the class JpaModule method provideValueEncoders.

@Contribute(ValueEncoderSource.class)
public static void provideValueEncoders(final MappedConfiguration<Class, ValueEncoderFactory> configuration, @Symbol(JpaSymbols.PROVIDE_ENTITY_VALUE_ENCODERS) final boolean provideEncoders, final EntityManagerSource entityManagerSource, final EntityManagerManager entityManagerManager, final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource) {
    if (!provideEncoders)
        return;
    for (final PersistenceUnitInfo info : entityManagerSource.getPersistenceUnitInfos()) {
        final EntityManagerFactory emf = entityManagerSource.getEntityManagerFactory(info.getPersistenceUnitName());
        final Metamodel metamodel = emf.getMetamodel();
        for (final EntityType<?> entity : metamodel.getEntities()) {
            final Class<?> javaType = entity.getJavaType();
            final ValueEncoderFactory factory = new ValueEncoderFactory() {

                @Override
                public ValueEncoder create(final Class type) {
                    return new JpaValueEncoder(entity, entityManagerManager, info.getPersistenceUnitName(), propertyAccess, typeCoercer, loggerSource.getLogger(javaType));
                }
            };
            configuration.add(javaType, factory);
        }
    }
}
Also used : JpaValueEncoder(org.apache.tapestry5.internal.jpa.JpaValueEncoder) EntityManagerFactory(javax.persistence.EntityManagerFactory) PersistenceUnitInfo(javax.persistence.spi.PersistenceUnitInfo) Metamodel(javax.persistence.metamodel.Metamodel) ValueEncoderFactory(org.apache.tapestry5.services.ValueEncoderFactory) 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