Skip to content
Merged
32 changes: 30 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,25 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.8</version>
</dependency>

<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
-->
<!-- END Logging Dependencies -->

<!-- Dependencies for Guice -->
Expand Down Expand Up @@ -389,10 +403,17 @@

<dependency>
<groupId>net.kencochrane.raven</groupId>
<artifactId>raven-log4j</artifactId>
<artifactId>raven-logback</artifactId>
<version>6.0.0</version>
</dependency>

<!--
<dependency>
<groupId>net.kencochrane.raven</groupId>
<artifactId>raven-log4j</artifactId>
<version>6.0.0</version>
</dependency>
-->
<!-- Lucene search engine -->
<dependency>
<groupId>org.apache.lucene</groupId>
Expand Down Expand Up @@ -439,12 +460,19 @@
<version>${metrics-version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-logback</artifactId>
<version>3.1.2</version>
</dependency>

<!--
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-log4j</artifactId>
<version>${metrics-version}</version>
</dependency>

-->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@
import com.parallax.server.blocklyprop.db.dao.impl.SessionDaoImpl;
import com.parallax.server.blocklyprop.db.dao.impl.UserDaoImpl;


/**
*
* @author Michel
*
* AbstractModule:
* A support class for Modules which reduces repetition and results in a more
* readable configuration. Simply extend this class, implement configure(),
* and call the inherited methods which mirror those found in Binder.
* For example:
*
* public class MyModule extends AbstractModule {
* protected void configure() {
* bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
* bind(CreditCardPaymentService.class);
* bind(PaymentService.class).to(CreditCardPaymentService.class);
* bindConstant().annotatedWith(Names.named("port")).to(8080);
* }
* }
*
*/
public class DaoModule extends AbstractModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
import com.google.inject.Provides;
import com.parallax.server.blocklyprop.db.utils.DataSourceSetup;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.dbcp2.PoolingDataSource;
import org.jooq.SQLDialect;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
*
Expand All @@ -37,6 +38,7 @@ protected void configure() {

@Provides
PoolingDataSource dataSource() throws ClassNotFoundException {

PoolingDataSource ds = DataSourceSetup.connect(configuration);
try {
ds.getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;


/**
*
Expand All @@ -29,6 +33,7 @@
public class SetupConfig extends GuiceServletContextListener {

private Configuration configuration;
private final Logger LOG = LoggerFactory.getLogger(this.getClass());

@Override
protected Injector getInjector() {
Expand Down Expand Up @@ -62,10 +67,11 @@ protected void configure() {

private void readConfiguration() {
try {
System.out.println("Looking for blocklyprop.properties in: " + System.getProperty("user.home"));
LOG.info("Looking for blocklyprop.properties in: {}", System.getProperty("user.home"));
DefaultConfigurationBuilder configurationBuilder = new DefaultConfigurationBuilder(getClass().getResource("/config.xml"));
configuration = configurationBuilder.getConfiguration();
} catch (ConfigurationException ce) {
LOG.error("{}", ce.getMessage());
ce.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
Expand All @@ -81,12 +87,20 @@ public void contextDestroyed(ServletContextEvent servletContextEvent) {
Driver driver = drivers.nextElement();
try {
DriverManager.deregisterDriver(driver);
// LOG.log(Level.INFO, String.format("deregistering jdbc driver: %s", driver));
LOG.info("deregistering jdbc driver: {}",driver);
} catch (SQLException sqlE) {
// LOG.log(Level.SEVERE, String.format("Error deregistering driver %s", driver), e);
}

}

// Shut down the loggers. Assume SLF4J is bound to logback-classic
// in the current environment
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
if (loggerContext != null) {
loggerContext.stop();
}

}

}
Loading