Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Created June 8, 2011 07:49
Show Gist options
  • Save mathieuancelin/1013991 to your computer and use it in GitHub Desktop.
Save mathieuancelin/1013991 to your computer and use it in GitHub Desktop.
private InjectionTarget it;
private AnnotatedType annotated;
private BeanManager beanManager;
public <T> T create(CreationalContext<T> creationalContext) {
annotated = beanManager.createAnnotatedType(myType);
it = manager.createInjectionTarget(annotated);
T instance = (T) it.produce(creationalContext);
it.inject(instance, creationalContext);
it.postConstruct(instance);
return instance;
}
public <T> void destroy(T instance, CreationalContext<T> creationalContext) {
it.preDestroy(instance);
it.dispose(instance);
creationalContext.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment