How to instance and use methods dynamically on a member of a class in java?
===

I have an issue with Java Reflection. Here's my code very much simplified.

Let's say we have this class :

    public class MyClassA {
        private MyClassB myPropertyB_1;
        private MyClassB myPropertyB_2;

        ...
    }

And this class (which is used as a property for MyClassA :

    public class MyClassB {

        private int myProperty;

        public MyClassB(){
        }

        ...
    }

I would like to use Java Reflection to do something like this, in <code>MyClassA</code> :

        public void methodThatUsesReflectionOnProperty(int id){
            // 1. Get the field using id
            // 2. Instanciate this field dynamically (i.e. new MyClassB() )
            // 3. Invoke some methods on this field dynamically (setters, addlisteners...)
    }

How could I do this ?