/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* PartialCompositeContext implements Context operations on
* composite names using implementations of the p_ interfaces
* defined by its subclasses.
*
* The main purpose provided by this class is that it deals with
* partial resolutions and continuations, so that callers of the
* Context operation don't have to.
*
* Types of clients that will be direct subclasses of
* PartialCompositeContext may be service providers that implement
* one of the JNDI protocols, but which do not deal with
* continuations. Usually, service providers will be using
* one of the subclasses of PartialCompositeContext.
*
* @author Rosanna Lee
*/
static {
try {
} catch (InvalidNameException e) {
// Should never happen
}
}
protected PartialCompositeContext() {
}
// ------ Abstract methods whose implementations come from subclasses
/* Equivalent to method in Resolver interface */
/* Equivalent to methods in Context interface */
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
throws NamingException;
// ------ should be overridden by subclass;
// ------ not abstract only for backward compatibility
/**
* A cheap way of getting the environment.
* Default implemenation is NOT cheap because it simply calls
* getEnvironment(), which most implementations clone before returning.
* Subclass should ALWAYS override this with the cheapest possible way.
* The toolkit knows to clone when necessary.
* @return The possibly null environment of the context.
*/
return getEnvironment();
}
// ------ implementations of methods in Resolver and Context
// ------ using corresponding p_ methods provided by subclass
/* implementations for method in Resolver interface using p_ method */
throws NamingException
{
}
throws NamingException
{
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
throw e;
}
}
return answer;
}
/* implementations for methods in Context interface using p_ methods */
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
}
}
throws NamingException
{
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
if (e.getRemainingNewName() != null) {
// %%% e.getRemainingNewName() should never be null
newName = e.getRemainingNewName();
}
}
}
throws NamingException
{
}
throws NamingException
{
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
throws NamingException
{
}
throws NamingException
{
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
}
PartialCompositeContext ctx = this;
try {
while (cont.isContinue()) {
}
} catch (CannotProceedException e) {
}
return answer;
}
throws NamingException {
new CompositeName(prefix));
}
/**
* This default implementation simply concatenates the two names.
* There's one twist when the "java.naming.provider.compose.elideEmpty"
* environment setting is set to "true": if each name contains a
* nonempty component, and if 'prefix' ends with an empty component or
* 'name' starts with one, then one empty component is dropped.
* For example:
* <pre>
* elideEmpty=false elideEmpty=true
* {"a"} + {"b"} => {"a", "b"} {"a", "b"}
* {"a"} + {""} => {"a", ""} {"a", ""}
* {"a"} + {"", "b"} => {"a", "", "b"} {"a", "b"}
* {"a", ""} + {"b", ""} => {"a", "", "b", ""} {"a", "b", ""}
* {"a", ""} + {"", "b"} => {"a", "", "", "b"} {"a", "", "b"}
* </pre>
*/
return res;
}
return res;
}
}
}
return res;
}
// ------ internal methods used by PartialCompositeContext
/**
* Tests whether a name contains a nonempty component.
*/
while (enum_.hasMoreElements()) {
return false;
}
}
return true;
}
/**
* Retrieves a PartialCompositeContext for the resolved object in
* cont. Throws CannotProceedException if not successful.
*/
throws NamingException {
if (obj instanceof PartialCompositeContext) {
// Just cast if octx already is PartialCompositeContext
// %%% ignoring environment for now
return (PartialCompositeContext)obj;
} else {
}
}
};