Skip to content

Commit

Permalink
CAMEL-6934 enabling dns addresses to not get cached
Browse files Browse the repository at this point in the history
  • Loading branch information
mach10 committed Dec 1, 2013
1 parent 46b5128 commit 3c3f4f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Mina2Configuration implements Cloneable {
private boolean autoStartTls = true;
private int maximumPoolSize = 16; // 16 is the default mina setting
private boolean orderedThreadPoolExecutor = true;
private boolean cachedAddress = true;

/**
* Returns a copy of this configuration
Expand Down Expand Up @@ -263,7 +264,19 @@ public boolean isOrderedThreadPoolExecutor() {
public void setOrderedThreadPoolExecutor(boolean orderedThreadPoolExecutor) {
this.orderedThreadPoolExecutor = orderedThreadPoolExecutor;
}


public void setCachedAddress(boolean shouldCacheAddress){
this.cachedAddress = shouldCacheAddress;
}

public boolean getCachedAddress(){
return this.cachedAddress;
}

public boolean isCachedAddress(){
return this.getCachedAddress();
}

// here we just shows the option setting of host, port, protocol
public String getUriString() {
return "mina2:" + getProtocol() + ":" + getHost() + ":" + getPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ private void closeConnection() {
}

private void openConnection() {
if(this.address == null || !this.configuration.isCachedAddress()){
setSocketAddress(this.configuration.getProtocol());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Creating connector to address: {} using connector: {} timeout: {} millis.", new Object[]{address, connector, timeout});
}
Expand Down Expand Up @@ -447,6 +450,16 @@ private void appendIoFiltersToChain(List<IoFilter> filters, DefaultIoFilterChain
}
}

private void setSocketAddress(String protocol){
if(protocol.equals("tcp")){
this.address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
}else if(configuration.isDatagramProtocol()){
this.address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
}else if(protocol.equals("vm")){
this.address = new VmPipeAddress(configuration.getPort());
}
}

/**
* Handles response from session writes
*/
Expand Down

0 comments on commit 3c3f4f0

Please sign in to comment.