Hey Martin,

DependentProvider.get() just returns a field value and so is just a simple
getter:

https://github.com/apache/deltaspike/blob/3d7c3804b96f6b63c139568bf3c6a497429090b3/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/DependentProvider.java#L57-61

Therefore I think there is no real benefit of assigning the result to a
local variable. I prefer the current version especially it is easier to
read the code this way.

Christian


2015-05-28 21:55 GMT+02:00 Martin Grigorov <[email protected]>:

> Hi,
>
> On Thu, May 28, 2015 at 6:06 PM, <[email protected]> wrote:
>
> > Repository: deltaspike
> > Updated Branches:
> >   refs/heads/master 1238dbaee -> e5b436922
> >
> >
> > DELTASPIKE-913 QuartzScheduler should use BeanProvider.getDependent()
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/deltaspike/commit/e5b43692
> > Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/e5b43692
> > Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/e5b43692
> >
> > Branch: refs/heads/master
> > Commit: e5b436922e61046ca33390e85f2f64c9171a8fc1
> > Parents: 1238dba
> > Author: Christian Kaltepoth <[email protected]>
> > Authored: Thu May 28 10:09:11 2015 +0200
> > Committer: Christian Kaltepoth <[email protected]>
> > Committed: Thu May 28 10:09:11 2015 +0200
> >
> > ----------------------------------------------------------------------
> >  .../apache/deltaspike/scheduler/impl/QuartzScheduler.java | 10
> ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e5b43692/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/QuartzScheduler.java
> > ----------------------------------------------------------------------
> > diff --git
> >
> a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/QuartzScheduler.java
> >
> b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/QuartzScheduler.java
> > index 587acf6..8ef3cc2 100644
> > ---
> >
> a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/QuartzScheduler.java
> > +++
> >
> b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/QuartzScheduler.java
> > @@ -20,6 +20,7 @@ package org.apache.deltaspike.scheduler.impl;
> >
> >  import org.apache.deltaspike.cdise.api.ContextControl;
> >  import org.apache.deltaspike.core.api.provider.BeanProvider;
> > +import org.apache.deltaspike.core.api.provider.DependentProvider;
> >  import org.apache.deltaspike.core.util.ClassUtils;
> >  import org.apache.deltaspike.core.util.ExceptionUtils;
> >  import org.apache.deltaspike.core.util.PropertyFileUtils;
> > @@ -419,7 +420,7 @@ public class QuartzScheduler implements
> Scheduler<Job>
> >      private class JobListenerContext
> >      {
> >          private Stack<Class<? extends Annotation>> scopes = new
> > Stack<Class<? extends Annotation>>();
> > -        private ContextControl contextControl;
> > +        private DependentProvider<ContextControl> contextControl;
> >
> >          public void startContexts(Scheduled scheduled)
> >          {
> > @@ -427,11 +428,11 @@ public class QuartzScheduler implements
> > Scheduler<Job>
> >
> >              if (!this.scopes.isEmpty())
> >              {
> > -                this.contextControl =
> > BeanProvider.getContextualReference(ContextControl.class);
> > +                this.contextControl =
> > BeanProvider.getDependent(ContextControl.class);
> >
> >                  for (Class<? extends Annotation> scopeAnnotation :
> > this.scopes)
> >                  {
> > -                    contextControl.startContext(scopeAnnotation);
> > +                    contextControl.get().startContext(scopeAnnotation);
> >
>
> Is it a good idea to cache the result of "contextControl.get()" and reuse
> it in the loop.
> I'm not sure how costly this is, but it seems useless to resolve the same
> thing again and again in a loop
>
>                  }
> >              }
> >          }
> > @@ -440,8 +441,9 @@ public class QuartzScheduler implements
> Scheduler<Job>
> >          {
> >              while (!this.scopes.empty())
> >              {
> > -                this.contextControl.stopContext(this.scopes.pop());
> > +
> this.contextControl.get().stopContext(this.scopes.pop());
> >
>
> same here
>
>
> >              }
> > +            this.contextControl.destroy();
> >          }
> >      }
> >
> >
> >
>



-- 
Christian Kaltepoth
Blog: http://blog.kaltepoth.de/
Twitter: http://twitter.com/chkal
GitHub: https://github.com/chkal

Reply via email to