Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* CDIUtil.java
 {{IS_NOTE
 	Purpose:
 		
 	Description:
 		
 	History:
 		Dec 29, 2009 6:22:32 PM, Created by henrichen
 }}IS_NOTE
Copyright (C) 2009 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
	This program is distributed under LGPL Version 2.1 in the hope that
	it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.zkoss.zkplus.cdi;
Some generic utility for use with CDI.

Applicable to CDI version 1.0 or later

To specify a different JNDI name for the bean manager, please specify them in zk.xml as follows. (By default is java:comp/env/BeanManager) since 5.0.11.


 <library-property>
  <name>org.zkoss.zkplus.cdi.beanManager.jndiName</name>
  <value>java:comp/env/BeanManager</value>
 </library-property>
 

Author(s):
henrichen
public class CDIUtil {
	private static BeanManager _manager;
Returns the CDI BeanManager. Default implementation use JNDI to lookup "java:comp/env/BeanManager".
 
	public static BeanManager getBeanManager() {
		if ( != null)
			return ;
		try {
			final InitialContext initialContext = new InitialContext();
			 = (BeanManagerinitialContext.lookup(Library.getProperty(
					"org.zkoss.zkplus.cdi.beanManager.jndiName",
					"java:comp/env/BeanManager"));
catch (NamingException e) { // Error getting the home interface
			throw XelException.Aide.wrap(e,
					"Cannot locate the BeanManager for JavaEE 6.");
		}
		return ;
	}
New to GrepCode? Check out our FAQ X