Skip to content

Instantly share code, notes, and snippets.

View joshlong's full-sized avatar
🍃
i'm on Twitter @starbuxman

Josh Long joshlong

🍃
i'm on Twitter @starbuxman
View GitHub Profile
/**
* Maps data from a JDBC {@code ResultSet} into Java 14 record objects of type T.
*
* @author <a href="mailto:josh@joshlong.com">Josh Long</a>
*/
class RecordRowMapper<T> implements RowMapper<T> {
private final Log logger = LogFactory.getLog(getClass());
private final Map<String, RecordComponent> mappedFields = new HashMap<>();
package com.example.fourteen;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.util.Assert;
import java.util.Date;
package com.example.reservationservice;
import io.r2dbc.postgresql.PostgresqlConnectionConfiguration;
import io.r2dbc.postgresql.PostgresqlConnectionFactory;
import io.r2dbc.spi.ConnectionFactory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
// java Curl.java
public class Curl {
@joshlong
joshlong / unzip-and-open.py
Last active April 17, 2024 15:31
unzip and open in intellij projcts generated from start.spring.io
#!/usr/bin/env python
import os
import subprocess
import sys
if __name__ == '__main__':
def run(c):
print('running: %s' % c)
@joshlong
joshlong / DemoApplication.java
Last active June 20, 2018 14:35
An example demonstrating `@Lazy`
package com.example.demo;
import lombok.extern.java.Log;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.ApplicationArguments;
@joshlong
joshlong / DemoApplication.kt
Created April 3, 2018 20:55
the entire REST service written in Kotlin and Spring Boot.
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.web.reactive.function.BodyInserters.fromObject
import org.springframework.web.reactive.function.server.ServerResponse.ok
import org.springframework.web.reactive.function.server.router
@SpringBootApplication
@joshlong
joshlong / DemoApplication.java
Created March 21, 2018 02:51
This example demonstrates some of the nice language features and APIs introduced since Java 8
package com.example.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@joshlong
joshlong / DynamicIntegration.kt
Last active January 6, 2018 01:42
Dynamic registration of Spring Integration adapters using functional bean definition with the Spring Framework 5.0 Kotlin DSL.
package com.example.feed
import com.rometools.rome.feed.synd.SyndEntry
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.support.beans
import org.springframework.core.io.UrlResource
import org.springframework.integration.dsl.IntegrationFlows
import org.springframework.integration.feed.dsl.Feed
import org.springframework.integration.handler.GenericHandler
@joshlong
joshlong / TestApplication.java
Last active June 9, 2022 09:49
an example demonstrating Spring's new `InjectionPoint` support
package com.example;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;