What is the correct way to invoke Beans.instantiate()?

Govind Seshadri

Typically, you should invoke the method as:

Beans.instantiate(this.getClass().getClassLoader(), yourBeanName)
Beans.instantiate() basically loads a class, creates a Class object, and then n instantiates an object of that class. If the Bean name corresponds to a serialized Bean prototype, it uses that prototype. Otherwise the instantiation uses a zero-argument constructor.

When invoking instantiate(), you should ensure that you have specified the correct name for the class. Also, the class should have public scope and should contain a no-arg constructor.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.