+ private final LoadingCache<Class<?>, ContainerNodeCodecContext<?>> rpcDataByClass = CacheBuilder.newBuilder()
+ .build(new CacheLoader<Class<?>, ContainerNodeCodecContext<?>>() {
+ @Override
+ public ContainerNodeCodecContext<?> load(final Class<?> key) {
+ final QName qname = BindingReflections.findQName(key);
+ final QNameModule qnameModule = qname.getModule();
+ final Module module = getSchema().findModule(qnameModule).orElseThrow(
+ () -> new IllegalArgumentException("Failed to find module for " + qnameModule));
+ final String className = BindingMapping.getClassName(qname);
+
+ for (final RpcDefinition potential : module.getRpcs()) {
+ final QName potentialQName = potential.getQName();
+ /*
+ * Check if rpc and class represents data from same module and then checks if rpc local name
+ * produces same class name as class name appended with Input/Output based on QName associated
+ * with binding class.
+ *
+ * FIXME: Rework this to have more precise logic regarding Binding Specification.
+ */
+ if (key.getSimpleName().equals(BindingMapping.getClassName(potentialQName) + className)) {
+ final ContainerLike schema = getRpcDataSchema(potential, qname);
+ checkArgument(schema != null, "Schema for %s does not define input / output.", potentialQName);
+ return (ContainerNodeCodecContext<?>) DataContainerCodecPrototype.from(key, schema, factory())
+ .get();
+ }
+ }
+
+ throw new IllegalArgumentException("Supplied class " + key + " is not valid RPC class.");
+ }
+ });
+