Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to override ServerThread name #93

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
SubethaSMTP.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.subethamail.smtp.server;

public class DefaultServerThreadNameProvider implements ServerThreadNameProvider {

public String getName(SMTPServer server) {
return ServerThread.class.getName() + " " + server.getDisplayableLocalSocketAddress();
}
}
14 changes: 14 additions & 0 deletions src/main/java/org/subethamail/smtp/server/SMTPServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class SMTPServer
@GuardedBy("this")
private ServerThread serverThread;

private ServerThreadNameProvider serverThreadNameProvider = new DefaultServerThreadNameProvider();

/**
* True if this SMTPServer was started. It remains true even if the
* SMTPServer has been stopped since. It is used to prevent restarting this
Expand Down Expand Up @@ -603,4 +605,16 @@ public SessionIdFactory getSessionIdFactory() {
public void setSessionIdFactory(SessionIdFactory sessionIdFactory) {
this.sessionIdFactory = sessionIdFactory;
}

/**
* Sets a thread name provider
* @param provider
*/
public void setServerThreadNameProvider(ServerThreadNameProvider provider){
this.serverThreadNameProvider = provider;
}

String getServerThreadName() {
return this.serverThreadNameProvider.getName(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ServerThread extends Thread

public ServerThread(SMTPServer server, ServerSocket serverSocket)
{
super(ServerThread.class.getName() + " " + server.getDisplayableLocalSocketAddress());
super(server.getServerThreadName());
this.server = server;
this.serverSocket = serverSocket;
// reserve a few places for graceful disconnects with informative
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.subethamail.smtp.server;

public interface ServerThreadNameProvider {

/**
* Generates a thead name for given server
*
* @param server
*/
String getName(SMTPServer server);
}