Skip to content

Commit

Permalink
Merge pull request #261 from TomasHofman/EJBCLIENT-218
Browse files Browse the repository at this point in the history
EJBCLIENT-218 Propagate invocation.timeout setting from legacy proper…
  • Loading branch information
dmlloyd authored Apr 28, 2017
2 parents 5ad49bc + 3993c60 commit 44466fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/org/jboss/ejb/client/EJBRootContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.URI;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.TimeUnit;

import javax.naming.Binding;
import javax.naming.Name;
Expand All @@ -38,6 +39,9 @@
import org.wildfly.security.auth.client.AuthenticationConfiguration;

class EJBRootContext extends AbstractContext {

private static final String PROPERTY_KEY_INVOCATION_TIMEOUT = "invocation.timeout";

private final Affinity affinity;
private final NamingProvider namingProvider;

Expand Down Expand Up @@ -149,7 +153,15 @@ protected Object lookupNative(final Name name) throws NamingException {
} else {
locator = StatelessEJBLocator.create(view, identifier, affinity);
}
return EJBClient.createProxy(locator, authenticationConfiguration, sslContext);
Object proxy = EJBClient.createProxy(locator, authenticationConfiguration, sslContext);

// if "invocation.timeout" is set in environment properties, set this value to created proxy
Long invocationTimeout = getLongValueFromEnvironment(PROPERTY_KEY_INVOCATION_TIMEOUT);
if (invocationTimeout != null) {
EJBClient.setInvocationTimeout(proxy, invocationTimeout, TimeUnit.MILLISECONDS);
}

return proxy;
}

private static ClassLoader getContextClassLoader(){
Expand Down Expand Up @@ -185,4 +197,12 @@ public void close() throws NamingException {
public String getNameInNamespace() throws NamingException {
return "";
}

private Long getLongValueFromEnvironment(String key) throws NamingException {
Object val = getEnvironment().get(key);
if (val != null && val instanceof String) {
return Long.parseLong((String) val);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public static void configure(final EJBClientContext.Builder builder) {
}
builder.setDeploymentNodeSelector(deploymentNodeSelector);
}

if (properties.getInvocationTimeout() != -1L) {
builder.setInvocationTimeout(properties.getInvocationTimeout());
}
}
}
}

0 comments on commit 44466fa

Please sign in to comment.