|
From: Martin K. <Mar...@St...> - 2005-02-21 20:13:18
|
Hi developers,
I am still dreaming about Spring supporting contributions
right out of the box. I posted an article in the architectural section
of the forum. I guess I found a quite good and sound implementation.
This is the short form:
1. new contribution tag features the same things bean also does.
<contribution extension-point="extensionPoint id" class="MyClass">
same as bean
</contribution>
2. A extension point is constructed by the application hosting it.
type ExtensionPoint {
//nothing just for identification
//maybe hidden storing of the extension point id for semantic equal
checking
}
3. Add support to the ApplicationContext for pulling the contributions
Object [] successfullInstanciatedContributions=
ApplicationContext.instanciateContributions(ExtensionPoint,
ExtensionPointPolicy);
4. ExtensionPointPolicy is about finishing the init process of a
contribution
since some not hardwired dependencies have to be set by the stakeholder
of the contribution and can not be described within the contribution
definition.
type ExtensionPointPolicy {
boolean isCompatibleContribution(ContributionDefinition);
injectAdditionalDependecies(Object contributionInstance);
}
So loading contributed toolbar actions may look like this:
MyApplication.loadToolBarActions{
Object [] toolBarActions=
applicationContext.instanciateContributions(toolbarActionsExtensionPoint,
new ToolBarActionsExtensionPointPolicy());
}
private class ToolBarActionsExtensionPointPolicy
implements ExtensionPointPolicy {
boolean isCompatibleContribution(ContributionDefinition) {
Class
contributionalType=contributionDefinition.getContributionType();
return contributionalType.isCompatible(ToolBarAction.class);
//no additional checking in this example
}
injectAdditionalDependencies(Object contributionInstance) {
((ToolBarAction)contributionInstance).setEnabled(true); //just to
be scenceless
}
}
Thats all. I guess this can be added quite cleanly. And I would enjoy doing
it myself :-).
It would provide great help I guess. The Spring RPC currently suffering
of the lack of defining contributions and using an extension point
mechanism.
All is described in more detail within the forum article.
Cheers,
Martin (Kersten)
----- Original Message -----
From: "Jean-Philippe Gariepy" <ga...@ya...>
To: <spr...@li...>
Sent: Monday, February 21, 2005 4:47 PM
Subject: RE: [Springframework-developer] Custom bean instantiation language?
>
> I choose the { and } characters for the lists and [ ] for the maps.
>
> So instead of...
>
> <bean id="myBean" class="example.MyClass">
> <property name="someList">
> <list>
> <value>item value</value>
> <ref bean="beanReference"/>
> </list>
> </property>
>
> <property name="someMap">
> <map>
> <entry key="key1">
> <value>value1</value>
> </entry>
> <entry key="key2">
> <value>value2</value>
> </entry>
> </map>
> </property>
> </bean>
>
> ...I have...
>
> <myBean class="example.MyClass">
> <someList>{item value, @beanReference}</someList>
> <someMap>[key1=value1, key2=value2]</someMap>
> </myBean>
>
> Note that I've allowed bean references to be keys. Hence, the following
> is
> legal:
>
> <myBean class="example.MyClass">
> <someList>{item value, @beanReference}</someList>
> <someMap>[@beanReference=value1, key2=value2]</someMap>
> </myBean>
>
> Of course, when a meta-character (@ , [ ] { } =) is part of the key or
> value,
> an escape character is required:
>
> <myBean class="example.MyClass">
> <emailAddresses>{user1\@domain1.com, user2\@domain2.com}</emailAddresses>
> </myBean>
>
> Jean-Philippe
>
> --- Cameron Braid <ca...@br...> wrote:
>
>> > -----Original Message-----
>> > From: spr...@li...
>> > [mailto:spr...@li...] On
>> > Behalf
>> > Of Jean-Philippe Gariepy
>> > Sent: Monday, 21 February 2005 12:29 PM
>> > To: spr...@li...
>> > Subject: Re: [Springframework-developer] Custom bean instantiation
>> > language?
>> >
>> > (This is an opportunity for me to share my thoughts about the bean
>> > factory.)
>>
>> --SNIP--
>>
>> > I've added other lightweight syntaxes for lists and maps.
>> >
>>
>> Can you please share them too. I like the look of this :)
>>
>>
>> Thanks,
>>
>> Cameron
>>
>
>
> =====
> ---------------------------------------
> Jean-Philippe Gariépy (ga...@ya...)
>
> "Quand l'appétit va, tout va."
> -Obélix
>
>
>
> __________________________________
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
> http://promotions.yahoo.com/new_mail
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|