spring-framework / org.springframework.util / SocketUtils / <init>

<init>

SocketUtils()

Although SocketUtils consists solely of static utility methods, this constructor is intentionally public. Rationale

Static methods from this class may be invoked from within XML configuration files using the Spring Expression Language (SpEL) and the following syntax.

<bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" />
If this constructor were private, you would be required to supply the fully qualified class name to SpEL's T() function for each usage. Thus, the fact that this constructor is public allows you to reduce boilerplate configuration with SpEL as can be seen in the following example.
<bean id="socketUtils" class="org.springframework.util.SocketUtils" /> <bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" /> <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" />