Thank you,

In my case, MapConfig contributions can be reduced to HazelcastConfigurer
contributions (and now I see I should have used the latter from the start)
so (to avoid many refactorings) I created another service that converts
MapConfig contributions to a HazelcastConfigurer.

public class MapConfigServiceImpl implements MapConfigService
{
private final Collection<MapConfig> mapConfigs;
 private final Logger logger;

 public MapConfigServiceImpl(Collection<MapConfig> mapConfigs, Logger
logger)
 {
this.mapConfigs = mapConfigs;
 this.logger = logger;
}

@Override
 public HazelcastConfigurer getHazelcastConfigurer()
{
 return new HazelcastConfigurer()
{
 @Override
public void configure(Config config)
 {
for (MapConfig mapConfig : mapConfigs)
 {
logger.info("Configuring map: " + mapConfig.getName());
 config.addMapConfig(mapConfig);
}
 }
};
 }
}


And in the module:

@Contribute(HazelcastConfigService.class)
 public static void contributeConfigurerForMapConfigs(
MapConfigService mapConfigService,
 Configuration<HazelcastConfigurer> hzConfigurers)
{
 hzConfigurers.add( mapConfigService.getHazelcastConfigurer() );
}



On Tue, Jun 4, 2013 at 12:50 PM, Ferran Maylinch
<ferranmayli...@gmail.com>wrote:

> Hello,
>
> I would like to contribute 2 collections to a service, but I am afraid
> Tapestry only supports one collection to be contributed. Am I right?
>
> My service constructor is like this:
>
> public HazelcastConfigServiceImpl(
>  final Collection<MapConfig> mapConfigs,
> final Collection<HazelcastConfigurer> hzConfigurers) { ... }
>
> And I try to contribute the hzConfigurers this way:
>
> @Contribute(HazelcastConfigService.class)
>  public static void
> contributeExecutorConfig(Configuration<HazelcastConfigurer> hzConfigurers)
>  {
> hzConfigurers.add(new HazelcastConfigurer()
>  {
> @Override
>  public void configure(Config config)
> {
>  config.addExecutorConfig(
> new ExecutorConfig(RankingsConstants.RANKINGS_EXECUTOR_SERVICE_NAME)
>  .setCorePoolSize(5)
> .setMaxPoolSize(5)
>  );
> }
>  });
> }
>
> But I get this exception:
>
> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could not
> find a coercion from type
> com.mobivery.malcom.categories.rankings.workers.services.MalcomRankingsWorkersModule$1
> to type com.hazelcast.config.MapConfig.
>
> It seems it is trying to insert my HazelcastConfigurer into
> the mapConfigs when it should go to the hzConfigurers.
>
> Thank you
>
> -- Ferran
>

Reply via email to