/*
* 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.
*/
/**
* A sample service provider that implements a hierarchical directory in memory.
* Every operation begins by doing a lookup on the name passed to it and then
* calls a corresponding "do<OperationName>" on the result of the lookup. The
* "do<OperationName>" does the work without any further resolution (it assumes
* that it is the target context).
*/
static private final boolean debug = false;
protected boolean ignoreCase = false;
private boolean alwaysUseFactory;
}
throw new OperationNotSupportedException(
"Cannot determine full name");
}
public HierMemDirCtx() {
this(null, false, false);
}
this(null, ignoreCase, false);
}
this(environment, ignoreCase, false);
}
boolean useFac) {
myEnv = environment;
this.ignoreCase = ignoreCase;
init();
this.alwaysUseFactory = useFac;
}
private void init() {
}
}
}
throws NamingException {
case 0:
// name is empty, caller wants this object
target = this;
break;
case 1:
// name is atomic, caller wants one of this object's bindings
break;
default:
// name is compound, delegate to child context
} else {
}
break;
}
}
if (useFactory) {
try {
(target instanceof HierMemDirCtx) ?
} catch (NamingException e) {
throw e;
} catch (Exception e) {
"Problem calling getObjectInstance");
e2.setRootCause(e);
throw e2;
}
} else {
return target;
}
}
}
}
throws NamingException {
}
throws NamingException {
}
boolean useFactory) throws NamingException {
throw new InvalidNameException("Cannot bind empty name");
}
if (useFactory) {
}
}
}
if (readOnlyEx != null) {
}
}
if(obj instanceof HierMemDirCtx) {
} else {
throw new SchemaViolationException(
"This context only supports binding objects of it's own kind");
}
}
}
}
throws NamingException {
}
throws NamingException {
}
boolean useFactory) throws NamingException {
throw new InvalidNameException("Cannot rebind empty name");
}
if (useFactory) {
}
//
// attrs == null -> use attrs from obj
// attrs != null -> use attrs
//
// %%% Strictly speaking, when attrs is non-null, we should
// take the explicit step of removing obj's attrs.
// We don't do that currently.
}
}
if (readOnlyEx != null) {
}
if(obj instanceof HierMemDirCtx) {
} else {
throw new SchemaViolationException(
"This context only supports binding objects of it's own kind");
}
}
}
throw new InvalidNameException("Cannot unbind empty name");
} else {
}
}
if (readOnlyEx != null) {
}
}
throws NamingException {
}
throws NamingException {
throw new InvalidNameException("Cannot rename empty name");
}
throw new InvalidNameException("Cannot rename across contexts");
}
}
if (readOnlyEx != null) {
}
// Check if new name exists
}
// Check if old name is bound
if (oldBinding == null) {
}
}
}
}
}
}
}
throws NamingException {
}
}
}
if (readOnlyEx != null) {
}
}
}
}
throws NamingException {
}
throws NamingException {
}
throws NamingException {
if (readOnlyEx != null) {
}
}
}
return newCtx;
}
// This context does not treat links specially
}
// Flat namespace; no federation; just call string version
}
return myParser;
}
return myParser;
}
throws NamingException {
new CompositeName(prefix));
}
throws NamingException {
return result;
}
throws NamingException {
}
throws NamingException {
return null;
}
} else {
}
}
throws NamingException {
}
throws NamingException {
return ctx.doGetAttributes();
}
}
throws NamingException {
}
throws NamingException {
}
throws NamingException {
return doGetAttributes();
}
}
}
return attrs;
}
throws NamingException {
}
throws NamingException {
throw new IllegalArgumentException(
"Cannot modify without an attribute");
}
// turn it into a modification Enumeration and pass it on
}
}
throws NamingException {
}
throws NamingException {
}
throws NamingException {
if (readOnlyEx != null) {
}
}
switch(mod.getModificationOp()) {
case ADD_ATTRIBUTE:
if (debug) {
}
if (existingAttr == null) {
} else {
// Add new attribute values to existing attribute
}
}
break;
case REPLACE_ATTRIBUTE:
} else {
}
break;
case REMOVE_ATTRIBUTE:
if (existingAttr != null) {
} else {
// Remove attribute values from existing attribute
}
}
}
}
break;
default:
throw new AttributeModificationException("Unknown mod_op");
}
}
return orig;
}
throws NamingException {
}
throws NamingException {
}
throws NamingException {
}
throws NamingException {
return new LazySearchEnumerationImpl(
target.doListBindings(false),
false); // alwaysUseFactory ignored because objReturnFlag == false
}
throws NamingException {
return new LazySearchEnumerationImpl(
}
Object[] filterArgs,
throws NamingException {
}
throws NamingException {
}
Object[] filterArgs,
throws NamingException {
}
// This function is called whenever a new object needs to be created.
// this is used so that if anyone subclasses us, they can override this
// and return object of their own kind.
}
// If the supplied name is a composite name, return the name that
// is its first component.
if(!(name instanceof HierarchicalName)) {
// If name is not of the correct type, make copy
canonicalName = new HierarchicalName();
for(int i = 0; i < n; i++) {
}
}
return canonicalName;
}
}
}
throw new OperationNotSupportedException();
}
throw new OperationNotSupportedException();
}
throws NamingException {
throw new OperationNotSupportedException();
}
throws NamingException {
throw new OperationNotSupportedException();
}
// Set context in readonly mode; throw e when update operation attempted.
readOnlyEx = e;
}
// Set context to support case-insensitive names
this.ignoreCase = ignoreCase;
}
}
}
public boolean hasMoreElements() {
try {
return hasMore();
} catch (NamingException e) {
return false;
}
}
return names.hasMoreElements();
}
try {
return next();
} catch (NamingException e) {
throw new NoSuchElementException(e.toString());
}
}
}
public void close() {
}
}
// Class for enumerating bindings
private boolean useFactory;
this.useFactory = useFactory;
}
if (useFactory) {
try {
} catch (NamingException e) {
throw e;
} catch (Exception e) {
"Problem calling getObjectInstance");
e2.setRootCause(e);
throw e2;
}
}
}
}
throws NamingException {
}
}
throws NamingException {
}
}
}
}
// CompundNames's HashCode() method isn't good enough for many string.
// The only prupose of this subclass is to have a more discerning
// hash function. We'll make up for the performance hit by caching
// the hash value.
// Creates an empty name
HierarchicalName() {
super(new Enumeration() {
public boolean hasMoreElements() {return false;}
},
}
}
super(n, syntax);
}
// just like String.hashCode, only it pays no attention to length
public int hashCode() {
if (hashValue == -1) {
int off = 0;
for (int i = len; i > 0; i--) {
}
}
return hashValue;
}
}
}
}
}
// This is the default name parser (used if setNameParser is not called)
static {
//mySyntax.put("jndi.syntax.separator.ava", "+");
//mySyntax.put("jndi.syntax.separator.typeval", "=");
};
}
}