- finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener>);
- }
-
- private def void method(CtClass it, Class<?> returnType, String name, Class<?> parameter, MethodGenerator function1) {
- val method = new CtMethod(returnType.asCtClass, name, Arrays.asList(parameter.asCtClass), it);
- function1.process(method);
- it.addMethod(method);
- }
-
- private def void implementMethodsFrom(CtClass target, CtClass source, MethodGenerator function1) {
- for (method : source.methods) {
- if (method.declaringClass == source) {
- val redeclaredMethod = new CtMethod(method, target, null);
- function1.process(redeclaredMethod);
- target.addMethod(redeclaredMethod);
- }
- }
- }
-
- private def CtClass createClass(String fqn, ClassGenerator cls) {
- val target = classPool.makeClass(fqn);
- cls.process(target);
- return target;
- }
-
- private def CtClass createClass(String fqn, CtClass superInterface, ClassGenerator cls) {
- val target = classPool.makeClass(fqn);
- target.implementsType(superInterface);
- cls.process(target);
- return target;
- }
-
- private def void implementsType(CtClass it, CtClass supertype) {
- checkArgument(supertype.interface, "Supertype must be interface");
- addInterface(supertype);
- }
-
- private def asCtClass(Class<?> class1) {
- classPool.get(class1);
- }
-
- private def CtField field(CtClass it, String name, Class<?> returnValue) {
- val field = new CtField(returnValue.asCtClass, name, it);
- field.modifiers = Modifier.PUBLIC
- addField(field);
- return field;
- }
-
- def get(ClassPool pool, Class<?> cls) {
- try {
- return pool.get(cls.name)
- } catch (NotFoundException e) {
- pool.appendClassPath(new LoaderClassPath(cls.classLoader));
- try {
- return pool.get(cls.name)
-
- } catch (NotFoundException ef) {
- pool.appendClassPath(new ClassClassPath(cls));
- return pool.get(cls.name)
- }
- }
- }
-
- protected def resolveInvokerClass(Class<? extends NotificationListener> class1) {
- val invoker = invokerClasses.get(class1);
- if (invoker !== null) {
- return invoker;
- }
- val newInvoker = generateListenerInvoker(class1);
- invokerClasses.put(class1, newInvoker);
- return newInvoker
- }
-}
-
-@Data
-package class RuntimeGeneratedInvoker implements NotificationInvoker {
-
- @Property
- val NotificationListener delegate;
-
- @Property
- var org.opendaylight.controller.sal.binding.api.NotificationListener invocationProxy;
-
- @Property
- var RuntimeGeneratedInvokerPrototype prototype;
-
- new(NotificationListener delegate, RuntimeGeneratedInvokerPrototype prototype) {
- _delegate = delegate;
- _prototype = prototype;
- _invocationProxy = prototype.protoClass.newInstance;
- RuntimeCodeHelper.setDelegate(_invocationProxy, delegate);