ejb-3.1

Controlling CDI Startup inside EJB 3.1

試著忘記壹切 提交于 2019-12-22 07:24:49
问题 I'm new in here and also new to the CDI world, and the first task I got in my job was to find out a way to controlled CDI uploading. We are using both EJB 3.1 and CDI 1.0 , and because they are controlled by different containers, we can control when and in what order the EJB Managed Beans will be up by using @Startup and @Singleton annotations. But the @Inject CDI bean I have declared in my class is coming as null since the CDI Container hasn't started yet. I have been trying for several days

Transaction management and CDI

让人想犯罪 __ 提交于 2019-12-22 07:02:00
问题 I would like to develop an application with CDI (I use Spring usually) to discover this technology. I have read many articles about CDI to learn how it works. I have a simple question about transaction management (for persistence in database for example): Is it mandatory to use EJB 3.1 to have transaction management or is it possible to have it with CDI only ? Thanks. 回答1: No, you can do it with CDI. You simply need to create an interceptor that starts, commits or rollsback a transaction. It

EJB 3.1 Singleton + JPA + JSF design advice needed

做~自己de王妃 提交于 2019-12-22 06:58:44
问题 Given: simple JSF webapp (no Seam), having JSF beans calling few EJB's which in turn load and persist JPA entities. What I want to is to use @Singleton annotation for ejb's and inject EntityManager instead of EntityManagerFactory : @Singleton public class MyEJB { @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME) protected EntityManager em; // not EntityManagerFactory } Spec says that @Singleton is thread-safe, supports concurrency and transaction attributes which (from my pov) makes it

What is the difference between mappedName and lookup attributes of @Resource annotation in EJB?

蹲街弑〆低调 提交于 2019-12-22 05:23:36
问题 I'm confused between two attributes of @Resource annotation. Java Documentations says : mappedName : A product specific name that this resource should be mapped to. The name of this resource, as defined by the name element or defaulted, is a name that is local to the application component using the resource. (It's a name in the JNDI java:comp/env namespace.) Many application servers provide a way to map these local names to names of resources known to the application server. This mapped name

How does @SessionScoped work with EJB? Is CDI only for web-tier?

拜拜、爱过 提交于 2019-12-22 04:07:37
问题 How is the session defined in @SessionScoped CDI bean? Is this annotation valid only when called from Servlet container, where the session is well defined in form of HttpSession ? If not, than how an EJB with @Inject @SessionScoped MyBean myBean can know what the session really is ? I mean, methods of this EJB could have been invoked by a standalone client, RESTful WS or by some other view. What should happen in such case? Should the annotation have no meaning, should it inject fresh MyBean

@Singleton @Startup @PostConstruct method guaranteed to return before EJBs made available for client calls?

亡梦爱人 提交于 2019-12-22 04:01:39
问题 In the context of a Java EE 6 application run on WebSphere 8.0, I need to execute a number of startup tasks before any business method can be executed. Using a @Startup @Singleton bean for this purpose seems like a promising solution. However, it is not entirely clear to me how exactly the application lifecycle would look like. The EJB 3.1 spec states the following: By default, the container is responsible for deciding when to initialize a Singleton bean instance. However, the bean developer

what is the purpose of including empty beans.xml in CDI implemenations projects?

て烟熏妆下的殇ゞ 提交于 2019-12-21 17:43:38
问题 I am using weld ,a RI of CDI as dependency injection component in my JSF-EJB-JPA web app. I see in my project we have empty beans.xml in META-INF/beans.xml in ejb.jar and WEB-INF/beans.xml in my WAR. I don't get it why we need to keep empty beans.xml when there nothing defined in that file? 回答1: CDI needs to scan all the classes of a bean archive at start-up and fire a bunch of events because almost any class is automatically a managed bean (read more here), even if it doesn't have any

Maven repository for EJB 3.1 API

亡梦爱人 提交于 2019-12-21 04:17:06
问题 What Maven repository can I use for EJB 3.1 API dependency? 回答1: This dependency from central worked. <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> 来源: https://stackoverflow.com/questions/2429245/maven-repository-for-ejb-3-1-api

injectionPoint.getBean() returns null if bean is an EJB bean in Java EE 7 (CDI 1.1)

久未见 提交于 2019-12-21 02:36:08
问题 I want to get bean from producer method in order to read its properties. In some scenarios the bean is a EJB Singleton bean. I've simplified my code to focus on the problem. My simple qualifier: @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface InjectMe {} Simple producer: @Dependent public class SimpleProducer { @Produces @InjectMe public String getInjectMe(InjectionPoint ip) { // ip.getBean() returns null for some reason return "ip=" + ip + ", bean="

injectionPoint.getBean() returns null if bean is an EJB bean in Java EE 7 (CDI 1.1)

三世轮回 提交于 2019-12-21 02:35:20
问题 I want to get bean from producer method in order to read its properties. In some scenarios the bean is a EJB Singleton bean. I've simplified my code to focus on the problem. My simple qualifier: @Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface InjectMe {} Simple producer: @Dependent public class SimpleProducer { @Produces @InjectMe public String getInjectMe(InjectionPoint ip) { // ip.getBean() returns null for some reason return "ip=" + ip + ", bean="