• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

JNDI Startup and Shutdown Classes

At the end of this chapter you will be able to:

  • Describe naming and directory services
  • Detail the high-level architecture of JNDI
  • Define basic terminology
  • View the JNDI tree in WebLogic Server
  • Use the Administration Console to deploy a startup or shutdown class

 

What is JNDI?

The Java Naming and Directory Interface (JNDI) is an API that supports accessing naming and directory services in Java programs. The purpose of a naming service is to associate names with objects and provide a way to access objects based on their names. Objects in a naming system can range from files in a file system and names located in Domain Name System (DNS) records, to Enterprise JavaBeans (EJB) components in an application server and user profiles in an LDAP (Lightweight Directory Access Protocol) directory.

As its name implies, JNDI doesn’t just deal with naming services. JNDI also encompasses directory services, which are a natural extension of naming services. The primary difference between the two is that a directory service allows the association of attributes with objects, such as an email address attribute for a user object, while a naming service does not. Thus, with a directory service, you can access the attributes of objects and search for objects based on their attributes. You can use JNDI to access directory services like LDAP and Novell Directory Services (NDS) directories.

  • The Java Naming and Directory Interface is an API for accessing different naming and directory services uniformly.
  • This is a major step forward because:

– Different services use vastly different naming schemes

– Java applications will be able to navigate seamlessly across databases, files, directories, objects and networks

 

Why JNDI?

  • In WebLogic Server, JNDI serves as a repository and lookup service for J2EE objects including:
  • EJB home stubs
  • JDBC DataSources
  • JMS connection factories, queues and topics
  • RMI stubs

 

JNDI Structure & Architecture

121

Naming Service

A naming service provides a method for mapping identifiers to entities or objects:

Naming Service vocabulary:

Binding: Association of an atomic name and an object

Example: www.bea.com is bound to 209.10.217.38

Namespace: A set of unique names in a naming system

            Example: www.bea.com/products

122

 

A JNDI Tree

123

Contexts and Subcontexts

A naming service associates names with objects. An association between a name and an object is called a binding, and a set of such bindings is called a context. A name in a context can be bound to another context that uses the same naming conventions; the bound context is called a subcontext. For example, in a filesystem, a directory (such as /temp) is a context that contains bindings between filenames and objects that the system can use to manipulate the files (often called file handles). If a directory contains a binding for another directory (e.g., /temp/javax), the subdirectory is a subcontext.

  • Subcontexts are referenced through dot delimiters (.)
  • Subcontexts must be created before objects are placed into them

If the following context exists: com.bea.examples

We cannot bind: com.bea.examples.ejb.SomeObject

Without first creating: com.bea.examples.ejb

 

JNDI for Administrators

  • An administrator needs to understand JNDI because it will be their job to:
  • verify objects are bound in the JNDI tree
  • set security on contexts within the JNDI tree

 

Viewing the JNDI Tree

124

 

Listing JNDI Contents

  • WLST provides a command line utility for viewing JNDI bindings.
  • jndi() changes to the jndi tree and ls() lists the bindings

 

125

 

Startup and Shutdown Classes

You can use startup and shutdown classes to configure a WebLogic Server to perform tasks when you start or gracefully shut down the server. A startup class is a Java program that is automatically loaded and executed when a WebLogic Server is started or restarted.

A shutdown class is a Java program that is automatically loaded and executed when the WebLogic Server is shut down either from the Administration Console or the weblogic.admin shutdown command.

To use startup or shutdown classes, you must configure and assign them to servers or clusters.

You can use a startup class to:

  • initialize objects in memory
  • reconstruct a JNDI tree
  • load critical values from the database
  • recover the system to the state that existed before shutdown

You can use a shutdown class to:

  • Shutdown classes are usually used to free resources obtained by startup classes.

 

Defining Startup/Shutdown Classes

126

 

When Are Startup Classes Loaded?

  • By default, startup classes are loaded after the J2EE deployment units.
  • J2EE deployment units load in this order: JDBC, JMS, Connectors, EJBs, Web Applications.
  • If “Run Before Application Deployments” is checked, then startup class are loaded right before deploying JDBC Data Sources.

127

 

Summary:

In this chapter we discussed:

  • What naming and directory services are
  • The high-level architecture of JNDI
  • Terminology used in naming and directory services
  • How to view the JNDI tree in WebLogic Server
  • How to deploy a startup or shutdown class via Administration Console
  • What startup and shutdown classes are and how they work
  • How to deploy a startup or shutdown class using the Administration Console

 

 

 

Summary
Review Date
Reviewed Item
JNDI Startup and Shutdown Classes
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on JNDI Startup and Shutdown Classes"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.