weld

enable CDI injection into a bean created by a producer method

混江龙づ霸主 提交于 2021-02-11 17:52:23
问题 Producer methods are very useful for creating instances programmatically and publishing them in a context. The problem is that all properties of an instance created by new and returned by a producer method are not injected by CDI. In the Weld documentation I've read that this is an intentional behaviour, but in many cases injection in those beans would be very useful. Is there a workaround to enable injection into such beans? 回答1: First, I have to ask why you are using Producers for beans

A reconnecting websocket can't connect to the server with FacesContext.getCurrentInstance() being resolved to null

家住魔仙堡 提交于 2021-01-04 11:14:23
问题 I have a plain Tomcat 8.5.47 having the following dependencies installed. <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.3.9</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.4.8.Final</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.1</version> </dependency> CDI seems to work fine, or at

A reconnecting websocket can't connect to the server with FacesContext.getCurrentInstance() being resolved to null

霸气de小男生 提交于 2021-01-04 11:10:53
问题 I have a plain Tomcat 8.5.47 having the following dependencies installed. <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.3.9</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.4.8.Final</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.1</version> </dependency> CDI seems to work fine, or at

A reconnecting websocket can't connect to the server with FacesContext.getCurrentInstance() being resolved to null

╄→гoц情女王★ 提交于 2021-01-04 11:09:02
问题 I have a plain Tomcat 8.5.47 having the following dependencies installed. <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.3.9</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.4.8.Final</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.1</version> </dependency> CDI seems to work fine, or at

A reconnecting websocket can't connect to the server with FacesContext.getCurrentInstance() being resolved to null

陌路散爱 提交于 2021-01-04 11:08:20
问题 I have a plain Tomcat 8.5.47 having the following dependencies installed. <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.3.9</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.4.8.Final</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.1</version> </dependency> CDI seems to work fine, or at

A reconnecting websocket can't connect to the server with FacesContext.getCurrentInstance() being resolved to null

柔情痞子 提交于 2021-01-04 11:07:33
问题 I have a plain Tomcat 8.5.47 having the following dependencies installed. <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.3.9</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.4.8.Final</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.1</version> </dependency> CDI seems to work fine, or at

Exception using weld CDI with Jetty: Singleton not set for STATIC_INSTANCE

跟風遠走 提交于 2020-12-08 06:20:32
问题 I am trying to configure Jetty with JSF and Weld CDI. After following this manual, I stumble upon the following stacktrace: Caused by: java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE => [] at org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider$RegistrySingleton.get(RegistrySingletonProvider.java:28) at org.jboss.weld.Container.instance(Container.java:55) at org.jboss.weld.SimpleCDI.<init>(SimpleCDI.java:77) at org.jboss.weld.environment.WeldProvider

CDI beans inside .jar are not found by the container (Unsatisfied dependencies)

最后都变了- 提交于 2020-12-05 05:01:06
问题 I have created a Java project to serve as a lib to other projects, reducing code duplication between projects. This lib project is exported to jar to be included in Web projects (WAR, not EAR). In Web projects (where these classes are being removed) everything worked as usual while all classes were kept on them ─ the injection of simple and complex objects (those with Producers and settings) was working normally. After removing these classes of the Web projects and add the jar with these same

Embedding Methods-细粒度文本分类,从相似度出发

此生再无相见时 提交于 2020-08-09 08:50:18
背景 实体分类是指给一个实体一个指定的标签,这在关系抽取,知识问答等任务中非常重要。一般实体分类的标签都小于20个,但是当标签之间具有层级结构,同一个实体在不同的上下文中便可能具有不同的角色。例如: Madonna starred as Breathless Mahoney in the film Dick Tracy Madonna signed with Sire Records in 1982 and released her eponymous debut album the next year. 这两句话中,第一句的Madonna因为主演了电影,她的分类应该是 actress ,而下一句Maddona推出了新专辑,这里她的分类应该是 musician 。 对于细粒度实体分类来说,一个最大的困难是标注文本的收集,因为在标注的时候不考虑上下文的话可能会如上文的例子一样,会引入很多噪音。实际上一个优秀的细粒度实体分类模型应该是可以处理这些噪音并且在训练过程中发现label之间的关系的。 针对这些问题,本文使用ranking loss来解决这些问题,下面我们来看看文中是怎么解决的吧 模型 1. 学习目标 文中为了平衡细粒度标签之间的关系,将输入的文本信息和标签信息全都映射到一个低维空间 中,其中H表示embedding的维度。映射方法如下图所示

CDI(Weld)高级<2> Interceptors(拦截器)

╄→尐↘猪︶ㄣ 提交于 2020-05-04 02:45:15
1.拦截器综述 拦截器的功能是定义在Java拦截器规范。 拦截器规范定义了三种拦截点: 业务方法拦截, 生命周期回调侦听, 超时拦截(EJB)方法。 在容器的生命周期中进行拦截 public class DependencyInjectionInterceptor { @PostConstruct public void injectDependencies(InvocationContext ctx) { ... } } EJB超时时使用的拦截器 public class TimeoutInterceptor { @AroundTimeout public Object manageTransaction(InvocationContext ctx) throws Exception { ... } } 在业务上,对某一个Bean的方法进行拦截 public class TransactionInterceptor { @AroundInvoke public Object manageTransaction(InvocationContext ctx) throws Exception { ... } } @AroundInvoke注释指定了要用作拦截器的方法,拦截器方法与被拦截的业务方法执行同一个java调用堆栈、同一个事务和安全上下文中。用