You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "wenjin272 (via GitHub)" <gi...@apache.org> on 2026/07/02 02:57:48 UTC

[I] [Tech Debt] Avoid using reflection to load implementation classes of resources during the compilation phase. [flink-agents]

wenjin272 opened a new issue, #864:
URL: https://github.com/apache/flink-agents/issues/864

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/flink-agents/issues) and found nothing similar.
   
   ### Description
   
   Currently, when determining whether a resource is a Python resource during Java-based agent plan compilation, the framework loads the resource's implementation class via reflection.
   
   ```
   if (PythonResourceWrapper.class.isAssignableFrom(
           Class.forName(
                   descriptor.getClazz(),
                   true,
                   Thread.currentThread().getContextClassLoader()))) {
       provider = new PythonResourceProvider(name, type, descriptor);
   } else {
       provider = new JavaResourceProvider(name, type, descriptor);
   }
   ```
   
   Currently, this requires resource dependencies to exist at the compile stage, but we actually only need them at runtime. Since Python resources must declare the `pythonClazz` argument, we can use this parameter to determine whether a resource is a Python resource.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Tech Debt] Avoid using reflection to load implementation classes of resources during the compilation phase. [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on issue #864:
URL: https://github.com/apache/flink-agents/issues/864#issuecomment-4891204017

   Hi, @da-daken, I haven’t started working on it yet, so please feel free to take it. 
   
   Yes, `PythonMCPServer` does not include `pythonClazz` because there is only one implementation of `MCPServer`. I think injecting `pythonClazz` feels a bit hacky. In fact, we can already determine whether an instance is a `PythonMCPServer` from its annotation. Therefore, I believe we can pass this information directly to `extractResource`, like:
   
   ```
   extractResource(
         ResourceType.MCP_SERVER,
         method,
         desc ->
                 new ResourceDescriptor(
                         desc.getModule(),
                         PythonMCPServer.class.getName(),
                         new HashMap<>(desc.getInitialArguments())),
         true);
   
   private void extractResource(ResourceType type, Method method) throws Exception {
           extractResource(type, method, null, false);
       }
   
   private void extractResource(
           ResourceType type,
           Method method,
           Function<ResourceDescriptor, ResourceDescriptor> descriptorDecorator,
           boolean isPython)
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Tech Debt] Avoid using reflection to load implementation classes of resources during the compilation phase. [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 closed issue #864: [Tech Debt] Avoid using reflection to load implementation classes of resources during the compilation phase.
URL: https://github.com/apache/flink-agents/issues/864


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org