1. /*
  2. * @(#)CannotProceedException.java 1.7 01/02/09
  3. *
  4. * Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.naming;
  11. import java.util.Hashtable;
  12. /**
  13. * This exception is thrown to indicate that the operation reached
  14. * a point in the name where the operation cannot proceed any further.
  15. * When performing an operation on a composite name, a naming service
  16. * provider may reach a part of the name that does not belong to its
  17. * namespace. At that point, it can construct a
  18. * CannotProceedException and then invoke methods provided by
  19. * javax.naming.spi.NamingManager (such as getContinuationContext())
  20. * to locate another provider to continue the operation. If this is
  21. * not possible, this exception is raised to the caller of the
  22. * context operation.
  23. *<p>
  24. * If the program wants to handle this exception in particular, it
  25. * should catch CannotProceedException explicitly before attempting to
  26. * catch NamingException.
  27. *<p>
  28. * A CannotProceedException instance is not synchronized against concurrent
  29. * multithreaded access. Multiple threads trying to access and modify
  30. * CannotProceedException should lock the object.
  31. *
  32. * @author Rosanna Lee
  33. * @author Scott Seligman
  34. * @version 1.7 01/02/09
  35. * @since 1.3
  36. */
  37. /*
  38. * The serialized form of a CannotProceedException object consists of
  39. * the serialized fields of its NamingException superclass, the remaining new
  40. * name (a Name object), the environment (a Hashtable), the altName field
  41. * (a Name object), and the serialized form of the altNameCtx field.
  42. */
  43. public class CannotProceedException extends NamingException {
  44. /**
  45. * Contains the remaining unresolved part of the second
  46. * "name" argument to Context.rename().
  47. * This information necessary for
  48. * continuing the Context.rename() operation.
  49. * <p>
  50. * This field is initialized to null.
  51. * It should not be manipulated directly: it should
  52. * be accessed and updated using getRemainingName() and setRemainingName().
  53. * @serial
  54. *
  55. * @see #getRemainingNewName
  56. * @see #setRemainingNewName
  57. */
  58. protected Name remainingNewName = null;
  59. /**
  60. * Contains the environment
  61. * relevant for the Context or DirContext method that cannot proceed.
  62. * <p>
  63. * This field is initialized to null.
  64. * It should not be manipulated directly: it should be accessed
  65. * and updated using getEnvironment() and setEnvironment().
  66. * @serial
  67. *
  68. * @see #getEnvironment
  69. * @see #setEnvironment
  70. */
  71. protected Hashtable environment = null;
  72. /**
  73. * Contains the name of the resolved object, relative
  74. * to the context <code>altNameCtx</code>. It is a composite name.
  75. * If null, then no name is specified.
  76. * See the <code>javax.naming.spi.ObjectFactory.getObjectInstance</code>
  77. * method for details on how this is used.
  78. * <p>
  79. * This field is initialized to null.
  80. * It should not be manipulated directly: it should
  81. * be accessed and updated using getAltName() and setAltName().
  82. * @serial
  83. *
  84. * @see #getAltName
  85. * @see #setAltName
  86. * @see #altNameCtx
  87. * @see javax.naming.spi.ObjectFactory#getObjectInstance
  88. */
  89. protected Name altName = null;
  90. /**
  91. * Contains the context relative to which
  92. * <code>altName</code> is specified. If null, then the default initial
  93. * context is implied.
  94. * See the <code>javax.naming.spi.ObjectFactory.getObjectInstance</code>
  95. * method for details on how this is used.
  96. * <p>
  97. * This field is initialized to null.
  98. * It should not be manipulated directly: it should
  99. * be accessed and updated using getAltNameCtx() and setAltNameCtx().
  100. * @serial
  101. *
  102. * @see #getAltNameCtx
  103. * @see #setAltNameCtx
  104. * @see #altName
  105. * @see javax.naming.spi.ObjectFactory#getObjectInstance
  106. */
  107. protected Context altNameCtx = null;
  108. /**
  109. * Constructs a new instance of CannotProceedException using an
  110. * explanation. All unspecified fields default to null.
  111. *
  112. * @param explanation A possibly null string containing additional
  113. * detail about this exception.
  114. * If null, this exception has no detail message.
  115. * @see java.lang.Throwable#getMessage
  116. */
  117. public CannotProceedException(String explanation) {
  118. super(explanation);
  119. }
  120. /**
  121. * Constructs a new instance of CannotProceedException.
  122. * All fields default to null.
  123. */
  124. public CannotProceedException() {
  125. super();
  126. }
  127. /**
  128. * Retrieves the environment that was in effect when this exception
  129. * was created.
  130. * @return Possibly null environment property set.
  131. * null means no environment was recorded for this exception.
  132. * @see #setEnvironment
  133. */
  134. public Hashtable getEnvironment() {
  135. return environment;
  136. }
  137. /**
  138. * Sets the environment that will be returned when getEnvironment()
  139. * is called.
  140. * @param environment A possibly null environment property set.
  141. * null means no environment is being recorded for
  142. * this exception.
  143. * @see #getEnvironment
  144. */
  145. public void setEnvironment(Hashtable environment) {
  146. this.environment = environment; // %%% clone it??
  147. }
  148. /**
  149. * Retrieves the "remaining new name" field of this exception, which is
  150. * used when this exception is thrown during a rename() operation.
  151. *
  152. * @return The possibly null part of the new name that has not been resolved.
  153. * It is a composite name. It can be null, which means
  154. * the remaining new name field has not been set.
  155. *
  156. * @see #setRemainingNewName
  157. */
  158. public Name getRemainingNewName() {
  159. return remainingNewName;
  160. }
  161. /**
  162. * Sets the "remaining new name" field of this exception.
  163. * This is the value returned by <code>getRemainingNewName()</code>.
  164. *<p>
  165. * <tt>newName</tt> is a composite name. If the intent is to set
  166. * this field using a compound name or string, you must
  167. * "stringify" the compound name, and create a composite
  168. * name with a single component using the string. You can then
  169. * invoke this method using the resulting composite name.
  170. *<p>
  171. * A copy of <code>newName</code> is made and stored.
  172. * Subsequent changes to <code>name</code> does not
  173. * affect the copy in this NamingException and vice versa.
  174. *
  175. * @param newName The possibly null name to set the "remaining new name" to.
  176. * If null, it sets the remaining name field to null.
  177. *
  178. * @see #getRemainingNewName
  179. */
  180. public void setRemainingNewName(Name newName) {
  181. if (newName != null)
  182. this.remainingNewName = (Name)(newName.clone());
  183. else
  184. this.remainingNewName = null;
  185. }
  186. /**
  187. * Retrieves the <code>altName</code> field of this exception.
  188. * This is the name of the resolved object, relative to the context
  189. * <code>altNameCtx</code>. It will be used during a subsequent call to the
  190. * <code>javax.naming.spi.ObjectFactory.getObjectInstance</code> method.
  191. *
  192. * @return The name of the resolved object, relative to
  193. * <code>altNameCtx</code>.
  194. * It is a composite name. If null, then no name is specified.
  195. *
  196. * @see #setAltName
  197. * @see #getAltNameCtx
  198. * @see javax.naming.spi.ObjectFactory#getObjectInstance
  199. */
  200. public Name getAltName() {
  201. return altName;
  202. }
  203. /**
  204. * Sets the <code>altName</code> field of this exception.
  205. *
  206. * @param altName The name of the resolved object, relative to
  207. * <code>altNameCtx</code>.
  208. * It is a composite name.
  209. * If null, then no name is specified.
  210. *
  211. * @see #getAltName
  212. * @see #setAltNameCtx
  213. */
  214. public void setAltName(Name altName) {
  215. this.altName = altName;
  216. }
  217. /**
  218. * Retrieves the <code>altNameCtx</code> field of this exception.
  219. * This is the context relative to which <code>altName</code> is named.
  220. * It will be used during a subsequent call to the
  221. * <code>javax.naming.spi.ObjectFactory.getObjectInstance</code> method.
  222. *
  223. * @return The context relative to which <code>altName</code> is named.
  224. * If null, then the default initial context is implied.
  225. *
  226. * @see #setAltNameCtx
  227. * @see #getAltName
  228. * @see javax.naming.spi.ObjectFactory#getObjectInstance
  229. */
  230. public Context getAltNameCtx() {
  231. return altNameCtx;
  232. }
  233. /**
  234. * Sets the <code>altNameCtx</code> field of this exception.
  235. *
  236. * @param altNameCtx
  237. * The context relative to which <code>altName</code>
  238. * is named. If null, then the default initial context
  239. * is implied.
  240. *
  241. * @see #getAltNameCtx
  242. * @see #setAltName
  243. */
  244. public void setAltNameCtx(Context altNameCtx) {
  245. this.altNameCtx = altNameCtx;
  246. }
  247. /**
  248. * Use serialVersionUID from JNDI 1.1.1 for interoperability
  249. */
  250. private static final long serialVersionUID = 1219724816191576813L;
  251. }