Beispiel #1
0
 private static ThreadLocalProxy<?> getFieldThreadLocalProxy(Field f, Object provider) {
   if (provider != null) {
     Object proxy = null;
     synchronized (provider) {
       try {
         proxy = InjectionUtils.extractFieldValue(f, provider);
       } catch (Throwable t) {
         // continue
       }
       if (!(proxy instanceof ThreadLocalProxy)) {
         proxy = InjectionUtils.createThreadLocalProxy(f.getType());
         InjectionUtils.injectFieldValue(f, provider, proxy);
       }
     }
     return (ThreadLocalProxy<?>) proxy;
   } else {
     return InjectionUtils.createThreadLocalProxy(f.getType());
   }
 }
Beispiel #2
0
 private static ThreadLocalProxy<?> getMethodThreadLocalProxy(Method m, Object provider) {
   if (provider != null) {
     Object proxy = null;
     synchronized (provider) {
       try {
         proxy =
             InjectionUtils.extractFromMethod(
                 provider, InjectionUtils.getGetterFromSetter(m), false);
       } catch (Throwable t) {
         // continue
       }
       if (!(proxy instanceof ThreadLocalProxy)) {
         proxy = InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]);
         InjectionUtils.injectThroughMethod(provider, m, proxy);
       }
     }
     return (ThreadLocalProxy<?>) proxy;
   } else {
     return InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]);
   }
 }