repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
skpdvdd/PAV | pav/src/pav/audiosource/UDPAudioSource.java | // Path: pav/src/pav/Config.java
// public final class Config
// {
// /**
// * Use FIFO audio source.
// */
// public static final String AUDIO_SOURCE_FIFO = "fifo";
//
// /**
// * Use socket audio source.
// */
// public static final String AUDIO_SOURCE_UDP = "udp";
//
// /**
// * Audio data are transfered as little-endian byte stream.
// */
// public static final String BYTE_ORDER_LE = "le";
//
// /**
// * Audio data are transfered as big-endian byte stream.
// */
// public static final String BYTE_ORDER_BE = "be";
//
// /**
// * The audio source to use.
// */
// public static String audioSource = AUDIO_SOURCE_UDP;
//
// /**
// * The sample size. Must be 512, 1024 or 2048.
// */
// public static int sampleSize = 1024;
//
// /**
// * The sample rate.
// */
// public static int sampleRate = 44100;
//
// /**
// * The byte order.
// */
// public static ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
//
// /**
// * The port the udp audio source should listen to.
// */
// public static int udpPort = 2198;
//
// /**
// * The path to the fifo the fifo audio source should use.
// */
// public static String fifoPath = "";
//
// /**
// * The width of the display window.
// */
// public static int windowWidth = 1024;
//
// /**
// * The height of the display window.
// */
// public static int windowHeight = 768;
//
// /**
// * The renderer to use.
// */
// public static String renderer = PConstants.P2D;
//
// private Config() { }
// }
| import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import pav.Config; |
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.audiosource;
/**
* UDP audio source.
*
* @author christopher
*/
public class UDPAudioSource extends AudioSource implements Runnable
{
private final AudioCallback _callback;
private final DatagramSocket _socket;
private final Thread _thread;
private boolean _closed;
/**
* Ctor.
*
* @param callback The callback to use. Must not be null
* @throws SocketException If the socket could not be created
*/
public UDPAudioSource(AudioCallback callback) throws SocketException
{
_callback = callback; | // Path: pav/src/pav/Config.java
// public final class Config
// {
// /**
// * Use FIFO audio source.
// */
// public static final String AUDIO_SOURCE_FIFO = "fifo";
//
// /**
// * Use socket audio source.
// */
// public static final String AUDIO_SOURCE_UDP = "udp";
//
// /**
// * Audio data are transfered as little-endian byte stream.
// */
// public static final String BYTE_ORDER_LE = "le";
//
// /**
// * Audio data are transfered as big-endian byte stream.
// */
// public static final String BYTE_ORDER_BE = "be";
//
// /**
// * The audio source to use.
// */
// public static String audioSource = AUDIO_SOURCE_UDP;
//
// /**
// * The sample size. Must be 512, 1024 or 2048.
// */
// public static int sampleSize = 1024;
//
// /**
// * The sample rate.
// */
// public static int sampleRate = 44100;
//
// /**
// * The byte order.
// */
// public static ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
//
// /**
// * The port the udp audio source should listen to.
// */
// public static int udpPort = 2198;
//
// /**
// * The path to the fifo the fifo audio source should use.
// */
// public static String fifoPath = "";
//
// /**
// * The width of the display window.
// */
// public static int windowWidth = 1024;
//
// /**
// * The height of the display window.
// */
// public static int windowHeight = 768;
//
// /**
// * The renderer to use.
// */
// public static String renderer = PConstants.P2D;
//
// private Config() { }
// }
// Path: pav/src/pav/audiosource/UDPAudioSource.java
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import pav.Config;
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.audiosource;
/**
* UDP audio source.
*
* @author christopher
*/
public class UDPAudioSource extends AudioSource implements Runnable
{
private final AudioCallback _callback;
private final DatagramSocket _socket;
private final Thread _thread;
private boolean _closed;
/**
* Ctor.
*
* @param callback The callback to use. Must not be null
* @throws SocketException If the socket could not be created
*/
public UDPAudioSource(AudioCallback callback) throws SocketException
{
_callback = callback; | _socket = new DatagramSocket(Config.udpPort); |
skpdvdd/PAV | pav/src/pav/configurator/Configurator.java | // Path: libpav/src/pav/lib/visualizer/Visualizer.java
// public interface Visualizer extends Serializable
// {
// /**
// * Sets the PApplet to draw to. Must be called before process().
// *
// * @param applet Where to draw to. Must not be null
// * @throws PAVException If the visualizer does not work with this applet
// */
// void drawTo(PApplet applet) throws PAVException;
//
// /**
// * Sets the area that can be used by this visualizer. If relative is set to false
// * the visualizer will use the given values as its boundary, independent of the
// * size of the PApplet. If relative is true, the values must be in the range [0,1]
// * and represent an area relative to the size of the PApplet. Processings coordinate
// * system is used, so (0,0) is the top left pixel.
// *
// * @param x1 Must be >= 0 and <= 1 if relative is true
// * @param y1 Must be >= 0 and <= 1 if relative is true
// * @param x2 Must be > x1 and <= 1 if relative is true
// * @param y2 Must be > y1 and <= 1 if relative is true
// * @param relative Whether or not the values are relative
// */
// void setArea(float x1, float y1, float x2, float y2, boolean relative);
//
// /**
// * Draws to the PApplet specified by drawTo.
// *
// * @throws PAVException If an error occures while drawing
// */
// void process() throws PAVException;
//
// /**
// * Sets the color to use when drawing this visualizer. How a visualizer uses the color
// * specified is not defined. It might not be used at all.
// *
// * @param color The color to use
// */
// void setColor(int color);
//
// /**
// * Sets two colors to interpolate between when drawing this visualizer. How a visualizer uses the colors
// * specified is not defined. They might not be used at all.
// *
// * @param a The color to start from
// * @param b The color to interpolate to
// * @param mode The color mode to use. Must bei either PApplet.RGB or PApplet.HSB
// */
// void setColor(int a, int b, int mode);
//
// /**
// * Sets the colors to interpolate between when drawing this visualizer. How a visualizer uses the colors
// * specified is not defined. They might not be used at all.
// *
// * @param thresholds The relative thresholds to use. Values must be between 0 and 1 and sorted. The first element must be 0, the last 1. Must be of same length as colors
// * @param colors The The colors to use. Must be of same length as thresholds
// * @param mode The color mode to use. Must be either PApplet.RGB or PApplet.HSB
// */
// void setColor(float[] thresholds, int[] colors, int mode);
//
// /**
// * Returns a short string representation of this visualizer.
// *
// * @return visualizer info
// */
// String toString();
//
// /**
// * Disposes this visualizer, releasing all resources that were used exclusively
// * by this visualizer. Subsequent calls to any methods of the visualizer might cause exceptions.
// */
// void dispose();
// }
| import pav.lib.visualizer.Visualizer; |
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.configurator;
/**
* Allows runtime configuration of a visualizer via a query entered by the user.
*/
public interface Configurator
{
/**
* Processes a configuration request.
*
* @param subject The visualizer to configure. Must not be null
* @param query The user query. Must not be null
* @return Whether this configurator was able to handle the configuration request
*/ | // Path: libpav/src/pav/lib/visualizer/Visualizer.java
// public interface Visualizer extends Serializable
// {
// /**
// * Sets the PApplet to draw to. Must be called before process().
// *
// * @param applet Where to draw to. Must not be null
// * @throws PAVException If the visualizer does not work with this applet
// */
// void drawTo(PApplet applet) throws PAVException;
//
// /**
// * Sets the area that can be used by this visualizer. If relative is set to false
// * the visualizer will use the given values as its boundary, independent of the
// * size of the PApplet. If relative is true, the values must be in the range [0,1]
// * and represent an area relative to the size of the PApplet. Processings coordinate
// * system is used, so (0,0) is the top left pixel.
// *
// * @param x1 Must be >= 0 and <= 1 if relative is true
// * @param y1 Must be >= 0 and <= 1 if relative is true
// * @param x2 Must be > x1 and <= 1 if relative is true
// * @param y2 Must be > y1 and <= 1 if relative is true
// * @param relative Whether or not the values are relative
// */
// void setArea(float x1, float y1, float x2, float y2, boolean relative);
//
// /**
// * Draws to the PApplet specified by drawTo.
// *
// * @throws PAVException If an error occures while drawing
// */
// void process() throws PAVException;
//
// /**
// * Sets the color to use when drawing this visualizer. How a visualizer uses the color
// * specified is not defined. It might not be used at all.
// *
// * @param color The color to use
// */
// void setColor(int color);
//
// /**
// * Sets two colors to interpolate between when drawing this visualizer. How a visualizer uses the colors
// * specified is not defined. They might not be used at all.
// *
// * @param a The color to start from
// * @param b The color to interpolate to
// * @param mode The color mode to use. Must bei either PApplet.RGB or PApplet.HSB
// */
// void setColor(int a, int b, int mode);
//
// /**
// * Sets the colors to interpolate between when drawing this visualizer. How a visualizer uses the colors
// * specified is not defined. They might not be used at all.
// *
// * @param thresholds The relative thresholds to use. Values must be between 0 and 1 and sorted. The first element must be 0, the last 1. Must be of same length as colors
// * @param colors The The colors to use. Must be of same length as thresholds
// * @param mode The color mode to use. Must be either PApplet.RGB or PApplet.HSB
// */
// void setColor(float[] thresholds, int[] colors, int mode);
//
// /**
// * Returns a short string representation of this visualizer.
// *
// * @return visualizer info
// */
// String toString();
//
// /**
// * Disposes this visualizer, releasing all resources that were used exclusively
// * by this visualizer. Subsequent calls to any methods of the visualizer might cause exceptions.
// */
// void dispose();
// }
// Path: pav/src/pav/configurator/Configurator.java
import pav.lib.visualizer.Visualizer;
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.configurator;
/**
* Allows runtime configuration of a visualizer via a query entered by the user.
*/
public interface Configurator
{
/**
* Processes a configuration request.
*
* @param subject The visualizer to configure. Must not be null
* @param query The user query. Must not be null
* @return Whether this configurator was able to handle the configuration request
*/ | boolean process(Visualizer subject, String query); |
skpdvdd/PAV | libpav/src/pav/lib/visualizer/Visualizer.java | // Path: libpav/src/pav/lib/PAVException.java
// public class PAVException extends Exception
// {
// private static final long serialVersionUID = 4985787077612555714L;
//
// /**
// * Ctor.
// */
// public PAVException()
// {
// super();
// }
//
// /**
// * Ctor.
// *
// * @param message The error message
// */
// public PAVException(String message)
// {
// super(message);
// }
//
// /**
// * Ctor.
// *
// * @param cause The cause of the error
// */
// public PAVException(Throwable cause)
// {
// super(cause);
// }
//
// /**
// * Ctor.
// *
// * @param message The error message
// * @param cause The cause of the error
// */
// public PAVException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
| import java.io.Serializable;
import pav.lib.PAVException;
import processing.core.PApplet; |
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.lib.visualizer;
/**
* A audio visualizer.
*
* @author christopher
*/
public interface Visualizer extends Serializable
{
/**
* Sets the PApplet to draw to. Must be called before process().
*
* @param applet Where to draw to. Must not be null
* @throws PAVException If the visualizer does not work with this applet
*/ | // Path: libpav/src/pav/lib/PAVException.java
// public class PAVException extends Exception
// {
// private static final long serialVersionUID = 4985787077612555714L;
//
// /**
// * Ctor.
// */
// public PAVException()
// {
// super();
// }
//
// /**
// * Ctor.
// *
// * @param message The error message
// */
// public PAVException(String message)
// {
// super(message);
// }
//
// /**
// * Ctor.
// *
// * @param cause The cause of the error
// */
// public PAVException(Throwable cause)
// {
// super(cause);
// }
//
// /**
// * Ctor.
// *
// * @param message The error message
// * @param cause The cause of the error
// */
// public PAVException(String message, Throwable cause)
// {
// super(message, cause);
// }
// }
// Path: libpav/src/pav/lib/visualizer/Visualizer.java
import java.io.Serializable;
import pav.lib.PAVException;
import processing.core.PApplet;
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.lib.visualizer;
/**
* A audio visualizer.
*
* @author christopher
*/
public interface Visualizer extends Serializable
{
/**
* Sets the PApplet to draw to. Must be called before process().
*
* @param applet Where to draw to. Must not be null
* @throws PAVException If the visualizer does not work with this applet
*/ | void drawTo(PApplet applet) throws PAVException; |
skpdvdd/PAV | pav/src/pav/audiosource/FIFOAudioSource.java | // Path: pav/src/pav/Config.java
// public final class Config
// {
// /**
// * Use FIFO audio source.
// */
// public static final String AUDIO_SOURCE_FIFO = "fifo";
//
// /**
// * Use socket audio source.
// */
// public static final String AUDIO_SOURCE_UDP = "udp";
//
// /**
// * Audio data are transfered as little-endian byte stream.
// */
// public static final String BYTE_ORDER_LE = "le";
//
// /**
// * Audio data are transfered as big-endian byte stream.
// */
// public static final String BYTE_ORDER_BE = "be";
//
// /**
// * The audio source to use.
// */
// public static String audioSource = AUDIO_SOURCE_UDP;
//
// /**
// * The sample size. Must be 512, 1024 or 2048.
// */
// public static int sampleSize = 1024;
//
// /**
// * The sample rate.
// */
// public static int sampleRate = 44100;
//
// /**
// * The byte order.
// */
// public static ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
//
// /**
// * The port the udp audio source should listen to.
// */
// public static int udpPort = 2198;
//
// /**
// * The path to the fifo the fifo audio source should use.
// */
// public static String fifoPath = "";
//
// /**
// * The width of the display window.
// */
// public static int windowWidth = 1024;
//
// /**
// * The height of the display window.
// */
// public static int windowHeight = 768;
//
// /**
// * The renderer to use.
// */
// public static String renderer = PConstants.P2D;
//
// private Config() { }
// }
| import java.io.FileInputStream;
import java.io.FileNotFoundException;
import pav.Config; |
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.audiosource;
/**
* FIFO audio source.
*
* @author christopher
*/
public class FIFOAudioSource extends AudioSource
{
private final AudioStream _stream;
/**
* Ctor.
*
* @param callback The callback. Must not be null
* @throws FileNotFoundException If the fifo does not exist
*/
public FIFOAudioSource(AudioCallback callback) throws FileNotFoundException
{ | // Path: pav/src/pav/Config.java
// public final class Config
// {
// /**
// * Use FIFO audio source.
// */
// public static final String AUDIO_SOURCE_FIFO = "fifo";
//
// /**
// * Use socket audio source.
// */
// public static final String AUDIO_SOURCE_UDP = "udp";
//
// /**
// * Audio data are transfered as little-endian byte stream.
// */
// public static final String BYTE_ORDER_LE = "le";
//
// /**
// * Audio data are transfered as big-endian byte stream.
// */
// public static final String BYTE_ORDER_BE = "be";
//
// /**
// * The audio source to use.
// */
// public static String audioSource = AUDIO_SOURCE_UDP;
//
// /**
// * The sample size. Must be 512, 1024 or 2048.
// */
// public static int sampleSize = 1024;
//
// /**
// * The sample rate.
// */
// public static int sampleRate = 44100;
//
// /**
// * The byte order.
// */
// public static ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
//
// /**
// * The port the udp audio source should listen to.
// */
// public static int udpPort = 2198;
//
// /**
// * The path to the fifo the fifo audio source should use.
// */
// public static String fifoPath = "";
//
// /**
// * The width of the display window.
// */
// public static int windowWidth = 1024;
//
// /**
// * The height of the display window.
// */
// public static int windowHeight = 768;
//
// /**
// * The renderer to use.
// */
// public static String renderer = PConstants.P2D;
//
// private Config() { }
// }
// Path: pav/src/pav/audiosource/FIFOAudioSource.java
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import pav.Config;
/*
* Processing Audio Visualization (PAV)
* Copyright (C) 2011 Christopher Pramerdorfer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pav.audiosource;
/**
* FIFO audio source.
*
* @author christopher
*/
public class FIFOAudioSource extends AudioSource
{
private final AudioStream _stream;
/**
* Ctor.
*
* @param callback The callback. Must not be null
* @throws FileNotFoundException If the fifo does not exist
*/
public FIFOAudioSource(AudioCallback callback) throws FileNotFoundException
{ | _stream = new AudioStream(new FileInputStream(Config.fifoPath), callback); |
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/WithMapFields.java | // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
| import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import com.googlecode.transloader.test.Triangulate;
| package com.googlecode.transloader.test.fixture;
public class WithMapFields extends NonCommonJavaObject {
private SortedMap map = new TreeMap();
{
| // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/WithMapFields.java
import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import com.googlecode.transloader.test.Triangulate;
package com.googlecode.transloader.test.fixture;
public class WithMapFields extends NonCommonJavaObject {
private SortedMap map = new TreeMap();
{
| map.put(Triangulate.anyInteger(), Triangulate.anyString());
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/NonCommonJavaObject.java | // Path: src/test/java/com/googlecode/transloader/test/ClassLoaderAndFieldsStringBuilder.java
// public class ClassLoaderAndFieldsStringBuilder {
// private static final String FIELD_SEPERATOR = " ";
// private static final String OPEN_BRACKET = "[" + FIELD_SEPERATOR;
// private static final String CLOSE_BRACKET = "]";
// private static final CyclicReferenceSafeTraverser CYCLIC_REFERENCE_TRAVERSER = new CyclicReferenceSafeTraverser();
//
// public static String toString(Object object) {
// StringBuffer buffer = new StringBuffer();
// append(buffer, object);
// return buffer.toString();
// }
//
// private static void append(final StringBuffer buffer, final Object object) {
// Traversal toStringTraversal = new Traversal() {
// public Object traverse(Object currentObject, Map referenceHistory) throws Exception {
// Class objectClass = object.getClass();
// String className = getName(objectClass);
// referenceHistory.put(currentObject, className + "<circular reference>");
// appendClassAndClassLoader(buffer, objectClass);
// appendFields(object, buffer);
// return buffer.toString();
// }
// };
// try {
// CYCLIC_REFERENCE_TRAVERSER.performWithoutFollowingCircles(toStringTraversal, object);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static String getName(Class clazz) {
// return ClassUtils.getShortClassName(clazz);
// }
//
// private static void appendFields(Object object, StringBuffer buffer) {
// buffer.append(OPEN_BRACKET);
// FieldReflector reflector = new FieldReflector(object);
// FieldDescription[] fieldDescriptions = reflector.getAllInstanceFieldDescriptions();
// for (int i = 0; i < fieldDescriptions.length; i++) {
// FieldDescription description = fieldDescriptions[i];
// try {
// buffer.append(description.getFieldName()).append("=");
// Object fieldValue = reflector.getValue(description);
// if (fieldValue == null) {
// buffer.append("null");
// } else if (fieldValue.getClass().isArray()) {
// appendArray(buffer, fieldValue);
// } else {
// appendValue(buffer, fieldValue, description.isPrimitive());
// }
// buffer.append(FIELD_SEPERATOR);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
// buffer.append(CLOSE_BRACKET);
// }
//
// private static void appendValue(StringBuffer buffer, Object fieldValue, boolean primitive) {
// if (fieldValue == null) {
// buffer.append("null");
// } else if (primitive || fieldBasedStringIsNotDeterministic(fieldValue)) {
// buffer.append(fieldValue);
// } else {
// append(buffer, fieldValue);
// }
// }
//
// private static boolean fieldBasedStringIsNotDeterministic(Object fieldValue) {
// return fieldValue instanceof String || fieldValue instanceof Map || fieldValue instanceof Set;
// }
//
// private static void appendArray(StringBuffer buffer, Object array) {
// Class arrayClass = array.getClass();
// appendClassAndClassLoader(buffer, arrayClass);
// buffer.append(OPEN_BRACKET);
// for (int i = 0; i < Array.getLength(array); i++) {
// appendValue(buffer, Array.get(array, i), arrayClass.getComponentType().isPrimitive());
// buffer.append(FIELD_SEPERATOR);
// }
// buffer.append(CLOSE_BRACKET);
// }
//
// private static void appendClassAndClassLoader(StringBuffer toStringBuffer, Class clazz) {
// toStringBuffer.append(getName(clazz)).append("(").append(clazz.getClassLoader()).append(")");
// }
// }
| import com.googlecode.transloader.test.ClassLoaderAndFieldsStringBuilder;
| package com.googlecode.transloader.test.fixture;
public class NonCommonJavaObject implements NonCommonJavaType {
public String toString() {
| // Path: src/test/java/com/googlecode/transloader/test/ClassLoaderAndFieldsStringBuilder.java
// public class ClassLoaderAndFieldsStringBuilder {
// private static final String FIELD_SEPERATOR = " ";
// private static final String OPEN_BRACKET = "[" + FIELD_SEPERATOR;
// private static final String CLOSE_BRACKET = "]";
// private static final CyclicReferenceSafeTraverser CYCLIC_REFERENCE_TRAVERSER = new CyclicReferenceSafeTraverser();
//
// public static String toString(Object object) {
// StringBuffer buffer = new StringBuffer();
// append(buffer, object);
// return buffer.toString();
// }
//
// private static void append(final StringBuffer buffer, final Object object) {
// Traversal toStringTraversal = new Traversal() {
// public Object traverse(Object currentObject, Map referenceHistory) throws Exception {
// Class objectClass = object.getClass();
// String className = getName(objectClass);
// referenceHistory.put(currentObject, className + "<circular reference>");
// appendClassAndClassLoader(buffer, objectClass);
// appendFields(object, buffer);
// return buffer.toString();
// }
// };
// try {
// CYCLIC_REFERENCE_TRAVERSER.performWithoutFollowingCircles(toStringTraversal, object);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static String getName(Class clazz) {
// return ClassUtils.getShortClassName(clazz);
// }
//
// private static void appendFields(Object object, StringBuffer buffer) {
// buffer.append(OPEN_BRACKET);
// FieldReflector reflector = new FieldReflector(object);
// FieldDescription[] fieldDescriptions = reflector.getAllInstanceFieldDescriptions();
// for (int i = 0; i < fieldDescriptions.length; i++) {
// FieldDescription description = fieldDescriptions[i];
// try {
// buffer.append(description.getFieldName()).append("=");
// Object fieldValue = reflector.getValue(description);
// if (fieldValue == null) {
// buffer.append("null");
// } else if (fieldValue.getClass().isArray()) {
// appendArray(buffer, fieldValue);
// } else {
// appendValue(buffer, fieldValue, description.isPrimitive());
// }
// buffer.append(FIELD_SEPERATOR);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
// buffer.append(CLOSE_BRACKET);
// }
//
// private static void appendValue(StringBuffer buffer, Object fieldValue, boolean primitive) {
// if (fieldValue == null) {
// buffer.append("null");
// } else if (primitive || fieldBasedStringIsNotDeterministic(fieldValue)) {
// buffer.append(fieldValue);
// } else {
// append(buffer, fieldValue);
// }
// }
//
// private static boolean fieldBasedStringIsNotDeterministic(Object fieldValue) {
// return fieldValue instanceof String || fieldValue instanceof Map || fieldValue instanceof Set;
// }
//
// private static void appendArray(StringBuffer buffer, Object array) {
// Class arrayClass = array.getClass();
// appendClassAndClassLoader(buffer, arrayClass);
// buffer.append(OPEN_BRACKET);
// for (int i = 0; i < Array.getLength(array); i++) {
// appendValue(buffer, Array.get(array, i), arrayClass.getComponentType().isPrimitive());
// buffer.append(FIELD_SEPERATOR);
// }
// buffer.append(CLOSE_BRACKET);
// }
//
// private static void appendClassAndClassLoader(StringBuffer toStringBuffer, Class clazz) {
// toStringBuffer.append(getName(clazz)).append("(").append(clazz.getClassLoader()).append(")");
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/NonCommonJavaObject.java
import com.googlecode.transloader.test.ClassLoaderAndFieldsStringBuilder;
package com.googlecode.transloader.test.fixture;
public class NonCommonJavaObject implements NonCommonJavaType {
public String toString() {
| return ClassLoaderAndFieldsStringBuilder.toString(this);
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/SerializableWithAnonymousClassFields.java | // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
| import com.googlecode.transloader.test.Triangulate;
| package com.googlecode.transloader.test.fixture;
public class SerializableWithAnonymousClassFields extends SerializableWithFinalFields {
private java.io.Serializable anonymousClassField = new Serializable() {
private NonCommonJavaType instanceInitializerField;
{
| // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/SerializableWithAnonymousClassFields.java
import com.googlecode.transloader.test.Triangulate;
package com.googlecode.transloader.test.fixture;
public class SerializableWithAnonymousClassFields extends SerializableWithFinalFields {
private java.io.Serializable anonymousClassField = new Serializable() {
private NonCommonJavaType instanceInitializerField;
{
| instanceInitializerField = new SerializableWithFinalFields(Triangulate.anyInteger());
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/WithSetFields.java | // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
| import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import com.googlecode.transloader.test.Triangulate;
| package com.googlecode.transloader.test.fixture;
// TODO find a way to clone HashSets and TreeSets without serialization so that non-Serializable Objects can be put into them!
/*
* All elements must be Serializable only because the this$0 field for anonymous classes is final (and
* pre-Java-5-JVMs prevent setting any final fields, including instance ones, even by reflection). This affects all
* HashSets and TreeSets because their implementation in the Sun JRE is backed by a Map which has a keySet field
* which is assigned an anonymous class.
*/
public class WithSetFields extends NonCommonJavaObject {
private Set set = new TreeSet(new ToStringComparator());
{
| // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/WithSetFields.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import com.googlecode.transloader.test.Triangulate;
package com.googlecode.transloader.test.fixture;
// TODO find a way to clone HashSets and TreeSets without serialization so that non-Serializable Objects can be put into them!
/*
* All elements must be Serializable only because the this$0 field for anonymous classes is final (and
* pre-Java-5-JVMs prevent setting any final fields, including instance ones, even by reflection). This affects all
* HashSets and TreeSets because their implementation in the Sun JRE is backed by a Map which has a keySet field
* which is assigned an anonymous class.
*/
public class WithSetFields extends NonCommonJavaObject {
private Set set = new TreeSet(new ToStringComparator());
{
| set.add(Triangulate.anyInteger());
|
fmunch/transloader | src/main/java/com/googlecode/transloader/clone/SerializationCloningStrategy.java | // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import org.apache.commons.io.input.ClassLoaderObjectInputStream;
import org.apache.commons.lang.SerializationException;
import org.apache.commons.lang.SerializationUtils;
import com.googlecode.transloader.Assert;
| package com.googlecode.transloader.clone;
/**
* A <code>CloningStrategy</code> that uses Java Serialization as its mechanism.
*
* @author Jeremy Wales
*/
public final class SerializationCloningStrategy implements CloningStrategy {
/**
* {@inheritDoc}
*
* @throws ClassCastException if the given <code>original</code> object is not {@link Serializable}
* @throws SerializationException if serialization fails
* @throws IOException if input fails during deserialization
* @throws ClassNotFoundException if the <code>targetClassLoader</code> cannot find a required class
*/
public Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader)
throws ClassCastException, SerializationException, IOException, ClassNotFoundException {
| // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
// Path: src/main/java/com/googlecode/transloader/clone/SerializationCloningStrategy.java
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import org.apache.commons.io.input.ClassLoaderObjectInputStream;
import org.apache.commons.lang.SerializationException;
import org.apache.commons.lang.SerializationUtils;
import com.googlecode.transloader.Assert;
package com.googlecode.transloader.clone;
/**
* A <code>CloningStrategy</code> that uses Java Serialization as its mechanism.
*
* @author Jeremy Wales
*/
public final class SerializationCloningStrategy implements CloningStrategy {
/**
* {@inheritDoc}
*
* @throws ClassCastException if the given <code>original</code> object is not {@link Serializable}
* @throws SerializationException if serialization fails
* @throws IOException if input fails during deserialization
* @throws ClassNotFoundException if the <code>targetClassLoader</code> cannot find a required class
*/
public Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader)
throws ClassCastException, SerializationException, IOException, ClassNotFoundException {
| Assert.areNotNull(original, targetClassLoader);
|
fmunch/transloader | src/main/java/com/googlecode/transloader/clone/reflect/CyclicReferenceSafeTraverser.java | // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
| import java.util.Map;
import org.apache.commons.collections.map.IdentityMap;
import com.googlecode.transloader.Assert;
| package com.googlecode.transloader.clone.reflect;
/**
* A utility for traversing through entire object graphs which may contain cyclic references, without thereby entering
* an endless loop. The implementation is thread-safe.
*
* @author Jeremy Wales
*/
public final class CyclicReferenceSafeTraverser {
private final ThreadLocal referenceHistoryForThread = new ThreadLocal();
/**
* Executes the given the traversal over the current location in the object graph if it has not already been
* traversed in the current journey through the graph.
*
* @param traversal the traversal to execute
* @param currentObjectInGraph the location in the object graph over which to perform the traversal
* @return the result of performing the traversal
* @throws Exception can throw any <code>Exception</code> from the traversal itself
*/
public Object performWithoutFollowingCircles(Traversal traversal, Object currentObjectInGraph) throws Exception {
| // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
// Path: src/main/java/com/googlecode/transloader/clone/reflect/CyclicReferenceSafeTraverser.java
import java.util.Map;
import org.apache.commons.collections.map.IdentityMap;
import com.googlecode.transloader.Assert;
package com.googlecode.transloader.clone.reflect;
/**
* A utility for traversing through entire object graphs which may contain cyclic references, without thereby entering
* an endless loop. The implementation is thread-safe.
*
* @author Jeremy Wales
*/
public final class CyclicReferenceSafeTraverser {
private final ThreadLocal referenceHistoryForThread = new ThreadLocal();
/**
* Executes the given the traversal over the current location in the object graph if it has not already been
* traversed in the current journey through the graph.
*
* @param traversal the traversal to execute
* @param currentObjectInGraph the location in the object graph over which to perform the traversal
* @return the result of performing the traversal
* @throws Exception can throw any <code>Exception</code> from the traversal itself
*/
public Object performWithoutFollowingCircles(Traversal traversal, Object currentObjectInGraph) throws Exception {
| Assert.areNotNull(traversal, currentObjectInGraph);
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/BaseTestCase.java | // Path: src/test/java/com/googlecode/transloader/test/fixture/IndependentClassLoader.java
// public final class IndependentClassLoader extends URLClassLoader {
// private static final ClassLoader INSTANCE = new IndependentClassLoader();
//
// public static ClassLoader getInstance() {
// return INSTANCE;
// }
//
// private IndependentClassLoader() {
// super(getAppClassLoaderUrls(), null);
// }
//
// private static URL[] getAppClassLoaderUrls() {
// URLClassLoader appClassLoader = (URLClassLoader) IndependentClassLoader.class.getClassLoader();
// return appClassLoader.getURLs();
// }
// }
| import junit.framework.TestCase;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import com.googlecode.transloader.test.fixture.IndependentClassLoader;
| package com.googlecode.transloader.test;
public abstract class BaseTestCase extends TestCase {
protected void dump(Object object) {
// System.out.println("[" + getName() + "] " + object.toString());
}
protected void assertEqualExceptForClassLoader(String originalString, Object clone) {
String originalClassLoaderString = this.getClass().getClassLoader().toString();
| // Path: src/test/java/com/googlecode/transloader/test/fixture/IndependentClassLoader.java
// public final class IndependentClassLoader extends URLClassLoader {
// private static final ClassLoader INSTANCE = new IndependentClassLoader();
//
// public static ClassLoader getInstance() {
// return INSTANCE;
// }
//
// private IndependentClassLoader() {
// super(getAppClassLoaderUrls(), null);
// }
//
// private static URL[] getAppClassLoaderUrls() {
// URLClassLoader appClassLoader = (URLClassLoader) IndependentClassLoader.class.getClassLoader();
// return appClassLoader.getURLs();
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/BaseTestCase.java
import junit.framework.TestCase;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import com.googlecode.transloader.test.fixture.IndependentClassLoader;
package com.googlecode.transloader.test;
public abstract class BaseTestCase extends TestCase {
protected void dump(Object object) {
// System.out.println("[" + getName() + "] " + object.toString());
}
protected void assertEqualExceptForClassLoader(String originalString, Object clone) {
String originalClassLoaderString = this.getClass().getClassLoader().toString();
| String cloneClassLoaderString = IndependentClassLoader.getInstance().toString();
|
fmunch/transloader | src/main/java/com/googlecode/transloader/clone/reflect/FieldDescription.java | // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
| import com.googlecode.transloader.Assert;
| package com.googlecode.transloader.clone.reflect;
/**
* Describes a field by its name, declaring class name and whether or not it is it of primitive type.
*
* @author Jeremy Wales
*/
public final class FieldDescription {
private final String declaringClassName;
private final String fieldName;
private final boolean primitive;
/**
* Constructs a <code>FieldDescription</code> with the given declaring <code>Class</code>, field name and
* declared field type.
*
* @param declaringClass the <code>Class</code> that declares the field
* @param fieldName the name of the field
* @param declaredType the declared type of the field
*/
public FieldDescription(Class declaringClass, String fieldName, Class declaredType) {
| // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
// Path: src/main/java/com/googlecode/transloader/clone/reflect/FieldDescription.java
import com.googlecode.transloader.Assert;
package com.googlecode.transloader.clone.reflect;
/**
* Describes a field by its name, declaring class name and whether or not it is it of primitive type.
*
* @author Jeremy Wales
*/
public final class FieldDescription {
private final String declaringClassName;
private final String fieldName;
private final boolean primitive;
/**
* Constructs a <code>FieldDescription</code> with the given declaring <code>Class</code>, field name and
* declared field type.
*
* @param declaringClass the <code>Class</code> that declares the field
* @param fieldName the name of the field
* @param declaredType the declared type of the field
*/
public FieldDescription(Class declaringClass, String fieldName, Class declaredType) {
| Assert.areNotNull(declaringClass, fieldName, declaredType);
|
fmunch/transloader | src/main/java/com/googlecode/transloader/clone/reflect/ObjenesisInstantiationStrategy.java | // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
| import org.objenesis.Objenesis;
import org.objenesis.ObjenesisStd;
import com.googlecode.transloader.Assert;
| package com.googlecode.transloader.clone.reflect;
/**
* Uses {@link ObjenesisStd} to create new instances of <code>Class</code>es without invoking their constructors.
*
* @author Jeremy Wales
*/
public final class ObjenesisInstantiationStrategy implements InstantiationStrategy {
private final Objenesis objenesis = new ObjenesisStd();
/**
* {@inheritDoc}
*/
public Object newInstance(Class type) throws Exception {
| // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
// Path: src/main/java/com/googlecode/transloader/clone/reflect/ObjenesisInstantiationStrategy.java
import org.objenesis.Objenesis;
import org.objenesis.ObjenesisStd;
import com.googlecode.transloader.Assert;
package com.googlecode.transloader.clone.reflect;
/**
* Uses {@link ObjenesisStd} to create new instances of <code>Class</code>es without invoking their constructors.
*
* @author Jeremy Wales
*/
public final class ObjenesisInstantiationStrategy implements InstantiationStrategy {
private final Objenesis objenesis = new ObjenesisStd();
/**
* {@inheritDoc}
*/
public Object newInstance(Class type) throws Exception {
| Assert.isNotNull(type);
|
fmunch/transloader | src/main/java/com/googlecode/transloader/ObjectWrapper.java | // Path: src/main/java/com/googlecode/transloader/clone/CloningStrategy.java
// public interface CloningStrategy {
// /**
// * The implementation which clones as little as possible to make the given object graph use <code>Class</code>es
// * that are the same as those that would be loaded through the given <code>ClassLoader</code>. This is the most
// * efficient implementation to use simply for the purpose of making sure the returned object graph is perfectly
// * compatible with all other objects referencing <code>Class</code>es loaded through the given
// * <code>ClassLoader</code>. It is also the implementation that is most likely to succeed in cloning any given
// * object graph because by attempting to clone as few objects as possible it is less likely to attempt to clone an
// * object that cannot be cloned (e.g. a non-{@link java.io.Serializable} with <code>final</code> fields in a
// * pre-Java-5 JVM).
// * <p>
// * However, the fact that it only clones what is necessary to make the object graph compatible with the given
// * <code>ClassLoader</code> means that usually <b>not all</b> of the objects in the graph will be cloned. This
// * means that, depending on the <code>Class</code>es in the object graph and which of these is the same if loaded
// * through the given <code>ClassLoader</code>, it is possible that a top level object is not cloned but objects
// * it references through fields are cloned. This effectively means that the existing object graph can be altered
// * rather than a new, purely seperate object graph being created. This <b>may not be what you want</b> if you want
// * to continue using the given object in its original context. In which case, use {@link CloningStrategy#MAXIMAL}.
// * </p>
// *
// * @see ReflectionCloningStrategy
// * @see MinimalCloningDecisionStrategy
// */
// CloningStrategy MINIMAL =
// new ReflectionCloningStrategy(new MinimalCloningDecisionStrategy(), new ObjenesisInstantiationStrategy(),
// new SerializationCloningStrategy());
//
// /**
// * The implementation which clones every <code>Object</code> in the given object graph. The given object graph is
// * not altered in any way and a completely new copy of the object graph referencing only <code>Class</code>es
// * loaded through the given <code>ClassLoader</code> is returned. Only primitives, which are not
// * <code>Object</code>s, are not cloned because they cannot be, as there is no concept of different references to
// * the same primitive value in Java. Similiar in behaviour to {@link SerializationCloningStrategy} except that it
// * can clone more object graphs because it does not rely on all referenced objects being
// * {@link java.io.Serializable} and also performs much faster than serialization.
// *
// * @see ReflectionCloningStrategy
// * @see MaximalCloningDecisionStrategy
// */
// CloningStrategy MAXIMAL =
// new ReflectionCloningStrategy(new MaximalCloningDecisionStrategy(), new ObjenesisInstantiationStrategy(),
// new SerializationCloningStrategy());
//
// /**
// * Clones the given object using the given <code>ClassLoader</code>.
// *
// * @param original the original object to be cloned
// * @param targetClassLoader the <code>ClassLoader</code> by which to load <code>Class</code>es for clones
// * @return the result of cloning the object graph
// * @throws Exception can throw any <code>Exception</code> depending on the implementation
// */
// Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader) throws Exception;
// }
| import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import com.googlecode.transloader.clone.CloningStrategy;
| package com.googlecode.transloader;
/**
* The wrapper appropriate for wrapping around all <code>Object</code>s referencing <code>Class</code>es from
* potentially foreign <code>ClassLoader</code>s.
*
* @author Jeremy Wales
*/
public final class ObjectWrapper {
private final Object wrappedObject;
| // Path: src/main/java/com/googlecode/transloader/clone/CloningStrategy.java
// public interface CloningStrategy {
// /**
// * The implementation which clones as little as possible to make the given object graph use <code>Class</code>es
// * that are the same as those that would be loaded through the given <code>ClassLoader</code>. This is the most
// * efficient implementation to use simply for the purpose of making sure the returned object graph is perfectly
// * compatible with all other objects referencing <code>Class</code>es loaded through the given
// * <code>ClassLoader</code>. It is also the implementation that is most likely to succeed in cloning any given
// * object graph because by attempting to clone as few objects as possible it is less likely to attempt to clone an
// * object that cannot be cloned (e.g. a non-{@link java.io.Serializable} with <code>final</code> fields in a
// * pre-Java-5 JVM).
// * <p>
// * However, the fact that it only clones what is necessary to make the object graph compatible with the given
// * <code>ClassLoader</code> means that usually <b>not all</b> of the objects in the graph will be cloned. This
// * means that, depending on the <code>Class</code>es in the object graph and which of these is the same if loaded
// * through the given <code>ClassLoader</code>, it is possible that a top level object is not cloned but objects
// * it references through fields are cloned. This effectively means that the existing object graph can be altered
// * rather than a new, purely seperate object graph being created. This <b>may not be what you want</b> if you want
// * to continue using the given object in its original context. In which case, use {@link CloningStrategy#MAXIMAL}.
// * </p>
// *
// * @see ReflectionCloningStrategy
// * @see MinimalCloningDecisionStrategy
// */
// CloningStrategy MINIMAL =
// new ReflectionCloningStrategy(new MinimalCloningDecisionStrategy(), new ObjenesisInstantiationStrategy(),
// new SerializationCloningStrategy());
//
// /**
// * The implementation which clones every <code>Object</code> in the given object graph. The given object graph is
// * not altered in any way and a completely new copy of the object graph referencing only <code>Class</code>es
// * loaded through the given <code>ClassLoader</code> is returned. Only primitives, which are not
// * <code>Object</code>s, are not cloned because they cannot be, as there is no concept of different references to
// * the same primitive value in Java. Similiar in behaviour to {@link SerializationCloningStrategy} except that it
// * can clone more object graphs because it does not rely on all referenced objects being
// * {@link java.io.Serializable} and also performs much faster than serialization.
// *
// * @see ReflectionCloningStrategy
// * @see MaximalCloningDecisionStrategy
// */
// CloningStrategy MAXIMAL =
// new ReflectionCloningStrategy(new MaximalCloningDecisionStrategy(), new ObjenesisInstantiationStrategy(),
// new SerializationCloningStrategy());
//
// /**
// * Clones the given object using the given <code>ClassLoader</code>.
// *
// * @param original the original object to be cloned
// * @param targetClassLoader the <code>ClassLoader</code> by which to load <code>Class</code>es for clones
// * @return the result of cloning the object graph
// * @throws Exception can throw any <code>Exception</code> depending on the implementation
// */
// Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader) throws Exception;
// }
// Path: src/main/java/com/googlecode/transloader/ObjectWrapper.java
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import com.googlecode.transloader.clone.CloningStrategy;
package com.googlecode.transloader;
/**
* The wrapper appropriate for wrapping around all <code>Object</code>s referencing <code>Class</code>es from
* potentially foreign <code>ClassLoader</code>s.
*
* @author Jeremy Wales
*/
public final class ObjectWrapper {
private final Object wrappedObject;
| private final CloningStrategy cloner;
|
fmunch/transloader | src/main/java/com/googlecode/transloader/clone/reflect/MaximalCloningDecisionStrategy.java | // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
| import com.googlecode.transloader.Assert;
| package com.googlecode.transloader.clone.reflect;
/**
* When injected into a {@link ReflectionCloningStrategy}, decides that all given objects and those that they reference
* should be cloned.
*
* @author Jeremy Wales
*/
public final class MaximalCloningDecisionStrategy implements CloningDecisionStrategy {
/**
* Decides that all objects should be shallow copied.
*
* @param original ignored; returns <code>true</code> regardless
* @param targetClassLoader ignored; returns <code>true</code> regardless
* @return <code>true</code> always
*/
public boolean shouldCloneObjectItself(Object original, ClassLoader targetClassLoader) {
| // Path: src/main/java/com/googlecode/transloader/Assert.java
// public final class Assert {
//
// private Assert() {
// }
//
// /**
// * Asserts that the given parameter is not <code>null</code>.
// *
// * @param parameter the parameter to check
// * @throws IllegalArgumentException if <code>parameter</code> is <code>null</code>
// * @return the given <code>parameter</code> (if an <code>Exception</code> was not already thrown because it was
// * <code>null</code>)
// */
// public static Object isNotNull(Object parameter) {
// areNotNull(new Object[] {parameter});
// return parameter;
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code> or <code>parameter2</code> is
// * <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2) {
// areNotNull(new Object[] {parameter1, parameter2});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameter1 the first parameter to check
// * @param parameter2 the second parameter to check
// * @param parameter3 the third parameter to check
// * @throws IllegalArgumentException if either <code>parameter1</code>, <code>parameter2</code> or
// * <code>parameter3</code> is <code>null</code>
// */
// public static void areNotNull(Object parameter1, Object parameter2, Object parameter3) {
// areNotNull(new Object[] {parameter1, parameter2, parameter3});
// }
//
// /**
// * Asserts that the given parameters are not <code>null</code>.
// *
// * @param parameters the parameters to check
// * @throws IllegalArgumentException if any elements of <code>parameters</code> are <code>null</code>
// */
// public static void areNotNull(Object[] parameters) {
// if (parameters == null) throw newNullParameterException(parameters);
// List parameterList = Arrays.asList(parameters);
// if (parameterList.contains(null)) throw newNullParameterException(parameterList);
// }
//
// private static IllegalArgumentException newNullParameterException(Object parameters) {
// return new IllegalArgumentException("Expecting no null parameters but received " + parameters + ".");
// }
//
// /**
// * Asserts that the given arrays are of the same length.
// *
// * @param array1 the first array in the comparison
// * @param array2 the second array in the comparison
// * @throws IllegalArgumentException if the length of <code>array1</code> is not equal to the length of
// * <code>array2</code>
// */
// public static void areSameLength(Object[] array1, Object[] array2) {
// if (array1.length != array2.length)
// throw new IllegalArgumentException(
// "Expecting equal length arrays but received " + Arrays.asList(array1) + " and " + Arrays.asList(array2) + ".");
// }
// }
// Path: src/main/java/com/googlecode/transloader/clone/reflect/MaximalCloningDecisionStrategy.java
import com.googlecode.transloader.Assert;
package com.googlecode.transloader.clone.reflect;
/**
* When injected into a {@link ReflectionCloningStrategy}, decides that all given objects and those that they reference
* should be cloned.
*
* @author Jeremy Wales
*/
public final class MaximalCloningDecisionStrategy implements CloningDecisionStrategy {
/**
* Decides that all objects should be shallow copied.
*
* @param original ignored; returns <code>true</code> regardless
* @param targetClassLoader ignored; returns <code>true</code> regardless
* @return <code>true</code> always
*/
public boolean shouldCloneObjectItself(Object original, ClassLoader targetClassLoader) {
| Assert.areNotNull(original, targetClassLoader);
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/WithPrimitiveFields.java | // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
| import com.googlecode.transloader.test.Triangulate;
| package com.googlecode.transloader.test.fixture;
public class WithPrimitiveFields extends NonCommonJavaObject {
private boolean booleanField;
private byte byteField;
private char charField;
private short shortField;
private int intField;
private long longField;
private float floatField;
private double doubleField;
public WithPrimitiveFields() {
| // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/WithPrimitiveFields.java
import com.googlecode.transloader.test.Triangulate;
package com.googlecode.transloader.test.fixture;
public class WithPrimitiveFields extends NonCommonJavaObject {
private boolean booleanField;
private byte byteField;
private char charField;
private short shortField;
private int intField;
private long longField;
private float floatField;
private double doubleField;
public WithPrimitiveFields() {
| booleanField = Triangulate.eitherBoolean();
|
fmunch/transloader | src/test/java/com/googlecode/transloader/test/fixture/WithListFields.java | // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.googlecode.transloader.test.Triangulate;
| package com.googlecode.transloader.test.fixture;
public class WithListFields extends NonCommonJavaObject {
List listFromArray =
Arrays.asList(new NonCommonJavaType[] {new WithPrimitiveFields(),
| // Path: src/test/java/com/googlecode/transloader/test/Triangulate.java
// public final class Triangulate {
// private static final Random RANDOM = new Random(System.currentTimeMillis());
// private static final byte[] ONE_BYTE_BUFFER = new byte[1];
// private static final Method[] MY_METHODS = Triangulate.class.getDeclaredMethods();
//
// private Triangulate() {
// }
//
// public static String anyString() {
// return anyDouble() + "";
// }
//
// public static String anyAlphaNumbericString() {
// return Long.toHexString(anyLong());
// }
//
// public static boolean eitherBoolean() {
// return RANDOM.nextBoolean();
// }
//
// public static byte anyByte() {
// RANDOM.nextBytes(ONE_BYTE_BUFFER);
// return ONE_BYTE_BUFFER[0];
// }
//
// public static char anyChar() {
// return (char) anyByte();
// }
//
// public static short anyShort() {
// return (short) anyByte();
// }
//
// public static int anyInt() {
// return RANDOM.nextInt();
// }
//
// public static int anyIntFromZeroTo(int upperBound) {
// return RANDOM.nextInt(upperBound);
// }
//
// public static Integer anyInteger() {
// return new Integer(anyInt());
// }
//
// public static long anyLong() {
// return RANDOM.nextLong();
// }
//
// public static float anyFloat() {
// return RANDOM.nextFloat();
// }
//
// public static double anyDouble() {
// return RANDOM.nextDouble();
// }
//
// public static Class anyClass() {
// return anyMethod().getReturnType();
// }
//
// public static Method anyMethod() {
// return MY_METHODS[anyIntFromZeroTo(MY_METHODS.length - 1)];
// }
//
// public static Object anyInstanceOf(Class type) {
// try {
// if (type == null || type == void.class) return null;
// if (type.isArray()) return anyArrayOf(type.getComponentType());
// Object triangulatedInstance = tryToTriangulateFromThisClass(type);
// if (triangulatedInstance != null) return triangulatedInstance;
// if (type.isInterface())
// return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {type},
// new TriangulatingInvocationHandler());
// if (Modifier.isAbstract(type.getModifiers()))
// return Enhancer.create(type, new TriangulatingInvocationHandler());
// return ObjenesisHelper.newInstance(type);
// } catch (Exception e) {
// throw new NestableRuntimeException(e);
// }
// }
//
// private static Object anyArrayOf(Class componentType) throws Exception {
// int length = anyIntFromZeroTo(3);
// Object array = Array.newInstance(componentType, length);
// for (int i = 0; i < length; i++) {
// Array.set(array, i, anyInstanceOf(componentType));
// }
// return array;
// }
//
// private static Object tryToTriangulateFromThisClass(Class type) throws Exception {
// for (int i = 0; i < MY_METHODS.length; i++) {
// Method method = MY_METHODS[i];
// Class returnType = method.getReturnType();
// boolean hasNoParameters = method.getParameterTypes() == null || method.getParameterTypes().length == 0;
// if (returnType == type && hasNoParameters) {
// return method.invoke(null, new Object[0]);
// }
// }
// return null;
// }
//
// private static class TriangulatingInvocationHandler implements InvocationHandler,
// net.sf.cglib.proxy.InvocationHandler {
// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// if (method.getReturnType() == Void.class) return null;
// if (method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class)
// return new Boolean(proxy == args[0]);
// if (method.getName().equals("hashCode") && method.getParameterTypes().length == 0)
// return new Integer(System.identityHashCode(proxy));
// if (method.getName().equals("toString") && method.getParameterTypes().length == 0)
// return TriangulatingInvocationHandler.class.getName() + '#' + System.identityHashCode(proxy);
// return anyInstanceOf(method.getReturnType());
// }
// }
// }
// Path: src/test/java/com/googlecode/transloader/test/fixture/WithListFields.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.googlecode.transloader.test.Triangulate;
package com.googlecode.transloader.test.fixture;
public class WithListFields extends NonCommonJavaObject {
List listFromArray =
Arrays.asList(new NonCommonJavaType[] {new WithPrimitiveFields(),
| new WithStringField(Triangulate.anyString())});
|
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
| import de.qyotta.eventstore.EventStoreSettings; | package de.qyotta.eventstore.communication;
public interface ESContext {
ESReader getReader();
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
import de.qyotta.eventstore.EventStoreSettings;
package de.qyotta.eventstore.communication;
public interface ESContext {
ESReader getReader();
| EventStoreSettings getSettings(); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static CloseableHttpClient httpClient(final EventStoreSettings settings) {
// if (settings.isCacheResponses()) {
// return newClosableCachingHttpClient(settings);
// }
// return newClosableHttpClient(settings);
// }
//
// private static CloseableHttpClient newClosableHttpClient(EventStoreSettings settings) {
// return HttpClientBuilder.create()
//
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static CloseableHttpClient newClosableCachingHttpClient(EventStoreSettings settings) {
// final CacheConfig cacheConfig = CacheConfig.custom()
// .setMaxCacheEntries(Integer.MAX_VALUE)
// .setMaxObjectSize(Integer.MAX_VALUE)
// .build();
//
// settings.getCacheDirectory()
// .mkdirs();
//
// return CachingHttpClientBuilder.create()
// .setHttpCacheStorage(new FileCacheStorage(cacheConfig, settings.getCacheDirectory()))
// .setCacheConfig(cacheConfig)
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static RequestConfig requestConfig(final EventStoreSettings settings) {
// return RequestConfig.custom()
// .setConnectTimeout(settings.getConnectionTimeoutMillis())
// .setSocketTimeout(settings.getSocketTimeoutMillis())
// .build();
// }
//
// private static CredentialsProvider credentialsProvider(final EventStoreSettings settings) {
// final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// credentialsProvider.setCredentials(new AuthScope(null, -1), new UsernamePasswordCredentials(settings.getUserName(), settings.getPassword()));
// return credentialsProvider;
// }
//
// }
| import org.apache.http.impl.client.CloseableHttpClient;
import de.qyotta.eventstore.EventStoreSettings;
import de.qyotta.eventstore.utils.HttpClientFactory; | package de.qyotta.eventstore.communication;
public class EsContextDefaultImpl implements ESContext {
private final CloseableHttpClient httpclient;
private final ESReader reader; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static CloseableHttpClient httpClient(final EventStoreSettings settings) {
// if (settings.isCacheResponses()) {
// return newClosableCachingHttpClient(settings);
// }
// return newClosableHttpClient(settings);
// }
//
// private static CloseableHttpClient newClosableHttpClient(EventStoreSettings settings) {
// return HttpClientBuilder.create()
//
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static CloseableHttpClient newClosableCachingHttpClient(EventStoreSettings settings) {
// final CacheConfig cacheConfig = CacheConfig.custom()
// .setMaxCacheEntries(Integer.MAX_VALUE)
// .setMaxObjectSize(Integer.MAX_VALUE)
// .build();
//
// settings.getCacheDirectory()
// .mkdirs();
//
// return CachingHttpClientBuilder.create()
// .setHttpCacheStorage(new FileCacheStorage(cacheConfig, settings.getCacheDirectory()))
// .setCacheConfig(cacheConfig)
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static RequestConfig requestConfig(final EventStoreSettings settings) {
// return RequestConfig.custom()
// .setConnectTimeout(settings.getConnectionTimeoutMillis())
// .setSocketTimeout(settings.getSocketTimeoutMillis())
// .build();
// }
//
// private static CredentialsProvider credentialsProvider(final EventStoreSettings settings) {
// final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// credentialsProvider.setCredentials(new AuthScope(null, -1), new UsernamePasswordCredentials(settings.getUserName(), settings.getPassword()));
// return credentialsProvider;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
import org.apache.http.impl.client.CloseableHttpClient;
import de.qyotta.eventstore.EventStoreSettings;
import de.qyotta.eventstore.utils.HttpClientFactory;
package de.qyotta.eventstore.communication;
public class EsContextDefaultImpl implements ESContext {
private final CloseableHttpClient httpclient;
private final ESReader reader; | private final EventStoreSettings settings; |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static CloseableHttpClient httpClient(final EventStoreSettings settings) {
// if (settings.isCacheResponses()) {
// return newClosableCachingHttpClient(settings);
// }
// return newClosableHttpClient(settings);
// }
//
// private static CloseableHttpClient newClosableHttpClient(EventStoreSettings settings) {
// return HttpClientBuilder.create()
//
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static CloseableHttpClient newClosableCachingHttpClient(EventStoreSettings settings) {
// final CacheConfig cacheConfig = CacheConfig.custom()
// .setMaxCacheEntries(Integer.MAX_VALUE)
// .setMaxObjectSize(Integer.MAX_VALUE)
// .build();
//
// settings.getCacheDirectory()
// .mkdirs();
//
// return CachingHttpClientBuilder.create()
// .setHttpCacheStorage(new FileCacheStorage(cacheConfig, settings.getCacheDirectory()))
// .setCacheConfig(cacheConfig)
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static RequestConfig requestConfig(final EventStoreSettings settings) {
// return RequestConfig.custom()
// .setConnectTimeout(settings.getConnectionTimeoutMillis())
// .setSocketTimeout(settings.getSocketTimeoutMillis())
// .build();
// }
//
// private static CredentialsProvider credentialsProvider(final EventStoreSettings settings) {
// final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// credentialsProvider.setCredentials(new AuthScope(null, -1), new UsernamePasswordCredentials(settings.getUserName(), settings.getPassword()));
// return credentialsProvider;
// }
//
// }
| import org.apache.http.impl.client.CloseableHttpClient;
import de.qyotta.eventstore.EventStoreSettings;
import de.qyotta.eventstore.utils.HttpClientFactory; | package de.qyotta.eventstore.communication;
public class EsContextDefaultImpl implements ESContext {
private final CloseableHttpClient httpclient;
private final ESReader reader;
private final EventStoreSettings settings;
private final ESWriter writer;
public EsContextDefaultImpl(final EventStoreSettings settings) {
this.settings = settings; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static CloseableHttpClient httpClient(final EventStoreSettings settings) {
// if (settings.isCacheResponses()) {
// return newClosableCachingHttpClient(settings);
// }
// return newClosableHttpClient(settings);
// }
//
// private static CloseableHttpClient newClosableHttpClient(EventStoreSettings settings) {
// return HttpClientBuilder.create()
//
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static CloseableHttpClient newClosableCachingHttpClient(EventStoreSettings settings) {
// final CacheConfig cacheConfig = CacheConfig.custom()
// .setMaxCacheEntries(Integer.MAX_VALUE)
// .setMaxObjectSize(Integer.MAX_VALUE)
// .build();
//
// settings.getCacheDirectory()
// .mkdirs();
//
// return CachingHttpClientBuilder.create()
// .setHttpCacheStorage(new FileCacheStorage(cacheConfig, settings.getCacheDirectory()))
// .setCacheConfig(cacheConfig)
// .setDefaultRequestConfig(requestConfig(settings))
// .setDefaultCredentialsProvider(credentialsProvider(settings))
// .setRedirectStrategy(new LaxRedirectStrategy())
// .setRetryHandler(new StandardHttpRequestRetryHandler())
// .setKeepAliveStrategy(new de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy())
// .setConnectionManagerShared(true)
//
// .build();
// }
//
// private static RequestConfig requestConfig(final EventStoreSettings settings) {
// return RequestConfig.custom()
// .setConnectTimeout(settings.getConnectionTimeoutMillis())
// .setSocketTimeout(settings.getSocketTimeoutMillis())
// .build();
// }
//
// private static CredentialsProvider credentialsProvider(final EventStoreSettings settings) {
// final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
// credentialsProvider.setCredentials(new AuthScope(null, -1), new UsernamePasswordCredentials(settings.getUserName(), settings.getPassword()));
// return credentialsProvider;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
import org.apache.http.impl.client.CloseableHttpClient;
import de.qyotta.eventstore.EventStoreSettings;
import de.qyotta.eventstore.utils.HttpClientFactory;
package de.qyotta.eventstore.communication;
public class EsContextDefaultImpl implements ESContext {
private final CloseableHttpClient httpclient;
private final ESReader reader;
private final EventStoreSettings settings;
private final ESWriter writer;
public EsContextDefaultImpl(final EventStoreSettings settings) {
this.settings = settings; | httpclient = HttpClientFactory.httpClient(settings); |
Qyotta/axon-eventstore | esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/test/EventStoreIntegrationTest.java | // Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/config/AbstractIntegrationTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// //@formatter:off
// @ContextConfiguration(classes = {
// TestConfiguration.class,
// }, loader = AnnotationConfigContextLoader.class)
// //@formatter:on
// @SuppressWarnings("nls")
// public abstract class AbstractIntegrationTest {
// private static final InMemoryEventstoreProvider EVENT_STORE_PROVIDER = new InMemoryEventstoreProvider();
// protected String myAggregateId;
//
// protected final List<Object> actualEvents = new LinkedList<>();
// private final EventListener EVENT_LISTENER = new EventListener() {
// @Override
// public void handle(@SuppressWarnings("rawtypes") final EventMessage event) {
// actualEvents.add(event.getPayload());
// }
// };
//
// @BeforeClass
// public static void beforeClass() {
// if (!EVENT_STORE_PROVIDER.isRunning()) {
// EVENT_STORE_PROVIDER.start();
// }
// }
//
// @AfterClass
// public static void afterClass() {
// EVENT_STORE_PROVIDER.stop();
// }
//
// @Autowired
// protected EventBus eventBus;
// @Autowired
// protected com.github.msemys.esjc.EventStore eventStore;
//
// @Before
// public final void initTest() {
// myAggregateId = UUID.randomUUID()
// .toString();
// eventBus.subscribe(EVENT_LISTENER);
// }
//
// protected <T extends AbstractAnnotatedAggregateRoot<?>> void deleteEventStream(final Class<T> classOfT, final String aggregateId) {
// eventStore.deleteStream(EsjcEventstoreUtil.getStreamName(classOfT.getSimpleName(), aggregateId, "domain"), ExpectedVersion.ANY);
// }
//
// protected <T> void expectEventsMatchingExactlyOnce(final List<T> expectedEvents) {
// expectEvents(expectedEvents, true);
// }
//
// protected <T> void expectEvents(final List<T> expectedEvents) {
// expectEvents(expectedEvents, false);
// }
//
// private <T> void expectEvents(final List<T> expectedEvents, final boolean exactlyOnce) {
// for (final Object expectedEvent : expectedEvents) {
// final AtomicInteger numberOfEventsMatching = new AtomicInteger(0);
// actualEvents.forEach(e -> {
// if (e.equals(expectedEvent)) {
// numberOfEventsMatching.incrementAndGet();
// }
// });
// if (numberOfEventsMatching.get() == 1) {
// continue;
// }
// if (exactlyOnce && numberOfEventsMatching.get() > 1) {
// fail("Expected event: " + expectedEvent + "found, but was matched multible times. (It matched " + numberOfEventsMatching.get() + " times.)");
// }
// final List<Object> eventsOfType = new LinkedList<>();
// for (final Object actual : actualEvents) {
// if (actual.getClass()
// .equals(expectedEvent.getClass())) {
// eventsOfType.add(actual);
// }
// }
// if (eventsOfType.isEmpty()) {
// fail("Expected an event of type: " + expectedEvent.getClass()
// .getName() + " but none was published.");
// }
// fail("Expected event: " + expectedEvent + ". Found the following events of the same type but none matched: " + eventsOfType);
// }
// }
// }
//
// Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/ChangeTestAggregate.java
// @Value
// public class ChangeTestAggregate {
// @TargetAggregateIdentifier
// private String aggregateId;
// }
//
// Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/CreateTestAggregate.java
// @Value
// @Revision("1")
// public class CreateTestAggregate {
// @TargetAggregateIdentifier
// private String aggregateId;
// }
//
// Path: axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/MyTestAggregate.java
// @NoArgsConstructor
// public class MyTestAggregate extends AbstractAnnotatedAggregateRoot<String> {
// private static final long serialVersionUID = 1L;
//
// @AggregateIdentifier
// private String aggregateId;
//
// @CommandHandler
// public MyTestAggregate(final CreateTestAggregate command, final MetaData metaData) {
// this.aggregateId = command.getAggregateId();
// apply(new TestAggregateCreated(command.getAggregateId()), metaData);
// }
//
// @CommandHandler
// public void onCommand(final ChangeTestAggregate command, final MetaData metaData) {
// if (!command.getAggregateId().equals(aggregateId)) {
// throw new IllegalStateException("Maximum number of events reached ;)"); //$NON-NLS-1$
// }
// apply(new TestAggregateChanged(command.getAggregateId()), metaData);
// }
//
// @EventSourcingHandler
// public void onEvent(final TestAggregateCreated event) {
// this.aggregateId = event.getAggregateId();
// }
//
// @EventSourcingHandler
// public void onEvent(@SuppressWarnings("unused") final TestAggregateChanged event) {
// //
// }
// }
| import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.axonframework.commandhandling.CommandExecutionException;
import org.axonframework.commandhandling.GenericCommandMessage;
import org.axonframework.commandhandling.gateway.CommandGateway;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.msemys.esjc.StreamEventsSlice;
import de.qyotta.axonframework.eventstore.config.AbstractIntegrationTest;
import de.qyotta.axonframework.eventstore.domain.ChangeTestAggregate;
import de.qyotta.axonframework.eventstore.domain.CreateTestAggregate;
import de.qyotta.axonframework.eventstore.domain.MyTestAggregate; | package de.qyotta.axonframework.eventstore.test;
@SuppressWarnings("nls")
public class EventStoreIntegrationTest extends AbstractIntegrationTest {
@Autowired
private CommandGateway commandGateway;
@After
public final void tearDown() { | // Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/config/AbstractIntegrationTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// //@formatter:off
// @ContextConfiguration(classes = {
// TestConfiguration.class,
// }, loader = AnnotationConfigContextLoader.class)
// //@formatter:on
// @SuppressWarnings("nls")
// public abstract class AbstractIntegrationTest {
// private static final InMemoryEventstoreProvider EVENT_STORE_PROVIDER = new InMemoryEventstoreProvider();
// protected String myAggregateId;
//
// protected final List<Object> actualEvents = new LinkedList<>();
// private final EventListener EVENT_LISTENER = new EventListener() {
// @Override
// public void handle(@SuppressWarnings("rawtypes") final EventMessage event) {
// actualEvents.add(event.getPayload());
// }
// };
//
// @BeforeClass
// public static void beforeClass() {
// if (!EVENT_STORE_PROVIDER.isRunning()) {
// EVENT_STORE_PROVIDER.start();
// }
// }
//
// @AfterClass
// public static void afterClass() {
// EVENT_STORE_PROVIDER.stop();
// }
//
// @Autowired
// protected EventBus eventBus;
// @Autowired
// protected com.github.msemys.esjc.EventStore eventStore;
//
// @Before
// public final void initTest() {
// myAggregateId = UUID.randomUUID()
// .toString();
// eventBus.subscribe(EVENT_LISTENER);
// }
//
// protected <T extends AbstractAnnotatedAggregateRoot<?>> void deleteEventStream(final Class<T> classOfT, final String aggregateId) {
// eventStore.deleteStream(EsjcEventstoreUtil.getStreamName(classOfT.getSimpleName(), aggregateId, "domain"), ExpectedVersion.ANY);
// }
//
// protected <T> void expectEventsMatchingExactlyOnce(final List<T> expectedEvents) {
// expectEvents(expectedEvents, true);
// }
//
// protected <T> void expectEvents(final List<T> expectedEvents) {
// expectEvents(expectedEvents, false);
// }
//
// private <T> void expectEvents(final List<T> expectedEvents, final boolean exactlyOnce) {
// for (final Object expectedEvent : expectedEvents) {
// final AtomicInteger numberOfEventsMatching = new AtomicInteger(0);
// actualEvents.forEach(e -> {
// if (e.equals(expectedEvent)) {
// numberOfEventsMatching.incrementAndGet();
// }
// });
// if (numberOfEventsMatching.get() == 1) {
// continue;
// }
// if (exactlyOnce && numberOfEventsMatching.get() > 1) {
// fail("Expected event: " + expectedEvent + "found, but was matched multible times. (It matched " + numberOfEventsMatching.get() + " times.)");
// }
// final List<Object> eventsOfType = new LinkedList<>();
// for (final Object actual : actualEvents) {
// if (actual.getClass()
// .equals(expectedEvent.getClass())) {
// eventsOfType.add(actual);
// }
// }
// if (eventsOfType.isEmpty()) {
// fail("Expected an event of type: " + expectedEvent.getClass()
// .getName() + " but none was published.");
// }
// fail("Expected event: " + expectedEvent + ". Found the following events of the same type but none matched: " + eventsOfType);
// }
// }
// }
//
// Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/ChangeTestAggregate.java
// @Value
// public class ChangeTestAggregate {
// @TargetAggregateIdentifier
// private String aggregateId;
// }
//
// Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/CreateTestAggregate.java
// @Value
// @Revision("1")
// public class CreateTestAggregate {
// @TargetAggregateIdentifier
// private String aggregateId;
// }
//
// Path: axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/domain/MyTestAggregate.java
// @NoArgsConstructor
// public class MyTestAggregate extends AbstractAnnotatedAggregateRoot<String> {
// private static final long serialVersionUID = 1L;
//
// @AggregateIdentifier
// private String aggregateId;
//
// @CommandHandler
// public MyTestAggregate(final CreateTestAggregate command, final MetaData metaData) {
// this.aggregateId = command.getAggregateId();
// apply(new TestAggregateCreated(command.getAggregateId()), metaData);
// }
//
// @CommandHandler
// public void onCommand(final ChangeTestAggregate command, final MetaData metaData) {
// if (!command.getAggregateId().equals(aggregateId)) {
// throw new IllegalStateException("Maximum number of events reached ;)"); //$NON-NLS-1$
// }
// apply(new TestAggregateChanged(command.getAggregateId()), metaData);
// }
//
// @EventSourcingHandler
// public void onEvent(final TestAggregateCreated event) {
// this.aggregateId = event.getAggregateId();
// }
//
// @EventSourcingHandler
// public void onEvent(@SuppressWarnings("unused") final TestAggregateChanged event) {
// //
// }
// }
// Path: esjc-axon-eventstore/tests/src/test/java/de/qyotta/axonframework/eventstore/test/EventStoreIntegrationTest.java
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.axonframework.commandhandling.CommandExecutionException;
import org.axonframework.commandhandling.GenericCommandMessage;
import org.axonframework.commandhandling.gateway.CommandGateway;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.msemys.esjc.StreamEventsSlice;
import de.qyotta.axonframework.eventstore.config.AbstractIntegrationTest;
import de.qyotta.axonframework.eventstore.domain.ChangeTestAggregate;
import de.qyotta.axonframework.eventstore.domain.CreateTestAggregate;
import de.qyotta.axonframework.eventstore.domain.MyTestAggregate;
package de.qyotta.axonframework.eventstore.test;
@SuppressWarnings("nls")
public class EventStoreIntegrationTest extends AbstractIntegrationTest {
@Autowired
private CommandGateway commandGateway;
@After
public final void tearDown() { | deleteEventStream(MyTestAggregate.class, myAggregateId); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy { | boolean matches(final Entry e); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
| private final ESContext context; |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context; | private List<Link> currentLinks; |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context;
private List<Link> currentLinks;
private Deque<Entry> currentEntries; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context;
private List<Link> currentLinks;
private Deque<Entry> currentEntries; | private EventResponse next; |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context;
private List<Link> currentLinks;
private Deque<Entry> currentEntries;
private EventResponse next;
private EventResponse previous;
private final String streamUrl;
/**
* Initialize this stream at the very beginning
*/
public EventStreamImpl(final String streamUrl, final ESContext context) {
this.streamUrl = streamUrl;
this.context = context;
loadFirstFeed();
loadNextEvent(null);
}
@Override
public synchronized void setAfterTitle(final String title) {
final Entry entry = setTo(e -> e.getTitle()
.equals(title));
loadNextEvent(readEvent(entry));
}
@Override
public synchronized void setAfterTimestamp(final Date timestamp) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamImpl implements EventStream {
private static final Logger LOGGER = LoggerFactory.getLogger(EventStreamImpl.class.getName());
public interface EntryMatchingStrategy {
boolean matches(final Entry e);
}
private final ESContext context;
private List<Link> currentLinks;
private Deque<Entry> currentEntries;
private EventResponse next;
private EventResponse previous;
private final String streamUrl;
/**
* Initialize this stream at the very beginning
*/
public EventStreamImpl(final String streamUrl, final ESContext context) {
this.streamUrl = streamUrl;
this.context = context;
loadFirstFeed();
loadNextEvent(null);
}
@Override
public synchronized void setAfterTitle(final String title) {
final Entry entry = setTo(e -> e.getTitle()
.equals(title));
loadNextEvent(readEvent(entry));
}
@Override
public synchronized void setAfterTimestamp(final Date timestamp) { | final Entry entry = setTo(e -> timestamp.before(EsUtils.timestampOf(e))); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | public synchronized void setAfterTimestamp(final Date timestamp) {
final Entry entry = setTo(e -> timestamp.before(EsUtils.timestampOf(e)));
next = readEvent(entry);
}
private synchronized Entry setTo(final EntryMatchingStrategy matcher) {
loadFirstFeed();
while (true) {
final Entry e = pollNextEntry();
if (e == null) {
return null;
}
if (matcher.matches(e)) {
return e;
}
}
}
private synchronized Entry pollNextEntry() {
if (!currentEntries.isEmpty()) {
return currentEntries.pollLast();
}
loadNextFeed();
if (!currentEntries.isEmpty()) {
return currentEntries.pollLast();
}
return null;
}
private synchronized void loadFeed(final String feedUrl) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
public synchronized void setAfterTimestamp(final Date timestamp) {
final Entry entry = setTo(e -> timestamp.before(EsUtils.timestampOf(e)));
next = readEvent(entry);
}
private synchronized Entry setTo(final EntryMatchingStrategy matcher) {
loadFirstFeed();
while (true) {
final Entry e = pollNextEntry();
if (e == null) {
return null;
}
if (matcher.matches(e)) {
return e;
}
}
}
private synchronized Entry pollNextEntry() {
if (!currentEntries.isEmpty()) {
return currentEntries.pollLast();
}
loadNextFeed();
if (!currentEntries.isEmpty()) {
return currentEntries.pollLast();
}
return null;
}
private synchronized void loadFeed(final String feedUrl) { | final EventStreamFeed feed = context.getReader() |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | currentLinks = feed.getLinks();
currentEntries = new LinkedList<>(feed.getEntries());
}
@Override
public synchronized boolean hasNext() {
return next != null;
}
@Override
public final synchronized EventResponse next() {
final EventResponse result = next;
loadNextEvent(result);
return result;
}
private synchronized void loadNextEvent(final EventResponse pPrevious) {
try {
previous = pPrevious;
LOGGER.info("Setting previous event to: " + previous);
if (!currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
currentLinks = feed.getLinks();
currentEntries = new LinkedList<>(feed.getEntries());
}
@Override
public synchronized boolean hasNext() {
return next != null;
}
@Override
public final synchronized EventResponse next() {
final EventResponse result = next;
loadNextEvent(result);
return result;
}
private synchronized void loadNextEvent(final EventResponse pPrevious) {
try {
previous = pPrevious;
LOGGER.info("Setting previous event to: " + previous);
if (!currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events | } catch (final EventDeletedException e) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | return next != null;
}
@Override
public final synchronized EventResponse next() {
final EventResponse result = next;
loadNextEvent(result);
return result;
}
private synchronized void loadNextEvent(final EventResponse pPrevious) {
try {
previous = pPrevious;
LOGGER.info("Setting previous event to: " + previous);
if (!currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events
} catch (final EventDeletedException e) {
loadNextEvent(pPrevious);
}
}
private synchronized boolean loadNextFeed() { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
return next != null;
}
@Override
public final synchronized EventResponse next() {
final EventResponse result = next;
loadNextEvent(result);
return result;
}
private synchronized void loadNextEvent(final EventResponse pPrevious) {
try {
previous = pPrevious;
LOGGER.info("Setting previous event to: " + previous);
if (!currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events
} catch (final EventDeletedException e) {
loadNextEvent(pPrevious);
}
}
private synchronized boolean loadNextFeed() { | final Link previousLink = find(PREVIOUS, currentLinks); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; |
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events
} catch (final EventDeletedException e) {
loadNextEvent(pPrevious);
}
}
private synchronized boolean loadNextFeed() {
final Link previousLink = find(PREVIOUS, currentLinks);
if (previousLink != null) {
loadFeed(previousLink.getUri());
return true;
}
return false;
}
@Override
public final synchronized EventResponse peek() {
return next;
}
private EventResponse readEvent(final Entry entry) {
if (entry == null) {
LOGGER.info("No more events");
return null;
} | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
if (loadNextFeed() && !currentEntries.isEmpty()) {
next = readEvent(currentEntries.pollLast());
return;
}
next = null; // no more events
} catch (final EventDeletedException e) {
loadNextEvent(pPrevious);
}
}
private synchronized boolean loadNextFeed() {
final Link previousLink = find(PREVIOUS, currentLinks);
if (previousLink != null) {
loadFeed(previousLink.getUri());
return true;
}
return false;
}
@Override
public final synchronized EventResponse peek() {
return next;
}
private EventResponse readEvent(final Entry entry) {
if (entry == null) {
LOGGER.info("No more events");
return null;
} | final Link find = find(EDIT, entry.getLinks()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | .setSummary(entry.getSummary());
LOGGER.info("Loaded event with number: " + event.getContent()
.getEventNumber());
return event;
}
private synchronized Link find(final String relation, final List<Link> links) {
for (final Link link : links) {
if (relation.equals(link.getRelation())) {
return link;
}
}
return null;
}
private synchronized void loadFirstFeed() {
loadFeed(streamUrl);
final Link last = find(Link.LAST, currentLinks);
if (last != null) {
loadFeed(last.getUri());
}
}
@Override
public synchronized void loadNext() {
if (hasNext()) {
return;
}
// reload the current feed | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
.setSummary(entry.getSummary());
LOGGER.info("Loaded event with number: " + event.getContent()
.getEventNumber());
return event;
}
private synchronized Link find(final String relation, final List<Link> links) {
for (final Link link : links) {
if (relation.equals(link.getRelation())) {
return link;
}
}
return null;
}
private synchronized void loadFirstFeed() {
loadFeed(streamUrl);
final Link last = find(Link.LAST, currentLinks);
if (last != null) {
loadFeed(last.getUri());
}
}
@Override
public synchronized void loadNext() {
if (hasNext()) {
return;
}
// reload the current feed | loadFeed(find(SELF, currentLinks).getUri()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils; | return;
}
// if the last event in the stream is the previous event there can be no new events
if (previous.getTitle()
.equals(currentEntries.peekFirst()
.getTitle())) {
return;
}
if (previous == null) {
// If previous is null this is the first event
next = readEvent(currentEntries.pollLast());
return;
}
findNext();
}
private void findNext() {
while (!currentEntries.isEmpty()) {
final Entry current = currentEntries.pollLast();
final String currentTitle = current.getTitle();
final String previousTitle = previous.getTitle();
if (currentTitle.equals(previousTitle) && !currentEntries.isEmpty()) {
// load the next one or not =)
next = readEvent(currentEntries.pollLast());
LOGGER.info("Found new event:" + next);
return;
}
} | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String EDIT = "edit";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String NEXT = "next";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String PREVIOUS = "previous";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// public static final String SELF = "self";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESContext.java
// public interface ESContext {
//
// ESReader getReader();
//
// EventStoreSettings getSettings();
//
// ESWriter getWriter();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Link.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// @SuppressWarnings("nls")
// public class Link {
// public static final String SELF = "self";
// public static final String LAST = "last";
// public static final String PREVIOUS = "previous";
// public static final String NEXT = "next";
// public static final String EDIT = "edit";
// private String uri;
// private String relation;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStreamImpl.java
import static de.qyotta.eventstore.model.Link.EDIT;
import static de.qyotta.eventstore.model.Link.NEXT;
import static de.qyotta.eventstore.model.Link.PREVIOUS;
import static de.qyotta.eventstore.model.Link.SELF;
import java.util.Date;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.communication.ESContext;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.Link;
import de.qyotta.eventstore.utils.EsUtils;
return;
}
// if the last event in the stream is the previous event there can be no new events
if (previous.getTitle()
.equals(currentEntries.peekFirst()
.getTitle())) {
return;
}
if (previous == null) {
// If previous is null this is the first event
next = readEvent(currentEntries.pollLast());
return;
}
findNext();
}
private void findNext() {
while (!currentEntries.isEmpty()) {
final Entry current = currentEntries.pollLast();
final String currentTitle = current.getTitle();
final String previousTitle = previous.getTitle();
if (currentTitle.equals(previousTitle) && !currentEntries.isEmpty()) {
// load the next one or not =)
next = readEvent(currentEntries.pollLast());
LOGGER.info("Found new event:" + next);
return;
}
} | loadFeed(find(NEXT, currentLinks).getUri()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESReader.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | package de.qyotta.eventstore.communication;
public interface ESReader {
EventStreamFeed readStream(String url);
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/ESReader.java
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
package de.qyotta.eventstore.communication;
public interface ESReader {
EventStreamFeed readStream(String url);
| EventResponse readEvent(String url); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/StreamEventsSlice.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.util.List;
import de.qyotta.eventstore.model.EventResponse;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
| package de.qyotta.neweventstore;
@Getter
@Setter
@Builder(toBuilder = true)
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public final class StreamEventsSlice {
private final long fromEventNumber;
private final long nextEventNumber;
private final boolean endOfStream;
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/StreamEventsSlice.java
import java.util.List;
import de.qyotta.eventstore.model.EventResponse;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
package de.qyotta.neweventstore;
@Getter
@Setter
@Builder(toBuilder = true)
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public final class StreamEventsSlice {
private final long fromEventNumber;
private final long nextEventNumber;
private final boolean endOfStream;
| private final List<EventResponse> events;
|
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter { | private static Map<String, List<Event>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<Event>>()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter {
private static Map<String, List<Event>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<Event>>());
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter {
private static Map<String, List<Event>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<Event>>());
@Override | public EventStreamFeed readStream(String url) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter {
private static Map<String, List<Event>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<Event>>());
@Override
public EventStreamFeed readStream(String url) {
throw new UnsupportedOperationException("In Memory version is not implemented yet.");
}
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderWriterInMemoryImpl.java
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderWriterInMemoryImpl implements ESReader, ESWriter {
private static Map<String, List<Event>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<Event>>());
@Override
public EventStreamFeed readStream(String url) {
throw new UnsupportedOperationException("In Memory version is not implemented yet.");
}
@Override | public EventResponse readEvent(String url) { |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
| import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10); | final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() { |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
| import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10); | final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() { |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
| import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10);
final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
private long previousEventNumber = -1;
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10);
final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
private long previousEventNumber = -1;
@Override | public void readEvent(final EventResponse event) { |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
| import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10);
final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
private long previousEventNumber = -1;
@Override
public void readEvent(final EventResponse event) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
//
// /**
// * Start at the beginning of the stream.
// */
// void start();
//
// /**
// * Start after the given title (exclusive)
// */
// void start(String title);
//
// /**
// * Start after the given timestamp (exclusive)
// */
// void start(Date timestamp);
//
// /**
// * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
// */
// void catchUp();
//
// boolean isPaused();
//
// void setPaused(boolean paused);
//
// /**
// * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
// *
// * @param catchUpTerminationPeriodMillis
// */
// void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
// void readEvent(final EventResponse event);
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
createEvents(10);
final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
private long previousEventNumber = -1;
@Override
public void readEvent(final EventResponse event) { | final Event expected = expectedEvents.remove(event.getContent() |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextInMemoryImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
| import de.qyotta.eventstore.EventStoreSettings; | package de.qyotta.eventstore.communication;
public class EsContextInMemoryImpl implements ESContext {
private final ESReader reader; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreSettings.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PRIVATE)
// @AllArgsConstructor(access = AccessLevel.PRIVATE)
// @SuppressWarnings("nls")
// public class EventStoreSettings {
// private static final String DEFAULT_PASSWORD = "changeit";
// private static final String DEFAULT_USERNAME = "admin";
// private static final String DEFAULT_SCHEME = "Basic";
// private static final String DEFAULT_REALM = "ES";
// private static final String DEFAULT_HOST = "http://127.0.0.1:2113";
// private static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 10000;
// private static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 10000;
//
// private String host;
// private String realm;
// private String scheme;
// private String userName;
// private String password;
// private Integer connectionTimeoutMillis;
// private Integer socketTimeoutMillis;
// private File cacheDirectory;
// private boolean cacheResponses;
//
// public static EventStoreSettings.EventStoreSettingsBuilder withDefaults() {
// return EventStoreSettings.builder()
// .host(DEFAULT_HOST)
// .realm(DEFAULT_REALM)
// .scheme(DEFAULT_SCHEME)
// .userName(DEFAULT_USERNAME)
// .password(DEFAULT_PASSWORD)
// .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
// .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
// .cacheDirectory(new File(System.getProperty("java.io.tmpdir") + "/es"))
// .cacheResponses(true);
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextInMemoryImpl.java
import de.qyotta.eventstore.EventStoreSettings;
package de.qyotta.eventstore.communication;
public class EsContextInMemoryImpl implements ESContext {
private final ESReader reader; | private final EventStoreSettings settings; |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
| import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson; | package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore { | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson;
package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore { | private final EventStoreClient client; |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
| import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson; | package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore {
private final EventStoreClient client;
private final Gson gson = new Gson();
@SuppressWarnings("nls")
private String prefix = "domain";
public EsEventStore(final EventStoreClient client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream events) { | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson;
package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore {
private final EventStoreClient client;
private final Gson gson = new Gson();
@SuppressWarnings("nls")
private String prefix = "domain";
public EsEventStore(final EventStoreClient client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream events) { | final Map<Object, List<Event>> identifierToEventStoreEvents = new HashMap<>(); |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
| import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson; | package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore {
private final EventStoreClient client;
private final Gson gson = new Gson();
@SuppressWarnings("nls")
private String prefix = "domain";
public EsEventStore(final EventStoreClient client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream events) {
final Map<Object, List<Event>> identifierToEventStoreEvents = new HashMap<>();
while (events.hasNext()) {
final DomainEventMessage message = events.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<Event>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Object identifier : identifierToEventStoreEvents.keySet()) { | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson;
package de.qyotta.axonframework.eventstore;
/**
* @author satan
*
*/
@SuppressWarnings({ "rawtypes" })
public class EsEventStore implements EventStore {
private final EventStoreClient client;
private final Gson gson = new Gson();
@SuppressWarnings("nls")
private String prefix = "domain";
public EsEventStore(final EventStoreClient client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream events) {
final Map<Object, List<Event>> identifierToEventStoreEvents = new HashMap<>();
while (events.hasNext()) {
final DomainEventMessage message = events.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<Event>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Object identifier : identifierToEventStoreEvents.keySet()) { | client.appendEvents(getStreamName(type, identifier, prefix), identifierToEventStoreEvents.get(identifier)); |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
| import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson; | DomainEventStream stream;
try {
final EventStream eventStoreEventStream = client.readEvents(getStreamName(type, identifier, prefix));
stream = new EsEventStreamBackedDomainEventStream(eventStoreEventStream);
if (!stream.hasNext()) {
throw new EventStreamNotFoundException(type, identifier);
}
} catch (final de.qyotta.eventstore.model.EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format("Aggregate of type [%s] with identifier [%s] cannot be found.", type, identifier), e); //$NON-NLS-1$
}
return stream;
}
/**
* Set the prefix to use for domain-event-streams. This defaults to 'domain'.
*
* @param prefix
*/
public void setPrefix(final String prefix) {
this.prefix = prefix;
}
private Event toEvent(final DomainEventMessage message) {
final HashMap<String, Object> metaData = new HashMap<>();
final HashMap<String, Object> eventMetaData = new HashMap<>();
for (final Entry<String, Object> entry : message.getMetaData()
.entrySet()) {
eventMetaData.put(entry.getKey(), entry.getValue());
}
| // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStoreClient.java
// public class EventStoreClient {
// private final ESContext context;
//
// public EventStoreClient(ESContext context) {
// this.context = context;
// }
//
// /**
// * Creates a new {@link EventStreamReaderImpl}. Catch up is scheduled at the given interval. If the given interval is 0 or negative it will not be scheduled but can be invoked manually.
// *
// * @param streamName
// * @param intervalMillis
// * @param callback
// * @return
// */
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback);
// }
//
// public EventStreamReader newEventStreamReader(final String streamName, final int intervalMillis, final EventStreamReaderCallback callback, final EventStreamReaderImpl.EventStreamReaderErrorCallback errorCallback) {
// return new EventStreamReaderImpl(streamUrlForName(streamName), context, intervalMillis, callback, errorCallback);
// }
//
// public EventStream readEvents(final String streamName) {
// return new EventStreamImpl(streamUrlForName(streamName), context);
// }
//
// public void createProjection(String name, final String... includedStreams) {
// context.getWriter()
// .createLinkedProjection(context.getSettings()
// .getHost(), name, includedStreams);
// }
//
// public void appendEvent(final String streamName, final Event event) {
// context.getWriter()
// .appendEvent(streamUrlForName(streamName), event);
// }
//
// public void appendEvents(final String streamName, final Collection<Event> collection) {
// context.getWriter()
// .appendEvents(streamUrlForName(streamName), collection);
// }
//
// public void deleteStream(final String streamName, final boolean deletePermanently) {
// context.getWriter()
// .deleteStream(streamUrlForName(streamName), deletePermanently);
// }
//
// private String streamUrlForName(final String streamName) {
// return context.getSettings()
// .getHost() + STREAMS_PATH + streamName;
// }
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStore.java
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.eventstore.EventStoreClient;
import de.qyotta.eventstore.EventStream;
import de.qyotta.eventstore.model.Event;
import static de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.serializer.Revision;
import com.google.gson.Gson;
DomainEventStream stream;
try {
final EventStream eventStoreEventStream = client.readEvents(getStreamName(type, identifier, prefix));
stream = new EsEventStreamBackedDomainEventStream(eventStoreEventStream);
if (!stream.hasNext()) {
throw new EventStreamNotFoundException(type, identifier);
}
} catch (final de.qyotta.eventstore.model.EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format("Aggregate of type [%s] with identifier [%s] cannot be found.", type, identifier), e); //$NON-NLS-1$
}
return stream;
}
/**
* Set the prefix to use for domain-event-streams. This defaults to 'domain'.
*
* @param prefix
*/
public void setPrefix(final String prefix) {
this.prefix = prefix;
}
private Event toEvent(final DomainEventMessage message) {
final HashMap<String, Object> metaData = new HashMap<>();
final HashMap<String, Object> eventMetaData = new HashMap<>();
for (final Entry<String, Object> entry : message.getMetaData()
.entrySet()) {
eventMetaData.put(entry.getKey(), entry.getValue());
}
| metaData.put(Constants.AGGREGATE_ID_KEY, message.getAggregateIdentifier()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.util.Date;
import de.qyotta.eventstore.model.EventResponse; | package de.qyotta.eventstore;
public interface EventStream {
boolean hasNext();
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
import java.util.Date;
import de.qyotta.eventstore.model.EventResponse;
package de.qyotta.eventstore;
public interface EventStream {
boolean hasNext();
| EventResponse next(); |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
| import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class AbstractEsTest {
private static final InMemoryEventstoreProvider EVENT_STORE_PROVIDER = new InMemoryEventstoreProvider();
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractEsTest.class.getName());
private static final int PORT = 4445;
private static final String BASE_URL = "http://127.0.0.1";
protected static final String HOST = BASE_URL + ":" + PORT;
private static final String STREAMS = "/streams";
protected static String BASE_STREAMS_URL = HOST + STREAMS + "/"; | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java
import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class AbstractEsTest {
private static final InMemoryEventstoreProvider EVENT_STORE_PROVIDER = new InMemoryEventstoreProvider();
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractEsTest.class.getName());
private static final int PORT = 4445;
private static final String BASE_URL = "http://127.0.0.1";
protected static final String HOST = BASE_URL + ":" + PORT;
private static final String STREAMS = "/streams";
protected static String BASE_STREAMS_URL = HOST + STREAMS + "/"; | protected Map<String, Event> expectedEvents; |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
| import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; | protected static final String HOST = BASE_URL + ":" + PORT;
private static final String STREAMS = "/streams";
protected static String BASE_STREAMS_URL = HOST + STREAMS + "/";
protected Map<String, Event> expectedEvents;
protected String streamName;
protected EventStoreClient client;
protected String streamUrl;
protected static final Map<String, String> METADATA = new LinkedHashMap<>();
static {
METADATA.put("TEST", "TEST");
}
@BeforeClass
public static void beforeClass() {
RestAssured.baseURI = BASE_URL;
RestAssured.port = PORT;
RestAssured.basePath = STREAMS;
if (!EVENT_STORE_PROVIDER.isRunning()) {
EVENT_STORE_PROVIDER.start();
}
}
@AfterClass
public static void afterClass() {
EVENT_STORE_PROVIDER.stop();
}
@Before
public final void setupTest() { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java
import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
protected static final String HOST = BASE_URL + ":" + PORT;
private static final String STREAMS = "/streams";
protected static String BASE_STREAMS_URL = HOST + STREAMS + "/";
protected Map<String, Event> expectedEvents;
protected String streamName;
protected EventStoreClient client;
protected String streamUrl;
protected static final Map<String, String> METADATA = new LinkedHashMap<>();
static {
METADATA.put("TEST", "TEST");
}
@BeforeClass
public static void beforeClass() {
RestAssured.baseURI = BASE_URL;
RestAssured.port = PORT;
RestAssured.basePath = STREAMS;
if (!EVENT_STORE_PROVIDER.isRunning()) {
EVENT_STORE_PROVIDER.start();
}
}
@AfterClass
public static void afterClass() {
EVENT_STORE_PROVIDER.stop();
}
@Before
public final void setupTest() { | client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults() |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
| import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; | METADATA.put("TEST", "TEST");
}
@BeforeClass
public static void beforeClass() {
RestAssured.baseURI = BASE_URL;
RestAssured.port = PORT;
RestAssured.basePath = STREAMS;
if (!EVENT_STORE_PROVIDER.isRunning()) {
EVENT_STORE_PROVIDER.start();
}
}
@AfterClass
public static void afterClass() {
EVENT_STORE_PROVIDER.stop();
}
@Before
public final void setupTest() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = getClass().getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
protected static void deleteStream(final String streamUrl) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/AbstractEsTest.java
import static com.jayway.restassured.RestAssured.given;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.jayway.restassured.RestAssured;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
METADATA.put("TEST", "TEST");
}
@BeforeClass
public static void beforeClass() {
RestAssured.baseURI = BASE_URL;
RestAssured.port = PORT;
RestAssured.basePath = STREAMS;
if (!EVENT_STORE_PROVIDER.isRunning()) {
EVENT_STORE_PROVIDER.start();
}
}
@AfterClass
public static void afterClass() {
EVENT_STORE_PROVIDER.stop();
}
@Before
public final void setupTest() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = getClass().getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
protected static void deleteStream(final String streamUrl) { | final int statusCode = given().headers(ES_HARD_DELETE_HEADER, true) |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStreamBackedDomainEventStream.java | // Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsEventStoreUtils {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final EventResponse eventResponse) {
// try {
// final Gson gson = createGson();
// final Class<?> payloadType = Class.forName(eventResponse.getContent()
// .getEventType());
// final Object payload = gson.fromJson(eventResponse.getContent()
// .getData(), payloadType);
//
// final Map<String, ?> metaData = gson.fromJson(eventResponse.getContent()
// .getMetadata(), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// return new GenericDomainEventMessage(eventResponse.getTitle(), new DateTime(eventResponse.getUpdated(), DateTimeZone.UTC), metaData.get(Constants.AGGREGATE_ID_KEY), eventResponse.getContent()
// .getEventNumber(), payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
//
// private static Gson createGson() {
// //// final RuntimeTypeAdapterFactory<Entity> typeFactory = RuntimeTypeAdapterFactory.of(Entity.class, "type")
// //// .registerSubtype(UserEntity.class);
// // final Gson gson = new GsonBuilder().registerTypeAdapterFactory(typeFactory)
// // .create();
// // return gson;
// return new Gson();
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
| import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils;
import de.qyotta.eventstore.EventStream; | package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes" })
public class EsEventStreamBackedDomainEventStream implements DomainEventStream {
| // Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsEventStoreUtils {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final EventResponse eventResponse) {
// try {
// final Gson gson = createGson();
// final Class<?> payloadType = Class.forName(eventResponse.getContent()
// .getEventType());
// final Object payload = gson.fromJson(eventResponse.getContent()
// .getData(), payloadType);
//
// final Map<String, ?> metaData = gson.fromJson(eventResponse.getContent()
// .getMetadata(), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// return new GenericDomainEventMessage(eventResponse.getTitle(), new DateTime(eventResponse.getUpdated(), DateTimeZone.UTC), metaData.get(Constants.AGGREGATE_ID_KEY), eventResponse.getContent()
// .getEventNumber(), payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
//
// private static Gson createGson() {
// //// final RuntimeTypeAdapterFactory<Entity> typeFactory = RuntimeTypeAdapterFactory.of(Entity.class, "type")
// //// .registerSubtype(UserEntity.class);
// // final Gson gson = new GsonBuilder().registerTypeAdapterFactory(typeFactory)
// // .create();
// // return gson;
// return new Gson();
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStreamBackedDomainEventStream.java
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils;
import de.qyotta.eventstore.EventStream;
package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes" })
public class EsEventStreamBackedDomainEventStream implements DomainEventStream {
| private final EventStream eventStream; |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStreamBackedDomainEventStream.java | // Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsEventStoreUtils {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final EventResponse eventResponse) {
// try {
// final Gson gson = createGson();
// final Class<?> payloadType = Class.forName(eventResponse.getContent()
// .getEventType());
// final Object payload = gson.fromJson(eventResponse.getContent()
// .getData(), payloadType);
//
// final Map<String, ?> metaData = gson.fromJson(eventResponse.getContent()
// .getMetadata(), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// return new GenericDomainEventMessage(eventResponse.getTitle(), new DateTime(eventResponse.getUpdated(), DateTimeZone.UTC), metaData.get(Constants.AGGREGATE_ID_KEY), eventResponse.getContent()
// .getEventNumber(), payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
//
// private static Gson createGson() {
// //// final RuntimeTypeAdapterFactory<Entity> typeFactory = RuntimeTypeAdapterFactory.of(Entity.class, "type")
// //// .registerSubtype(UserEntity.class);
// // final Gson gson = new GsonBuilder().registerTypeAdapterFactory(typeFactory)
// // .create();
// // return gson;
// return new Gson();
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
| import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils;
import de.qyotta.eventstore.EventStream; | package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes" })
public class EsEventStreamBackedDomainEventStream implements DomainEventStream {
private final EventStream eventStream;
public EsEventStreamBackedDomainEventStream(final EventStream eventStream) {
this.eventStream = eventStream;
}
@Override
public boolean hasNext() {
return eventStream.hasNext();
}
@Override
public DomainEventMessage next() { | // Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsEventStoreUtils {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final EventResponse eventResponse) {
// try {
// final Gson gson = createGson();
// final Class<?> payloadType = Class.forName(eventResponse.getContent()
// .getEventType());
// final Object payload = gson.fromJson(eventResponse.getContent()
// .getData(), payloadType);
//
// final Map<String, ?> metaData = gson.fromJson(eventResponse.getContent()
// .getMetadata(), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// return new GenericDomainEventMessage(eventResponse.getTitle(), new DateTime(eventResponse.getUpdated(), DateTimeZone.UTC), metaData.get(Constants.AGGREGATE_ID_KEY), eventResponse.getContent()
// .getEventNumber(), payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
//
// private static Gson createGson() {
// //// final RuntimeTypeAdapterFactory<Entity> typeFactory = RuntimeTypeAdapterFactory.of(Entity.class, "type")
// //// .registerSubtype(UserEntity.class);
// // final Gson gson = new GsonBuilder().registerTypeAdapterFactory(typeFactory)
// // .create();
// // return gson;
// return new Gson();
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/EventStream.java
// public interface EventStream {
//
// boolean hasNext();
//
// EventResponse next();
//
// EventResponse peek();
//
// void setAfterTimestamp(final Date timestamp);
//
// void setAfterTitle(final String eventId);
//
// /**
// * Attempts to load the next event in the stream from the current point. If the next event was already loaded this method does nothing. This method is only useful after hasNext returned false.
// * After this method has been called use hasNext to check whether a new event arrived.
// */
// void loadNext();
//
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsEventStreamBackedDomainEventStream.java
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import de.qyotta.axonframework.eventstore.utils.EsEventStoreUtils;
import de.qyotta.eventstore.EventStream;
package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes" })
public class EsEventStreamBackedDomainEventStream implements DomainEventStream {
private final EventStream eventStream;
public EsEventStreamBackedDomainEventStream(final EventStream eventStream) {
this.eventStream = eventStream;
}
@Override
public boolean hasNext() {
return eventStream.hasNext();
}
@Override
public DomainEventMessage next() { | return EsEventStoreUtils.domainEventMessageOf(eventStream.next()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderDefaultImpl implements ESReader {
private static final Logger LOGGER = LoggerFactory.getLogger(EsReaderDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private String name;
public EsReaderDefaultImpl(final CloseableHttpClient httpclient) {
this(EsReaderDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsReaderDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsReaderDefaultImpl implements ESReader {
private static final Logger LOGGER = LoggerFactory.getLogger(EsReaderDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private String name;
public EsReaderDefaultImpl(final CloseableHttpClient httpclient) {
this(EsReaderDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsReaderDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(Event.class, new JsonDeserializer<Event>() { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override | public EventStreamFeed readStream(final String url) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override | public EventResponse readEvent(String url) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | .data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich"); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich"); | httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | .data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich"); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich"); | httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; |
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich");
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
// httpget.addHeader("ES-LongPoll", "5");
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
@Override
public EventStreamFeed readStream(final String url) {
try {
return loadFeed(url);
} catch (final IOException e) {
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich");
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
// httpget.addHeader("ES-LongPoll", "5");
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) { | HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich");
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
// httpget.addHeader("ES-LongPoll", "5");
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) {
HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus());
}
final int statusCode = response.getStatusLine()
.getStatusCode();
if (HttpStatus.SC_NOT_FOUND == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
throw new RuntimeException("Could not initialize EventStreamImpl from url: '" + url + "'.", e);
}
}
@Override
public EventResponse readEvent(String url) {
try {
return loadEvent(url);
} catch (final IOException e) {
throw new RuntimeException("Could not load EventResponse from url: '" + url + "'.", e);
}
}
private EventStreamFeed loadFeed(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url + "?embed=rich");
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
// httpget.addHeader("ES-LongPoll", "5");
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) {
HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus());
}
final int statusCode = response.getStatusLine()
.getStatusCode();
if (HttpStatus.SC_NOT_FOUND == statusCode || HttpStatus.SC_NO_CONTENT == statusCode) { | throw new EventStreamNotFoundException(); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | throw new RuntimeException("Could not load stream feed from url: " + url);
}
final EventStreamFeed result = gson.fromJson(new BufferedReader(new InputStreamReader(response.getEntity()
.getContent())), EventStreamFeed.class);
EntityUtils.consume(response.getEntity());
return result;
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
private EventResponse loadEvent(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url);
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
LOGGER.info("Executing request " + httpget.getRequestLine());
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) {
HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus());
}
final int statusCode = response.getStatusLine()
.getStatusCode();
if (HttpStatus.SC_GONE == statusCode) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_EVENTSTORE_ATOM_JSON = "application/vnd.eventstore.atom+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ACCEPT_HEADER = "Accept";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventDeletedException.java
// public class EventDeletedException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamNotFoundException.java
// public class EventStreamNotFoundException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsReaderDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.ACCEPT_EVENTSTORE_ATOM_JSON;
import static de.qyotta.eventstore.utils.Constants.ACCEPT_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventDeletedException;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
import de.qyotta.eventstore.model.EventStreamNotFoundException;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
throw new RuntimeException("Could not load stream feed from url: " + url);
}
final EventStreamFeed result = gson.fromJson(new BufferedReader(new InputStreamReader(response.getEntity()
.getContent())), EventStreamFeed.class);
EntityUtils.consume(response.getEntity());
return result;
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
private EventResponse loadEvent(final String url) throws IOException {
try {
final HttpGet httpget = new HttpGet(url);
httpget.addHeader(ACCEPT_HEADER, ACCEPT_EVENTSTORE_ATOM_JSON);
LOGGER.info("Executing request " + httpget.getRequestLine());
final HttpCacheContext context = HttpCacheContext.create();
final CloseableHttpResponse response = httpclient.execute(httpget, context);
try {
if (context.getCacheResponseStatus() != null) {
HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus());
}
final int statusCode = response.getStatusLine()
.getStatusCode();
if (HttpStatus.SC_GONE == statusCode) { | throw new EventDeletedException(); |
Qyotta/axon-eventstore | esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStreamBackedDomainEventStream.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
| import java.util.LinkedList;
import java.util.concurrent.ExecutionException;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.slf4j.LoggerFactory;
import com.github.msemys.esjc.EventStore;
import com.github.msemys.esjc.ResolvedEvent;
import com.github.msemys.esjc.StreamEventsSlice;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil; | long from = firstSequenceNumber;
long numberOfEventsTotal = lastSequenceNumber - firstSequenceNumber;
int numberOfEventsPerSlice = DEFAULT_NUMBER_OF_EVENTS_PER_SLICE;
if (numberOfEventsTotal < DEFAULT_NUMBER_OF_EVENTS_PER_SLICE) {
numberOfEventsPerSlice = Math.toIntExact(numberOfEventsTotal);
}
while (numberOfEventsTotal > 0) {
try {
final StreamEventsSlice streamEventsSlice = client.readStreamEventsForward(streamName, from, numberOfEventsPerSlice, true)
.get();
events.addAll(streamEventsSlice.events);
from = streamEventsSlice.nextEventNumber;
numberOfEventsTotal = numberOfEventsTotal - numberOfEventsPerSlice;
} catch (InterruptedException | ExecutionException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
@Override
public boolean hasNext() {
return !events.isEmpty() && currentEventNumber < events.size();
}
@Override
public DomainEventMessage next() {
final ResolvedEvent resolvedEvent = events.get(currentEventNumber);
currentEventNumber++; | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStreamBackedDomainEventStream.java
import java.util.LinkedList;
import java.util.concurrent.ExecutionException;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.slf4j.LoggerFactory;
import com.github.msemys.esjc.EventStore;
import com.github.msemys.esjc.ResolvedEvent;
import com.github.msemys.esjc.StreamEventsSlice;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil;
long from = firstSequenceNumber;
long numberOfEventsTotal = lastSequenceNumber - firstSequenceNumber;
int numberOfEventsPerSlice = DEFAULT_NUMBER_OF_EVENTS_PER_SLICE;
if (numberOfEventsTotal < DEFAULT_NUMBER_OF_EVENTS_PER_SLICE) {
numberOfEventsPerSlice = Math.toIntExact(numberOfEventsTotal);
}
while (numberOfEventsTotal > 0) {
try {
final StreamEventsSlice streamEventsSlice = client.readStreamEventsForward(streamName, from, numberOfEventsPerSlice, true)
.get();
events.addAll(streamEventsSlice.events);
from = streamEventsSlice.nextEventNumber;
numberOfEventsTotal = numberOfEventsTotal - numberOfEventsPerSlice;
} catch (InterruptedException | ExecutionException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
@Override
public boolean hasNext() {
return !events.isEmpty() && currentEventNumber < events.size();
}
@Override
public DomainEventMessage next() {
final ResolvedEvent resolvedEvent = events.get(currentEventNumber);
currentEventNumber++; | return EsjcEventstoreUtil.domainEventMessageOf(resolvedEvent); |
Qyotta/axon-eventstore | axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.lang.reflect.Type;
import java.util.Map;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.GenericDomainEventMessage;
import org.axonframework.domain.MetaData;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass; | package de.qyotta.axonframework.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public final class EsEventStoreUtils {
private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
//
}.getType();
public static final String getStreamName(final String type, final Object identifier, final String prefix) {
return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
}
@SuppressWarnings({ "rawtypes", "unchecked" }) | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsEventStoreUtils.java
import java.lang.reflect.Type;
import java.util.Map;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.GenericDomainEventMessage;
import org.axonframework.domain.MetaData;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass;
package de.qyotta.axonframework.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public final class EsEventStoreUtils {
private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
//
}.getType();
public static final String getStreamName(final String type, final Object identifier, final String prefix) {
return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
}
@SuppressWarnings({ "rawtypes", "unchecked" }) | public static DomainEventMessage domainEventMessageOf(final EventResponse eventResponse) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.time.Instant;
import java.util.Date;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass; | package de.qyotta.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public class EsUtils {
private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
import java.time.Instant;
import java.util.Date;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass;
package de.qyotta.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public class EsUtils {
private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
| public static long getEventNumber(final Entry entry) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.time.Instant;
import java.util.Date;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass; | package de.qyotta.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public class EsUtils {
private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
public static long getEventNumber(final Entry entry) {
final String title = entry.getTitle();
final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
return Long.valueOf(subsequenceNumber);
}
public static Date timestampOf(final Entry entry) {
return Date.from(Instant.parse(entry.getUpdated()));
}
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
import java.time.Instant;
import java.util.Date;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.EventResponse;
import lombok.experimental.UtilityClass;
package de.qyotta.eventstore.utils;
@UtilityClass
@SuppressWarnings("nls")
public class EsUtils {
private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
public static long getEventNumber(final Entry entry) {
final String title = entry.getTitle();
final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
return Long.valueOf(subsequenceNumber);
}
public static Date timestampOf(final Entry entry) {
return Date.from(Instant.parse(entry.getUpdated()));
}
| public static Date timestampOf(final EventResponse entry) { |
Qyotta/axon-eventstore | esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
| import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil; | package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes", "nls" })
public class EsjcEventStore implements EventStore, PartialStreamSupport {
private static final String AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND = "Aggregate of type [%s] with identifier [%s] cannot be found.";
private final com.github.msemys.esjc.EventStore client;
private final Gson gson = new Gson();
private String prefix = "domain";
public EsjcEventStore(final com.github.msemys.esjc.EventStore client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream eventStream) {
final Map<Object, List<EventData>> identifierToEventStoreEvents = new HashMap<>();
while (eventStream.hasNext()) {
final DomainEventMessage message = eventStream.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<EventData>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Entry<Object, List<EventData>> entry : identifierToEventStoreEvents.entrySet()) { | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java
import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil;
package de.qyotta.axonframework.eventstore;
@SuppressWarnings({ "rawtypes", "nls" })
public class EsjcEventStore implements EventStore, PartialStreamSupport {
private static final String AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND = "Aggregate of type [%s] with identifier [%s] cannot be found.";
private final com.github.msemys.esjc.EventStore client;
private final Gson gson = new Gson();
private String prefix = "domain";
public EsjcEventStore(final com.github.msemys.esjc.EventStore client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream eventStream) {
final Map<Object, List<EventData>> identifierToEventStoreEvents = new HashMap<>();
while (eventStream.hasNext()) {
final DomainEventMessage message = eventStream.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<EventData>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Entry<Object, List<EventData>> entry : identifierToEventStoreEvents.entrySet()) { | final String streamName = getStreamName(type, entry.getKey(), prefix); |
Qyotta/axon-eventstore | esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
| import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil; | private final com.github.msemys.esjc.EventStore client;
private final Gson gson = new Gson();
private String prefix = "domain";
public EsjcEventStore(final com.github.msemys.esjc.EventStore client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream eventStream) {
final Map<Object, List<EventData>> identifierToEventStoreEvents = new HashMap<>();
while (eventStream.hasNext()) {
final DomainEventMessage message = eventStream.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<EventData>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Entry<Object, List<EventData>> entry : identifierToEventStoreEvents.entrySet()) {
final String streamName = getStreamName(type, entry.getKey(), prefix);
final List<EventData> events = entry.getValue();
client.appendToStream(streamName, ExpectedVersion.ANY, events);
}
}
@Override
public DomainEventStream readEvents(final String type, final Object identifier) {
try { | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java
import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil;
private final com.github.msemys.esjc.EventStore client;
private final Gson gson = new Gson();
private String prefix = "domain";
public EsjcEventStore(final com.github.msemys.esjc.EventStore client) {
this.client = client;
}
@Override
public void appendEvents(final String type, final DomainEventStream eventStream) {
final Map<Object, List<EventData>> identifierToEventStoreEvents = new HashMap<>();
while (eventStream.hasNext()) {
final DomainEventMessage message = eventStream.next();
final Object identifier = message.getAggregateIdentifier();
if (!identifierToEventStoreEvents.containsKey(identifier)) {
identifierToEventStoreEvents.put(identifier, new LinkedList<EventData>());
}
identifierToEventStoreEvents.get(identifier)
.add(toEvent(message));
}
for (final Entry<Object, List<EventData>> entry : identifierToEventStoreEvents.entrySet()) {
final String streamName = getStreamName(type, entry.getKey(), prefix);
final List<EventData> events = entry.getValue();
client.appendToStream(streamName, ExpectedVersion.ANY, events);
}
}
@Override
public DomainEventStream readEvents(final String type, final Object identifier) {
try { | final EsjcEventStreamBackedDomainEventStream eventStream = new EsjcEventStreamBackedDomainEventStream(EsjcEventstoreUtil.getStreamName(type, identifier, prefix), client); |
Qyotta/axon-eventstore | esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java | // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
| import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil; | throw new EventStreamNotFoundException(type, identifier);
}
return eventStream;
} catch (final EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format(AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND, type, identifier), e);
}
}
@Override
public DomainEventStream readEvents(String type, Object identifier, long firstSequenceNumber, long lastSequenceNumber) {
try {
final EsjcEventStreamBackedDomainEventStream eventStream = new EsjcEventStreamBackedDomainEventStream(EsjcEventstoreUtil.getStreamName(type, identifier, prefix), client, firstSequenceNumber,
lastSequenceNumber);
if (!eventStream.hasNext()) {
throw new EventStreamNotFoundException(type, identifier);
}
return eventStream;
} catch (final EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format(AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND, type, identifier), e);
}
}
private EventData toEvent(final DomainEventMessage message) {
final HashMap<String, Object> metaData = new HashMap<>();
final HashMap<String, Object> eventMetaData = new HashMap<>();
for (final Entry<String, Object> entry : message.getMetaData()
.entrySet()) {
eventMetaData.put(entry.getKey(), entry.getValue());
}
| // Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/Constants.java
// @SuppressWarnings("nls")
// public interface Constants {
// public static final String ES_EVENT_TYPE_STREAM_PREFIX = "$et-";
// public static final String DOMAIN_EVENT_TYPE = DomainEventMessage.class.getSimpleName();
// public static final String AGGREGATE_ID_KEY = "AgregateIdentifier";
// public static final String PAYLOAD_REVISION_KEY = "PayloadRevision";
// public static final String EVENT_METADATA_KEY = "EventMetaData";
// }
//
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/utils/EsjcEventstoreUtil.java
// @UtilityClass
// @SuppressWarnings("nls")
// public final class EsjcEventstoreUtil {
// private static final Type METADATA_TYPE = new TypeToken<Map<String, ?>>() {
// //
// }.getType();
//
// private static final Gson gson = new Gson();
// private static final Charset UTF_8 = Charset.forName("UTF-8");
//
// public static final String getStreamName(final String type, final Object identifier, final String prefix) {
// return prefix + "-" + type.toLowerCase() + "-" + identifier.toString();
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
// try {
// final RecordedEvent originalEvent = event.originalEvent();
// final Class<?> payloadType = Class.forName(originalEvent.eventType);
// final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
// final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);
//
// final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
// final long sequenceNumber = originalEvent.eventNumber;
// final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
// final String identifier = String.valueOf(originalEvent.eventId);
// final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
// return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
// } catch (final ClassNotFoundException e) {
// throw new RuntimeException(e);
// }
//
// }
// }
// Path: esjc-axon-eventstore/lib/src/main/java/de/qyotta/axonframework/eventstore/EsjcEventStore.java
import static de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil.getStreamName;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.axonframework.domain.DomainEventMessage;
import org.axonframework.domain.DomainEventStream;
import org.axonframework.eventstore.EventStore;
import org.axonframework.eventstore.EventStreamNotFoundException;
import org.axonframework.eventstore.PartialStreamSupport;
import org.axonframework.serializer.Revision;
import com.github.msemys.esjc.EventData;
import com.github.msemys.esjc.ExpectedVersion;
import com.google.gson.Gson;
import de.qyotta.axonframework.eventstore.utils.Constants;
import de.qyotta.axonframework.eventstore.utils.EsjcEventstoreUtil;
throw new EventStreamNotFoundException(type, identifier);
}
return eventStream;
} catch (final EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format(AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND, type, identifier), e);
}
}
@Override
public DomainEventStream readEvents(String type, Object identifier, long firstSequenceNumber, long lastSequenceNumber) {
try {
final EsjcEventStreamBackedDomainEventStream eventStream = new EsjcEventStreamBackedDomainEventStream(EsjcEventstoreUtil.getStreamName(type, identifier, prefix), client, firstSequenceNumber,
lastSequenceNumber);
if (!eventStream.hasNext()) {
throw new EventStreamNotFoundException(type, identifier);
}
return eventStream;
} catch (final EventStreamNotFoundException e) {
throw new EventStreamNotFoundException(String.format(AGGREGATE_OF_TYPE_S_WITH_IDENTIFIER_S_CANNOT_BE_FOUND, type, identifier), e);
}
}
private EventData toEvent(final DomainEventMessage message) {
final HashMap<String, Object> metaData = new HashMap<>();
final HashMap<String, Object> eventMetaData = new HashMap<>();
for (final Entry<String, Object> entry : message.getMetaData()
.entrySet()) {
eventMetaData.put(entry.getKey(), entry.getValue());
}
| metaData.put(Constants.AGGREGATE_ID_KEY, message.getAggregateIdentifier()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override | public void appendEvents(final String url, final Collection<Event> collection) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url); | post.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON_EVENTS); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
package de.qyotta.eventstore.communication;
@SuppressWarnings("nls")
public class EsWriterDefaultImpl implements ESWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(EsWriterDefaultImpl.class.getName());
private final Gson gson;
private final CloseableHttpClient httpclient;
private final String name;
public EsWriterDefaultImpl(final CloseableHttpClient httpclient) {
this(EsWriterDefaultImpl.class.getSimpleName() + "_" + UUID.randomUUID(), httpclient);
}
public EsWriterDefaultImpl(String name, final CloseableHttpClient httpclient) {
this.name = name;
this.httpclient = httpclient;
final GsonBuilder gsonBuilder = new GsonBuilder();
gson = gsonBuilder.create();
}
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url); | post.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON_EVENTS); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | }
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url);
post.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON_EVENTS);
final JsonArray body = new JsonArray();
for (final Event e : collection) {
final JsonObject o = new JsonObject();
o.addProperty("eventId", e.getEventId());
o.addProperty("eventType", e.getEventType());
o.add("metadata", gson.fromJson(e.getMetadata(), JsonObject.class));
o.add("data", gson.fromJson(e.getData(), JsonObject.class));
body.add(o);
}
final String jsonString = gson.toJson(body);
post.setEntity(new StringEntity(jsonString, ContentType.create(CONTENT_TYPE_JSON_EVENTS, Consts.UTF_8)));
LOGGER.debug("Executing request " + read(post.getEntity()
.getContent()));
final HttpCacheContext context = HttpCacheContext.create();
CloseableHttpResponse response = null;
try {
response = httpclient.execute(post, context);
if (context.getCacheResponseStatus() != null) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
}
@Override
public void appendEvents(final String url, final Collection<Event> collection) {
try {
try {
final HttpPost post = new HttpPost(url);
post.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON_EVENTS);
final JsonArray body = new JsonArray();
for (final Event e : collection) {
final JsonObject o = new JsonObject();
o.addProperty("eventId", e.getEventId());
o.addProperty("eventType", e.getEventType());
o.add("metadata", gson.fromJson(e.getMetadata(), JsonObject.class));
o.add("data", gson.fromJson(e.getData(), JsonObject.class));
body.add(o);
}
final String jsonString = gson.toJson(body);
post.setEntity(new StringEntity(jsonString, ContentType.create(CONTENT_TYPE_JSON_EVENTS, Consts.UTF_8)));
LOGGER.debug("Executing request " + read(post.getEntity()
.getContent()));
final HttpCacheContext context = HttpCacheContext.create();
CloseableHttpResponse response = null;
try {
response = httpclient.execute(post, context);
if (context.getCacheResponseStatus() != null) { | HttpCacheLoggingUtil.logCacheResponseStatus(name, context.getCacheResponseStatus()); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | response.close();
}
}
} finally {
httpclient.close();
}
} catch (
final Exception e) {
throw new RuntimeException("Could not appends events to stream-url: " + url, e);
}
}
private static String read(InputStream input) throws IOException {
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) {
return buffer.lines()
.collect(Collectors.joining("\n"));
}
}
@Override
public void appendEvent(final String url, final Event event) {
appendEvents(url, Arrays.asList(event));
}
@Override
public void deleteStream(final String url, boolean deletePermanently) {
try {
try {
final HttpDelete delete = new HttpDelete(url); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
response.close();
}
}
} finally {
httpclient.close();
}
} catch (
final Exception e) {
throw new RuntimeException("Could not appends events to stream-url: " + url, e);
}
}
private static String read(InputStream input) throws IOException {
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) {
return buffer.lines()
.collect(Collectors.joining("\n"));
}
}
@Override
public void appendEvent(final String url, final Event event) {
appendEvents(url, Arrays.asList(event));
}
@Override
public void deleteStream(final String url, boolean deletePermanently) {
try {
try {
final HttpDelete delete = new HttpDelete(url); | delete.addHeader(ES_HARD_DELETE_HEADER, String.valueOf(deletePermanently)); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
| import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil; | public void deleteStream(final String url, boolean deletePermanently) {
try {
try {
final HttpDelete delete = new HttpDelete(url);
delete.addHeader(ES_HARD_DELETE_HEADER, String.valueOf(deletePermanently));
LOGGER.info("Executing request " + delete.getRequestLine());
final CloseableHttpResponse response = httpclient.execute(delete);
try {
if (HttpStatus.SC_NO_CONTENT != response.getStatusLine()
.getStatusCode()) {
throw new RuntimeException("Could not delete stream with url: " + url);
}
} finally {
response.close();
}
} finally {
httpclient.close();
}
} catch (final IOException e) {
throw new RuntimeException("Could not delete stream with url: " + url, e);
}
}
@Override
public void createLinkedProjection(String host, String projectionName, String... includedStreams) {
final String url = host + "/projections/continuous?name=" + projectionName + "&emit=yes&checkpoints=yes&enabled=yes";
try {
try {
final HttpPost post = new HttpPost(url); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_HEADER = "Event-Type";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON = "application/json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String CONTENT_TYPE_JSON_EVENTS = "application/vnd.eventstore.events+json";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/Constants.java
// public static final String ES_HARD_DELETE_HEADER = "ES-HardDelete";
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/HttpCacheLoggingUtil.java
// public class HttpCacheLoggingUtil {
// private static final Logger LOGGER = LoggerFactory.getLogger(HttpCacheLoggingUtil.class.getName());
//
// @SuppressWarnings("nls")
// public static void logCacheResponseStatus(String prefix, CacheResponseStatus cacheResponseStatus) {
// switch (cacheResponseStatus) {
// case CACHE_HIT:
// LOGGER.debug(prefix + ":A response was generated from the cache with no requests sent upstream");
// break;
// case CACHE_MODULE_RESPONSE:
// LOGGER.debug(prefix + ":The response was generated directly by the caching module");
// break;
// case CACHE_MISS:
// LOGGER.debug(prefix + ":The response came from an upstream server");
// break;
// case VALIDATED:
// LOGGER.debug(prefix + ":The response was generated from the cache after validating the entry with the origin server");
// break;
// default:
// break;
// }
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsWriterDefaultImpl.java
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_HEADER;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON;
import static de.qyotta.eventstore.utils.Constants.CONTENT_TYPE_JSON_EVENTS;
import static de.qyotta.eventstore.utils.Constants.ES_HARD_DELETE_HEADER;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.utils.HttpCacheLoggingUtil;
public void deleteStream(final String url, boolean deletePermanently) {
try {
try {
final HttpDelete delete = new HttpDelete(url);
delete.addHeader(ES_HARD_DELETE_HEADER, String.valueOf(deletePermanently));
LOGGER.info("Executing request " + delete.getRequestLine());
final CloseableHttpResponse response = httpclient.execute(delete);
try {
if (HttpStatus.SC_NO_CONTENT != response.getStatusLine()
.getStatusCode()) {
throw new RuntimeException("Could not delete stream with url: " + url);
}
} finally {
response.close();
}
} finally {
httpclient.close();
}
} catch (final IOException e) {
throw new RuntimeException("Could not delete stream with url: " + url, e);
}
}
@Override
public void createLinkedProjection(String host, String projectionName, String... includedStreams) {
final String url = host + "/projections/continuous?name=" + projectionName + "&emit=yes&checkpoints=yes&enabled=yes";
try {
try {
final HttpPost post = new HttpPost(url); | post.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | package de.qyotta.neweventstore;
public class AtomFeedJsonReader {
private Gson gson;
public AtomFeedJsonReader() {
final GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
package de.qyotta.neweventstore;
public class AtomFeedJsonReader {
private Gson gson;
public AtomFeedJsonReader() {
final GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(Event.class, new JsonDeserializer<Event>() { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | public Event deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
public Event deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
| public List<Entry> readAtomFeed(InputStream in) { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; | final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
public List<Entry> readAtomFeed(InputStream in) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
final Event.EventBuilder e = Event.builder();
final JsonObject object = json.getAsJsonObject();
final JsonElement dataElement = object.get("data");
final JsonElement metadataElement = object.get("metadata");
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
public List<Entry> readAtomFeed(InputStream in) { | final EventStreamFeed eventStreamFeed = gson.fromJson(new BufferedReader(new InputStreamReader(in)), EventStreamFeed.class); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed; |
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
public List<Entry> readAtomFeed(InputStream in) {
final EventStreamFeed eventStreamFeed = gson.fromJson(new BufferedReader(new InputStreamReader(in)), EventStreamFeed.class);
return eventStreamFeed.getEntries();
}
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventStreamFeed.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventStreamFeed {
// private String title;
// private String id;
// private String updated;
// private Author author;
// boolean headOfStream;
// private List<Link> links;
// private List<Entry> entries;
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/AtomFeedJsonReader.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.model.EventStreamFeed;
final String eventStreamId = object.get("eventStreamId")
.getAsString();
final String eventId = object.get("eventId")
.getAsString();
final Long eventNumber = object.get("eventNumber")
.getAsLong();
final String eventType = object.get("eventType")
.getAsString();
final String data = gson.toJson(dataElement);
final String metadata = gson.toJson(metadataElement);
return e.eventStreamId(eventStreamId)
.eventId(eventId)
.eventNumber(eventNumber)
.eventType(eventType)
.data(data)
.metadata(metadata)
.build();
}
});
gson = gsonBuilder.create();
}
public List<Entry> readAtomFeed(InputStream in) {
final EventStreamFeed eventStreamFeed = gson.fromJson(new BufferedReader(new InputStreamReader(in)), EventStreamFeed.class);
return eventStreamFeed.getEntries();
}
| public EventResponse readEvent(InputStream in) throws JsonSyntaxException, IOException { |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() { | client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults() |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = EventStreamTest.class.getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
int count = 0;
long previousEventNumber = -1;
while (eventStream.hasNext()) { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = EventStreamTest.class.getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
int count = 0;
long previousEventNumber = -1;
while (eventStream.hasNext()) { | final EventResponse next = eventStream.next(); |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils; | package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = EventStreamTest.class.getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
int count = 0;
long previousEventNumber = -1;
while (eventStream.hasNext()) {
final EventResponse next = eventStream.next(); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils;
package de.qyotta.eventstore;
@SuppressWarnings("nls")
public class EventStreamTest extends AbstractEsTest {
private int numberOfStoredEvents;
@Before
public void setUp() {
client = new EventStoreClient(new EsContextDefaultImpl(EventStoreSettings.withDefaults()
.host(HOST)
.build()));
streamName = EventStreamTest.class.getSimpleName() + "-" + UUID.randomUUID();
streamUrl = BASE_STREAMS_URL + streamName;
expectedEvents = new HashMap<>();
}
@After
public void tearDown() {
// try hard deleting created streams. This might not do anything depending on the test
deleteStream(streamUrl);
}
@Test
public void shouldTraverseAllEventsInOrder() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
int count = 0;
long previousEventNumber = -1;
while (eventStream.hasNext()) {
final EventResponse next = eventStream.next(); | final Event actual = next.getContent(); |
Qyotta/axon-eventstore | eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
| import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils; |
@Test
public void shouldNotFailOnASingleStoredEvent() throws InterruptedException {
numberOfStoredEvents = 1;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
final EventResponse next = eventStream.next();
final Event actual = next.getContent();
final Event expected = expectedEvents.get(actual.getEventId());
assertThat(actual.getEventId(), is(equalTo(expected.getEventId())));
assertThat(actual.getEventType(), is(equalTo(expected.getEventType())));
assertThat(actual.getMetadata(), is(equalTo(expected.getMetadata())));
assertThat(actual.getData(), is(equalTo(expected.getData())));
assertFalse(eventStream.hasNext());
}
@Test
public void shouldSetToTheBeginning() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
// got to the end
while (eventStream.hasNext()) {
eventStream.next();
}
// now set to the beginning
final Date fromDate = Date.from(Instant.EPOCH);
eventStream.setAfterTimestamp(fromDate);
final EventResponse next = eventStream.next(); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/communication/EsContextDefaultImpl.java
// public class EsContextDefaultImpl implements ESContext {
//
// private final CloseableHttpClient httpclient;
// private final ESReader reader;
// private final EventStoreSettings settings;
// private final ESWriter writer;
//
// public EsContextDefaultImpl(final EventStoreSettings settings) {
// this.settings = settings;
// httpclient = HttpClientFactory.httpClient(settings);
//
// reader = new EsReaderDefaultImpl(httpclient);
// writer = new EsWriterDefaultImpl(httpclient);
// }
//
// @Override
// public ESReader getReader() {
// return reader;
// }
//
// @Override
// public EventStoreSettings getSettings() {
// return settings;
// }
//
// @Override
// public ESWriter getWriter() {
// return writer;
// }
//
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EsUtils.java
// @UtilityClass
// @SuppressWarnings("nls")
// public class EsUtils {
// private static final String SEQUENCE_NUMBER_TITLE_SEPERATOR = "@";
//
// public static long getEventNumber(final Entry entry) {
// final String title = entry.getTitle();
// final String subsequenceNumber = title.substring(0, title.indexOf(SEQUENCE_NUMBER_TITLE_SEPERATOR));
// return Long.valueOf(subsequenceNumber);
// }
//
// public static Date timestampOf(final Entry entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// public static Date timestampOf(final EventResponse entry) {
// return Date.from(Instant.parse(entry.getUpdated()));
// }
//
// }
// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamTest.java
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.exparity.hamcrest.date.DateMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import de.qyotta.eventstore.communication.EsContextDefaultImpl;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EsUtils;
@Test
public void shouldNotFailOnASingleStoredEvent() throws InterruptedException {
numberOfStoredEvents = 1;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
final EventResponse next = eventStream.next();
final Event actual = next.getContent();
final Event expected = expectedEvents.get(actual.getEventId());
assertThat(actual.getEventId(), is(equalTo(expected.getEventId())));
assertThat(actual.getEventType(), is(equalTo(expected.getEventType())));
assertThat(actual.getMetadata(), is(equalTo(expected.getMetadata())));
assertThat(actual.getData(), is(equalTo(expected.getData())));
assertFalse(eventStream.hasNext());
}
@Test
public void shouldSetToTheBeginning() throws InterruptedException {
numberOfStoredEvents = 100;
createEvents(numberOfStoredEvents);
final EventStream eventStream = client.readEvents(streamName);
// got to the end
while (eventStream.hasNext()) {
eventStream.next();
}
// now set to the beginning
final Date fromDate = Date.from(Instant.EPOCH);
eventStream.setAfterTimestamp(fromDate);
final EventResponse next = eventStream.next(); | assertThat(EsUtils.timestampOf(next), is(DateMatchers.after(fromDate))); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/MainExample.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
| import java.net.MalformedURLException;
import java.net.URL;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
import de.qyotta.eventstore.model.EventResponse; | try {
final StreamEventsSlice slice = esHttpEventStore.readEventsForward(streamName, nextEventNumber, 4096, "");
final long end = System.currentTimeMillis();
final double throughput = slice.getNextEventNumber() / (double) ((end - start) / 1000);
String x = "";
if (slice.isEndOfStream()) {
x += "[head of stream reached] ";
}
x += "Read " + slice.getNextEventNumber() + ". throughput:" + throughput + " events/s";
System.out.println(x);
nextEventNumber = slice.getNextEventNumber();
retryWaitTime = 1;
} catch (final Exception e) {
System.err.println("Failed to process. Job ends now, but will be re-scheduled in " + retryWaitTime + " ms. Don't worry: " + e + " caused by: " + e.getCause()
.getMessage());
Thread.sleep(retryWaitTime);
retryWaitTime = retryWaitTime * 2;
}
}
}
private static void readBackwards() throws ReadFailedException { | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/MainExample.java
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
import de.qyotta.eventstore.model.EventResponse;
try {
final StreamEventsSlice slice = esHttpEventStore.readEventsForward(streamName, nextEventNumber, 4096, "");
final long end = System.currentTimeMillis();
final double throughput = slice.getNextEventNumber() / (double) ((end - start) / 1000);
String x = "";
if (slice.isEndOfStream()) {
x += "[head of stream reached] ";
}
x += "Read " + slice.getNextEventNumber() + ". throughput:" + throughput + " events/s";
System.out.println(x);
nextEventNumber = slice.getNextEventNumber();
retryWaitTime = 1;
} catch (final Exception e) {
System.err.println("Failed to process. Job ends now, but will be re-scheduled in " + retryWaitTime + " ms. Don't worry: " + e + " caused by: " + e.getCause()
.getMessage());
Thread.sleep(retryWaitTime);
retryWaitTime = retryWaitTime * 2;
}
}
}
private static void readBackwards() throws ReadFailedException { | final EventResponse lastEvent = esHttpEventStore.readLastEvent(streamName); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer; | public ESHttpEventStore(final String identifier, final ThreadFactory threadFactory, final URL url, final CredentialsProvider credentialsProvider, final int longPollSec, final int connectTimeout,
final int connectionRequestTimeout, final int socketTimeout) {
super();
this.identifier = identifier;
this.threadFactory = threadFactory;
this.url = url;
this.credentialsProvider = credentialsProvider;
this.longPollSec = longPollSec;
this.connectTimeout = connectTimeout;
this.connectionRequestTimeout = connectionRequestTimeout;
this.socketTimeout = socketTimeout;
this.open = false;
this.hostAndPort = url.getHost() + ":" + url.getPort();
this.host = url.getHost();
atomFeedReader = new AtomFeedJsonReader();
}
public void setHost(final String host) {
this.host = host;
}
private void open() {
if (open) {
// Ignore
return;
}
final HttpAsyncClientBuilder builder = HttpAsyncClients.custom()
.setMaxConnPerRoute(1000)
.setMaxConnTotal(1000) | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer;
public ESHttpEventStore(final String identifier, final ThreadFactory threadFactory, final URL url, final CredentialsProvider credentialsProvider, final int longPollSec, final int connectTimeout,
final int connectionRequestTimeout, final int socketTimeout) {
super();
this.identifier = identifier;
this.threadFactory = threadFactory;
this.url = url;
this.credentialsProvider = credentialsProvider;
this.longPollSec = longPollSec;
this.connectTimeout = connectTimeout;
this.connectionRequestTimeout = connectionRequestTimeout;
this.socketTimeout = socketTimeout;
this.open = false;
this.hostAndPort = url.getHost() + ":" + url.getPort();
this.host = url.getHost();
atomFeedReader = new AtomFeedJsonReader();
}
public void setHost(final String host) {
this.host = host;
}
private void open() {
if (open) {
// Ignore
return;
}
final HttpAsyncClientBuilder builder = HttpAsyncClients.custom()
.setMaxConnPerRoute(1000)
.setMaxConnTotal(1000) | .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer; | return;
}
final HttpAsyncClientBuilder builder = HttpAsyncClients.custom()
.setMaxConnPerRoute(1000)
.setMaxConnTotal(1000)
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy())
.setThreadFactory(threadFactory);
if (credentialsProvider != null) {
builder.setDefaultCredentialsProvider(credentialsProvider);
}
httpclient = builder.build();
httpclient.start();
this.open = true;
}
public void close() {
if (!open) {
// Ignore
return;
}
try {
httpclient.close();
} catch (final IOException ex) {
throw new RuntimeException("Cannot close http client", ex);
}
this.open = false;
}
| // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer;
return;
}
final HttpAsyncClientBuilder builder = HttpAsyncClients.custom()
.setMaxConnPerRoute(1000)
.setMaxConnTotal(1000)
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy())
.setThreadFactory(threadFactory);
if (credentialsProvider != null) {
builder.setDefaultCredentialsProvider(credentialsProvider);
}
httpclient = builder.build();
httpclient.start();
this.open = true;
}
public void close() {
if (!open) {
// Ignore
return;
}
try {
httpclient.close();
} catch (final IOException ex) {
throw new RuntimeException("Cannot close http client", ex);
}
this.open = false;
}
| public EventResponse readEvent(final String streamName, final int eventNumber) throws ReadFailedException { |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer; | }
this.open = false;
}
public EventResponse readEvent(final String streamName, final int eventNumber) throws ReadFailedException {
ensureOpen();
final String msg = "readEvent(" + streamName + ", " + eventNumber + ")";
try {
final URI uri = new URIBuilder(url.toURI()).setPath("/streams/" + streamName + "/" + eventNumber)
.build();
return readEvent(uri, "");
} catch (final URISyntaxException ex) {
throw new ReadFailedException(streamName, msg, ex);
}
}
private void ensureOpen() {
if (!open) {
open();
}
}
public EventResponse readLastEvent(final String streamName) throws ReadFailedException {
ensureOpen();
final String msg = "readLastEvent(" + streamName + ")";
try {
final URI uri = new URIBuilder(url.toURI()).setPath("/streams/" + streamName + "/head/backward/1")
.build(); | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer;
}
this.open = false;
}
public EventResponse readEvent(final String streamName, final int eventNumber) throws ReadFailedException {
ensureOpen();
final String msg = "readEvent(" + streamName + ", " + eventNumber + ")";
try {
final URI uri = new URIBuilder(url.toURI()).setPath("/streams/" + streamName + "/" + eventNumber)
.build();
return readEvent(uri, "");
} catch (final URISyntaxException ex) {
throw new ReadFailedException(streamName, msg, ex);
}
}
private void ensureOpen() {
if (!open) {
open();
}
}
public EventResponse readLastEvent(final String streamName) throws ReadFailedException {
ensureOpen();
final String msg = "readLastEvent(" + streamName + ")";
try {
final URI uri = new URIBuilder(url.toURI()).setPath("/streams/" + streamName + "/head/backward/1")
.build(); | final List<Entry> entries = readFeed(streamName, uri, msg, ""); |
Qyotta/axon-eventstore | eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer; | }
final long nextEventNumber;
final boolean endOfStream;
if (forward) {
nextEventNumber = fromEventNumber + events.size();
endOfStream = count > events.size();
} else {
if (fromEventNumber - count < 0) {
nextEventNumber = 0;
} else {
nextEventNumber = fromEventNumber - count;
}
endOfStream = fromEventNumber - count < 0;
}
return StreamEventsSlice.builder()
.fromEventNumber(fromEventNumber)
.nextEventNumber(nextEventNumber)
.events(events)
.endOfStream(endOfStream)
.build();
}
private EventResponse doit(final Entry entry) {
return EventResponse.builder()
.author(entry.getAuthor())
.summary(entry.getSummary())
.id(entry.getId())
.title(entry.getTitle())
.updated(entry.getUpdated()) | // Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Entry.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Entry {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String data;
// private String metaData;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
// private List<Link> links;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
// private String eventId;
// private String eventType;
// private Long eventNumber;
// private String streamId;
// private Boolean isLinkMetaData;
// private Long positionEventNumber;
// private String positionStreamId;
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private String eventStreamId;
// private String data;
// private String metadata;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
// private String title;
// private String id;
// private String updated;
// private Author author;
// private String summary;
//
// private Event content;
// }
//
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/DefaultConnectionKeepAliveStrategy.java
// @Immutable
// public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
// private static final Logger LOGGER = LoggerFactory.getLogger(DefaultConnectionKeepAliveStrategy.class.getName());
//
// public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
//
// private static final long DEFAULT_KEEP_ALIVE = 15 * 1000;
//
// @Override
// public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
// Args.notNull(response, "HTTP response");
// final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// final HeaderElement he = it.nextElement();
// final String param = he.getName();
// final String value = he.getValue();
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch (final NumberFormatException ignore) {
// LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
// }
// }
// }
// return DEFAULT_KEEP_ALIVE;
// }
//
// }
// Path: eventstore-client/src/main/java/de/qyotta/neweventstore/ESHttpEventStore.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.qyotta.eventstore.model.Entry;
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.DefaultConnectionKeepAliveStrategy;
import io.prometheus.client.Histogram;
import io.prometheus.client.Histogram.Timer;
}
final long nextEventNumber;
final boolean endOfStream;
if (forward) {
nextEventNumber = fromEventNumber + events.size();
endOfStream = count > events.size();
} else {
if (fromEventNumber - count < 0) {
nextEventNumber = 0;
} else {
nextEventNumber = fromEventNumber - count;
}
endOfStream = fromEventNumber - count < 0;
}
return StreamEventsSlice.builder()
.fromEventNumber(fromEventNumber)
.nextEventNumber(nextEventNumber)
.events(events)
.endOfStream(endOfStream)
.build();
}
private EventResponse doit(final Entry entry) {
return EventResponse.builder()
.author(entry.getAuthor())
.summary(entry.getSummary())
.id(entry.getId())
.title(entry.getTitle())
.updated(entry.getUpdated()) | .content(Event.builder() |
greipadmin/greip | org.greip/src/org/greip/color/ColorChooserHSB.java | // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
| import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.greip.nls.Messages;
| /**
* Copyright (c) 2016 by Thomas Lorbeer
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**/
package org.greip.color;
public final class ColorChooserHSB extends AbstractColorChooser {
public static class Factory implements IColorChooserFactory {
private final ColorResolution colorResolution;
private final boolean showInfo;
private final boolean showHistory;
public Factory(final ColorResolution colorResolution) {
this(colorResolution, false, false);
}
public Factory(final ColorResolution colorResolution, final boolean showInfo, final boolean showHistory) {
this.colorResolution = colorResolution;
this.showInfo = showInfo;
this.showHistory = showHistory;
}
@Override
public AbstractColorChooser create(final Composite parent) {
return new ColorChooserHSB(parent, colorResolution, showInfo, showHistory);
}
}
private IColorSliderConnector connector;
public ColorChooserHSB(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
@Override
protected Composite createColorChooserPanel() {
final ColorResolution colorResolution = getColorResolution();
| // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
// Path: org.greip/src/org/greip/color/ColorChooserHSB.java
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.greip.nls.Messages;
/**
* Copyright (c) 2016 by Thomas Lorbeer
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**/
package org.greip.color;
public final class ColorChooserHSB extends AbstractColorChooser {
public static class Factory implements IColorChooserFactory {
private final ColorResolution colorResolution;
private final boolean showInfo;
private final boolean showHistory;
public Factory(final ColorResolution colorResolution) {
this(colorResolution, false, false);
}
public Factory(final ColorResolution colorResolution, final boolean showInfo, final boolean showHistory) {
this.colorResolution = colorResolution;
this.showInfo = showInfo;
this.showHistory = showHistory;
}
@Override
public AbstractColorChooser create(final Composite parent) {
return new ColorChooserHSB(parent, colorResolution, showInfo, showHistory);
}
}
private IColorSliderConnector connector;
public ColorChooserHSB(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
@Override
protected Composite createColorChooserPanel() {
final ColorResolution colorResolution = getColorResolution();
| final SliderPanel panel = new SliderPanel(this, SWT.HORIZONTAL, colorResolution, Messages.Hue, Messages.Saturation,
|
greipadmin/greip | org.greip/src/org/greip/color/ColorCircleChooser.java | // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
| import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.greip.nls.Messages;
| private ColorCircle colorCircle;
private IColorSliderConnector connector;
public ColorCircleChooser(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
private void createColorCircle(final Composite parent) {
colorCircle = new ColorCircle(parent, getColorResolution());
colorCircle.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
colorCircle.addListener(SWT.Modify, e -> setNewRGB(determineNewRGB()));
colorCircle.addListener(SWT.Selection, e -> notifyListeners(SWT.Selection, new Event()));
}
private RGB determineNewRGB() {
final float hue = colorCircle.getRGB().getHSB()[0];
final float[] hsb = connector.getRGB().getHSB();
final float saturation = hsb[2];
final float brightness = hsb[1] == 0.0f ? 1.0f : hsb[1];
final RGB rgb = new RGB(hue, saturation, brightness);
connector.setRGB(rgb);
return rgb;
}
private void createSliders(final Composite parent) {
final ColorResolution colorResolution = getColorResolution();
| // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
// Path: org.greip/src/org/greip/color/ColorCircleChooser.java
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.greip.nls.Messages;
private ColorCircle colorCircle;
private IColorSliderConnector connector;
public ColorCircleChooser(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
private void createColorCircle(final Composite parent) {
colorCircle = new ColorCircle(parent, getColorResolution());
colorCircle.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
colorCircle.addListener(SWT.Modify, e -> setNewRGB(determineNewRGB()));
colorCircle.addListener(SWT.Selection, e -> notifyListeners(SWT.Selection, new Event()));
}
private RGB determineNewRGB() {
final float hue = colorCircle.getRGB().getHSB()[0];
final float[] hsb = connector.getRGB().getHSB();
final float saturation = hsb[2];
final float brightness = hsb[1] == 0.0f ? 1.0f : hsb[1];
final RGB rgb = new RGB(hue, saturation, brightness);
connector.setRGB(rgb);
return rgb;
}
private void createSliders(final Composite parent) {
final ColorResolution colorResolution = getColorResolution();
| final SliderPanel panel = new SliderPanel(parent, SWT.VERTICAL, colorResolution, Messages.Saturation, Messages.Brightness);
|
greipadmin/greip | org.greip/src/org/greip/color/ColorChooserRGB.java | // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
| import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.greip.nls.Messages;
| /**
* Copyright (c) 2016 by Thomas Lorbeer
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**/
package org.greip.color;
public final class ColorChooserRGB extends AbstractColorChooser {
public static class Factory implements IColorChooserFactory {
private final ColorResolution colorResolution;
private final boolean showInfo;
private final boolean showHistory;
public Factory(final ColorResolution colorResolution) {
this(colorResolution, false, false);
}
public Factory(final ColorResolution colorResolution, final boolean showInfo, final boolean showHistory) {
this.colorResolution = colorResolution;
this.showInfo = showInfo;
this.showHistory = showHistory;
}
@Override
public AbstractColorChooser create(final Composite parent) {
return new ColorChooserRGB(parent, colorResolution, showInfo, showHistory);
}
}
private IColorSliderConnector connector;
public ColorChooserRGB(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
@Override
protected Composite createColorChooserPanel() {
final ColorResolution colorResolution = getColorResolution();
| // Path: org.greip/src/org/greip/nls/Messages.java
// public class Messages extends NLS {
// private static final String BUNDLE_NAME = "org.greip.nls.messages"; //$NON-NLS-1$
//
// // Color choosers
// public static String Blue;
// public static String Green;
// public static String Red;
// public static String Hue;
// public static String Saturation;
// public static String Brightness;
//
// // Font chooser
// public static String Font;
// public static String Size;
// public static String Bold;
// public static String Italic;
//
// // Calculator
// public static String Error;
// public static String Overflow;
//
// static {
// // initialize resource bundle
// NLS.initializeMessages(BUNDLE_NAME, Messages.class);
// }
//
// private Messages() {
// }
// }
// Path: org.greip/src/org/greip/color/ColorChooserRGB.java
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.greip.nls.Messages;
/**
* Copyright (c) 2016 by Thomas Lorbeer
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**/
package org.greip.color;
public final class ColorChooserRGB extends AbstractColorChooser {
public static class Factory implements IColorChooserFactory {
private final ColorResolution colorResolution;
private final boolean showInfo;
private final boolean showHistory;
public Factory(final ColorResolution colorResolution) {
this(colorResolution, false, false);
}
public Factory(final ColorResolution colorResolution, final boolean showInfo, final boolean showHistory) {
this.colorResolution = colorResolution;
this.showInfo = showInfo;
this.showHistory = showHistory;
}
@Override
public AbstractColorChooser create(final Composite parent) {
return new ColorChooserRGB(parent, colorResolution, showInfo, showHistory);
}
}
private IColorSliderConnector connector;
public ColorChooserRGB(final Composite parent, final ColorResolution colorResolution, final boolean showInfo,
final boolean showHistory) {
super(parent, colorResolution, showInfo, showHistory);
setRGB(getBackground().getRGB());
}
@Override
protected Composite createColorChooserPanel() {
final ColorResolution colorResolution = getColorResolution();
| final SliderPanel panel = new SliderPanel(this, SWT.HORIZONTAL, colorResolution, Messages.Red, Messages.Green, Messages.Blue);
|
geomesa/geomesa-tutorials | geomesa-tutorials-common/src/main/java/org/geomesa/example/quickstart/GeoMesaQuickStart.java | // Path: geomesa-tutorials-common/src/main/java/org/geomesa/example/data/TutorialData.java
// public interface TutorialData {
//
// String getTypeName();
// SimpleFeatureType getSimpleFeatureType();
// List<SimpleFeature> getTestData();
// List<Query> getTestQueries();
// Filter getSubsetFilter();
//
//
// /**
// * Creates a geotools filter based on a bounding box and date range
// *
// * @param geomField geometry attribute name
// * @param x0 bounding box min x value
// * @param y0 bounding box min y value
// * @param x1 bounding box max x value
// * @param y1 bounding box max y value
// * @param dateField date attribute name
// * @param t0 minimum time, exclusive, in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
// * @param t1 maximum time, exclusive, in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
// * @param attributesQuery any additional query string, or null
// * @return filter object
// * @throws CQLException if invalid CQL
// */
// static Filter createFilter(String geomField, double x0, double y0, double x1, double y1,
// String dateField, String t0, String t1,
// String attributesQuery) throws CQLException {
//
// // there are many different geometric predicates that might be used;
// // here, we just use a bounding-box (BBOX) predicate as an example.
// // this is useful for a rectangular query area
// String cqlGeometry = "BBOX(" + geomField + ", " + x0 + ", " + y0 + ", " + x1 + ", " + y1 + ")";
//
// // there are also quite a few temporal predicates; here, we use a
// // "DURING" predicate, because we have a fixed range of times that
// // we want to query
// String cqlDates = "(" + dateField + " DURING " + t0 + "/" + t1 + ")";
//
// // there are quite a few predicates that can operate on other attribute
// // types; the GeoTools Filter constant "INCLUDE" is a default that means
// // to accept everything
// String cqlAttributes = attributesQuery == null ? "INCLUDE" : attributesQuery;
//
// String cql = cqlGeometry + " AND " + cqlDates + " AND " + cqlAttributes;
//
// // we use geotools ECQL class to parse a CQL string into a Filter object
// return ECQL.toFilter(cql);
// }
// }
| import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.geomesa.example.data.TutorialData;
import org.geotools.data.DataAccessFactory.Param;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.DataUtilities;
import org.geotools.data.FeatureReader;
import org.geotools.data.FeatureWriter;
import org.geotools.data.Query;
import org.geotools.data.Transaction;
import org.geotools.data.simple.SimpleFeatureStore;
import org.geotools.filter.identity.FeatureIdImpl;
import org.geotools.filter.text.ecql.ECQL;
import org.geotools.util.factory.Hints;
import org.locationtech.geomesa.index.geotools.GeoMesaDataStore;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.sort.SortBy;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map; | /*
* Copyright (c) 2013-2018 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0 which
* accompanies this distribution and is available at
* http://www.opensource.org/licenses/apache2.0.php.
*/
package org.geomesa.example.quickstart;
public abstract class GeoMesaQuickStart implements Runnable {
private final Map<String, String> params; | // Path: geomesa-tutorials-common/src/main/java/org/geomesa/example/data/TutorialData.java
// public interface TutorialData {
//
// String getTypeName();
// SimpleFeatureType getSimpleFeatureType();
// List<SimpleFeature> getTestData();
// List<Query> getTestQueries();
// Filter getSubsetFilter();
//
//
// /**
// * Creates a geotools filter based on a bounding box and date range
// *
// * @param geomField geometry attribute name
// * @param x0 bounding box min x value
// * @param y0 bounding box min y value
// * @param x1 bounding box max x value
// * @param y1 bounding box max y value
// * @param dateField date attribute name
// * @param t0 minimum time, exclusive, in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
// * @param t1 maximum time, exclusive, in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
// * @param attributesQuery any additional query string, or null
// * @return filter object
// * @throws CQLException if invalid CQL
// */
// static Filter createFilter(String geomField, double x0, double y0, double x1, double y1,
// String dateField, String t0, String t1,
// String attributesQuery) throws CQLException {
//
// // there are many different geometric predicates that might be used;
// // here, we just use a bounding-box (BBOX) predicate as an example.
// // this is useful for a rectangular query area
// String cqlGeometry = "BBOX(" + geomField + ", " + x0 + ", " + y0 + ", " + x1 + ", " + y1 + ")";
//
// // there are also quite a few temporal predicates; here, we use a
// // "DURING" predicate, because we have a fixed range of times that
// // we want to query
// String cqlDates = "(" + dateField + " DURING " + t0 + "/" + t1 + ")";
//
// // there are quite a few predicates that can operate on other attribute
// // types; the GeoTools Filter constant "INCLUDE" is a default that means
// // to accept everything
// String cqlAttributes = attributesQuery == null ? "INCLUDE" : attributesQuery;
//
// String cql = cqlGeometry + " AND " + cqlDates + " AND " + cqlAttributes;
//
// // we use geotools ECQL class to parse a CQL string into a Filter object
// return ECQL.toFilter(cql);
// }
// }
// Path: geomesa-tutorials-common/src/main/java/org/geomesa/example/quickstart/GeoMesaQuickStart.java
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.geomesa.example.data.TutorialData;
import org.geotools.data.DataAccessFactory.Param;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.DataUtilities;
import org.geotools.data.FeatureReader;
import org.geotools.data.FeatureWriter;
import org.geotools.data.Query;
import org.geotools.data.Transaction;
import org.geotools.data.simple.SimpleFeatureStore;
import org.geotools.filter.identity.FeatureIdImpl;
import org.geotools.filter.text.ecql.ECQL;
import org.geotools.util.factory.Hints;
import org.locationtech.geomesa.index.geotools.GeoMesaDataStore;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.sort.SortBy;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/*
* Copyright (c) 2013-2018 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0 which
* accompanies this distribution and is available at
* http://www.opensource.org/licenses/apache2.0.php.
*/
package org.geomesa.example.quickstart;
public abstract class GeoMesaQuickStart implements Runnable {
private final Map<String, String> params; | private final TutorialData data; |
hawkular/hawkular-android-client | mobile/src/main/java/org/hawkular/client/android/service/AlertService.java | // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Alert.java
// public final class Alert implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("severity")
// private String severity;
//
// @SerializedName("status")
// private String status;
//
// @SerializedName("ctime")
// private long ctime;
//
// @SerializedName("evalSets")
// private List<List<AlertEvaluation>> evalSets;
//
// @SerializedName("notes")
// private List<Note> notes;
//
// @SerializedName("trigger")
// private Trigger trigger;
//
// @VisibleForTesting
// public Alert(@NonNull String id, long timestamp, @NonNull List<List<AlertEvaluation>> evaluations, @NonNull String severity,
// @NonNull String status, @NonNull List<Note> notes) {
// this.id = id;
// this.ctime = timestamp;
// this.evalSets = evaluations;
// this.severity = severity;
// this.status = status;
// this.notes = notes;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getSeverity() {
// return severity;
// }
//
// public String getStatus() {
// return status;
// }
//
// public long getTimestamp() {
// return ctime;
// }
//
// public List<List<AlertEvaluation>> getEvaluations() {
// return evalSets;
// }
//
// public Trigger getTrigger() {
// return trigger;
// }
//
// public List<Note> getNotes() {
// return notes;
// }
//
// public static Creator<Alert> CREATOR = new Creator<Alert>() {
// @Override
// public Alert createFromParcel(Parcel parcel) {
// return new Alert(parcel);
// }
//
// @Override
// public Alert[] newArray(int size) {
// return new Alert[size];
// }
// };
//
// private Alert(Parcel parcel) {
// this.id = parcel.readString();
// this.severity = parcel.readString();
// this.status = parcel.readString();
// this.ctime = parcel.readLong();
//
// evalSets = new ArrayList<>();
// notes = new ArrayList<>();
//
// parcel.readList(evalSets, Lister.class.getClassLoader());
// parcel.readList(notes, Note.class.getClassLoader());
//
// this.trigger = parcel.readParcelable(Trigger.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(severity);
// parcel.writeString(status);
// parcel.writeLong(ctime);
//
// parcel.writeList(evalSets);
// parcel.writeList(notes);
//
// parcel.writeParcelable(trigger, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static class Lister extends ArrayList<AlertEvaluation> implements Parcelable {
//
// protected Lister(Parcel in) {
// this.addAll(in.readArrayList(AlertEvaluation.class.getClassLoader()));
// }
//
// public static final Creator<Lister> CREATOR = new Creator<Lister>() {
// @Override
// public Lister createFromParcel(Parcel in) {
// return new Lister(in);
// }
//
// @Override
// public Lister[] newArray(int size) {
// return new Lister[size];
// }
// };
//
// @Override public int describeContents() {
// return 0;
// }
//
// @Override public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeList(this);
// }
// }
//
// }
| import java.util.List;
import org.hawkular.client.android.backend.model.Alert;
import retrofit2.Call;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query; | /*
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.client.android.service;
public interface AlertService {
@GET("hawkular/alerts") | // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Alert.java
// public final class Alert implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("severity")
// private String severity;
//
// @SerializedName("status")
// private String status;
//
// @SerializedName("ctime")
// private long ctime;
//
// @SerializedName("evalSets")
// private List<List<AlertEvaluation>> evalSets;
//
// @SerializedName("notes")
// private List<Note> notes;
//
// @SerializedName("trigger")
// private Trigger trigger;
//
// @VisibleForTesting
// public Alert(@NonNull String id, long timestamp, @NonNull List<List<AlertEvaluation>> evaluations, @NonNull String severity,
// @NonNull String status, @NonNull List<Note> notes) {
// this.id = id;
// this.ctime = timestamp;
// this.evalSets = evaluations;
// this.severity = severity;
// this.status = status;
// this.notes = notes;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getSeverity() {
// return severity;
// }
//
// public String getStatus() {
// return status;
// }
//
// public long getTimestamp() {
// return ctime;
// }
//
// public List<List<AlertEvaluation>> getEvaluations() {
// return evalSets;
// }
//
// public Trigger getTrigger() {
// return trigger;
// }
//
// public List<Note> getNotes() {
// return notes;
// }
//
// public static Creator<Alert> CREATOR = new Creator<Alert>() {
// @Override
// public Alert createFromParcel(Parcel parcel) {
// return new Alert(parcel);
// }
//
// @Override
// public Alert[] newArray(int size) {
// return new Alert[size];
// }
// };
//
// private Alert(Parcel parcel) {
// this.id = parcel.readString();
// this.severity = parcel.readString();
// this.status = parcel.readString();
// this.ctime = parcel.readLong();
//
// evalSets = new ArrayList<>();
// notes = new ArrayList<>();
//
// parcel.readList(evalSets, Lister.class.getClassLoader());
// parcel.readList(notes, Note.class.getClassLoader());
//
// this.trigger = parcel.readParcelable(Trigger.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(severity);
// parcel.writeString(status);
// parcel.writeLong(ctime);
//
// parcel.writeList(evalSets);
// parcel.writeList(notes);
//
// parcel.writeParcelable(trigger, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// public static class Lister extends ArrayList<AlertEvaluation> implements Parcelable {
//
// protected Lister(Parcel in) {
// this.addAll(in.readArrayList(AlertEvaluation.class.getClassLoader()));
// }
//
// public static final Creator<Lister> CREATOR = new Creator<Lister>() {
// @Override
// public Lister createFromParcel(Parcel in) {
// return new Lister(in);
// }
//
// @Override
// public Lister[] newArray(int size) {
// return new Lister[size];
// }
// };
//
// @Override public int describeContents() {
// return 0;
// }
//
// @Override public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeList(this);
// }
// }
//
// }
// Path: mobile/src/main/java/org/hawkular/client/android/service/AlertService.java
import java.util.List;
import org.hawkular.client.android.backend.model.Alert;
import retrofit2.Call;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
/*
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.client.android.service;
public interface AlertService {
@GET("hawkular/alerts") | Call<List<Alert>> get(); |
hawkular/hawkular-android-client | mobile/src/main/java/org/hawkular/client/android/activity/MetricActivity.java | // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Metric.java
// public final class Metric implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("path")
// private String path;
//
// @SerializedName("properties")
// private MetricProperties properties;
//
// @SerializedName("type")
// private MetricConfiguration configuration;
//
// @VisibleForTesting
// public Metric(@NonNull String id, @NonNull MetricProperties properties, @NonNull MetricConfiguration config) {
// this.id = id;
// this.path = path;
// this.properties = properties;
// this.configuration = config;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPath() {
// return path;
// }
//
// public MetricProperties getProperties() {
// return properties;
// }
//
// public MetricConfiguration getConfiguration() {
// return configuration;
// }
//
// public static Creator<Metric> CREATOR = new Creator<Metric>() {
// @Override
// public Metric createFromParcel(Parcel parcel) {
// return new Metric(parcel);
// }
//
// @Override
// public Metric[] newArray(int size) {
// return new Metric[size];
// }
// };
//
// private Metric(Parcel parcel) {
// this.id = parcel.readString();
// this.name = parcel.readString();
// this.path = parcel.readString();
// this.properties = parcel.readParcelable(MetricProperties.class.getClassLoader());
// this.configuration = parcel.readParcelable(MetricConfiguration.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(name);
// parcel.writeString(path);
// parcel.writeParcelable(properties, flags);
// parcel.writeParcelable(configuration, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
// }
//
// Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Resource.java
// public class Resource implements Parcelable
// {
//
// private String id;
// private List<Data> data = null;
// public final static Creator<Resource> CREATOR = new Creator<Resource>() {
//
//
// @SuppressWarnings({
// "unchecked"
// })
// public Resource createFromParcel(Parcel in) {
// Resource instance = new Resource();
// instance.id = ((String) in.readValue((String.class.getClassLoader())));
// in.readList(instance.data, (Data.class.getClassLoader()));
// return instance;
// }
//
// public Resource[] newArray(int size) {
// return (new Resource[size]);
// }
//
// }
// ;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public List<Data> getData() {
// return data;
// }
//
// public void setData(List<Data> data) {
// this.data = data;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeValue(id);
// dest.writeList(data);
// }
//
// public int describeContents() {
// return 0;
// }
//
// }
| import org.hawkular.client.android.R;
import org.hawkular.client.android.backend.model.Metric;
import org.hawkular.client.android.backend.model.Resource;
import org.hawkular.client.android.util.Fragments;
import org.hawkular.client.android.util.Intents;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import butterknife.BindView;
import butterknife.ButterKnife; | private void setUpToolbar() {
setSupportActionBar(toolbar);
if (getSupportActionBar() == null) {
return;
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void setUpMetric() {
Fragments.Operator.of(this).set(R.id.layout_container, getMetricFragment());
}
private Fragment getMetricFragment() {
switch (getMetric().getConfiguration().getType()) {
case "AVAILABILITY":
return Fragments.Builder.buildMetricAvailabilityFragment(getMetric());
case "GAUGE":
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
case "COUNTER":
return Fragments.Builder.buildMetricCounterFragment(getMetric());
default:
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
}
}
| // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Metric.java
// public final class Metric implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("path")
// private String path;
//
// @SerializedName("properties")
// private MetricProperties properties;
//
// @SerializedName("type")
// private MetricConfiguration configuration;
//
// @VisibleForTesting
// public Metric(@NonNull String id, @NonNull MetricProperties properties, @NonNull MetricConfiguration config) {
// this.id = id;
// this.path = path;
// this.properties = properties;
// this.configuration = config;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPath() {
// return path;
// }
//
// public MetricProperties getProperties() {
// return properties;
// }
//
// public MetricConfiguration getConfiguration() {
// return configuration;
// }
//
// public static Creator<Metric> CREATOR = new Creator<Metric>() {
// @Override
// public Metric createFromParcel(Parcel parcel) {
// return new Metric(parcel);
// }
//
// @Override
// public Metric[] newArray(int size) {
// return new Metric[size];
// }
// };
//
// private Metric(Parcel parcel) {
// this.id = parcel.readString();
// this.name = parcel.readString();
// this.path = parcel.readString();
// this.properties = parcel.readParcelable(MetricProperties.class.getClassLoader());
// this.configuration = parcel.readParcelable(MetricConfiguration.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(name);
// parcel.writeString(path);
// parcel.writeParcelable(properties, flags);
// parcel.writeParcelable(configuration, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
// }
//
// Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Resource.java
// public class Resource implements Parcelable
// {
//
// private String id;
// private List<Data> data = null;
// public final static Creator<Resource> CREATOR = new Creator<Resource>() {
//
//
// @SuppressWarnings({
// "unchecked"
// })
// public Resource createFromParcel(Parcel in) {
// Resource instance = new Resource();
// instance.id = ((String) in.readValue((String.class.getClassLoader())));
// in.readList(instance.data, (Data.class.getClassLoader()));
// return instance;
// }
//
// public Resource[] newArray(int size) {
// return (new Resource[size]);
// }
//
// }
// ;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public List<Data> getData() {
// return data;
// }
//
// public void setData(List<Data> data) {
// this.data = data;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeValue(id);
// dest.writeList(data);
// }
//
// public int describeContents() {
// return 0;
// }
//
// }
// Path: mobile/src/main/java/org/hawkular/client/android/activity/MetricActivity.java
import org.hawkular.client.android.R;
import org.hawkular.client.android.backend.model.Metric;
import org.hawkular.client.android.backend.model.Resource;
import org.hawkular.client.android.util.Fragments;
import org.hawkular.client.android.util.Intents;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import butterknife.BindView;
import butterknife.ButterKnife;
private void setUpToolbar() {
setSupportActionBar(toolbar);
if (getSupportActionBar() == null) {
return;
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void setUpMetric() {
Fragments.Operator.of(this).set(R.id.layout_container, getMetricFragment());
}
private Fragment getMetricFragment() {
switch (getMetric().getConfiguration().getType()) {
case "AVAILABILITY":
return Fragments.Builder.buildMetricAvailabilityFragment(getMetric());
case "GAUGE":
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
case "COUNTER":
return Fragments.Builder.buildMetricCounterFragment(getMetric());
default:
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
}
}
| private Resource getResource() { |
hawkular/hawkular-android-client | mobile/src/main/java/org/hawkular/client/android/activity/MetricActivity.java | // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Metric.java
// public final class Metric implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("path")
// private String path;
//
// @SerializedName("properties")
// private MetricProperties properties;
//
// @SerializedName("type")
// private MetricConfiguration configuration;
//
// @VisibleForTesting
// public Metric(@NonNull String id, @NonNull MetricProperties properties, @NonNull MetricConfiguration config) {
// this.id = id;
// this.path = path;
// this.properties = properties;
// this.configuration = config;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPath() {
// return path;
// }
//
// public MetricProperties getProperties() {
// return properties;
// }
//
// public MetricConfiguration getConfiguration() {
// return configuration;
// }
//
// public static Creator<Metric> CREATOR = new Creator<Metric>() {
// @Override
// public Metric createFromParcel(Parcel parcel) {
// return new Metric(parcel);
// }
//
// @Override
// public Metric[] newArray(int size) {
// return new Metric[size];
// }
// };
//
// private Metric(Parcel parcel) {
// this.id = parcel.readString();
// this.name = parcel.readString();
// this.path = parcel.readString();
// this.properties = parcel.readParcelable(MetricProperties.class.getClassLoader());
// this.configuration = parcel.readParcelable(MetricConfiguration.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(name);
// parcel.writeString(path);
// parcel.writeParcelable(properties, flags);
// parcel.writeParcelable(configuration, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
// }
//
// Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Resource.java
// public class Resource implements Parcelable
// {
//
// private String id;
// private List<Data> data = null;
// public final static Creator<Resource> CREATOR = new Creator<Resource>() {
//
//
// @SuppressWarnings({
// "unchecked"
// })
// public Resource createFromParcel(Parcel in) {
// Resource instance = new Resource();
// instance.id = ((String) in.readValue((String.class.getClassLoader())));
// in.readList(instance.data, (Data.class.getClassLoader()));
// return instance;
// }
//
// public Resource[] newArray(int size) {
// return (new Resource[size]);
// }
//
// }
// ;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public List<Data> getData() {
// return data;
// }
//
// public void setData(List<Data> data) {
// this.data = data;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeValue(id);
// dest.writeList(data);
// }
//
// public int describeContents() {
// return 0;
// }
//
// }
| import org.hawkular.client.android.R;
import org.hawkular.client.android.backend.model.Metric;
import org.hawkular.client.android.backend.model.Resource;
import org.hawkular.client.android.util.Fragments;
import org.hawkular.client.android.util.Intents;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import butterknife.BindView;
import butterknife.ButterKnife; | return;
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void setUpMetric() {
Fragments.Operator.of(this).set(R.id.layout_container, getMetricFragment());
}
private Fragment getMetricFragment() {
switch (getMetric().getConfiguration().getType()) {
case "AVAILABILITY":
return Fragments.Builder.buildMetricAvailabilityFragment(getMetric());
case "GAUGE":
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
case "COUNTER":
return Fragments.Builder.buildMetricCounterFragment(getMetric());
default:
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
}
}
private Resource getResource() {
return getIntent().getParcelableExtra(Intents.Extras.RESOURCE);
}
| // Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Metric.java
// public final class Metric implements Parcelable {
// @RecordId
// @SerializedName("id")
// private String id;
//
// @SerializedName("name")
// private String name;
//
// @SerializedName("path")
// private String path;
//
// @SerializedName("properties")
// private MetricProperties properties;
//
// @SerializedName("type")
// private MetricConfiguration configuration;
//
// @VisibleForTesting
// public Metric(@NonNull String id, @NonNull MetricProperties properties, @NonNull MetricConfiguration config) {
// this.id = id;
// this.path = path;
// this.properties = properties;
// this.configuration = config;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPath() {
// return path;
// }
//
// public MetricProperties getProperties() {
// return properties;
// }
//
// public MetricConfiguration getConfiguration() {
// return configuration;
// }
//
// public static Creator<Metric> CREATOR = new Creator<Metric>() {
// @Override
// public Metric createFromParcel(Parcel parcel) {
// return new Metric(parcel);
// }
//
// @Override
// public Metric[] newArray(int size) {
// return new Metric[size];
// }
// };
//
// private Metric(Parcel parcel) {
// this.id = parcel.readString();
// this.name = parcel.readString();
// this.path = parcel.readString();
// this.properties = parcel.readParcelable(MetricProperties.class.getClassLoader());
// this.configuration = parcel.readParcelable(MetricConfiguration.class.getClassLoader());
// }
//
// @Override
// public void writeToParcel(Parcel parcel, int flags) {
// parcel.writeString(id);
// parcel.writeString(name);
// parcel.writeString(path);
// parcel.writeParcelable(properties, flags);
// parcel.writeParcelable(configuration, flags);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
// }
//
// Path: mobile/src/main/java/org/hawkular/client/android/backend/model/Resource.java
// public class Resource implements Parcelable
// {
//
// private String id;
// private List<Data> data = null;
// public final static Creator<Resource> CREATOR = new Creator<Resource>() {
//
//
// @SuppressWarnings({
// "unchecked"
// })
// public Resource createFromParcel(Parcel in) {
// Resource instance = new Resource();
// instance.id = ((String) in.readValue((String.class.getClassLoader())));
// in.readList(instance.data, (Data.class.getClassLoader()));
// return instance;
// }
//
// public Resource[] newArray(int size) {
// return (new Resource[size]);
// }
//
// }
// ;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public List<Data> getData() {
// return data;
// }
//
// public void setData(List<Data> data) {
// this.data = data;
// }
//
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeValue(id);
// dest.writeList(data);
// }
//
// public int describeContents() {
// return 0;
// }
//
// }
// Path: mobile/src/main/java/org/hawkular/client/android/activity/MetricActivity.java
import org.hawkular.client.android.R;
import org.hawkular.client.android.backend.model.Metric;
import org.hawkular.client.android.backend.model.Resource;
import org.hawkular.client.android.util.Fragments;
import org.hawkular.client.android.util.Intents;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import butterknife.BindView;
import butterknife.ButterKnife;
return;
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void setUpMetric() {
Fragments.Operator.of(this).set(R.id.layout_container, getMetricFragment());
}
private Fragment getMetricFragment() {
switch (getMetric().getConfiguration().getType()) {
case "AVAILABILITY":
return Fragments.Builder.buildMetricAvailabilityFragment(getMetric());
case "GAUGE":
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
case "COUNTER":
return Fragments.Builder.buildMetricCounterFragment(getMetric());
default:
return Fragments.Builder.buildMetricGaugeFragment(getMetric());
}
}
private Resource getResource() {
return getIntent().getParcelableExtra(Intents.Extras.RESOURCE);
}
| private Metric getMetric() { |
kovertopz/Paulscode-SoundSystem | src/main/java/de/jarnbjo/vorbis/Floor0.java | // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
| import java.io.IOException;
import de.jarnbjo.util.io.BitInputStream; | /*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Floor0.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Floor0.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Floor0 extends Floor {
private int order, rate, barkMapSize, amplitudeBits, amplitudeOffset;
private int bookList[];
| // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
// Path: src/main/java/de/jarnbjo/vorbis/Floor0.java
import java.io.IOException;
import de.jarnbjo.util.io.BitInputStream;
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Floor0.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Floor0.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Floor0 extends Floor {
private int order, rate, barkMapSize, amplitudeBits, amplitudeOffset;
private int bookList[];
| protected Floor0(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException { |
kovertopz/Paulscode-SoundSystem | src/main/java/de/jarnbjo/vorbis/IdentificationHeader.java | // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
| import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import de.jarnbjo.util.io.BitInputStream; | /*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: IdentificationHeader.java,v 1.3 2003/03/31 00:20:16 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: IdentificationHeader.java,v $
* Revision 1.3 2003/03/31 00:20:16 jarnbjo
* no message
*
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
/**
*/
public class IdentificationHeader {
private int version, channels, sampleRate, bitrateMaximum, bitrateNominal, bitrateMinimum, blockSize0, blockSize1;
private boolean framingFlag;
private MdctFloat[] mdct=new MdctFloat[2];
//private MdctLong[] mdctInt=new MdctLong[2];
private static final long HEADER = 0x736962726f76L; // 'vorbis'
| // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
// Path: src/main/java/de/jarnbjo/vorbis/IdentificationHeader.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import de.jarnbjo.util.io.BitInputStream;
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: IdentificationHeader.java,v 1.3 2003/03/31 00:20:16 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: IdentificationHeader.java,v $
* Revision 1.3 2003/03/31 00:20:16 jarnbjo
* no message
*
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
/**
*/
public class IdentificationHeader {
private int version, channels, sampleRate, bitrateMaximum, bitrateNominal, bitrateMinimum, blockSize0, blockSize1;
private boolean framingFlag;
private MdctFloat[] mdct=new MdctFloat[2];
//private MdctLong[] mdctInt=new MdctLong[2];
private static final long HEADER = 0x736962726f76L; // 'vorbis'
| public IdentificationHeader(BitInputStream source) throws VorbisFormatException, IOException { |
kovertopz/Paulscode-SoundSystem | src/main/java/de/jarnbjo/vorbis/Floor1.java | // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
| import java.io.IOException;
import java.util.*;
import de.jarnbjo.util.io.BitInputStream; | /*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Floor1.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $multip
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Floor1.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Floor1 extends Floor implements Cloneable {
private int[] partitionClassList;
private int maximumClass, multiplier, rangeBits;
private int[] classDimensions;
private int[] classSubclasses;
private int[] classMasterbooks;
private int[][] subclassBooks;
private int[] xList;
private int[] yList;
private int[] lowNeighbours, highNeighbours;
//private boolean[] step2Flags;
private static final int[] RANGES = {256, 128, 86, 64};
private Floor1() {
}
| // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
// Path: src/main/java/de/jarnbjo/vorbis/Floor1.java
import java.io.IOException;
import java.util.*;
import de.jarnbjo.util.io.BitInputStream;
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Floor1.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $multip
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Floor1.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Floor1 extends Floor implements Cloneable {
private int[] partitionClassList;
private int maximumClass, multiplier, rangeBits;
private int[] classDimensions;
private int[] classSubclasses;
private int[] classMasterbooks;
private int[][] subclassBooks;
private int[] xList;
private int[] yList;
private int[] lowNeighbours, highNeighbours;
//private boolean[] step2Flags;
private static final int[] RANGES = {256, 128, 86, 64};
private Floor1() {
}
| protected Floor1(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException { |
kovertopz/Paulscode-SoundSystem | src/main/java/de/jarnbjo/vorbis/Residue2.java | // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
| import java.io.IOException;
import java.util.*;
import de.jarnbjo.util.io.BitInputStream; | /*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Residue2.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Residue2.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Residue2 extends Residue {
private double[][] decodedVectors;
private Residue2() {
}
| // Path: src/main/java/de/jarnbjo/util/io/BitInputStream.java
// public interface BitInputStream {
//
// /**
// * constant for setting this stream's mode to little endian
// *
// * @see #setEndian(int)
// */
//
// public static final int LITTLE_ENDIAN = 0;
//
// /**
// * constant for setting this stream's mode to big endian
// *
// * @see #setEndian(int)
// */
//
// public static final int BIG_ENDIAN = 1;
//
// /**
// * reads one bit (as a boolean) from the input stream
// *
// * @return <code>true</code> if the next bit is 1,
// * <code>false</code> otherwise
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public boolean getBit() throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(int bits) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the signed integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getSignedInt(int bits) throws IOException;
//
// /**
// * reads a huffman codeword based on the <code>root</code>
// * parameter and returns the decoded value
// *
// * @param root the root of the Huffman tree used to decode the codeword
// * @return the decoded unsigned integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int getInt(HuffmanNode root) throws IOException;
//
// /**
// * reads an integer encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public int readSignedRice(int order) throws IOException;
//
// /**
// * fills the array from <code>offset</code> with <code>len</code>
// * integers encoded as "signed rice" as described in
// * the FLAC audio format specification
// *
// * @param order
// * @param buffer
// * @param offset
// * @param len
// * @return the decoded integer value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
//
// /**
// * reads <code>bits</code> number of bits from the input
// * stream
// *
// * @return the unsigned long value read from the stream
// *
// * @throws IOException if an I/O error occurs
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public long getLong(int bits) throws IOException;
//
// /**
// * causes the read pointer to be moved to the beginning
// * of the next byte, remaining bits in the current byte
// * are discarded
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void align();
//
// /**
// * changes the endian mode used when reading bit-wise from
// * the stream, changing the mode mid-stream will cause the
// * read cursor to move to the beginning of the next byte
// * (as if calling the <code>allign</code> method
// *
// * @see #align()
// *
// * @throws UnsupportedOperationException if the method is not supported by the implementation
// */
//
// public void setEndian(int endian);
// }
// Path: src/main/java/de/jarnbjo/vorbis/Residue2.java
import java.io.IOException;
import java.util.*;
import de.jarnbjo.util.io.BitInputStream;
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Residue2.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Residue2.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
class Residue2 extends Residue {
private double[][] decodedVectors;
private Residue2() {
}
| protected Residue2(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException { |
jimmc/HapiPodcastJ | src/info/xuluan/podcast/tests/LockTest.java | // Path: src/info/xuluan/podcast/utils/LockHandler.java
// public class LockHandler {
//
// private ReentrantReadWriteLock lock;
// private Boolean status;
//
// public LockHandler()
// {
// lock = new ReentrantReadWriteLock();
// status = false;
// }
//
// public boolean getStatus()
// {
// return status;
// }
//
// public boolean locked()
// {
// lock.readLock().lock();
// if (status) {
// lock.readLock().unlock();
// return false;
//
// }
// lock.readLock().unlock();
//
// lock.writeLock().lock();
// status = true;
// lock.writeLock().unlock();
//
// return true;
// }
//
// public void release()
// {
// lock.writeLock().lock();
// status = false;
// lock.writeLock().unlock();
// }
//
//
//
// }
| import junit.framework.TestCase;
import info.xuluan.podcast.utils.LockHandler; | /*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.xuluan.podcast.tests;
public class LockTest extends TestCase {
public void testLock() throws Exception { | // Path: src/info/xuluan/podcast/utils/LockHandler.java
// public class LockHandler {
//
// private ReentrantReadWriteLock lock;
// private Boolean status;
//
// public LockHandler()
// {
// lock = new ReentrantReadWriteLock();
// status = false;
// }
//
// public boolean getStatus()
// {
// return status;
// }
//
// public boolean locked()
// {
// lock.readLock().lock();
// if (status) {
// lock.readLock().unlock();
// return false;
//
// }
// lock.readLock().unlock();
//
// lock.writeLock().lock();
// status = true;
// lock.writeLock().unlock();
//
// return true;
// }
//
// public void release()
// {
// lock.writeLock().lock();
// status = false;
// lock.writeLock().unlock();
// }
//
//
//
// }
// Path: src/info/xuluan/podcast/tests/LockTest.java
import junit.framework.TestCase;
import info.xuluan.podcast.utils.LockHandler;
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.xuluan.podcast.tests;
public class LockTest extends TestCase {
public void testLock() throws Exception { | LockHandler lock = new LockHandler(); |
jimmc/HapiPodcastJ | src/info/xuluan/podcast/provider/PodcastProvider.java | // Path: src/info/xuluan/podcast/utils/Log.java
// public class Log {
//
// public final static int VERBOSE = 0;
//
// public final static int DEBUG = 1;
// public final static int INFO = 2;
// public final static int WARN = 3;
// public final static int ERROR = 4;
//
// public final static int DEFAULT_LEVEL = 3;
// private static int initialLevel = DEFAULT_LEVEL;
//
// private final String clazz;
//
// private int level;
// private static final String TAG = "PODCAST";
//
// public static Log getDebugLog(Class<?> clazz, int l) {
// Log log = new Log(clazz);
// log.level = l;
// return log;
// }
//
// public static Log getLog(Class<?> clazz) {
// return new Log(clazz);
// }
//
// public static void setInitialLevel(int level) {
// initialLevel = level;
// }
// public static int initialLevel() {
// return initialLevel;
// }
//
// public Log(Class<?> clazz) {
// this.clazz = "[" + clazz.getSimpleName() + "] ";
// level = initialLevel;
// }
//
// public void verbose(String message) {
// verbose(message, null);
// }
//
// public void debug(String message) {
// debug(message, null);
// }
//
// public void info(String message) {
// info(message, null);
// }
//
// public void warn(String message) {
// warn(message, null);
// }
//
// public void error(String message) {
// error(message, null);
// }
//
// public void verbose(String message, Throwable t) {
// if(VERBOSE<level)
// return;
// if (message != null)
// android.util.Log.v(TAG, clazz + message);
// if (t != null)
// android.util.Log.v(TAG, clazz + t.toString());
// }
//
// public void debug(String message, Throwable t) {
// if(DEBUG<level)
// return;
// if (message != null)
// android.util.Log.d(TAG, clazz + message);
// if (t != null)
// android.util.Log.d(TAG, clazz + t.toString());
// }
//
// public void info(String message, Throwable t) {
// if(INFO<level)
// return;
// if (message != null)
// android.util.Log.i(TAG, clazz + message);
// if (t != null)
// android.util.Log.i(TAG, clazz + t.toString());
// }
//
// public void warn(String message, Throwable t) {
// if(WARN<level)
// return;
// if (message != null)
// android.util.Log.w(TAG, clazz + message);
// if (t != null)
// android.util.Log.w(TAG, clazz + t.toString());
// }
//
// public void error(String message, Throwable t) {
// if(ERROR<level)
// return;
// if (message != null)
// android.util.Log.e(TAG, clazz + message);
// if (t != null)
// android.util.Log.e(TAG, clazz + t.toString());
// }
// }
| import info.xuluan.podcast.utils.Log;
import java.util.HashMap;
import java.util.Locale;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
| package info.xuluan.podcast.provider;
public class PodcastProvider extends ContentProvider {
public static final String AUTHORITY = PodcastProvider.class.getName()
.toLowerCase(Locale.getDefault());
private static final int TYPE_ALL_SUBSCRIPTIONS = 0;
private static final int TYPE_SINGLE_SUBSCRIPTION = 1;
private static final int TYPE_ALL_ITEMS = 2;
private static final int TYPE_SINGLE_ITEM = 3;
| // Path: src/info/xuluan/podcast/utils/Log.java
// public class Log {
//
// public final static int VERBOSE = 0;
//
// public final static int DEBUG = 1;
// public final static int INFO = 2;
// public final static int WARN = 3;
// public final static int ERROR = 4;
//
// public final static int DEFAULT_LEVEL = 3;
// private static int initialLevel = DEFAULT_LEVEL;
//
// private final String clazz;
//
// private int level;
// private static final String TAG = "PODCAST";
//
// public static Log getDebugLog(Class<?> clazz, int l) {
// Log log = new Log(clazz);
// log.level = l;
// return log;
// }
//
// public static Log getLog(Class<?> clazz) {
// return new Log(clazz);
// }
//
// public static void setInitialLevel(int level) {
// initialLevel = level;
// }
// public static int initialLevel() {
// return initialLevel;
// }
//
// public Log(Class<?> clazz) {
// this.clazz = "[" + clazz.getSimpleName() + "] ";
// level = initialLevel;
// }
//
// public void verbose(String message) {
// verbose(message, null);
// }
//
// public void debug(String message) {
// debug(message, null);
// }
//
// public void info(String message) {
// info(message, null);
// }
//
// public void warn(String message) {
// warn(message, null);
// }
//
// public void error(String message) {
// error(message, null);
// }
//
// public void verbose(String message, Throwable t) {
// if(VERBOSE<level)
// return;
// if (message != null)
// android.util.Log.v(TAG, clazz + message);
// if (t != null)
// android.util.Log.v(TAG, clazz + t.toString());
// }
//
// public void debug(String message, Throwable t) {
// if(DEBUG<level)
// return;
// if (message != null)
// android.util.Log.d(TAG, clazz + message);
// if (t != null)
// android.util.Log.d(TAG, clazz + t.toString());
// }
//
// public void info(String message, Throwable t) {
// if(INFO<level)
// return;
// if (message != null)
// android.util.Log.i(TAG, clazz + message);
// if (t != null)
// android.util.Log.i(TAG, clazz + t.toString());
// }
//
// public void warn(String message, Throwable t) {
// if(WARN<level)
// return;
// if (message != null)
// android.util.Log.w(TAG, clazz + message);
// if (t != null)
// android.util.Log.w(TAG, clazz + t.toString());
// }
//
// public void error(String message, Throwable t) {
// if(ERROR<level)
// return;
// if (message != null)
// android.util.Log.e(TAG, clazz + message);
// if (t != null)
// android.util.Log.e(TAG, clazz + t.toString());
// }
// }
// Path: src/info/xuluan/podcast/provider/PodcastProvider.java
import info.xuluan.podcast.utils.Log;
import java.util.HashMap;
import java.util.Locale;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
package info.xuluan.podcast.provider;
public class PodcastProvider extends ContentProvider {
public static final String AUTHORITY = PodcastProvider.class.getName()
.toLowerCase(Locale.getDefault());
private static final int TYPE_ALL_SUBSCRIPTIONS = 0;
private static final int TYPE_SINGLE_SUBSCRIPTION = 1;
private static final int TYPE_ALL_ITEMS = 2;
private static final int TYPE_SINGLE_ITEM = 3;
| private final Log log = Log.getLog(getClass());
|
jimmc/HapiPodcastJ | src/info/xuluan/podcast/FlingGestureDetector.java | // Path: src/info/xuluan/podcast/utils/Log.java
// public class Log {
//
// public final static int VERBOSE = 0;
//
// public final static int DEBUG = 1;
// public final static int INFO = 2;
// public final static int WARN = 3;
// public final static int ERROR = 4;
//
// public final static int DEFAULT_LEVEL = 3;
// private static int initialLevel = DEFAULT_LEVEL;
//
// private final String clazz;
//
// private int level;
// private static final String TAG = "PODCAST";
//
// public static Log getDebugLog(Class<?> clazz, int l) {
// Log log = new Log(clazz);
// log.level = l;
// return log;
// }
//
// public static Log getLog(Class<?> clazz) {
// return new Log(clazz);
// }
//
// public static void setInitialLevel(int level) {
// initialLevel = level;
// }
// public static int initialLevel() {
// return initialLevel;
// }
//
// public Log(Class<?> clazz) {
// this.clazz = "[" + clazz.getSimpleName() + "] ";
// level = initialLevel;
// }
//
// public void verbose(String message) {
// verbose(message, null);
// }
//
// public void debug(String message) {
// debug(message, null);
// }
//
// public void info(String message) {
// info(message, null);
// }
//
// public void warn(String message) {
// warn(message, null);
// }
//
// public void error(String message) {
// error(message, null);
// }
//
// public void verbose(String message, Throwable t) {
// if(VERBOSE<level)
// return;
// if (message != null)
// android.util.Log.v(TAG, clazz + message);
// if (t != null)
// android.util.Log.v(TAG, clazz + t.toString());
// }
//
// public void debug(String message, Throwable t) {
// if(DEBUG<level)
// return;
// if (message != null)
// android.util.Log.d(TAG, clazz + message);
// if (t != null)
// android.util.Log.d(TAG, clazz + t.toString());
// }
//
// public void info(String message, Throwable t) {
// if(INFO<level)
// return;
// if (message != null)
// android.util.Log.i(TAG, clazz + message);
// if (t != null)
// android.util.Log.i(TAG, clazz + t.toString());
// }
//
// public void warn(String message, Throwable t) {
// if(WARN<level)
// return;
// if (message != null)
// android.util.Log.w(TAG, clazz + message);
// if (t != null)
// android.util.Log.w(TAG, clazz + t.toString());
// }
//
// public void error(String message, Throwable t) {
// if(ERROR<level)
// return;
// if (message != null)
// android.util.Log.e(TAG, clazz + message);
// if (t != null)
// android.util.Log.e(TAG, clazz + t.toString());
// }
// }
| import info.xuluan.podcast.utils.Log;
import android.content.Intent;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View; | package info.xuluan.podcast;
public class FlingGestureDetector extends SimpleOnGestureListener {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private Flingable flingable;
| // Path: src/info/xuluan/podcast/utils/Log.java
// public class Log {
//
// public final static int VERBOSE = 0;
//
// public final static int DEBUG = 1;
// public final static int INFO = 2;
// public final static int WARN = 3;
// public final static int ERROR = 4;
//
// public final static int DEFAULT_LEVEL = 3;
// private static int initialLevel = DEFAULT_LEVEL;
//
// private final String clazz;
//
// private int level;
// private static final String TAG = "PODCAST";
//
// public static Log getDebugLog(Class<?> clazz, int l) {
// Log log = new Log(clazz);
// log.level = l;
// return log;
// }
//
// public static Log getLog(Class<?> clazz) {
// return new Log(clazz);
// }
//
// public static void setInitialLevel(int level) {
// initialLevel = level;
// }
// public static int initialLevel() {
// return initialLevel;
// }
//
// public Log(Class<?> clazz) {
// this.clazz = "[" + clazz.getSimpleName() + "] ";
// level = initialLevel;
// }
//
// public void verbose(String message) {
// verbose(message, null);
// }
//
// public void debug(String message) {
// debug(message, null);
// }
//
// public void info(String message) {
// info(message, null);
// }
//
// public void warn(String message) {
// warn(message, null);
// }
//
// public void error(String message) {
// error(message, null);
// }
//
// public void verbose(String message, Throwable t) {
// if(VERBOSE<level)
// return;
// if (message != null)
// android.util.Log.v(TAG, clazz + message);
// if (t != null)
// android.util.Log.v(TAG, clazz + t.toString());
// }
//
// public void debug(String message, Throwable t) {
// if(DEBUG<level)
// return;
// if (message != null)
// android.util.Log.d(TAG, clazz + message);
// if (t != null)
// android.util.Log.d(TAG, clazz + t.toString());
// }
//
// public void info(String message, Throwable t) {
// if(INFO<level)
// return;
// if (message != null)
// android.util.Log.i(TAG, clazz + message);
// if (t != null)
// android.util.Log.i(TAG, clazz + t.toString());
// }
//
// public void warn(String message, Throwable t) {
// if(WARN<level)
// return;
// if (message != null)
// android.util.Log.w(TAG, clazz + message);
// if (t != null)
// android.util.Log.w(TAG, clazz + t.toString());
// }
//
// public void error(String message, Throwable t) {
// if(ERROR<level)
// return;
// if (message != null)
// android.util.Log.e(TAG, clazz + message);
// if (t != null)
// android.util.Log.e(TAG, clazz + t.toString());
// }
// }
// Path: src/info/xuluan/podcast/FlingGestureDetector.java
import info.xuluan.podcast.utils.Log;
import android.content.Intent;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
package info.xuluan.podcast;
public class FlingGestureDetector extends SimpleOnGestureListener {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private Flingable flingable;
| private final Log log = Log.getLog(getClass()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.