use of org.glassfish.contextpropagation.weblogic.workarea.spi.WorkContextEntry in project Payara by payara.
the class WorkContextLocalMap method remove.
public WorkContext remove(String key) throws NoWorkContextException, PropertyReadOnlyException {
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "remove(" + key + ")");
}
WorkContextEntry wce = getEntry(key);
if (wce == WorkContextEntry.NULL_CONTEXT) {
throw new NoWorkContextException(key);
} else if (!wce.isOriginator() && !WorkContextAccessController.isAccessAllowed(key, WorkContextAccessController.DELETE)) {
throw new PropertyReadOnlyException("No DELETE permission for key: \"" + key + "\"");
} else {
map.remove(key);
}
version++;
return wce.getWorkContext();
}
use of org.glassfish.contextpropagation.weblogic.workarea.spi.WorkContextEntry in project Payara by payara.
the class WorkContextLocalMap method put.
// Implementation of weblogic.workarea.WorkContextMap
@SuppressWarnings("unchecked")
public WorkContext put(String key, WorkContext workContext, int propagationMode) throws PropertyReadOnlyException {
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "put(" + key + ", " + workContext + ")");
}
if (key == null || key.equals("")) {
throw new NullPointerException("Cannot use null key");
}
if (workContext == null) {
throw new NullPointerException("Cannot use null WorkContext");
}
WorkContextEntry wce = (WorkContextEntry) map.get(key);
if (wce != null) {
// Can't modify read-only properties
if (!WorkContextAccessController.isAccessAllowed(key, WorkContextAccessController.UPDATE)) {
throw new PropertyReadOnlyException(key);
}
} else if (!WorkContextAccessController.isAccessAllowed(key, WorkContextAccessController.CREATE)) {
throw new AccessControlException("No CREATE permission for key: \"" + key + "\"");
}
// Replace whatever is there.
map.put(key, new WorkContextEntryImpl(key, workContext, propagationMode));
version++;
return wce == null ? null : wce.getWorkContext();
}
use of org.glassfish.contextpropagation.weblogic.workarea.spi.WorkContextEntry in project Payara by payara.
the class WorkContextLocalMap method receiveResponse.
@SuppressWarnings("unchecked")
public void receiveResponse(WorkContextInput in) throws IOException {
HashSet<String> propKeySet = new HashSet<String>();
// should come back in the response.
synchronized (map) {
for (Iterator<WorkContextEntry> i = map.values().iterator(); i.hasNext(); ) {
WorkContextEntry wce = (WorkContextEntry) i.next();
int propMode = wce.getPropagationMode();
// If PropagationMode is "not" ONEWAY and LOCAL, remove the entry
if (((propMode & PropagationMode.ONEWAY) == 0) && ((propMode & PropagationMode.LOCAL) == 0)) {
propKeySet.add(wce.getName());
i.remove();
version++;
}
}
}
// Nothing is as nothing does.
if (in == null) {
return;
}
// properties.
while (true) {
try {
WorkContextEntry wce = WorkContextEntryImpl.readEntry(in);
version++;
if (wce == WorkContextEntry.NULL_CONTEXT) {
break;
}
if (propKeySet.contains(wce.getName())) {
// this allows the caller to remain the originator of the properties.
map.put(wce.getName(), new WorkContextEntryImpl(wce.getName(), wce.getWorkContext(), wce.getPropagationMode()));
} else {
map.put(wce.getName(), wce);
}
} catch (ClassNotFoundException cnfe) {
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "receiveResponse : ", cnfe);
}
// Ignored and proceed with other entries
// FIX ME andyp 19-Aug-08 -- need to log this failure.
}
}
}
use of org.glassfish.contextpropagation.weblogic.workarea.spi.WorkContextEntry in project Payara by payara.
the class WorkContextLocalMap method copyThreadContexts.
@SuppressWarnings("unchecked")
public WorkContextMapInterceptor copyThreadContexts(int mode) {
if (map.isEmpty()) {
return null;
}
WorkContextLocalMap copy = new WorkContextLocalMap();
copy.map.putAll(map);
copy.version = version;
for (Iterator<WorkContextEntry> i = copy.map.values().iterator(); i.hasNext(); ) {
WorkContextEntry e = (WorkContextEntry) i.next();
if ((e.getPropagationMode() & mode) == 0) {
i.remove();
}
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "copyThreadContexts(" + e.toString() + ")");
}
}
if (copy.map.isEmpty()) {
return null;
} else {
return copy;
}
}
use of org.glassfish.contextpropagation.weblogic.workarea.spi.WorkContextEntry in project Payara by payara.
the class WorkContextLocalMap method receiveRequest.
@SuppressWarnings("unchecked")
public void receiveRequest(WorkContextInput in) throws IOException {
while (true) {
try {
WorkContextEntry wce = WorkContextEntryImpl.readEntry(in);
if (wce == WorkContextEntry.NULL_CONTEXT) {
break;
}
String key = wce.getName();
map.put(key, wce);
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "receiveRequest(" + wce.toString() + ")");
}
} catch (ClassNotFoundException cnfe) {
if (debugWorkContext.isLoggable(Level.FINEST)) {
debugWorkContext.log(Level.FINEST, "receiveRequest : ", cnfe);
}
// Ignored and proceed with other entries
// FIX ME andyp 19-Aug-08 -- need to log this failure.
}
}
}
Aggregations