Your question is a bit general. There are places in my applications, and in the framework, where the same code operates with different configurations.
Remember that in Tapestry IoC, you can instantiate ordinary objects, not just services. You can let Tapestry do it for you, and it will take care of injecting dependencies into an instance of your class. The main difference between an ordinary object and a service: - Services have a unique id that can be used to identify them for injection elsewhere via @InjectService (this is no longer recommended) - Services are lazily initialized (but objects can be as well, as long as Tapestry knows what interface to use as a proxy) - Services may have a configuration - Services may have an alternate life cycle (such as per-thread) - Services may be decorated - Service methods may be advised As an example, take the BindingFactory interface; in Tapestry, every prefix ("prop:", "message:", "literal:", "component:", etc.) maps to an instance of BindingFactory. Some of these instances are full services, some are objects with dependencies, some are simple objects (actually, this is no longer true; they are now almost all full services, but that's just to make it easier to override their behavior ... and that's only because MappedConfiguration.override() is relatively new ... but I digress). So how do you have multiple objects with the same interface? The BindingFactory instances are contributed to the BindingSource service, each given a unique name. The BindingSource doesn't otherwise know the differences between them, and that's as should be. So in your case, if you have multiple objects running at the same time with different configurations (but the same instance) you are in good shape, following a similar pattern. Or, if you just need a single service with a different configuration based on some environmental factors, then you can create your own buildService() method and decide what configuration to supply. That is, provide a Service Builder method that can use Java code to decide what to instantiate and configure; see http://tapestry.apache.org/tapestry-ioc-modules.html The bind() method (and ServiceBinder) was an optimization added later, that simply makes it easier to handle the standard case of an interface/implementation combo that Tapestry instantiates and initializes. On Fri, Feb 3, 2012 at 9:54 AM, Thiago H. de Paula Figueiredo <thiag...@gmail.com> wrote: > On Fri, 03 Feb 2012 14:24:35 -0200, Erik Fäßler <erik.faess...@uni-jena.de> > wrote: > >> I thought of the component to become a IoC module. But I fear, modules are >> kind of static, too - I can't have different "instances" of a module, can >> I?Point is, all configuration parameters defined in a module are global as >> far as I know. This would be just like the static configuration class I have >> problems with. > > > Not of the same module, but you can always have multiple services wrapping > around some data (in this case, configuration) and have this services allow > changing the configuration on the fly. > > >> Is there a convenient way to deal with such situations? Or am I just >> failing the design goal of Tapestry's IoC container here? I would like to >> use the IoC container to manage the parts of my component and would regret >> when this would not be possible due to my multiple-deployment requirement. > > > Don't forget you can have different JARs with different module classes > providing different implementations for the same service interface. This is > not a problem at all. You can even define a given module will be loader or > not through system properties. Check the documentation. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and > instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org