You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tamaya.apache.org by Anatole Tresch <at...@gmail.com> on 2016/01/28 00:42:11 UTC
What should be the result of accessing a single key in the
PropertySource SPI ?
Hi all
trying to extend the PropertyFilter by defining a FilterContext, an
additional possible constraint in our SPI was jumping in my face:
When I access the full map a PropertySource can return a Map (OK not much
surpising), which contains normal data, as well as possible metadata ,e.g.
a=b
_a.source=etcd:12.23.1.2:4001
_a.ttl=3235
_a.sensitivity=high
This is perfectl, since I can pass all entries starting with an '_' as
metadata entries to the FilterContext, which may use any kind of metadata
determining what filtering should be applied.
But in case of a single property access I cannot return additional data
from the SPI, since it is defined that only one key/value combination can
be returned:
String get(String key);
My first naive idea was to allow the PropertySource in the case above to
return a Map as well:
Map<String,String> get(String key);
But this would add significant overhead. Since we must create a new Map on
every key accessed.
An alternative would be to add an additional metadata-accessor to the
PropertySource:
/**
* Return the metadata for the given key, or for all
* keys provided by this PropertySource.
* @param key the key for which metadata should be acc * essed. If
null, metadata valid for all entries
* provided by this PropertySource, should be returned
* @return the metadata, never null.
*/
Map<String,String> getMetadata(String key);
WDYT?
Best,
Anatole
--
*Anatole Tresch*
Java Engineer & Architect, JSR Spec Lead
Glärnischweg 10
CH - 8620 Wetzikon
*Switzerland, Europe Zurich, GMT+1*
*Twitter: @atsticks*
*Blogs: **http://javaremarkables.blogspot.ch/
<http://javaremarkables.blogspot.ch/>*
*Google: atsticksMobile +41-76 344 62 79*
Re: What should be the result of accessing a single key in the
PropertySource SPI ?
Posted by "P. Ottlinger" <po...@apache.org>.
Am 28.01.2016 um 07:35 schrieb Romain Manni-Bucau:
> Not going with map but Value with the same spirit than the context sounds
> cleaner to me.
+1
We could wrap it in a Pair-like style
PropertyValue {
String value;
ContextData data;
}
API:
PropertyValue get(String key).
There could be ContextDataFactory methods to create special-purpose
contexts like
ContextDataFactory.private(String key) or
other special values like
ContextData NONE = emptyContextData
to ease the usage of it.
Cheers,
Phil
Re: What should be the result of accessing a single key in the
PropertySource SPI ?
Posted by Anatole Tresch <at...@gmail.com>.
Hi
+1 sounds good ;)
I will create related jiea issues lster for all things discussed so far, so
have clear documentation as well...
Anatole
Am 28.01.2016 07:35 schrieb "Romain Manni-Bucau" <rm...@gmail.com>:
> Hi Anatole
>
> Not going with map but Value with the same spirit than the context sounds
> cleaner to me.
>
> Regarding the overhead the Value can just be cached - and evicted when
> source is updating/updated.
> Le 28 janv. 2016 00:43, "Anatole Tresch" <at...@gmail.com> a écrit :
>
> > Hi all
> >
> > trying to extend the PropertyFilter by defining a FilterContext, an
> > additional possible constraint in our SPI was jumping in my face:
> >
> > When I access the full map a PropertySource can return a Map (OK not much
> > surpising), which contains normal data, as well as possible metadata
> ,e.g.
> >
> > a=b
> > _a.source=etcd:12.23.1.2:4001
> > _a.ttl=3235
> > _a.sensitivity=high
> >
> > This is perfectl, since I can pass all entries starting with an '_' as
> > metadata entries to the FilterContext, which may use any kind of metadata
> > determining what filtering should be applied.
> > But in case of a single property access I cannot return additional data
> > from the SPI, since it is defined that only one key/value combination can
> > be returned:
> >
> > String get(String key);
> >
> > My first naive idea was to allow the PropertySource in the case above to
> > return a Map as well:
> >
> > Map<String,String> get(String key);
> >
> > But this would add significant overhead. Since we must create a new Map
> on
> > every key accessed.
> >
> > An alternative would be to add an additional metadata-accessor to the
> > PropertySource:
> >
> > /**
> > * Return the metadata for the given key, or for all
> > * keys provided by this PropertySource.
> > * @param key the key for which metadata should be acc * essed. If
> > null, metadata valid for all entries
> > * provided by this PropertySource, should be returned
> > * @return the metadata, never null.
> > */
> > Map<String,String> getMetadata(String key);
> >
> > WDYT?
> >
> > Best,
> > Anatole
> >
> >
> >
> > --
> > *Anatole Tresch*
> > Java Engineer & Architect, JSR Spec Lead
> > Glärnischweg 10
> > CH - 8620 Wetzikon
> >
> > *Switzerland, Europe Zurich, GMT+1*
> > *Twitter: @atsticks*
> > *Blogs: **http://javaremarkables.blogspot.ch/
> > <http://javaremarkables.blogspot.ch/>*
> >
> > *Google: atsticksMobile +41-76 344 62 79*
> >
>
Re: What should be the result of accessing a single key in the
PropertySource SPI ?
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Anatole
Not going with map but Value with the same spirit than the context sounds
cleaner to me.
Regarding the overhead the Value can just be cached - and evicted when
source is updating/updated.
Le 28 janv. 2016 00:43, "Anatole Tresch" <at...@gmail.com> a écrit :
> Hi all
>
> trying to extend the PropertyFilter by defining a FilterContext, an
> additional possible constraint in our SPI was jumping in my face:
>
> When I access the full map a PropertySource can return a Map (OK not much
> surpising), which contains normal data, as well as possible metadata ,e.g.
>
> a=b
> _a.source=etcd:12.23.1.2:4001
> _a.ttl=3235
> _a.sensitivity=high
>
> This is perfectl, since I can pass all entries starting with an '_' as
> metadata entries to the FilterContext, which may use any kind of metadata
> determining what filtering should be applied.
> But in case of a single property access I cannot return additional data
> from the SPI, since it is defined that only one key/value combination can
> be returned:
>
> String get(String key);
>
> My first naive idea was to allow the PropertySource in the case above to
> return a Map as well:
>
> Map<String,String> get(String key);
>
> But this would add significant overhead. Since we must create a new Map on
> every key accessed.
>
> An alternative would be to add an additional metadata-accessor to the
> PropertySource:
>
> /**
> * Return the metadata for the given key, or for all
> * keys provided by this PropertySource.
> * @param key the key for which metadata should be acc * essed. If
> null, metadata valid for all entries
> * provided by this PropertySource, should be returned
> * @return the metadata, never null.
> */
> Map<String,String> getMetadata(String key);
>
> WDYT?
>
> Best,
> Anatole
>
>
>
> --
> *Anatole Tresch*
> Java Engineer & Architect, JSR Spec Lead
> Glärnischweg 10
> CH - 8620 Wetzikon
>
> *Switzerland, Europe Zurich, GMT+1*
> *Twitter: @atsticks*
> *Blogs: **http://javaremarkables.blogspot.ch/
> <http://javaremarkables.blogspot.ch/>*
>
> *Google: atsticksMobile +41-76 344 62 79*
>