This file contains 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 Agent3 { | |
public static void main(String[] args) { | |
premain("", ByteBuddyAgent.installOnOpenJDK()); | |
Service service = new Service(); | |
System.out.println(service); | |
} | |
public static void premain(String arguments, Instrumentation instrumentation) { | |
// System.out.println(Service.class.getCanonicalName()); |
This file contains 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 Test { | |
public static class ArrayListWrapper { | |
int id; | |
ArrayList<Integer> list = new ArrayList<>(); | |
public ArrayListWrapper(int id) { | |
this.id = id; | |
} | |
public void add(int i) { |
This file contains 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 Tests { | |
static Path dir = Paths.get("/tmp/test"); | |
static Database test; | |
static Env env; | |
static { | |
try { | |
FileUtils.deleteIfExist(dir); | |
Files.createDirectory(dir); | |
} catch (IOException e) { |
This file contains 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
TrueFxDecoder decoder = new TrueFxDecoder(); | |
FileReader<TrueFxData> reader = FileReader.create(decoder, file.listFiles()); | |
long periodLength = TimeUnit.DAYS.toMillis(1); | |
PeriodEntries<TrueFxData> periods = PeriodEntries.create(reader, periodLength); | |
for (List<TrueFxData> entries : periods) { | |
// data for each day | |
for (TrueFxData entry : entries) { | |
// process each entry | |
} |
This file contains 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 PeriodEntries<T extends Timestamped> implements Iterable<List<T>> { | |
private final Iterator<List<T extends Timestamped>> entriesIt; | |
private final long interval; | |
private PeriodEntries(Iterable<List<T>> entriesIt, long interval) { | |
this.entriesIt = entriesIt.iterator(); | |
this.interval = interval; | |
} | |
public static <T extends Timestamped> PeriodEntries<T> create(Iterable<List<T>> entriesIt, long interval) { | |
return new PeriodEntries<T>(entriesIt, interval); |
This file contains 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
TextRowDecoder decoder = new TextRowDecoder(4, comma); | |
FileReader<byte[][]> reader = FileReader.create(decoder, file.listFiles()); | |
for (List<byte[][]> chunk : reader) { | |
// do something with each chunk | |
} |
This file contains 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 FileReader implements Iterable<List<T>> { | |
private static final long CHUNK_SIZE = 4096; | |
private final Decoder<T> decoder; | |
private Iterator<File> files; | |
private FileReader(Decoder<T> decoder, File... files) { | |
this(decoder, Arrays.asList(files)); | |
} | |
private FileReader(Decoder<T> decoder, List<File> files) { | |
this.files = files.iterator(); |
This file contains 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 TextRowDecoder implements Decoder<byte[][]> { | |
private static final byte LF = 10; | |
private final int numFields; | |
private final byte delimiter; | |
public TextRowDecoder(int numFields, byte delimiter) { | |
this.numFields = numFields; | |
this.delimiter = delimiter; | |
} | |
@Override | |
public byte[][] decode(ByteBuffer buffer) { |
This file contains 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 interface Decoder<T> { | |
public T decode(ByteBuffer buffer); | |
} |
This file contains 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.validation.constraints.Max; | |
import javax.validation.constraints.Min; | |
import javax.validation.constraints.Pattern; | |
import javax.validation.constraints.Size; | |
@Configuration | |
public class MysqlXADataSource { | |
@Property(desc = "User name to use for connection authentication.") | |
@Size(min = 6, max = 255) | |
private String user = ""; // default value - hence optional property |