// Path: server/src/main/java/com/cloudwise/sap/niping/inject/NiPingServiceBinder.java
// @Data
// @AllArgsConstructor
// public class NiPingServiceBinder extends AbstractBinder {
// 
//     private DBI jdbi;
//     private ObjectMapper jsonMapper;
//     private SapConfiguration sapConfiguration;
//     private JobConfiguration jobConfiguration;
// 
//     @Override
//     protected void configure() {
//         bind(jsonMapper).to(ObjectMapper.class);
//         //dao
//         bind(jdbi.onDemand(AccessCredentialsDao.class)).to(AccessCredentialsDao.class);
//         bind(jdbi.onDemand(UserDao.class)).to(UserDao.class);
//         bind(jdbi.onDemand(TaskDao.class)).to(TaskDao.class);
//         bind(jdbi.onDemand(MonitorDao.class)).to(MonitorDao.class);
//         bind(jdbi.onDemand(MonitorTaskDao.class)).to(MonitorTaskDao.class);
//         bind(jdbi.onDemand(MonitorNiPingResultDao.class)).to(MonitorNiPingResultDao.class);
// 
//         //config
//         bind(sapConfiguration).to(SapConfiguration.class);
//         bind(jobConfiguration).to(JobConfiguration.class);
//         //jdbi
//         bind(jdbi).to(DBI.class);
//         //service
//         bind(AuthService.class).in(Singleton.class).to(AuthService.class);
//         bind(MonitorService.class).in(Singleton.class).to(MonitorService.class);
//         bind(TaskService.class).in(Singleton.class).to(TaskService.class);
//         bind(TaskConverter.class).in(Singleton.class).to(TaskConverter.class);
//         bind(MonitorResultService.class).in(Singleton.class).to(MonitorResultService.class);
//         //auth
//         bind(SapOAuthenticator.class).in(Singleton.class).to(SapOAuthenticator.class);
//         bind(SapBasicAuthenticator.class).in(Singleton.class).to(SapBasicAuthenticator.class);
//     }
// }
// 
// Path: server/src/main/java/com/cloudwise/sap/niping/resource/AuthFilterDynamicBinding.java
// public class AuthFilterDynamicBinding implements DynamicFeature {
// 
//     @Override
//     public void configure(ResourceInfo resourceInfo, FeatureContext context) {
//         Method method = resourceInfo.getResourceMethod();
//         Annotation[][] parameterAnnotations = method.getParameterAnnotations();
//         for (Annotation[] annotations : parameterAnnotations) {
//             for (Annotation annotation : annotations) {
//                 if (annotation.annotationType().equals(Session.class) && !method.getName().startsWith("log")) {
//                     context.register(NiPingAuthFilter.class);
//                 }
//             }
//         }
//     }
// }


import com.cloudwise.sap.niping.auth.*;
import com.cloudwise.sap.niping.inject.NiPingServiceBinder;
import com.cloudwise.sap.niping.resource.AuthFilterDynamicBinding;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.auth.AuthFilter;
import io.dropwizard.auth.PolymorphicAuthDynamicFeature;
import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider;
import io.dropwizard.auth.basic.BasicCredentialAuthFilter;
import io.dropwizard.auth.oauth.OAuthCredentialAuthFilter;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.jersey.sessions.SessionFactoryProvider;
import io.dropwizard.migrations.MigrationsBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.views.ViewBundle;
import org.eclipse.jetty.server.session.SessionHandler;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.skife.jdbi.v2.DBI;
package com.cloudwise.sap.niping;


public class NiPingMonitorApplication extends Application<ServerConfiguration> {

    public static void main(String[] args) throws Exception {
        new NiPingMonitorApplication().run(args);
    }

    @Override
    public void run(ServerConfiguration configuration, Environment environment) throws Exception {

        final DBIFactory factory = new DBIFactory();
        final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "sapData");

