use of org.glassfish.contextpropagation.internal.Utils.PrivilegedWireAdapterAccessor in project Payara by payara.
the class DefaultWireAdapter method nextEntry.
@Override
public Entry nextEntry() throws IOException, ClassNotFoundException {
String className = null;
Entry.ContextType contextType = Entry.ContextType.fromOrdinal(ois.readByte());
ContextBootstrap.debug(MessageID.READ_CONTEXT_TYPE, contextType);
Object value = null;
switch(contextType) {
case BOOLEAN:
value = ois.readBoolean();
break;
case BYTE:
value = ois.readByte();
break;
case SHORT:
value = ois.readShort();
break;
case INT:
value = ois.readInt();
break;
case LONG:
value = ois.readLong();
break;
case STRING:
value = ois.readUTF();
break;
case ASCII_STRING:
value = readAscii();
break;
case VIEW_CAPABLE:
try {
PrivilegedWireAdapterAccessor priviledgedCM = (PrivilegedWireAdapterAccessor) ContextMapHelper.getScopeAwareContextMap();
priviledgedCM.createViewCapable(key, false);
Entry entry = priviledgedCM.getAccessControlledMap(false).getEntry(key);
ContextBootstrap.debug(MessageID.READ_VALUE, "<a ViewCapable>");
EnumSet<PropagationMode> propModes = readPropModes();
ContextBootstrap.debug(MessageID.READ_PROP_MODES, propModes);
return entry;
} catch (InsufficientCredentialException e) {
throw new AssertionError("Wire adapter should have sufficient privileges to create a ViewCapable.");
}
case SERIALIZABLE:
value = WLSContext.HELPER.readFromBytes(readBytes(ois));
break;
case BIGDECIMAL:
case BIGINTEGER:
case ATOMICINTEGER:
case ATOMICLONG:
value = ois.readObject();
break;
case CHAR:
value = ois.readChar();
break;
case DOUBLE:
value = ois.readDouble();
break;
case FLOAT:
value = ois.readFloat();
break;
case OPAQUE:
boolean hasClassName = ois.readBoolean();
className = hasClassName ? readAscii() : null;
byte[] bytes = readBytes(ois);
SerializableContextFactory factory = WireAdapter.HELPER.findContextFactory(key, className);
value = factory == null ? bytes : WLSContext.HELPER.readFromBytes(factory.createInstance(), bytes);
break;
default:
// TODO log unexpected case
break;
}
ContextBootstrap.debug(MessageID.READ_VALUE, value);
EnumSet<PropagationMode> propModes = readPropModes();
ContextBootstrap.debug(MessageID.READ_PROP_MODES, propModes);
return className == null ? new Entry(value, propModes, contextType) : Entry.createOpaqueEntryInstance(value, propModes, className);
}
Aggregations