## org.jboss.naming
Class ExternalContext

    java.lang.Object
      |
      +--javax.management.NotificationBroadcasterSupport
            |
            +--org.jboss.util.ServiceMBeanSupport
                  |
                  +--org.jboss.naming.ExternalContext

All Implemented Interfaces:
  ExternalContextMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, Service, ServiceMBean

public class ExternalContext
extends ServiceMBeanSupport
implements ExternalContextMBean

A MBean that binds an arbitrary InitialContext into the JBoss default InitialContext as a Reference. If RemoteAccess is enabled, the reference is a Serializable object that is capable of creating the InitialContext remotely. If RemoteAccess if false, the reference is to a nonserializable object that can only be used from within this VM.

Version:
  $Revision: 1.5.4.1 $
Author:
  Scott_Stark@displayscape.com
See Also:
  `NonSerializableFactory`

Inner Class Summary
`static class` `ExternalContext.SerializableInitialContext` The external InitialContext information class.

Fields inherited from class org.jboss.util.ServiceMBeanSupport
`log, server`

Fields inherited from interface org.jboss.util.ServiceMBean
`STARTED, STARTING, states, STOPPED, STOPPING`

Constructor Summary
`ExternalContext()`
`ExternalContext(java.lang.String jndiName, java.lang.String contextPropsURL)`

Method Summary
`boolean` `getCacheContext()` Get the cacheContext flag.
`java.lang.String` `getInitialContext()` Get the class name of the InitialContext implementation to use.
`java.lang.String` `getJndiName()` Set the jndi name under which the external context is bound.
`java.lang.String` `getName()`
`boolean` `getRemoteAccess()` Get the remote access flag.
`void` `initService()`
`void` `setCacheContext(boolean cacheContext)` set the cacheContext flag.
`void` `setInitialContext(java.lang.String className)` Set the class name of the InitialContext implementation to use.
`void` `setJndiName(java.lang.String jndiName)` Set the jndi name under which the external context is bound.
`void` `setProperties(java.lang.String contextPropsURL)` Set the InitialContex class environment properties.
`void` `setRemoteAccess(boolean remoteAccess)` Set the remote access flag.
`void` `startService()` Start the service by binding the external context into the JBoss InitialContext.
`void` `stopService()` Stop the service by unbinding the external context into the JBoss InitialContext.

Methods inherited from class org.jboss.util.ServiceMBeanSupport
`destroy, destroyService, getObjectName, getServer, getState, getStateString, init, nextSequenceNumber, postDeregister, postRegister, preDeregister, preRegister, start, stop`

Methods inherited from class javax.management.NotificationBroadcasterSupport
`addNotificationListener, getNotificationInfo, removeNotificationListener, sendNotification`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jboss.util.ServiceMBean
`getState, getStateString`

Methods inherited from interface org.jboss.util.Service
`destroy, init, start, stop`

Constructor Detail

### ExternalContext

    public ExternalContext()

### ExternalContext

    public ExternalContext(java.lang.String jndiName,
                           java.lang.String contextPropsURL)
                    throws java.io.IOException,
                           javax.naming.NamingException

Method Detail

### getJndiName

    public java.lang.String getJndiName()

  Set the jndi name under which the external context is bound.
  Specified by:
    `getJndiName` in interface `ExternalContextMBean`

### setJndiName

    public void setJndiName(java.lang.String jndiName)
                     throws javax.naming.NamingException

  Set the jndi name under which the external context is bound.
  Specified by:
    `setJndiName` in interface `ExternalContextMBean`

### getRemoteAccess

    public boolean getRemoteAccess()

  Description copied from interface: `ExternalContextMBean`
  Get the remote access flag. If true, the external context is bound using Serializable object that allows the InitialContext to be recreated remotely.
  Specified by:
    `getRemoteAccess` in interface `ExternalContextMBean`

### setRemoteAccess

    public void setRemoteAccess(boolean remoteAccess)

  Description copied from interface: `ExternalContextMBean`
  Set the remote access flag. If true, the external context is bound using Serializable object that allows the InitialContext to be recreated remotely.
  Specified by:
    `setRemoteAccess` in interface `ExternalContextMBean`

### getCacheContext

    public boolean getCacheContext()

  Description copied from interface: `ExternalContextMBean`
  Get the cacheContext flag.
  Specified by:
    `getCacheContext` in interface `ExternalContextMBean`

### setCacheContext

    public void setCacheContext(boolean cacheContext)

  Description copied from interface: `ExternalContextMBean`
  set the cacheContext flag. When set to true, the external Context is only created when the mbean is started and then stored as an in memory object until the mbean is stopped. If cacheContext if set to false, the external Context is created on each lookup using the mbean Properties and InitialContext class. When the uncached Context is looked up by a client, the client should invoke close() on the Context to prevent resource leaks.
  Specified by:
    `setCacheContext` in interface `ExternalContextMBean`

### getInitialContext

    public java.lang.String getInitialContext()

  Get the class name of the InitialContext implementation to use. Should be one of: javax.naming.InitialContext javax.naming.directory.InitialDirContext javax.naming.ldap.InitialLdapContext
  Specified by:
    `getInitialContext` in interface `ExternalContextMBean`
  Returns:
    the classname of the InitialContext to use

### setInitialContext

    public void setInitialContext(java.lang.String className)
                           throws java.lang.ClassNotFoundException

  Set the class name of the InitialContext implementation to use. Should be one of: javax.naming.InitialContext javax.naming.directory.InitialDirContext javax.naming.ldap.InitialLdapContext The default is javax.naming.InitialContex.
  Specified by:
    `setInitialContext` in interface `ExternalContextMBean`
  Parameters:
    `contextClass,` - the classname of the InitialContext to use

### setProperties

    public void setProperties(java.lang.String contextPropsURL)
                       throws java.io.IOException

  Set the InitialContex class environment properties.
  Specified by:
    `setProperties` in interface `ExternalContextMBean`
  Following copied from interface: `org.jboss.naming.ExternalContextMBean`
  Parameters:
    `contextPropsURL,` - either a URL string to a jndi.properties type of content or a name of a resource to locate via the current thread context classpath.
  Throws:
    `IOException,` - thrown if the url/resource cannot be loaded.

### getName

    public java.lang.String getName()

  Specified by:
    `getName` in interface `ServiceMBean`
  Overrides:
    `getName` in class `ServiceMBeanSupport`

### initService

    public void initService()
                     throws java.lang.Exception

  Overrides:
    `initService` in class `ServiceMBeanSupport`

### startService

    public void startService()
                      throws java.lang.Exception

  Start the service by binding the external context into the JBoss InitialContext.
  Overrides:
    `startService` in class `ServiceMBeanSupport`

### stopService

    public void stopService()

  Stop the service by unbinding the external context into the JBoss InitialContext.
  Overrides:
    `stopService` in class `ServiceMBeanSupport`

Copyright © 2000 The JBoss Organization. All Rights Reserved.