cdi

What is the Spring DI equivalent of CDI's InjectionPoint?

烈酒焚心 提交于 2019-12-30 04:06:34
问题 I would like to create a Spring's bean producer method which is aware who invoked it, so I've started with the following code: @Configuration public class LoggerProvider { @Bean @Scope("prototype") public Logger produceLogger() { // get known WHAT bean/component invoked this producer Class<?> clazz = ... return LoggerFactory.getLogger(clazz); } } How can I get the information who wants to get the bean injected? I'm looking for some equivalent of CDI's InjectionPoint in Spring world. 回答1: As

WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default

那年仲夏 提交于 2019-12-30 01:34:33
问题 I'm a Java EE-newbie. I want to test JSF and therefore made a simple program but can not deploy it. I get the following error message: cannot Deploy onlineshop-war deploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private de.java2enterprise.onlineshop.RegisterController.customer at de.java2enterprise

JSF 2 localization (managed bean)

我是研究僧i 提交于 2019-12-29 15:02:11
问题 I have a properties file for localization: foo=Bar title=Widget Application This is tied in as a resource-bundle in the faces-config: <resource-bundle> <base-name>com.example.messages.messages</base-name> <var>msgs</var> </resource-bundle> I can access this just fine in the facelets view using EL: <title>#{msgs.title}</title> However, if there are things like SQLExceptions, I need to be able to write messages from the managed bean. This is all working also: FacesMessage message = new

JSF 2 localization (managed bean)

天大地大妈咪最大 提交于 2019-12-29 15:02:08
问题 I have a properties file for localization: foo=Bar title=Widget Application This is tied in as a resource-bundle in the faces-config: <resource-bundle> <base-name>com.example.messages.messages</base-name> <var>msgs</var> </resource-bundle> I can access this just fine in the facelets view using EL: <title>#{msgs.title}</title> However, if there are things like SQLExceptions, I need to be able to write messages from the managed bean. This is all working also: FacesMessage message = new

Get rid of org.jboss.weld.context.NonexistentConversationException, when a query-string parameter named cid is appended to the URL

和自甴很熟 提交于 2019-12-29 08:57:31
问题 Take a simple CDI (it could also be a JSF managed bean) bean as follows. import java.io.Serializable; import javax.inject.Named; import javax.faces.view.ViewScoped; @Named @ViewScoped public class TestManagedBean implements Serializable { private static final long serialVersionUID=1L; public TestManagedBean() {} } If this bean is accessed by an XHTML page with a query-string parameter named cid which is needed for a @ConversationScoped CDI managed bean (which may accidently/deliberately be

Transaction is required to perform this operation (either use a transaction or extended persistence context)

一曲冷凌霜 提交于 2019-12-29 08:35:09
问题 I'm using Wildfly 10.0.0 Final, Java EE7, Maven and JPA 2.1. When I am querying my database for records it works fine and lists out the employees, but when I am trying to persist a new employee it gives me the following exception: javax.servlet.ServletException: WFLYJPA0060: Transaction is required to perform this operation (either use a transaction or extended persistence context) javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) io.undertow.servlet.handlers.ServletHandler

Inject a stateless EJB with @Inject into CDI Weld ManagedBean (JSF 1.2 EJB Application on jboss 6 AS)

↘锁芯ラ 提交于 2019-12-29 04:51:12
问题 Currently I am trying to inject a stateless EJB into a CDI managed controller on Jboss 6 AS Final. The controller is managed in the context an accessible from the JSF pages. If I inject the stateless bean with @EJB it is working. If I inject the stateless EJB with @Inject I get the following Exception: My controller: @Named("TestController") public class TestController { @Inject private TestManagerLocal myTestManager; ... } } My stateless bean: @SuppressWarnings("unchecked") @Stateless public

Understanding the necessity of type Safety in CDI

旧城冷巷雨未停 提交于 2019-12-29 03:34:06
问题 First I should clarify that this post is not intended to criticize CDI, but to discover the thinking and assumptions behind the design of CDI and that will have obvious influence on designing any web app, which uses CDI. One of the most distinguished feature of CDI (of Java EE 6) is type safety . Jboss Seam was not safe in type. It uses name to qualify any instance to inject. Like bellow: @Name("myBean") public class MyBean implements Bean { ... } @Name("yourBean") public class YourBean

Inject CDI managed bean in custom Shiro AuthorizingRealm

时光总嘲笑我的痴心妄想 提交于 2019-12-28 13:23:44
问题 In an app I'm building we're using straight Java 6 EE and JBoss (no Spring, etc), with JPA/Hibernate, JSF, CDI and EJBs. I haven't found many good general security solutions (recommendations are welcome), but the best bet I found is Apache Shiro. However this seems to have a number of shortcomings. Some of which you can read about at Balus C's site: http://balusc.blogspot.com/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html But I've stumbled on another big problem which is already

Inject CDI managed bean in custom Shiro AuthorizingRealm

徘徊边缘 提交于 2019-12-28 13:23:35
问题 In an app I'm building we're using straight Java 6 EE and JBoss (no Spring, etc), with JPA/Hibernate, JSF, CDI and EJBs. I haven't found many good general security solutions (recommendations are welcome), but the best bet I found is Apache Shiro. However this seems to have a number of shortcomings. Some of which you can read about at Balus C's site: http://balusc.blogspot.com/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html But I've stumbled on another big problem which is already