Skip to content

Commit

Permalink
Cleanups, tiny optimizations and removals of unused code
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Nov 14, 2022
1 parent 41ce2ef commit 1e1482a
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 181 deletions.
Expand Up @@ -396,7 +396,7 @@ public Object lookup(String name) throws NamingException {
}


private Object lookup(String name, int level ) throws NamingException {
private Object lookup(String name, int level) throws NamingException {
// Before any lookup bind any NamedNamingObjectProxy
// Skip if in plain Java SE client
// FIXME this should really be moved somewhere else
Expand Down
Expand Up @@ -63,7 +63,7 @@ public class TransientContext implements Context, Serializable {
// Issue 7067: lots of lookup failures in a heavily concurrent client.
// So add a read/write lock, which allows unlimited concurrent readers,
// and only imposes a global lock on relatively infrequent updates.
private static final ReadWriteLock lock = new ReentrantReadWriteLock() ;
private static final ReadWriteLock lock = new ReentrantReadWriteLock();

public TransientContext() {
}
Expand Down Expand Up @@ -132,22 +132,20 @@ private Context drillDownAndCreateSubcontext(String name) throws NamingException
if (bindings.containsKey(name)) {
throw new NameAlreadyBoundException("Subcontext " + name + " already present");
}

TransientContext ctx = null;
ctx = new TransientContext();
TransientContext ctx = new TransientContext();
bindings.put(name, ctx);
return ctx;
}
String suffix = n.getSuffix(1).toString();
Context retCtx, ctx; // the created context
Context ctx;
try {
ctx = resolveContext(n.get(0));
} catch (NameNotFoundException e) {
ctx = new TransientContext();
}
retCtx = ctx.createSubcontext(suffix);
Context subCtx = ctx.createSubcontext(suffix);
bindings.put(n.get(0), ctx);
return retCtx;
return subCtx;
} finally {
lock.writeLock().unlock();
}
Expand Down Expand Up @@ -257,11 +255,12 @@ public void bind(String name, Object obj) throws NamingException {
doBindOrRebind(n.toString(), obj, false);
} else {
String suffix = n.getSuffix(1).toString();
String subCtxName = n.get(0);
Context ctx;
try {
ctx = resolveContext(n.get(0));
ctx = resolveContext(subCtxName);
} catch (NameNotFoundException e) {
ctx = createSubcontext(n.get(0));
ctx = createSubcontext(subCtxName);
}
ctx.bind(suffix, obj);
}
Expand Down
Expand Up @@ -56,6 +56,7 @@ public <T> T create(Context ic) throws NamingException {
try {
// FIXME: race conditions?
ic.addToEnvironment(GlassfishNamingManager.LOGICAL_NAME, name);
// FIXME: always false.
if (cacheResult) {
result = value.get();
if (result == null) {
Expand Down
Expand Up @@ -412,7 +412,7 @@ public void startElement(String uri, String localName, String qName, Attributes
}

if (LOG.isLoggable(Level.FINER)) {
LOG.finer("start of element " + uri + " with local name "+ localName + " and " + qName);
LOG.finer("start of element with uri=" + uri + ", localName=" + localName + " and qName=" + qName);
}
XMLNode<?> node = null;
elementData = new StringBuffer();
Expand Down Expand Up @@ -475,8 +475,8 @@ public void endElement(String uri, String localName, String qName) {
}

if (LOG.isLoggable(Level.FINER)) {
LOG.finer(
"End of element " + uri + " local name " + localName + " and " + qName + " value " + elementData);
LOG.finer("End of element with uri=" + uri + ", localName=" + localName + ", qName=" + qName + " and value="
+ elementData);
}
if (nodes.isEmpty()) {
// no more nodes to pop
Expand Down
Expand Up @@ -72,17 +72,6 @@ private Constants() { /* disallow instantiation */ }
public static final String ENVIRONMENT_VALUE = "env-entry-value";
public static final String ENVIRONMENT_TYPE = "env-entry-type";


public static final String RESOURCE_REFERENCE = "resource-ref";
public static final String RESOURCE_REFERENCE_NAME = "res-ref-name";
public static final String RESOURCE_TYPE = "res-type";
public static final String RESOURCE_AUTHORIZATION = "res-auth";


public static final String RESOURCE_ENV_REFERENCE = "resource-env-ref";
public static final String RESOURCE_ENV_REFERENCE_NAME = "resource-env-ref-name";
public static final String RESOURCE_ENV_REFERENCE_TYPE = "resource-env-ref-type";

public static final String SECURITY_ROLE = "security-role";
public static final String ROLE_NAME = "role-name";
public static final String NAME = "name";
Expand Down

0 comments on commit 1e1482a

Please sign in to comment.