Movatterモバイル変換


[0]ホーム

URL:


Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Pages Technology

6.  JavaServer Pages Documents

7.  JavaServer Pages Standard Tag Library

8.  Custom Tags in JSP Pages

9.  Scripting in JSP Pages

10.  JavaServer Faces Technology

11.  Using JavaServer Faces Technology in JSP Pages

12.  Developing with JavaServer Faces Technology

13.  Creating Custom UI Components

14.  Configuring JavaServer Faces Applications

15.  Internationalizing and Localizing Web Applications

Part III Web Services

16.  Building Web Services with JAX-WS

17.  Binding between XML Schema and Java Classes

18.  Streaming API for XML

19.  SOAP with Attachments API for Java

Part IV Enterprise Beans

20.  Enterprise Beans

21.  Getting Started with Enterprise Beans

22.  Session Bean Examples

23.  A Message-Driven Bean Example

Part V Persistence

24.  Introduction to the Java Persistence API

25.  Persistence in the Web Tier

26.  Persistence in the EJB Tier

27.  The Java Persistence Query Language

Part VI Services

28.  Introduction to Security in the Java EE Platform

29.  Securing Java EE Applications

30.  Securing Web Applications

31.  The Java Message Service API

32.  Java EE Examples Using the JMS API

33.  Transactions

34.  Resource Connections

Resources and JNDI Naming

DataSource Objects and Connection Pools

Resource Injection

Field-Based Injection

Method-Based Injection

Class-Based Injection

Declaring Multiple Resources

Theconfirmer Example Application

Running theconfirmer Example Application

Creating a Mail Session

Building, Packaging, and Deployingconfirmer in NetBeans IDE

Building, Packaging, and Deployingconfirmer Using Ant

Running theconfirmer Client in NetBeans IDE

Running theconfirmer Client Using Ant

Further Information about Resources

35.  Connector Architecture

Part VII Case Studies

36.  The Coffee Break Application

37.  The Duke's Bank Application

Part VIII Appendixes

A.  Java Encoding Schemes

B.  About the Authors

Index

 

The Java EE 5 Tutorial

Java Coffee Cup logo
PreviousContentsNext

Resources and JNDI Naming

In a distributed application, components need to access other components and resources suchas databases. For example, a servlet might invoke remote methods on an enterprisebean that retrieves information from a database. In the Java EE platform, theJava Naming and Directory Interface (JNDI) naming service enables components to locate other componentsand resources.

A resource is a program object that provides connections to systems, such asdatabase servers and messaging systems. (A JDBC resource is sometimes referred to asa data source.) Each resource object is identified by a unique, people-friendly name,called the JNDI name.

For example, the JNDI name of the JDBC resource for the JavaDB database that is shipped with the Application Server isjdbc/__default.

An administrator creates resources in a JNDI namespace. In the Application Server, youcan use either the Admin Console or theasadmin command to create resources.Applications then use annotations to inject the resources. If an application uses resourceinjection, the Application Server invokes the JNDI API, and the application is notrequired to do so. However, it is also possible for an application tolocate resources by making direct calls to the JNDI API.

A resource object and its JNDI name are bound together by thenaming and directory service. To create a new resource, a new name-object binding isentered into the JNDI namespace.

For information on creating Java Message Service (JMS) resources, seeCreating JMS Administered Objects for the Synchronous Receive Example. For anexample of creating a JDBC resource, seeCreating a Data Source in the Application Server.

You inject resources by using the@Resource annotation in an application. For informationon resource injection, see the following sections of this Tutorial:

You can use a deployment descriptor to override the resource mapping that youspecify in an annotation. Using a deployment descriptor allows you to change anapplication by repackaging it, rather than by both recompiling the source files andrepackaging. However, for most applications, a deployment descriptor is not necessary.

PreviousContentsNext

Copyright © 2010, Oracle and/or its affiliates. All rights reserved.Legal Notices


[8]ページ先頭

©2009-2025 Movatter.jp