[Design the new POJO MicroContainer] - Re: Annotation processing
by alesj
"alesj" wrote :
| Perhaps put in in the MetaData under 'ControllerContext.name' name?
| And push in/out this info in KernelControllerContextAction.dispatchJoinPoint invocation?
| Or just simply put in in for good when we first create MetaData for context - in PreInstallAction?
Is doing this too hacky?
| protected void addMetaData(MutableMetaDataRepository repository, ControllerContext context, MemoryMetaDataLoader mutable)
| {
| mutable.addMetaData(ControllerContext.class.getSimpleName() + ".name", context.getName(), Object.class);
| }
|
| ...
|
| Object name = metaData.getMetaData("ControllerContext.name");
| if (name == null)
| return false;
|
| ScopeKey instanceKey = new ScopeKey(CommonLevels.INSTANCE, name.toString());
|
|
I'm passing all tests with this new getScopeMetaData/isEmpty impl. :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080912#4080912
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080912
16 years, 8 months
[Design the new POJO MicroContainer] - Re: Annotation processing
by alesj
"alesj" wrote :
| OK, I'll then put the getScopeMetaData/isEmpty ugliness into RetrievalBridge. :-)
| public MetaData getScopeMetaData(ScopeKey scopeKey)
| {
| if (scopeKey == null)
| throw new IllegalArgumentException("Null scope key");
|
| if (retrieval instanceof MetaDataContext)
| {
| MetaDataContext context = (MetaDataContext)retrieval;
| List<MetaDataRetrieval> matchingRetrievals = new ArrayList<MetaDataRetrieval>();
| List<MetaDataRetrieval> localRetrievals = context.getLocalRetrievals();
| for (MetaDataRetrieval localRetrieval : localRetrievals)
| {
| if (scopeKey.equals(localRetrieval.getScope()))
| matchingRetrievals.add(localRetrieval);
| }
| if (matchingRetrievals.isEmpty() == false)
| return new MetaDataRetrievalToMetaDataBridge(new AbstractMetaDataContext(context, matchingRetrievals));
| }
| else if (scopeKey.equals(retrieval.getScope()))
| return new MetaDataRetrievalToMetaDataBridge(new AbstractMetaDataContext(retrieval));
| return null;
| }
|
| public boolean isEmpty()
| {
| return retrieval.isEmpty();
| }
|
This is what I've pushed in (also added MetaDataRetrieval.isEmpty()). I think it should do the trick.
But if I want to remove the hack with joinpoint being ControllerContext aware, I need to get the context's name from somewhere.
| ScopeKey instanceKey = new ScopeKey(CommonLevels.INSTANCE, "<context_name>");
| MetaData instanceMetaData = metaData.getScopeMetaData(instanceKey);
| if (instanceMetaData != null && instanceMetaData.isEmpty() == false)
| {
| return true;
| }
|
Perhaps put in in the MetaData under 'ControllerContext.name' name?
And push in/out this info in KernelControllerContextAction.dispatchJoinPoint invocation?
Or just simply put in in for good when we first create MetaData for context - in PreInstallAction?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080904#4080904
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080904
16 years, 8 months
[Design the new POJO MicroContainer] - Re: Annotation processing
by adrian@jboss.org
"alesj" wrote :
| No.
| I mean that referencing MetaDataContext in MetaDataRetrievalToMetaDataBridge via 'instance of' is not what I would consider good OO. Specially with a name yelling out the purpose - Retrieval bridge ... not Context bridge. :-)
|
I agree, but the MetaData was never originally designed to retrieve structure
which is what MetaDataContext adds to the retrievals.
i.e. MetaDataRetrieval instanceof MetaDataContext == isRetrievalStructured()
The MetaData is actually designed to hide the structure so the client doesn't have to know
about it, i.e. it does not (need to) know what hierarchical scopes are linking retrievals together.
Its only this AOP requirement/optimization to ask if there is any instance metadata
(and only create a proxy if there is) that introduces the need to know structure.
Maybe we should leave it as the simple hasInstanceMetaData() on the MetaData api
and forget about revealing structure through an api that wasn't designed for it?
But you're still going to need to do the ugliness inside the bridge either way.
It's still better to have the ugliness hidden inside MetaData than
have AOP + others trying to play with things they almost certainly don't understand. :-)
I have similar thoughts about some of the code I did for the
ScopeInfo/ScopeBuilder which virtually duplicate the same code
to initialize non-existant scopes.
It would be much better to hide the ugliness inside the metadata api.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080876#4080876
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080876
16 years, 8 months
[Design the new POJO MicroContainer] - Re: Annotation processing
by alesj
"adrian(a)jboss.org" wrote : If you want me to do it then I will, but don't ask to write all the code in the forum. :-)
|
I think this is the first attempt of somebody else then you writing anything to do with metadata. So I guess it's only fair to ask you before. :-)
"adrian(a)jboss.org" wrote :
|
| | public interface MetaDataContext extends MetaDataRetrieval
| |
| | AND
| |
| | /**
| | * Create a new AbstractMetaDataContext.
| | *
| | * @param parent the parent
| | * @param retrievals the retrievals
| | */
| | public AbstractMetaDataContext(MetaDataContext parent, List<MetaDataRetrieval> retrievals)
| |
|
Hmmm, I think I'm able to see the MetaDataContext extends MetaDataRetrieval. And looking at the impl's constructor. ;-)
"adrian(a)jboss.org" wrote : If you mean it isn't a MetaDataContext in the first place,
|
No.
I mean that referencing MetaDataContext in MetaDataRetrievalToMetaDataBridge via 'instance of' is not what I would consider good OO. Specially with a name yelling out the purpose - Retrieval bridge ... not Context bridge. :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080871#4080871
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080871
16 years, 8 months