java ee - Integrate in a CDI application that the container does not support it? -


my application deployed on jonas 5.2.2 doesn't support cdi ejb. need use cdi on ejb. know how use cdi on war part of application don't know in ejb part.

is there way add support cdi ejb application in container not support it?

my boss won't upgrade server version supports it.

[edit] use cdi-weld: i've found beginning of solution :

    //cdi uses annotatedtype object read annotations of class     annotatedtype<daotest> type = beanmanager.createannotatedtype(daotest.class);     //the extension uses injectiontarget delegate instantiation, dependency injection      //and lifecycle callbacks cdi container     injectiontarget<daotest> = beanmanager.createinjectiontarget(type);     //each instance needs own cdi creationalcontext     creationalcontext ctx = beanmanager.createcreationalcontext(null);     //instantiate framework component , inject dependencies     test = it.produce(ctx);  //call constructor     system.out.println("instance" + test);     it.inject(test, ctx);  //call initializer methods , perform field injection     it.postconstruct(test);  //call @postconstruct method      test.test();      it.predestroy(test);  //call @predestroy method     it.dispose(test);  //it safe discard instance     ctx.release();  //clean dependent objects 

i've test injection of in daotest :

@named @dependent public class daotest implements serializable { private static final long serialversionuid = 1l;   @persitence(value = "cdi-ejb") private entitymanager em;  @inject  private user user;   public void test(){     system.out.println(user.getname());      em.getclass(); }  public entitymanager getem() {      return em; }  public void setem(entitymanager em) {     this.em = em; }  public daotest() {     // todo auto-generated constructor stub } 

}

it works, entitymanager not resolve witjh @persistencecontext. think must use @produce annotation don't understand how it.

you need use deltaspike beanprovider functionality.

http://deltaspike.apache.org/documentation.html


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -