Kernel kernel = controller.getKernel();
KernelMetaDataRepository repository = kernel.getMetaDataRepository();
KernelConfigurator configurator = kernel.getConfigurator();
BeanMetaData metaData = context.getBeanMetaData();
BeanInfo info = context.getBeanInfo();
MetaData repositoryMetaData = repository.getMetaData(context);
Joinpoint joinPoint = configurator.getConstructorJoinPoint(info, metaData.getConstructor(), metaData, repositoryMetaData);
BeanValidatorBridge bridge = getBeanValidatorBridge(context);
if (bridge != null)
bridge.validateConstructorValues(context, joinPoint);
Object object = dispatchJoinPoint(context, joinPoint);
if (object == null)
throw new IllegalStateException("Instantiate joinpoint returned a null object: " + joinPoint);
if (bridge != null)
bridge.validateInstance(context, object);
context.setTarget(object);
try
{
if (info == null)
{
info = configurator.getBeanInfo(object.getClass(), metaData.getAccessMode());
context.setBeanInfo(info);
// update class scope with class info
repository = kernel.getMetaDataRepository();
// remove old context
repository.removeMetaData(context);
// create new scope key
ScopeInfo scopeInfo = context.getScopeInfo();
ScopeKey scopeKey = new ScopeKey(scopeInfo.getScope().getScopes());
scopeKey.addScope(CommonLevels.CLASS, info.getClassInfo().getType());
scopeInfo.setScope(scopeKey);
// re-register
repository.addMetaData(context);
// handle custom annotations