Skip to content

Commit

Permalink
[EJBCLIENT-347] Add ability to close opened channels for given EJBCli…
Browse files Browse the repository at this point in the history
…entContext
  • Loading branch information
tadamski committed Dec 20, 2019
1 parent 5dea742 commit 6fe254a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/jboss/ejb/_private/Logs.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public interface Logs extends BasicLogger {

@LogMessage(level = ERROR)
@Message(id = 508, value = "Failed to execute Runnable %s")
void taskFailed(Runnable runnable, @Cause Throwable t);
void taskFailed(Runnable runnable, @Cause Throwable t);

@LogMessage(level = ERROR)
@Message(id = 509, value = "Unexpected exception processing EJB request")
Expand All @@ -432,6 +432,10 @@ public interface Logs extends BasicLogger {
@Message(id = 512, value = "Server error (remote EJB is not stateful): %s")
EJBException ejbNotStateful(String serverMessage);

@LogMessage(level = ERROR)
@Message(id = 513, value = "Exception occurred when trying to close the transport provider")
void exceptionDuringTransportProviderClose(@Cause Exception e);

// Remote messages; no ID for brevity but should be translated

@Message(value = "No such EJB: %s")
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/jboss/ejb/client/EJBClientContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,16 @@ DeploymentNodeSelector getDeploymentNodeSelector() {
return deploymentNodeSelector;
}

public void close() {
for (EJBTransportProvider transportProvider : transportProviders) {
try {
transportProvider.close(receiverContext);
} catch (Exception e) {
log.exceptionDuringTransportProviderClose(e);
}
}
}

static final class ClassInterceptor {
private final String className;
private final EJBClientInterceptorInformation interceptor;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jboss/ejb/client/EJBTransportProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ default void notifyRegistered(EJBReceiverContext receiverContext) {}
* @throws IllegalArgumentException if the protocol is not supported
*/
EJBReceiver getReceiver(EJBReceiverContext receiverContext, String uriScheme) throws IllegalArgumentException;

void close(EJBReceiverContext receiverContext) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ private IoFuture<ConnectionPeerIdentity> getConnection(final AbstractInvocationC
return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> Endpoint.getCurrent().getConnectedIdentity(target, "ejb", "jboss", authenticationContext));
}
}

public void close() throws Exception {
serviceHandle.closeChannel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ public EJBReceiver getReceiver(final EJBReceiverContext receiverContext, final S
}
}
}

public void close(final EJBReceiverContext receiverContext) throws Exception {
receiverContext.getClientContext().getAttachment(ATTACHMENT_KEY).close();
}
}

0 comments on commit 6fe254a

Please sign in to comment.