How can I find what Resources a Java EE container provides?

How can I find what “Resources” a Java EE container provides? Can I discover this programmatically, or is there documentation I should refer to? (Note that the Java EE tutorial is vague on this subject.)

Here is an example of what I’m talking about:

I was reading the Java EE 6 documentation for Using the Timer
Service,
and I noticed that it doesn’t really explain what the TimerService
technically is. If you read the documentation, you eventually see an
example that a TimerService is obtainable using the @Resource
annotation.

From this I take it that a TimerService is a Resource provided by the
container. If it weren’t for the example, I never would have realized
this without reading a third-party blog post: at no point does the
official tutorial say that “TimerService is a container-provided
Resource”. TimerService is very useful, so I would like to know what
other Resources are available.

To be clear, I’m not looking for a third-party blog post, and the official Java EE tutorial is just that, a tutorial: it’s not comprehensive. And I briefly checked the Java EE 7 Platform JSR, but I couldn’t find a reference to TimerService.

Is there a way to programmatically find the Resources a container provides, or is there a documented list of Resources a Java EE container must provide?

You’re under a bit of misconception here. First, divorce the @Resource annotation from javax.ejb.TimerService. Now read the following excerpt from the JavaEE api:

The Resource annotation marks a resource that is needed by the application. This annotation may be applied to an application component class, or to fields or methods of the component class. When the annotation is applied to a field or method, the container will inject an instance of the requested resource into the application component when the component is initialized. If the annotation is applied to the component class, the annotation declares a resource that the application will look up at runtime.

What that implies is that anything can be declared a resource, to be injected by @Resource. The annotation can be used to inject anything, ranging from primitive <env-entry/> definitions in the web.xml, to various connection managers (Java Mail, Datasources e.t.c) and it is done on-demand

Typically, it’s items that are eligible for JNDI-based access, that are injected using @Resource. What this means is that, you need to have a JNDI name, to address a resource before going to look for it (the default value of the name element is the field name
qualified by the class name). JSR-250, which defines the @Resource annotation lists all the viable targets for that annotation.

If however, you’re confident you really want to know everything that the container might be able to inject, you could try listing all available JNDI entries. I don’t recommend it.


As for TimerService in specific, a container must provide an implementation of TimerService in order to be JavaEE compliant. This is a quote from JSR 345:

The container must provide the implementation of the TimerService,
Timer, and TimerHandle interfaces.

If you look at the table of contents of JSR 345, you’ll see that TimerService gets a chapter to itself, at the same level as topics like “Security Management”. This just goes to show that while TimerService may feel like a utility class, it’s arguably at the same level of abstraction as any other container-provided service

If you’re looking for an authoritative list of mandatory container-provided services, the spec is the place to look. Knowing which spec to look at can be tricky, but as TimerService is in the javax.ejb package, the EJB spec is a good guess.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật