This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('com.netflix.rxjava:rxjava-groovy:0.20.7') | |
@Grab('io.reactivex:rxjava-reactive-streams:0.3.0') | |
@Grab('org.apache.camel:camel-rx:2.14.1') | |
@Grab('io.ratpack:ratpack-groovy:0.9.11') | |
@Grab('org.slf4j:slf4j-simple:1.6.6') | |
import org.apache.camel.impl.* | |
import org.apache.camel.rx.* | |
import static rx.RxReactiveStreams.toPublisher | |
import static ratpack.groovy.Groovy.ratpack | |
import static ratpack.sse.ServerSentEvents.serverSentEvents; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AbandonedConnectionsAwareDatasourceFactory extends DataSourceFactory { | |
private int removeAbandonedTimeout = 60; | |
private boolean removeAbandoned = false; | |
@Override | |
public ManagedDataSource build(MetricRegistry metricRegistry, String name) { | |
ManagedPooledDataSource build = (ManagedPooledDataSource) super.build(metricRegistry, name); | |
build.setRemoveAbandonedTimeout(removeAbandonedTimeout); | |
build.setRemoveAbandoned(removeAbandoned); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Device {} | |
class Router extends Device {} | |
class GenericDAO<T, ID extends Serializable> { | |
protected Class<T> persistentClass; | |
protected Class<ID> idClass; | |
private GenericDAO() { | |
List <ResolvedType> typeParameters = new TypeResolver().resolve(this.getClass()).typeParametersFor(GenericDAO.class); | |
this.persistentClass = (Class<T>) typeParameters.get(0).getErasedType(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install(new FactoryModuleBuilder().build(PayloadServiceFactory.class)); | |
public interface GenericPayloadFactory { | |
PayloadService<? extends Payload> create(); | |
} | |
public interface Payload {} | |
public class JsonPayload implements Payload {} | |
public class XmlPayload implements Payload {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: | |
image: 'tutum/hello-world:latest' | |
environment: | |
- FORCE_SSL=yes | |
- 'VIRTUAL_HOST=http://hello.example.com, https://hello.example.com' | |
ports: | |
- '80' | |
web: | |
image: 'example/web-site:latest' | |
environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private TrustManager[] loadTrustManagers(String certificateFile) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { | |
KeyStore trustedCertStore = KeyStore.getInstance(KeyStore.getDefaultType()); | |
trustedCertStore.load(SecurityModule.class.getClassLoader().getResourceAsStream(), null); | |
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | |
tmf.init(trustedCertStore); | |
return tmf.getTrustManagers(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GET | |
@Path("/update") | |
@UnitOfWork(transactional = false) | |
public World update(World world) { | |
return transactionDao.updatesWorld(world); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.dropwizard.Application; | |
import io.dropwizard.Configuration; | |
import io.dropwizard.client.JerseyClientBuilder; | |
import io.dropwizard.setup.Environment; | |
import io.dropwizard.testing.junit.DropwizardAppRule; | |
import org.assertj.core.data.MapEntry; | |
import org.eclipse.jetty.servlets.CrossOriginFilter; | |
import org.junit.ClassRule; | |
import org.junit.Test; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.Singleton; | |
import javax.ws.rs.container.ContainerRequestContext; | |
import javax.ws.rs.container.ContainerResponseContext; | |
import javax.ws.rs.container.ContainerResponseFilter; | |
import javax.ws.rs.core.MultivaluedMap; | |
import javax.ws.rs.ext.Provider; | |
import java.io.IOException; | |
@Singleton | |
@Provider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonProperty; | |
import java.time.LocalDate; | |
import java.time.LocalDateTime; | |
public class Dummy { | |
@JsonProperty | |
public LocalDate localDate; | |
@JsonProperty |