Dependency Management in Java EE

Source: Internet
Author: User
Tags message queue

No matter how great you are, you cannot accomplish a great task on your own, and the Java EE component is the same, and no component can do all the tasks independently. While a component often needs the help of other resources at work, it involves the " dependency Management " that we are going to talk about in the process of seeking help . A simple session bean, for example, needs to borrow persistent data from a JDBC data source, and a message-driven bean, for example, needs to pass a message to the JMS message queue. Here are some questions about how to get resources from the server in the component.

As in real life, you need a fire alarm, a bandit. 120 help then just dial the phone number, but only if you need to know the phone number first. The mapping to Java EE is that there are many resources in the server, and developers need to define the referenced resources in the program before they can use them. A reference to a resource in a component can be dynamically parsed from the program code, or it can be automatically parsed by the container when the component is instantiated (Dependency injection?). )。

A reference to a resource is made up of two parts: the name and the target are similar to the relationship between key and value in JSON, and the previous name is primarily for the person, and the target behind is the resource that really needs to go to the server. With the name and the target is equivalent to know the police or the fire alarm phone the rest of the information you need to tell each other, the key left home fire will know to get the hydraulic pliers, encountered the bandits police know with guns. The official language is that each resource reference requires a set of different information that is specific to the type of resource it executes. Usually a reference is declared by the following annotations: @Resource, @EJB, @PersistenceContext, or @persistenceunit. Similar to spring annotations can be placed where you want to place (class, field, or Setter method) different locations depending on whether the server will automatically parse (load).

The different types of dependency types are described one after the other: dependency lookup, Dependency injection, declarative dependency, in essence they are all similar to the external resources needed to find the program through specific information.

Dependency Management in Java EE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.