java-ee-6

What are the best debugging tricks with Weld/CDI?

时间秒杀一切 提交于 2019-12-20 09:21:43
问题 One of the beauties with Java EE 6 is the new dependency injection framework - CDI with the Weld reference implementation - which has prompted us to start migrating internally to JSR-330 in an implementation agnostic manner, with the explicit target of being able to have a core jar which is frozen, and then being able to add extra jars providing new modules replacing functionality in the core jar. I am now in the process of making the above work with Weld, and to be frank there is simply too

How to inject objects of the same class with different scopes?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 06:25:01
问题 In terms of simplicity and correctness, what is the best way to inject objects of the same class with different scopes? In a servlet I want to have injected objects of the same class with different scopes. Still don't know if going to use jsf. Simplicity: Making a Qualifier and a producer method for each scope is too much; making an interface, two classes and adding and alternative in beans.xml is also too much; having an Address#isCurrent() method doesn't make sense. Correctness: JSR299, 3

How to inject a Session Bean into a Message Driven Bean?

谁都会走 提交于 2019-12-19 19:55:55
问题 I'm reasonably new to Java EE, so this might be stupid.. bear with me pls :D I would like to inject a stateless session bean into a message-driven bean. Basically, the MDB gets a JMS message, then uses a session bean to perform the work. The session bean holds the business logic. Here's my Session Bean: @Stateless public class TestBean implements TestBeanRemote { public void doSomething() { // business logic goes here } } The matching interface: @Remote public interface TestBeanRemote {

how to instantiate more then one CDI/Weld bean for one class?

佐手、 提交于 2019-12-19 06:46:20
问题 In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initialization parameters? Is it also possible to create a bean without changing the class....I mean without adding annotation? ADDED Let me make an example. <bean id=

how to instantiate more then one CDI/Weld bean for one class?

陌路散爱 提交于 2019-12-19 06:46:08
问题 In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initialization parameters? Is it also possible to create a bean without changing the class....I mean without adding annotation? ADDED Let me make an example. <bean id=

How to connect remote EJB module from application client

半城伤御伤魂 提交于 2019-12-18 19:11:41
问题 I have a EJB module in remote Glassfish server and application client in my computer. I want to connect from the application client to the remote EJB. Here is the my EJB interface: @Remote public interface BookEJBRemote { public String getTitle(); } Here is the my ejb: @Stateless public class BookEJB implements BookEJBRemote { @Override public String getTitle() { return "Twenty Thousand Leagues Under the Sea"; } } I have several questions : Can I use Dependency Injection in the remote

How to connect remote EJB module from application client

牧云@^-^@ 提交于 2019-12-18 19:11:01
问题 I have a EJB module in remote Glassfish server and application client in my computer. I want to connect from the application client to the remote EJB. Here is the my EJB interface: @Remote public interface BookEJBRemote { public String getTitle(); } Here is the my ejb: @Stateless public class BookEJB implements BookEJBRemote { @Override public String getTitle() { return "Twenty Thousand Leagues Under the Sea"; } } I have several questions : Can I use Dependency Injection in the remote

@PersistenceContext EntityManager thread-safety in Spring and Java EE

纵然是瞬间 提交于 2019-12-18 15:33:46
问题 EntityManager is not thread-safe by definition. Servlets specs says that in non-distributed environment and without implementing SingleThreadModel , there is only one servlet instance per definition . Therefore, in Java EE when you inject an EntityManager through the @PersistenceContext into Servlet's field - it's not thread safe: public class MyServlet extends HttpServlet { // Not thread-safe, should be using EMF instead. @PersistenceContext private EntityManager em; } Is this correct to say

How do I configure a Java EE maven project in Eclipse?

房东的猫 提交于 2019-12-18 11:37:12
问题 I know Maven pretty well, but I usually work with Netbeans, which makes it quite easy to deploy Java EE applications - and handle hot deployment of any changes. The team I work with now uses Eclipse as their IDE of choice, but none of them has worked with Maven projects before; so I need to know how to correctly add Eclipse's project facets to the maven projects we have, in order to support (hot) deployment through WTP. We are using Weblogic 12c for this particular endeavour. Our project

Interceptor method not called with interceptor binding

旧巷老猫 提交于 2019-12-18 04:38:08
问题 I'm using Java EE 6 & Jboss AS7.1 and try to use interceptor binding (Example from jboss site). I have an InterceptorBinding annotation: @InterceptorBinding @Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) public @interface GeoRestrictedEquipment { } The interceptor: @GeoRestrictedEquipment @Interceptor public class GeoRestrictedEquipmentInterceptor { @EJB EquipmentDao equipmenttDao; @EJB SecurityService securityService; @AroundInvoke public Object checker