JACK 5.4 Application Interface

aos.dci.jndi
Class PortalContext

java.lang.Object
  extended byaos.dci.jndi.PortalContext
All Implemented Interfaces:
javax.naming.Context

public class PortalContext
extends java.lang.Object
implements javax.naming.Context

A JNDI service provider that integrates with an existing portal. This JNDI Context object only provides the lookup(), list() and listBindings() functionality. An instance of this class is returned by the InitialPortalContext.getInitialContext(Hashtable) method.

The lookup(String) method can handle names like:

The list(String) and listBindings(String) methods can handle patterns like:

An example of using this interface follows:


  import java.util.Enumeration;
  import java.util.Hashtable;
  import javax.naming.InitialContext;
  import javax.naming.Context;
  import javax.naming.NamingException;
  import javax.naming.NameClassPair;
  import javax.naming.Binding;

  public class JNDI_Utils {
      protected static InitialContext     iContext = null;

      // Call this after your local portal has been created!
      public static void jndiInit() {
          Hashtable   props = new Hashtable(3);
          props.put(Context.INITIAL_CONTEXT_FACTORY,
                 "aos.dci.jndi.InitialPortalContext");
          // DCI only allows one portal per process currently.
          // so we can provide an empty (or null) portal name and
          // the first (only) portal in the process will be used.
          props.put(Context.PROVIDER_URL, "");
          try {
              iContext = new InitialContext(props);
          } catch ( NamingException ex ) {
              ex.printStackTrace();
          }
      }

      public static void jndiLookup(String n) {
          try {
              System.err.println("=>["+iContext.lookup(n)+"]");
          } catch (NamingException ex) {
              ex.printStackTrace();
          }
      }

      public static void jndiList(String n) {
          try {
              Enumeration en = iContext.list(n);
              if ( en == null ) {
                  System.err.println("WARNING: list() => null");
                  return;
              }
              while (en.hasMoreElements()) {
                  NameClassPair o = (NameClassPair) en.nextElement();
                  System.err.println("=> \""+o.getName()+
                             "\" (type="+o.getClassName()+")");
              }
          } catch (NamingException ex) {
              ex.printStackTrace();
          }
     }

     public static void jndiListBindings(String n) {
          try {
              Enumeration en = iContext.listBindings(n);
              if ( en == null ) {
                  System.err.println("WARNING: list() => null");
                  return;
              }
              while (en.hasMoreElements()) {
                  NameClassPair o = (NameClassPair) en.nextElement();
                  System.err.println("=> \""+o.getName()+
                             "\" (type="+o.getClassName()+
                             ") obj="+o.getObject()));
              }
          } catch (NamingException ex) {
              ex.printStackTrace();
          }
      }
  }
 


Field Summary
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
PortalContext(java.lang.String local_portal_name, java.util.Hashtable env)
          Constructor, not used directly.
 
Method Summary
 void bind(javax.naming.Name name, java.lang.Object obj)
          This operation is not supported.
 void bind(java.lang.String name, java.lang.Object obj)
          This operation is not supported.
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
          This operation is not supported.
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
          This operation is not supported.
 javax.naming.Context createSubcontext(javax.naming.Name name)
          This operation is not supported.
 javax.naming.Context createSubcontext(java.lang.String name)
          This operation is not supported.
 void destroySubcontext(javax.naming.Name name)
          This operation is not supported.
 void destroySubcontext(java.lang.String name)
          This operation is not supported.
 javax.naming.NameParser getNameParser(javax.naming.Name name)
          This operation is not supported.
 javax.naming.NameParser getNameParser(java.lang.String name)
          This operation is not supported.
 javax.naming.NamingEnumeration list(javax.naming.Name name)
          Same as calling list(nameToString(name)).
 javax.naming.NamingEnumeration list(java.lang.String name)
          Return a list of known portals matching the given pattern.
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
          Same as calling listBindings(nameToString(name)).
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
          Same as calling list(name) but the NameClassPairs in the list will also contain the underlying object as well as the name.
 java.lang.Object lookup(javax.naming.Name name)
          Calls lookup(nameToString(name)).
 java.lang.Object lookup(java.lang.String name)
          Returns an Object representing the given name or null if not found.
 java.lang.Object lookupLink(javax.naming.Name name)
          This is the same as calling lookup(nameToString(name)).
 java.lang.Object lookupLink(java.lang.String name)
          This is the same as calling lookup(String name) since this flat context does not treat links specially.
