View RSS Feed

Tutorial

JNDI Tutorials

  1. JNDI Best Practices

    by , 07-07-2012 at 04:29 PM
    Remote JNDI lookup are considered as quite expensive sort of remote method call. For performance of JNDI lookup, applications will be doing it once. Hence home handles caching will be improving the performance in this kind of situation. It is also an expensive task to make a connection with JNDI. Caching of these context references will be improving the performance of applications.

    One class is used for abstraction of all usage of JNDI and also EJB home object lookup, initial context ...
    Categories
    Tutorial
  2. Using jndi in user authentication

    by , 07-07-2012 at 04:28 PM
    JNDI is used as naming service. It is commonly used to give security mechanism to make users authenticated to access the system resources. Credentials and user information is stored in directory services as entries. It is worthy to point it out that security model is not defined by JNDI however security model is used which has been defined in directory service.

    Default initialContext is involved in creation of new Context that is in use of anonymous clients.
    Java Code:
    // Connect
    ...
    Categories
    Tutorial
  3. JNDI Context Operations

    by , 07-07-2012 at 04:26 PM
    When connection of client is made with JNDI services and JNDI context i.e. usingInitialContext() is obtained then any interface method could be applied. Basic javax.naming.Context interface operations included are bind() usage so that an entry could be added, rebind() so that an entry name could be replaced, lookup() so that to locate or to find an object, & unbind() so that an entry could be deleted. Given below is a figure which illustrates such kind of operations. Logically it is said that ...
  4. LDAP Programming with JNDI

    by , 07-07-2012 at 04:24 PM
    Objects present in LDAP server could be manipulated by connecting with server. Also, you may require the authentication with server. For making connections with server get a reference of DirContext interface to an object. This is done with class InitialDirContext that would be taking hashtable.

    Given code could be used for authentication and connection of user with LDAP server. It shall be noted that simpler authentications are used over here. Simpler kind of authentications include ...
    Categories
    Tutorial
  5. RMI Registry Service Provider for JNDI

    by , 07-07-2012 at 04:23 PM
    Service providers like RMI registry permits the applications of JNDI so that remote objects could be accessed that are registered along with “RMI registry”. Once registry location is known, naming context is created by the provider for those objects that have been registered into registry. In some other JNDI namespace, like LDAP, it is possible to bind this context. Functionality that has been offered by class java.rmi.Naming gets subsumed by this new functionality.

    Major benefit ...
  6. JNDI and J2EE

    by , 07-07-2012 at 04:21 PM
    JNDI is considered to be the standardized service API, of J2EE platform. It gives a standard API to application components so that to refer to the resources as well as other components of other applications. A standard naming policy is defined by J2EE so that it could be used along with JNDI so that it could be made possible to write applications in “deployment” environment independent way. J2EE services could be referenced by just looking at them accordingly by considering logical names present ...
    Categories
    Tutorial
  7. The JNDI APIs

    by , 07-07-2012 at 04:20 PM
    Five packages are present in JNDI APIs:

    • javax.naming: Interfaces and classes are present to access the naming services. E.g., Context interface is defined by it that is considered as an entry point into naming so that lookup could be performed.
    • javax.naming.directory: Naming package is extended so that interfaces and classes could be provided to access the directory services. E.g, new classes are added for attributes and DirContext interface is provided that present
    ...
    Categories
    Tutorial
  8. Modifying JNDI Directory Entries

    by , 07-07-2012 at 04:19 PM
    Directory entry’s attribute values modification usually involves the usage of modifyAttributes() of DirContext. This method’s one variant would take the modification type, directory name entry and also anAttribute object which hold modified Attributes object. Other variant would be taking name as well as javax.naming.directory.

    E.g, let us assume that phone number “303 454 3365” is required to be removed from attribute telephonenumber of entry of a user and to be replaced with some ...
    Categories
    Tutorial
  9. Binding JNDI Objects

    by , 07-07-2012 at 04:17 PM
    Subordinates of Context are stored as Binding objects set. Binding is basically an association present b/w objects and name. Hence it has already been observed that Binding objects hold its name, object and its class. A newer Binding could be added to Context along with thebind() method. E.g, Addition of binding could be done to already existing Context as following:

    Java Code:
    java.io.File newfile = java.io.File("c:\temp\newfile");
    tempContext.bind("newfile",
    ...
    Categories
    Tutorial
  10. Listing the Bindings of a Context

    by , 07-07-2012 at 04:16 PM
    Context’s listBinding() method give out some alternate mean to access the Context children. It has been seen that aNamingEnumeration would be returned by the list(), of NameValuePair objects where access is being provided by every NameValuePair to the class name and name of every single child present in Context. A NamingEnumeration is also returned by listBinding() however in this particular case Binding objects are present in enumeration. NameValuePair has a subclass Binding. Actual child object ...
    Categories
    Tutorial
  11. How JNDI Names Work

    by , 07-07-2012 at 04:15 PM
    Children name of any Context is being allowed to be listed by list() method. It has just been seen that children name could be listed of a Context when list() method is called by usage of empty string, as a parameter. Now let us assume again that Contextobject is there for naming the subdirectories which are present under javax.
    Java Code:
    NamingEnumeration childrenOfNaming = namingContext.list("");
    Result that would come out would be NamingEnumeration which holds objects ...
    Tags: jndi names Add / Edit Tags
    Categories
    Tutorial
  12. Listing the Children of a JNDI Context

    by , 07-07-2012 at 04:13 PM
    One common operation of JNDI is name’s list retrieval of the children. E.g, Enterprise JavaBeans names could be obtained by an application to check if one of them is running or childer names list of InitialContext so that Swing JTree component could be populated. Object’s children names are listed by the help of list() method.
    Java Code:
    NamingEnumeration children = initialContext.list("");
    Javax.naming.NameClassPair object’s javax.naming.NamingEnumeration is returned ...
    Tags: jndi context Add / Edit Tags
    Categories
    Tutorial
  13. Looking Up Objects in a JNDI Context

    by , 07-07-2012 at 04:12 PM
    By name retrieval of an object from naming or directory system is known as looking up object. This is lookup() method’s job. Lookup performance is considered analogous to obtain a friend’s number from some phone book by his name. JNDI could be used so that to look up or retrieve EJB components from remote object or application server, from remote “RMI” registry.

    When lookup() is called, child’s name is specified of the required context.A java.lang.Object is returned by lookup() which ...
    Tags: jndi context Add / Edit Tags
    Categories
    Tutorial
  14. Using the JNDI InitialContext Class

    by , 07-07-2012 at 04:10 PM
    Context interface is implemented by Class javax.naming.InitialContext and is considered as enterance point in a naming system. InitialContextobject shall be created first for using JNDI so that objects could be accessed. Set of properties are taken by the InitialContext constructor in a form like java.util.Hashtable and other subclasses, like a Properties object. In lookup e.g, InitialContext is created as following:

    Java Code:
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,
    ...
  15. Introducing the JNDI Context

    by , 07-07-2012 at 04:08 PM
    Names are associated with objects by a naming servie. Association b/w an object and a name is known as binding. Such binding set is known as a context. Name present in one context could possibly be made bound with other context which utilizes similar naming conventions. Bound context is known as subcontext. For instance directory present in a filesystem is those contexts which hold binding b/w objects and filenames which are used for manipulation of files by the system. If a binding is present ...
    Tags: jndi context Add / Edit Tags
    Categories
    Tutorial
  16. A JNDI Example

    by , 07-07-2012 at 04:06 PM
    In naming systems, an object could be accessed by creating initial context for sake of a naming system so that an entry point could be gained into a naming system. Once initial context is present, an object could be looked up by name.

    Java Code:
    import java.util.Properties;
    import javax.naming.*;
    
    public class Lookup {        
      public static void main(String[] args) {        
        String name = "";
        if (args.length > 0)
    ...
    Tags: jndi example Add / Edit Tags
    Categories
    Tutorial
  17. Naming and Directory Concepts

    by , 07-07-2012 at 04:03 PM
    Directory and naming concepts would be explored deeply so that to give a little introduction of JNDI. It will also be discussed that how directory or naming services would be used by Java programs.

    Naming services are the concepts by which an association is made b/w names and objects. Objects founds are based upon the names. Naming service’s basic function is to map down those names which are people friendly to the objects like identifiers, addresses or objects which are required ...
    Categories
    Tutorial
  18. JNDI Architecture

    by , 07-07-2012 at 04:02 PM
    JNDI architecture and JDBC architecture is somewhat similar. Both of them are involved in providing standardized API which is protocol independent created at the protocol specific driver’s top or the provider implementations. Data source in use will be insulating the application, for example, this doesn’t really matter whether LDAP or NDS directory services will be accessed by the application.

    Both SPI as well as API are included in JNDI architecture as it has been given in figure. ...
    Categories
    Tutorial
  19. JNDI Context and InitialContext

    by , 07-07-2012 at 04:00 PM
    In JNDI, Context interface has a very important and central role. A set of bindings are presented by a context within a naming service in which similar naming convention is being shared. Methods are provided by the context object to bind the names with objects and unbind them from objects and also to list down the bindings.

    Subcontext functionality is also provided by few naming services. This is same as a directory which is present in some filesystem. Basically, subcontext is that ...
  20. Introduction to naming services

    by , 07-07-2012 at 03:58 PM
    Generic naming service organization has been decpicted in the following figure:

    Name:  1.jpg
Views: 597
Size:  24.1 KB

    A generic naming service


    Set of bindings are maintained by the naming service. Names are related by the bindings to the objects. In a naming system, all the objects are named similarly. Naming service is used by the client so that the objects could be located by names.

    Many naming services are present among which few of them will ...
    Categories
    Tutorial
  21. What is JNDI?

    by , 07-07-2012 at 03:53 PM
    To access various naming or directory services, JNDI or Java Naming and directory interface is used that is basically an application programming interface (API). Java Naming and directory interfacen is not considered specified to some specific naming/directory service. Various system could be accessed by it which include file systems; Java RMI, EJB, distributed object system & directory services for example NIS+, Novell NetWare and LDAP.

    JNDI and JDBC are same because both of ...
    Tags: jndi Add / Edit Tags
    Categories
    Tutorial
  22. Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb

    by , 01-02-2012 at 06:27 PM
    The alias or logical reference java:comp/env/ejb/MyBean has always been a recommended approach as the physical JNDI location i.e. ejb/MyBean may not be guaranteed that it (specified in the code) will be present. In case the physical location is changed, code will also be broken down. Your code will not be able to get modified by the deployer. This problem is solved by the logical references which bind the logical names in the application server to the physical name. Declaration will be done of ...

    Updated 01-15-2012 at 08:23 AM by JNDI

    Tags: lookup ejb Add / Edit Tags
    Categories
    Tutorial
  23. EJB 3.1 Global JNDI Names

    by , 01-02-2012 at 06:24 PM
    Session beans are registered to JNDI context automatically. Whether through look up or dependency injection, a client obtains the reference towards beans from the JNDI context. Bean registered under a name is basically registered to the JNDI context container and is referred commonly as “the global JNDI name”. Global JNDI names are applied to the session beans which expose the Local views.

    java:global[/<application-name>]/<module-name>/<bean-name>[!<fully qualified ...

    Updated 01-15-2012 at 08:24 AM by JNDI

    Categories
    Tutorial
  24. Locating EJB Home Interface

    by , 01-02-2012 at 06:21 PM
    Home interface of EJB can be located by an EJB client via standard JNDI API. To make available the home interfaces of its deployed beans EJB is considered responsible, using JNDI. JNDI namespace of a client can be configured to consider the EJBs home interfaces which are installed on other hosts or containers.

    Java Code: This is the code to locate EJB Home Interface
    import java.util.Collection;
    import java.util.Iterator;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    ...

    Updated 01-14-2012 at 06:20 PM by JNDI

    Categories
    Tutorial
  25. What is JNDI

    by , 01-02-2012 at 06:19 PM
    Java Naming & Directory Interface gives the generic interface to the Lightweight Directory Access protocol or other director services for example, DNS or NDS. The components of the J2EE application use JNDI interfaces to look up & to refer the user defined and system provided objects in component environment. JNDI is not defined for one specified directory or naming service. Different system kinds may be accessed which also includes the file systems. The JNDI API makes the applications look ...
    Tags: jndi Add / Edit Tags
    Categories
    Tutorial