*/
package org.opendaylight.controller.sal.binding.codegen.impl;
+import com.google.common.base.Supplier;
+
import java.util.Map;
import java.util.WeakHashMap;
import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
-import com.google.common.base.Supplier;
-
abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
@GuardedBy("this")
private final Map<Class<? extends NotificationListener>, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>();
utils.getLock().lock();
try {
- invoker = ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Supplier<RuntimeGeneratedInvokerPrototype>() {
- @Override
- public RuntimeGeneratedInvokerPrototype get() {
- return generateListenerInvoker(cls);
- }
- });
+ synchronized (utils) {
+ invoker = ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Supplier<RuntimeGeneratedInvokerPrototype>() {
+ @Override
+ public RuntimeGeneratedInvokerPrototype get() {
+ return generateListenerInvoker(cls);
+ }
+ });
+ }
invokerClasses.put(cls, invoker);
return invoker;
public final <T extends RpcService> T getDirectProxyFor(final Class<T> serviceType) {
utils.getLock().lock();
try {
- return ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), directProxySupplier(serviceType));
+ synchronized (utils) {
+ return ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), directProxySupplier(serviceType));
+ }
} finally {
utils.getLock().unlock();
}
utils.getLock().lock();
try {
- final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
- return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
+ synchronized (utils) {
+ final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
+ return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
+ }
} finally {
utils.getLock().unlock();
}