roqmarcelo / cdi

Simple J2EE project to test CDI capabilities on a non JEE environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cdi

Simple J2EE project to test CDI capabilities on a non JEE environment

  1. The following example initializes the Application class in the CDI context.
public static void main(String[] args) {
    CdiContext context = CdiContext.INSTANCE;

    Application application = context.getBean(Application.class);

    application.run();
}
  1. After the initialization, the Application class can use the CDI injectors to create instances of other objects and use other CDI capabilities, like qualification and other stuff
@Singleton
public class Application {

	@Inject @Type(GreetingType.FORMAL)
	Greeting greeting;
	
	public void run() {
		System.out.println(greeting.greet());
	}
}

About

Simple J2EE project to test CDI capabilities on a non JEE environment


Languages

Language:Java 100.0%