java-ee

Definition of a Java Container

爷,独闯天下 提交于 2019-12-28 08:09:28
问题 I've read\heard many times about java containers such as a servlet container, however, I can't seem to find a good definition of what a container is in the enterprise java world. Does anyone know of a good definition of an enterprise java container? 回答1: Referring more generally to the Container pattern (of which an enterprise Java container could be considered a specialization), the book Server Component Patterns by M.Volter, et al. offers the following: [A CONTAINER provides] an execution

Is it possible to inject a CDI Bean into a static variable in Java EE 6?

∥☆過路亽.° 提交于 2019-12-28 07:02:01
问题 Is this possible: @Inject @MessageTransport(MessageTransportType.SMS) public static MessageSender messageSender; I'm getting a NPE when i'm trying to access this static variable. So I wonder, if it is not possible in general. Thanks in advance. 回答1: Not done in general because a static variable cannot have a scope, i.e. it's just one for the whole class (read application) and therefore it doesn't make sense since every instance would try to set it to a new value based on the current scope.

h:commandbutton, how to redirect to external site?(JSF 2) [duplicate]

北慕城南 提交于 2019-12-28 06:49:08
问题 This question already has an answer here : Redirect to external URL in JSF (1 answer) Closed 4 years ago . When i use command button to redirect to pages, inside my project, u just need to give the name of the page with no extention, followed by ?faces-redirect=true in the action attribute and i will get redirected. But what if i want to get redirected to an external page(example:www.google.com)? I tried in many ways: www.google.com, google.com, http://google.com but i failed. This is what i

ThreadLocal to store ServletRequest and Response in servlet: what for?

旧巷老猫 提交于 2019-12-28 05:54:17
问题 Once I have came across a pattern, where ServletRequest and response objects are put to servlet's local ThreadLocal variables. The servlet class has also methods to get current request and response objects. So in order to get these objects you still need to operate with servlet object. What is the point of having these ThrealLocal local variables? 回答1: The point is to have the request and response objects in classes that would otherwise would not have them (for example they are not servlets).

Autodetect classes in Hibernate from jar

僤鯓⒐⒋嵵緔 提交于 2019-12-28 04:28:22
问题 I have a JavaEE project with several entities with the following persistence.xml file: ... <properties> <!-- Scan for annotated classes --> <property name="hibernate.archive.autodetection" value="class"/> ... And it seems to work. The project is then deployed as a JAR to two different projects. In one them, the persistence.xml file is basically the same as the one above, i.e. uses the autodetection feature of Hibernate. However, it does not seem to work (because I think it needs to load

Should Enterprise Java entities be dumb?

随声附和 提交于 2019-12-28 03:36:12
问题 In our legacy Java EE application, there are loads of value object (VO) classes which typically contain only getters and setters, maybe equals() and hashCode() . These are (typically) the entities to be saved in persistence storage. (For the record, our app has no EJBs - although that might change in the future -, and we use Hibernate for persisting our entities.) All the business logic to manipulate the data in VOs is in separate classes (not EJBs, just POJOs). My OO mindset hates this, as I

Should Enterprise Java entities be dumb?

烂漫一生 提交于 2019-12-28 03:36:05
问题 In our legacy Java EE application, there are loads of value object (VO) classes which typically contain only getters and setters, maybe equals() and hashCode() . These are (typically) the entities to be saved in persistence storage. (For the record, our app has no EJBs - although that might change in the future -, and we use Hibernate for persisting our entities.) All the business logic to manipulate the data in VOs is in separate classes (not EJBs, just POJOs). My OO mindset hates this, as I

Java web service without a web application server

六月ゝ 毕业季﹏ 提交于 2019-12-28 03:06:14
问题 We have a message processing server, which start a few threads processing the message interact with the database etc..... now the client want to have a web service server on the server, they will be able to querying the message processing server, with a web service client. e.g. give me all the messages for today, or delete the message with id.... the problem are: The server just a standard j2se application, doesn't run inside application server, like tomcat or glassfish. To handle a Http

Configure JPA to let PostgreSQL generate the primary key value

假装没事ソ 提交于 2019-12-28 02:48:44
问题 So our project use PostgreSQL database and we use JPA for operating the database. We have created the entities from the database with automatic creator in Netbeans 7.1.2. After small changes our primary key values are described as: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Basic(optional = false) @NotNull @Column(name = "idwebuser", nullable = false) private Integer idwebuser; The problem is that now the application is not flexible, because when we modify the database directly

What is the relationship between component family, component type and renderer type?

余生长醉 提交于 2019-12-28 02:00:07
问题 When I am learning custom component development in JSF, I got confused with the relationship between component family, component type and renderer type. For example, I registered a renderer and a custom component as shown below. faces-config.xml : <component> <component-type>study.faces.Div</component-type> <component-class>javax.faces.component.UIPanel</component-class> </component> <render-kit> <render-kit-id>HTML_BASIC</render-kit-id> <renderer> <component-family>javax.faces.Panel<