|
From: Tom T. <tom...@pr...> - 2004-04-24 21:47:57
|
Colin, In our project, we have some common functionality that's developed separately and included as a jar file, so I've been thinking about this as well. As the common beans are usually defined in the app's own xml file, however, you can use the regular alias functionality: <bean id="myDataSource" name="com.whatever.componenta.dataSource,com.something.componentb.dataSource" class="..."> ... </bean> The standalone alias functionality would only be needed if you wanted to make a bean of component A available with a different name to component B. I don't think that's a common scenario... Best regards, Tom. On Fri, 23 Apr 2004 09:08:05 -0400, "Colin Sampaleanu" <col...@ex...> said: > I've been thinking about how you would go about assembling multiple > spring-enabled components from different sources. Consider component A > and component B: both ship with an internal application context > definition file, which defines the beans they work with, and ideally > doesn't have to be changed at all, just used as one of the definition > files making up a complete appContext. But both need to use a dataSource > to feed to other beans. They could define the datasource themselves, but > then you would have to to modify the config (or use an externaal > property file), and the same data would have to be configured in a > number of places. They could also just use a common bean name like > dataSource, but then you have the problem that that name may conflict > with another unrelated bean. > > So I think if a component is realistically going to be used by a 3rd > party, it needs to name its beans in its appcontext with something like > package unique ids. Then all that is needed is a way to map a component > specific bean id to another id. > > So I propose we add the concept of a standalone alias to the > BeanFactory/AppContext. In the xml variants, it would be a top level > <alias> element or something similar, and all it would do would provide > an alias for an existing bean name. > > So component a for example would refer to the datasource as: > com.whatever.componenta.dataSource > and component b woudl use for example: > com.something.componentb.dataSource > > Now the app using these components would use a multi-file appcontext > definition where two of the files come from the respective components, > and one file is for the app itself, and in that it would provide aliases > so the datasource can be found. > > <alias from="com.whatever.componenta.dataSource" to="myDataSource"/> > <alias from="com.something.componentb.dataSource" to="myDataSource"/> > > I think this is relatively trivial to implement, and would be pretty > useful in these kinds of situations. > > What do you guys think? > > Regards, > Colin > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek > For a limited time only, get FREE Ground shipping on all orders of $35 > or more. Hurry up and shop folks, this offer expires April 30th! > http://www.thinkgeek.com/freeshipping/?cpg=12297 > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |