Skip to content

Commit

Permalink
Merge pull request #235 from kabir/JBEAP-9352
Browse files Browse the repository at this point in the history
[EJBCLIENT-200] Make the Builder methods return this
  • Loading branch information
dmlloyd authored Mar 16, 2017
2 parents 5682fea + a7399c0 commit a3053cf
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 46 deletions.
15 changes: 10 additions & 5 deletions src/main/java/org/jboss/ejb/client/EJBClientCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,32 @@ public static final class Builder {
public Builder() {
}

public void setName(final String name) {
public Builder setName(final String name) {
Assert.checkNotNullParam("name", name);
this.name = name;
return this;
}

public void setMaximumConnectedNodes(final long maximumConnectedNodes) {
public Builder setMaximumConnectedNodes(final long maximumConnectedNodes) {
Assert.checkMinimumParameter("maximumConnectedNodes", 0, maximumConnectedNodes);
this.maximumConnectedNodes = maximumConnectedNodes;
return this;
}

public void setConnectTimeoutMilliseconds(final long connectTimeoutMilliseconds) {
public Builder setConnectTimeoutMilliseconds(final long connectTimeoutMilliseconds) {
Assert.checkMinimumParameter("connectTimeoutMilliseconds", -1L, connectTimeoutMilliseconds);
this.connectTimeoutMilliseconds = connectTimeoutMilliseconds;
return this;
}

public void setClusterNodeSelector(final ClusterNodeSelector clusterNodeSelector) {
public Builder setClusterNodeSelector(final ClusterNodeSelector clusterNodeSelector) {
this.clusterNodeSelector = clusterNodeSelector;
return this;
}

public void setOverrideConfiguration(final AuthenticationConfiguration overrideConfiguration) {
public Builder setOverrideConfiguration(final AuthenticationConfiguration overrideConfiguration) {
this.overrideConfiguration = overrideConfiguration;
return this;
}

/**
Expand Down
36 changes: 24 additions & 12 deletions src/main/java/org/jboss/ejb/client/EJBClientContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,97 +541,109 @@ public Builder() {
invocationTimeout = clientContext.invocationTimeout;
}

public void addInterceptor(EJBClientInterceptor interceptor) {
public Builder addInterceptor(EJBClientInterceptor interceptor) {
Assert.checkNotNullParam("interceptor", interceptor);
if (globalInterceptors == null) {
globalInterceptors = new ArrayList<>();
}
globalInterceptors.add(EJBClientInterceptorInformation.forInstance(interceptor));
return this;
}

public void addInterceptor(Class<? extends EJBClientInterceptor> interceptorClass) {
public Builder addInterceptor(Class<? extends EJBClientInterceptor> interceptorClass) {
Assert.checkNotNullParam("interceptorClass", interceptorClass);
if (globalInterceptors == null) {
globalInterceptors = new ArrayList<>();
}
globalInterceptors.add(EJBClientInterceptorInformation.forClass(interceptorClass));
return this;
}

public void addClassInterceptor(String className, EJBClientInterceptor interceptor) {
public Builder addClassInterceptor(String className, EJBClientInterceptor interceptor) {
Assert.checkNotNullParam("className", className);
Assert.checkNotNullParam("interceptor", interceptor);
if (classInterceptors == null) {
classInterceptors = new ArrayList<>();
}
classInterceptors.add(new ClassInterceptor(className, EJBClientInterceptorInformation.forInstance(interceptor)));
return this;
}

public void addClassInterceptor(String className, Class<? extends EJBClientInterceptor> interceptorClass) {
public Builder addClassInterceptor(String className, Class<? extends EJBClientInterceptor> interceptorClass) {
Assert.checkNotNullParam("className", className);
Assert.checkNotNullParam("interceptorClass", interceptorClass);
if (classInterceptors == null) {
classInterceptors = new ArrayList<>();
}
classInterceptors.add(new ClassInterceptor(className, EJBClientInterceptorInformation.forClass(interceptorClass)));
return this;
}

public void addMethodInterceptor(String className, EJBMethodLocator methodLocator, EJBClientInterceptor interceptor) {
public Builder addMethodInterceptor(String className, EJBMethodLocator methodLocator, EJBClientInterceptor interceptor) {
Assert.checkNotNullParam("className", className);
Assert.checkNotNullParam("methodLocator", methodLocator);
Assert.checkNotNullParam("interceptor", interceptor);
if (methodInterceptors == null) {
methodInterceptors = new ArrayList<>();
}
methodInterceptors.add(new MethodInterceptor(className, methodLocator, EJBClientInterceptorInformation.forInstance(interceptor)));
return this;
}

public void addMethodInterceptor(String className, EJBMethodLocator methodLocator, Class<? extends EJBClientInterceptor> interceptorClass) {
public Builder addMethodInterceptor(String className, EJBMethodLocator methodLocator, Class<? extends EJBClientInterceptor> interceptorClass) {
Assert.checkNotNullParam("className", className);
Assert.checkNotNullParam("methodLocator", methodLocator);
Assert.checkNotNullParam("interceptorClass", interceptorClass);
if (methodInterceptors == null) {
methodInterceptors = new ArrayList<>();
}
methodInterceptors.add(new MethodInterceptor(className, methodLocator, EJBClientInterceptorInformation.forClass(interceptorClass)));
return this;
}

public void addTransportProvider(EJBTransportProvider provider) {
public Builder addTransportProvider(EJBTransportProvider provider) {
Assert.checkNotNullParam("provider", provider);
if (transportProviders == null) {
transportProviders = new ArrayList<>();
}
transportProviders.add(provider);
return this;
}

public void addClientConnection(EJBClientConnection connection) {
public Builder addClientConnection(EJBClientConnection connection) {
Assert.checkNotNullParam("connection", connection);
if (clientConnections == null) {
clientConnections = new ArrayList<>();
}
clientConnections.add(connection);
return this;
}

public void addClientCluster(EJBClientCluster cluster) {
public Builder addClientCluster(EJBClientCluster cluster) {
Assert.checkNotNullParam("cluster", cluster);
if (clientClusters == null) {
clientClusters = new ArrayList<>();
}
clientClusters.add(cluster);
return this;
}

public void setClusterNodeSelector(final ClusterNodeSelector clusterNodeSelector) {
public Builder setClusterNodeSelector(final ClusterNodeSelector clusterNodeSelector) {
Assert.checkNotNullParam("clusterNodeSelector", clusterNodeSelector);
this.clusterNodeSelector = clusterNodeSelector;
return this;
}

public void setDeploymentNodeSelector(final DeploymentNodeSelector deploymentNodeSelector) {
public Builder setDeploymentNodeSelector(final DeploymentNodeSelector deploymentNodeSelector) {
Assert.checkNotNullParam("deploymentNodeSelector", deploymentNodeSelector);
this.deploymentNodeSelector = deploymentNodeSelector;
return this;
}

public void setInvocationTimeout(final long invocationTimeout) {
public Builder setInvocationTimeout(final long invocationTimeout) {
Assert.checkMinimumParameter("invocationTimeout", 0L, invocationTimeout);
this.invocationTimeout = invocationTimeout;
return this;
}

public EJBClientContext build() {
Expand Down
87 changes: 58 additions & 29 deletions src/main/java/org/jboss/ejb/client/legacy/JBossEJBProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,40 +469,49 @@ static final class Builder extends CommonSubconfiguration.Builder {
Builder() {
}

void setEndpointName(final String endpointName) {
Builder setEndpointName(final String endpointName) {
this.endpointName = endpointName;
return this;
}

void setEndpointCreationOptions(final OptionMap endpointCreationOptions) {
Builder setEndpointCreationOptions(final OptionMap endpointCreationOptions) {
this.endpointCreationOptions = endpointCreationOptions;
return this;
}

void setRemoteConnectionProviderCreationOptions(final OptionMap remoteConnectionProviderCreationOptions) {
Builder setRemoteConnectionProviderCreationOptions(final OptionMap remoteConnectionProviderCreationOptions) {
this.remoteConnectionProviderCreationOptions = remoteConnectionProviderCreationOptions;
return this;
}

void setConnectionList(final List<ConnectionConfiguration> connectionList) {
Builder setConnectionList(final List<ConnectionConfiguration> connectionList) {
this.connectionList = connectionList;
return this;
}

void setClusterConfigurations(final Map<String, ClusterConfiguration> clusterConfigurations) {
Builder setClusterConfigurations(final Map<String, ClusterConfiguration> clusterConfigurations) {
this.clusterConfigurations = clusterConfigurations;
return this;
}

void setInvocationTimeout(final long invocationTimeout) {
Builder setInvocationTimeout(final long invocationTimeout) {
this.invocationTimeout = invocationTimeout;
return this;
}

void setReconnectTimeout(final long reconnectTimeout) {
Builder setReconnectTimeout(final long reconnectTimeout) {
this.reconnectTimeout = reconnectTimeout;
return this;
}

void setDeploymentNodeSelectorClassName(final String deploymentNodeSelectorClassName) {
Builder setDeploymentNodeSelectorClassName(final String deploymentNodeSelectorClassName) {
this.deploymentNodeSelectorClassName = deploymentNodeSelectorClassName;
return this;
}

void setDeploymentNodeSelectorSupplier(final ExceptionSupplier<DeploymentNodeSelector, ReflectiveOperationException> deploymentNodeSelectorSupplier) {
Builder setDeploymentNodeSelectorSupplier(final ExceptionSupplier<DeploymentNodeSelector, ReflectiveOperationException> deploymentNodeSelectorSupplier) {
this.deploymentNodeSelectorSupplier = deploymentNodeSelectorSupplier;
return this;
}
}

Expand Down Expand Up @@ -565,32 +574,39 @@ abstract static class Builder {
Builder() {
}

void setConnectionOptions(final OptionMap connectionOptions) {
Builder setConnectionOptions(final OptionMap connectionOptions) {
this.connectionOptions = connectionOptions;
return this;
}

void setCallbackHandlerClassName(final String callbackHandlerClassName) {
Builder setCallbackHandlerClassName(final String callbackHandlerClassName) {
this.callbackHandlerClassName = callbackHandlerClassName;
return this;
}

void setCallbackHandlerSupplier(final ExceptionSupplier<CallbackHandler, ReflectiveOperationException> callbackHandlerSupplier) {
Builder setCallbackHandlerSupplier(final ExceptionSupplier<CallbackHandler, ReflectiveOperationException> callbackHandlerSupplier) {
this.callbackHandlerSupplier = callbackHandlerSupplier;
return this;
}

void setConnectionTimeout(final long connectionTimeout) {
Builder setConnectionTimeout(final long connectionTimeout) {
this.connectionTimeout = connectionTimeout;
return this;
}

void setChannelOptions(final OptionMap channelOptions) {
Builder setChannelOptions(final OptionMap channelOptions) {
this.channelOptions = channelOptions;
return this;
}

void setConnectEagerly(final boolean connectEagerly) {
Builder setConnectEagerly(final boolean connectEagerly) {
this.connectEagerly = connectEagerly;
return this;
}

void setAuthenticationConfiguration(final AuthenticationConfiguration authenticationConfiguration) {
Builder setAuthenticationConfiguration(final AuthenticationConfiguration authenticationConfiguration) {
this.authenticationConfiguration = authenticationConfiguration;
return this;
}

boolean populateFromProperties(final Properties properties, final String prefix, final ClassLoader classLoader, final Builder defaultsBuilder) {
Expand Down Expand Up @@ -687,12 +703,14 @@ boolean populateFromProperties(final Properties properties, final String prefix,
return true;
}

void setHost(final String host) {
Builder setHost(final String host) {
this.host = host;
return this;
}

void setPort(final int port) {
Builder setPort(final int port) {
this.port = port;
return this;
}
}
}
Expand Down Expand Up @@ -743,24 +761,29 @@ static final class Builder extends CommonSubconfiguration.Builder {
Builder() {
}

void setClusterName(final String clusterName) {
Builder setClusterName(final String clusterName) {
this.clusterName = clusterName;
return this;
}

void setMaximumAllowedConnectedNodes(final long maximumAllowedConnectedNodes) {
Builder setMaximumAllowedConnectedNodes(final long maximumAllowedConnectedNodes) {
this.maximumAllowedConnectedNodes = maximumAllowedConnectedNodes;
return this;
}

void setClusterNodeSelectorClassName(final String clusterNodeSelectorClassName) {
Builder setClusterNodeSelectorClassName(final String clusterNodeSelectorClassName) {
this.clusterNodeSelectorClassName = clusterNodeSelectorClassName;
return this;
}

void setClusterNodeSelectorSupplier(final ExceptionSupplier<ClusterNodeSelector, ReflectiveOperationException> clusterNodeSelectorSupplier) {
Builder setClusterNodeSelectorSupplier(final ExceptionSupplier<ClusterNodeSelector, ReflectiveOperationException> clusterNodeSelectorSupplier) {
this.clusterNodeSelectorSupplier = clusterNodeSelectorSupplier;
return this;
}

void setNodeConfigurations(final List<ClusterNodeConfiguration> nodeConfigurations) {
Builder setNodeConfigurations(final List<ClusterNodeConfiguration> nodeConfigurations) {
this.nodeConfigurations = nodeConfigurations;
return this;
}

boolean populateFromProperties(final Properties properties, final String prefix, final ClassLoader classLoader, final CommonSubconfiguration.Builder defaultsBuilder) {
Expand Down Expand Up @@ -825,8 +848,9 @@ static final class Builder extends CommonSubconfiguration.Builder {
Builder() {
}

void setNodeName(final String nodeName) {
Builder setNodeName(final String nodeName) {
this.nodeName = nodeName;
return this;
}
}
}
Expand Down Expand Up @@ -876,24 +900,29 @@ static final class Builder {
Builder() {
}

void setUserName(final String userName) {
Builder setUserName(final String userName) {
this.userName = userName;
return this;
}

void setPassword(final String password) {
Builder setPassword(final String password) {
this.password = password;
return this;
}

void setMechanismRealm(final String mechanismRealm) {
Builder setMechanismRealm(final String mechanismRealm) {
this.mechanismRealm = mechanismRealm;
return this;
}

void setCallbackHandlerClassName(final String callbackHandlerClassName) {
Builder setCallbackHandlerClassName(final String callbackHandlerClassName) {
this.callbackHandlerClassName = callbackHandlerClassName;
return this;
}

void setCallbackHandlerSupplier(final ExceptionSupplier<CallbackHandler, ReflectiveOperationException> callbackHandlerSupplier) {
Builder setCallbackHandlerSupplier(final ExceptionSupplier<CallbackHandler, ReflectiveOperationException> callbackHandlerSupplier) {
this.callbackHandlerSupplier = callbackHandlerSupplier;
return this;
}

boolean populateFromProperties(final Properties properties, final String prefix, final ClassLoader classLoader) {
Expand Down

0 comments on commit a3053cf

Please sign in to comment.