<commit_before>/*
 * Copyright 2017 FBK/CREATE-NET
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.createnet.raptor.auth.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import javax.sql.DataSource;
import org.createnet.raptor.models.auth.Role;
import org.createnet.raptor.models.auth.User;
import org.createnet.raptor.auth.service.repository.UserRepository;
import org.createnet.raptor.auth.service.services.BrokerMessageHandler;
import org.createnet.raptor.auth.service.services.UserService;
import org.createnet.raptor.config.ConfigurationLoader;
import org.createnet.raptor.dispatcher.DispatcherConfiguration;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Profile;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
@Profile("default")
@SpringBootApplication(exclude = { EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
@EnableCaching
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableRetry
@EntityScan(basePackageClasses = org.createnet.raptor.models.auth.User.class)
@ComponentScan(basePackages = "org.createnet.raptor.auth.service")
@EnableScheduling
public class Application {

    static final public ObjectMapper mapper = new ObjectMapper();

    static ConfigurableApplicationContext instance;

    public static void main(String[] args) {
        getInstance();
    }

    static public ConfigurableApplicationContext getInstance() {
        return getInstance(new String[]{});
    }

    static public ConfigurableApplicationContext getInstance(String[] args) {
        if (instance == null) {
            instance = new SpringApplicationBuilder(Application.class)
                    .bannerMode(Banner.Mode.OFF)
                    .logStartupInfo(false)
                    .headless(true)
                    .web(true)
                    .application()
                    .run(args);
        }
        return instance;
    }

    static public void close() {
        getInstance().close();
    }

    @Value("${raptor.admin.enabled}")
    private Boolean defaultUserEnabled;
    @Value("${raptor.admin.username}")
    private String defaultUserUsername;<commit_msg>fix singleton call<commit_after>/*
 * Copyright 2017 FBK/CREATE-NET
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.createnet.raptor.auth.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import javax.sql.DataSource;
import org.createnet.raptor.models.auth.Role;
import org.createnet.raptor.models.auth.User;
import org.createnet.raptor.auth.service.repository.UserRepository;
import org.createnet.raptor.auth.service.services.BrokerMessageHandler;
import org.createnet.raptor.auth.service.services.UserService;
import org.createnet.raptor.config.ConfigurationLoader;
import org.createnet.raptor.dispatcher.DispatcherConfiguration;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Profile;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
@Profile("default")
@SpringBootApplication(exclude = { EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
@EnableCaching
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableRetry
@EntityScan(basePackageClasses = org.createnet.raptor.models.auth.User.class)
@ComponentScan(basePackages = "org.createnet.raptor.auth.service")
@EnableScheduling
public class Application {

    static final public ObjectMapper mapper = new ObjectMapper();

    static ConfigurableApplicationContext instance;

    public static void main(String[] args) {
        getInstance(args);
    }

    static public ConfigurableApplicationContext getInstance() {
        return getInstance(new String[]{});
    }

    static public ConfigurableApplicationContext getInstance(String[] args) {
        if (instance == null) {
            instance = new SpringApplicationBuilder(Application.class)
                    .bannerMode(Banner.Mode.OFF)
                    .logStartupInfo(false)
                    .headless(true)
                    .web(true)
                    .application()
                    .run(args);
        }
        return instance;
    }

    static public void close() {
        getInstance().close();
    }

    @Value("${raptor.admin.enabled}")
    private Boolean defaultUserEnabled;
    @Value("${raptor.admin.username}")
    private String defaultUserUsername;
{'fraction_non_alphanumeric': 0.09016310404214366, 'fraction_numerical': 0.0018235234525377367, 'mean_word_length': 5.189341692789968, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5567150', 'n_tokens_mistral': 2582, 'n_tokens_neox': 2535, 'n_words': 491}