protected  java.lang.String nameToString(javax.naming.Name name)
          Convert a composite name to a String but since only simple names are used in this implementation, this is basically a no-op.
 void rebind(javax.naming.Name name, java.lang.Object obj)
          This operation is not supported.
 void rebind(java.lang.String name, java.lang.Object obj)
          This operation is not supported.
 void rename(javax.naming.Name oldname, javax.naming.Name newname)
          This operation is not supported.
 void rename(java.lang.String oldname, java.lang.String newname)
          This operation is not supported.
 void unbind(javax.naming.Name name)
          This operation is not supported.
 void unbind(java.lang.String name)
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.naming.Context
addToEnvironment, close, getEnvironment, getNameInNamespace, removeFromEnvironment
 

Constructor Detail

PortalContext

public PortalContext(java.lang.String local_portal_name,
                     java.util.Hashtable env)
Constructor, not used directly. Use InitialPortalContext.getInitialContext(Hashtable) instead.

Method Detail

nameToString

protected java.lang.String nameToString(javax.naming.Name name)
Convert a composite name to a String but since only simple names are used in this implementation, this is basically a no-op.

Parameters:
name - The non-null composite or compound name to process.
Returns:
The non-null string name in this namespace to be processed.

lookup

public java.lang.Object lookup(java.lang.String name)
Returns an Object representing the given name or null if not found. See the class definition above for more details.

Specified by:
lookup in interface javax.naming.Context

lookup

public java.lang.Object lookup(javax.naming.Name name)
Calls lookup(nameToString(name)). See the class definition above for more details.

Specified by:
lookup in interface javax.naming.Context

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
This operation is not supported.

Specified by:
bind in interface javax.naming.Context

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
This operation is not supported.

Specified by:
bind in interface javax.naming.Context

rebind

public void rebind(java.lang.String name,
                   java.lang.Object obj)
This operation is not supported.

Specified by:
rebind in interface javax.naming.Context

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
This operation is not supported.

Specified by:
rebind in interface javax.naming.Context

unbind

public void unbind(java.lang.String name)
This operation is not supported.

Specified by:
unbind in interface javax.naming.Context

unbind

public void unbind(javax.naming.Name name)
This operation is not supported.

Specified by:
unbind in interface javax.naming.Context

rename

public void rename(java.lang.String oldname,
                   java.lang.String newname)
This operation is not supported.

Specified by:
rename in interface javax.naming.Context

rename

public void rename(javax.naming.Name oldname,
                   javax.naming.Name newname)
This operation is not supported.

Specified by:
rename in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(java.lang.String name)
Return a list of known portals matching the given pattern. The returned NamingEnumeration consists of NameClassPair items.
See the class definition above for details about recognized patterns.

Specified by:
list in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
Same as calling list(nameToString(name)). See the class definition above for details about recognized patterns.

Specified by:
list in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
Same as calling list(name) but the NameClassPairs in the list will also contain the underlying object as well as the name. See the class definition above for details about recognized patterns.

Specified by:
listBindings in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
Same as calling listBindings(nameToString(name)). See the class definition above for details about recognized patterns.

Specified by:
listBindings in interface javax.naming.Context

destroySubcontext

public void destroySubcontext(java.lang.String name)
This operation is not supported.

Specified by:
destroySubcontext in interface javax.naming.Context

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
This operation is not supported.

Specified by:
destroySubcontext in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
This operation is not supported.

Specified by:
createSubcontext in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
This operation is not supported.

Specified by:
createSubcontext in interface javax.naming.Context

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
This is the same as calling lookup(String name) since this flat context does not treat links specially.

Specified by:
lookupLink in interface javax.naming.Context

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
This is the same as calling lookup(nameToString(name)).

Specified by:
lookupLink in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
This operation is not supported.

Specified by:
getNameParser in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
This operation is not supported.

Specified by:
getNameParser in interface javax.naming.Context

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
This operation is not supported.

Specified by:
composeName in interface javax.naming.Context

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
This operation is not supported.

Specified by:
composeName in interface javax.naming.Context

JACK 5.4 Application Interface

Copyright (C) 1999-2008, Agent Oriented Software Pty. Ltd.

US Government Restricted Rights
The JACK Modules and relevant Software Material have been developed entirely at private expense and are accordingly provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013 or subparagraph (c)(1) and (2) of the Commercial Computer Software Restricted Rights and 48 CFR 52.2270-19, as applicable.


Agent Oriented Software Pty. Ltd.     http://www.aosgrp.com
PO Box 639, Carlton South, Victoria 3053, Australia
Phone: +61 3 9349 5055, Fax: +61 3 9349 5088