页: 1 SLSB, 读到ejb-jar.xml
文档中的配置值。
This class has only private fields and for each field a corresponding getter method. In my application I have a lot of other EJBs that use an instance of ConfigParameter
to read the configuration values.
Now, I thought it would be good idea to make ConfigParameter
a @Singleton
, since its state is shared across the whole application.
但在<代码>ejb-jar.xml 仅限<条码>、<条码>或<条码>。 档案对此有目共 The:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<enterprise-beans>
<session>
<ejb-name>ConfigParameter</ejb-name>
<ejb-class>myapp.util.ConfigParameter</ejb-class>
<session-type>Stateless</session-type> <!-- make this a Singleton -->
<env-entry>
<env-entry-name>adminRoleName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>admin</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
我的问题是:
- Is it a good idea to make this bean a singleton?
- If yes, how can I achieve this?
- For understanding: Why is it not allowed to set
session-type
to Singleton?