Christian, > That's very good (and fast implemented). But do you realy have to do the > double-check on the class. I mean the user sees anyway what class it is > from the JavaDoc and HiveMind will always check that it fits the Service > interface. > > Sure if the static field changes this ensures consistency, but on the other > hand it would be also very convient to change all services referenced but > just changing the static field without the need to go into the module. >
It is not really required, but somehow I was reluctant to change the class attribute to an optional attribute. At first I thought that using both the attributes "class" and "static-field" would be the best solution, but then I decided to make the two attributes mutually exclusive, which of course requires the "static-field" attribute to specify a fully qualified field name, but I'm still unsure. I could of course also have used the same syntax as in Javadoc, i.e. a # to delimit the field from the class. I was hoping someone on the mailing list would have an insightful opinion on this. Of course this could be taken further to also encompass static methods (with parameters?). Maybe these additions would also make sense to <create-instance> and <create-object>. If the developers feel like this would be a meaningful addition to the HiveMind framework I'd be happy to make a contribution. --knut > > On Wed, 1 Oct 2003 12:40:12 +0200, Knut Wannheden > <[EMAIL PROTECTED]> wrote: > > > I have created a copy of the hivemind.BuilderFactory service which allows > > me > > to write: > > > > <invoke-factory service-id="my.BuilderFactory"> > > <construct class="foo.Bar" static-field="foo.Bar.INSTANCE"/> > > </invoke-factory> > > > > given that I have something like: > > > > package foo; > > public interface Bar { > > static final INSTANCE = new BarImpl(); > > } > > > > The class attribute is used to check that the object specified by the > > static-field is of a given type, which is an interface in this example. > > > > --knut > > > >> That's certainly a good idea. > >> > >> On Wed, 1 Oct 2003 07:50:42 +0200, Knut Wannheden > >> <[EMAIL PROTECTED]> wrote: > >> > >> > Hi, > >> > > >> > I was wondering whether it would make sense to extend the BuildFactory > >> > service (or maybe add a new wervice) to also be able to construct > > objects > >> > by > >> > returning the value of a classes static field or by calling a static > >> > method > >> > on a class. The former would obviously be simpler. E.g. (as a new > >> > service): > >> > > >> > <invoke-factory service-id="hivemind.StaticBuilderFactory"> > >> > <construct class="foo.Bar" static-field="BAZ"> > >> > <set.../> > >> > </construct> > >> > </invoke-factory> > >> > > >> > --knut > >> > > >> > > >> > > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [EMAIL PROTECTED] > >> > For additional commands, e-mail: [EMAIL PROTECTED] > >> > > >> > >> > >> > >> -- Using M2, Opera's revolutionary e-mail client: > >> http://www.opera.com/m2/ > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]