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