        ObjectMapper objectMapper = environment.getObjectMapper();
        SapConfiguration sapConfiguration = configuration.getSapConfig();
        JobConfiguration jobConfiguration = configuration.getJobConfig();
// Path: server/src/main/java/com/cloudwise/sap/niping/inject/NiPingServiceBinder.java
// @Data
// @AllArgsConstructor
// public class NiPingServiceBinder extends AbstractBinder {
// 
//     private DBI jdbi;
//     private ObjectMapper jsonMapper;
//     private SapConfiguration sapConfiguration;
//     private JobConfiguration jobConfiguration;
// 
//     @Override
//     protected void configure() {
//         bind(jsonMapper).to(ObjectMapper.class);
//         //dao
//         bind(jdbi.onDemand(AccessCredentialsDao.class)).to(AccessCredentialsDao.class);
//         bind(jdbi.onDemand(UserDao.class)).to(UserDao.class);
//         bind(jdbi.onDemand(TaskDao.class)).to(TaskDao.class);
//         bind(jdbi.onDemand(MonitorDao.class)).to(MonitorDao.class);
//         bind(jdbi.onDemand(MonitorTaskDao.class)).to(MonitorTaskDao.class);
//         bind(jdbi.onDemand(MonitorNiPingResultDao.class)).to(MonitorNiPingResultDao.class);
// 
//         //config
//         bind(sapConfiguration).to(SapConfiguration.class);
//         bind(jobConfiguration).to(JobConfiguration.class);
//         //jdbi
//         bind(jdbi).to(DBI.class);
//         //service
//         bind(AuthService.class).in(Singleton.class).to(AuthService.class);
//         bind(MonitorService.class).in(Singleton.class).to(MonitorService.class);
//         bind(TaskService.class).in(Singleton.class).to(TaskService.class);
//         bind(TaskConverter.class).in(Singleton.class).to(TaskConverter.class);
//         bind(MonitorResultService.class).in(Singleton.class).to(MonitorResultService.class);
//         //auth
//         bind(SapOAuthenticator.class).in(Singleton.class).to(SapOAuthenticator.class);
//         bind(SapBasicAuthenticator.class).in(Singleton.class).to(SapBasicAuthenticator.class);
//     }
// }
// 
// Path: server/src/main/java/com/cloudwise/sap/niping/resource/AuthFilterDynamicBinding.java
// public class AuthFilterDynamicBinding implements DynamicFeature {
// 
//     @Override
//     public void configure(ResourceInfo resourceInfo, FeatureContext context) {
//         Method method = resourceInfo.getResourceMethod();
//         Annotation[][] parameterAnnotations = method.getParameterAnnotations();
//         for (Annotation[] annotations : parameterAnnotations) {
//             for (Annotation annotation : annotations) {
//                 if (annotation.annotationType().equals(Session.class) && !method.getName().startsWith("log")) {
//                     context.register(NiPingAuthFilter.class);
//                 }
//             }
//         }
//     }
// }


// Path: server/src/main/java/com/cloudwise/sap/niping/NiPingMonitorApplication.java
import com.cloudwise.sap.niping.auth.*;
import com.cloudwise.sap.niping.inject.NiPingServiceBinder;
import com.cloudwise.sap.niping.resource.AuthFilterDynamicBinding;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.auth.AuthFilter;
import io.dropwizard.auth.PolymorphicAuthDynamicFeature;
import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider;
import io.dropwizard.auth.basic.BasicCredentialAuthFilter;
import io.dropwizard.auth.oauth.OAuthCredentialAuthFilter;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.jersey.sessions.SessionFactoryProvider;
import io.dropwizard.migrations.MigrationsBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.views.ViewBundle;
import org.eclipse.jetty.server.session.SessionHandler;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.skife.jdbi.v2.DBI;

package com.cloudwise.sap.niping;


public class NiPingMonitorApplication extends Application<ServerConfiguration> {

    public static void main(String[] args) throws Exception {
        new NiPingMonitorApplication().run(args);
    }

    @Override
    public void run(ServerConfiguration configuration, Environment environment) throws Exception {

        final DBIFactory factory = new DBIFactory();
        final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "sapData");

        ObjectMapper objectMapper = environment.getObjectMapper();
        SapConfiguration sapConfiguration = configuration.getSapConfig();
        JobConfiguration jobConfiguration = configuration.getJobConfig();
        NiPingServiceBinder niPingServiceBinder = new NiPingServiceBinder(jdbi, objectMapper, sapConfiguration, jobConfiguration);