Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

JNDI overview, Part 4: the Doc-u-Matic, a JNDI application

Pull together your JNDI knowledge with a JNDI-enabled application

  • Print
  • Feedback

Page 4 of 6

  /**
   * Gets the reference for the library.
   *
   * @returns the reference
   *
   */
  public
  Reference
  getReference() {
    Reference reference = null;
    try {
      // Store the properties as an array of bytes.
      ByteArrayOutputStream bytearrayoutputstream = new 
ByteArrayOutputStream();
      m_properties.store(bytearrayoutputstream, null);
      // Create a reference to the library.
      reference = new Reference(
        JNDILibrary.class.getName(),
        new BinaryRefAddr("properties", bytearrayoutputstream.toByteArray()),
        JNDILibraryFactory.class.getName(),
        null
      );
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
    return reference;
  }


JNDILibraryFactory.java

The JNDILibraryFactory class is used on the client-side to create an instance of the JNDILibrary class when a JNDI library is looked up in a directory service. JNDILibraryFactory's primary operation: transform the stored binary property-file information into live property information. This transformation allows the new instance to function identically to the version that was stored:

  • Print
  • Feedback

Resources