All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.bagofwords.web.WebContainerConfiguration Maven / Gradle / Ivy

Go to download

Utility classes that are used in the count-db project and other bow-* projects

There is a newer version: 1.2.0
Show newest version
package be.bagofwords.web;

import be.bagofwords.application.MainClass;
import be.bagofwords.application.annotations.BowConfiguration;
import be.bagofwords.util.HashUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;

@BowConfiguration
public class WebContainerConfiguration {

    @Bean
    @Autowired
    public WebContainer createWebContainer(MainClass mainClass) {
        long hashCode = HashUtils.hashCode(mainClass.getClass().getSimpleName());
        if (hashCode < 0) {
            hashCode = -hashCode;
        }
        int randomPortForApplication = (int) (1023 + (hashCode % (65535 - 1023)));
        return new WebContainer(randomPortForApplication);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy