Re: [xwiki-devs] [xwiki-notifications] r20119 - platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest
On May 19, 2009, at 7:52 PM, fmancinelli (SVN) wrote:
Author: fmancinelli Date: 2009-05-19 19:52:09 +0200 (Tue, 19 May 2009) New Revision: 20119
Modified: platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/ ComponentsObjectFactory.java Log: [Minor] Use component descriptors in order to check whether a component has a PER_LOOKUP instantiation strategy.
Modified: platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/ rest/ComponentsObjectFactory.java =================================================================== --- platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/ ComponentsObjectFactory.java 2009-05-19 17:47:18 UTC (rev 20118) +++ platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/ ComponentsObjectFactory.java 2009-05-19 17:52:09 UTC (rev 20119) @@ -25,6 +25,7 @@ import org.restlet.ext.jaxrs.InstantiateException; import org.restlet.ext.jaxrs.ObjectFactory; import org.xwiki.component.annotation.InstantiationStrategy; +import org.xwiki.component.descriptor.ComponentDescriptor; import org.xwiki.component.descriptor.ComponentInstantiationStrategy; import org.xwiki.component.manager.ComponentLookupException; import org.xwiki.component.manager.ComponentManager; @@ -65,6 +66,8 @@ XWikiRestComponent component = (XWikiRestComponent) componentManager.lookup(XWikiRestComponent.class, clazz.getName());
+ ComponentDescriptor componentDescriptor = componentManager.getComponentDescriptor(XWikiRestComponent.class, clazz.getName()); + /* * Retrieve the releasable component list from the context. This is used to store component instances that * need to be released later. @@ -79,11 +82,8 @@ }
/* Only add components that have a per-lookup instantiation stategy. */ - InstantiationStrategy is = component.getClass().getAnnotation(InstantiationStrategy.class); - if (is != null) { - if (is.value().equals(ComponentInstantiationStrategy.PER_LOOKUP)) { - releasableComponentReferences.add(component); - } + if (componentDescriptor .getInstantiationStrategy ().equals(ComponentInstantiationStrategy.PER_LOOKUP)) {
you could write: if (componentDescriptor.getInstantiationStrategy() == ComponentInstantiationStrategy.PER_LOOKUP) -Vincent
+ releasableComponentReferences.add(component); }
/*
On May 19, 2009, at 8:09 PM, Vincent Massol wrote:
+ if (componentDescriptor .getInstantiationStrategy ().equals(ComponentInstantiationStrategy.PER_LOOKUP)) {
you could write:
if (componentDescriptor.getInstantiationStrategy() == ComponentInstantiationStrategy.PER_LOOKUP)
Right :) Thanks. Fabio
participants (2)
-
Fabio Mancinelli -
Vincent Massol