use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class CNBindingEnumeration method mapBinding.
/**
* Constructs a JNDI Binding object from the COS Naming binding
* object.
*
* @throws org.omg.CosNaming.NamingContextPackage.CannotProceed Unable to obtain a continuation context
* @throws org.omg.CosNaming.NamingContextPackage.InvalidNameCNCtx Name not understood.
* @throws NamingException One of the above.
*/
private javax.naming.Binding mapBinding(org.omg.CosNaming.Binding bndg) throws NamingException {
java.lang.Object obj = _ctx.callResolve(bndg.binding_name);
Name cname = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(bndg.binding_name);
try {
obj = NamingManager.getObjectInstance(obj, cname, _ctx, _env);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory();
ne.setRootCause(e);
throw ne;
}
// Use cname.toString() instead of bindingName because the name
// in the binding should be a composite name
String cnameStr = cname.toString();
javax.naming.Binding jbndg = new javax.naming.Binding(cnameStr, obj);
NameComponent[] comps = _ctx.makeFullName(bndg.binding_name);
String fullName = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToInsString(comps);
jbndg.setNameInNamespace(fullName);
return jbndg;
}
use of org.omg.CosNaming.NameComponent in project jdk8u_jdk by JetBrains.
the class CNNameParser method parseComponent.
/**
* Return a NameComponent given its stringified form.
*/
private static NameComponent parseComponent(String compStr) throws InvalidNameException {
NameComponent comp = new NameComponent();
int kindSep = -1;
int len = compStr.length();
int j = 0;
char[] newStr = new char[len];
boolean escaped = false;
// Find the kind separator
for (int i = 0; i < len && kindSep < 0; i++) {
if (escaped) {
newStr[j++] = compStr.charAt(i);
escaped = false;
} else if (compStr.charAt(i) == escapeChar) {
if (i + 1 >= len) {
throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
} else if (isMeta(compStr.charAt(i + 1))) {
escaped = true;
} else {
throw new InvalidNameException(compStr + ": invalid character being escaped");
}
} else if (compStr.charAt(i) == kindSeparator) {
kindSep = i;
} else {
newStr[j++] = compStr.charAt(i);
}
}
// Set id
comp.id = new String(newStr, 0, j);
// Set kind
if (kindSep < 0) {
// no kind separator
comp.kind = "";
} else {
// unescape kind
j = 0;
escaped = false;
for (int i = kindSep + 1; i < len; i++) {
if (escaped) {
newStr[j++] = compStr.charAt(i);
escaped = false;
} else if (compStr.charAt(i) == escapeChar) {
if (i + 1 >= len) {
throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
} else if (isMeta(compStr.charAt(i + 1))) {
escaped = true;
} else {
throw new InvalidNameException(compStr + ": invalid character being escaped");
}
} else {
newStr[j++] = compStr.charAt(i);
}
}
comp.kind = new String(newStr, 0, j);
}
return comp;
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class CNCtx method destroySubcontext.
/**
* Uses the callDestroy function to destroy the context. Destroys
* the current context if name is empty.
*
* @param name JNDI Name
* @throws javax.naming.OperationNotSupportedException when list is invoked
* with a non-null argument
*/
public void destroySubcontext(Name name) throws NamingException {
if (_nc == null)
throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
NamingContext the_nc = _nc;
NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name);
if (name.size() > 0) {
try {
javax.naming.Context ctx = (javax.naming.Context) callResolve(path);
CNCtx cnc = (CNCtx) ctx;
the_nc = cnc._nc;
//remove the reference to the context
cnc.close();
} catch (ClassCastException e) {
throw new NotContextException(name.toString());
} catch (CannotProceedException e) {
javax.naming.Context cctx = getContinuationContext(e);
cctx.destroySubcontext(e.getRemainingName());
return;
} catch (NameNotFoundException e) {
if (e.getRootCause() instanceof NotFound && leafNotFound((NotFound) e.getRootCause(), path[path.length - 1])) {
// leaf missing OK
return;
}
throw e;
} catch (NamingException e) {
throw e;
}
}
callDestroy(the_nc);
callUnbind(path);
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class CNNameParser method parseComponent.
/**
* Return a NameComponent given its stringified form.
*/
private static NameComponent parseComponent(String compStr) throws InvalidNameException {
NameComponent comp = new NameComponent();
int kindSep = -1;
int len = compStr.length();
int j = 0;
char[] newStr = new char[len];
boolean escaped = false;
// Find the kind separator
for (int i = 0; i < len && kindSep < 0; i++) {
if (escaped) {
newStr[j++] = compStr.charAt(i);
escaped = false;
} else if (compStr.charAt(i) == escapeChar) {
if (i + 1 >= len) {
throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
} else if (isMeta(compStr.charAt(i + 1))) {
escaped = true;
} else {
throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
}
} else if (compStr.charAt(i) == kindSeparator) {
kindSep = i;
} else {
newStr[j++] = compStr.charAt(i);
}
}
// Set id
comp.id = new String(newStr, 0, j);
// Set kind
if (kindSep < 0) {
// no kind separator
comp.kind = "";
} else {
// unescape kind
j = 0;
escaped = false;
for (int i = kindSep + 1; i < len; i++) {
if (escaped) {
newStr[j++] = compStr.charAt(i);
escaped = false;
} else if (compStr.charAt(i) == escapeChar) {
if (i + 1 >= len) {
throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
} else if (isMeta(compStr.charAt(i + 1))) {
escaped = true;
} else {
throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
}
} else {
newStr[j++] = compStr.charAt(i);
}
}
comp.kind = new String(newStr, 0, j);
}
return comp;
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class CNNameParser method insStringToStringifiedComps.
/**
* Converts an INS-syntax string name into a Vector in which
* each element of the vector contains a stringified form of
* a NameComponent.
*/
private static Vector insStringToStringifiedComps(String str) throws InvalidNameException {
int len = str.length();
Vector components = new Vector(10);
char[] id = new char[len];
char[] kind = new char[len];
int idCount, kindCount;
boolean idMode;
for (int i = 0; i < len; ) {
// reset for new component
idCount = kindCount = 0;
// always start off parsing id
idMode = true;
while (i < len) {
if (str.charAt(i) == compSeparator) {
break;
} else if (str.charAt(i) == escapeChar) {
if (i + 1 >= len) {
throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(str);
} else if (isMeta(str.charAt(i + 1))) {
// skip escape and let meta through
++i;
if (idMode) {
id[idCount++] = str.charAt(i++);
} else {
kind[kindCount++] = str.charAt(i++);
}
} else {
throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(str);
}
} else if (idMode && str.charAt(i) == kindSeparator) {
// just look for the first kindSeparator
// skip kind separator
++i;
idMode = false;
} else {
if (idMode) {
id[idCount++] = str.charAt(i++);
} else {
kind[kindCount++] = str.charAt(i++);
}
}
}
components.addElement(stringifyComponent(new NameComponent(new String(id, 0, idCount), new String(kind, 0, kindCount))));
if (i < len) {
// skip separator
++i;
}
}
return components;
}
Aggregations