Skip to content

How can I use FactoryBean to manager dynamic bean? #33994

@Ai-010

Description

@Ai-010

I have defined an interface A,I want to implement dynamic A-class bean management through FactoryBean+JDK proxy

pubic interface A<T>{
       Class<T> getType(); 
     
       default void deleteAll(){
              Query.from(getType()).deleteAll();
       }
}


public AFactoryBean<T,A<T>> implements FactoryBean<A<T>>{
      
     public AFactoryBean(Class<A<T>> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

      public Class<?> getObjectType(){
              return A.class;
      }
      public A<T> getObject(){
             Class<T> type ;//How can I get the T class;
              InvocationHandler  handler =new AInvocationHandler(type,.....);
              return (A) Proxy.newProxyInstance(
                mapperInterface.getClassLoader(),  
                new Class[]{mapperInterface}, 
                handler 
             );
      }
}

How can I get the T class? I have no class implements A,I just want to use JDK proxy. Is there any other way to achieve it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions