full_name stringlengths 7 104 | description stringlengths 4 725 ⌀ | topics stringlengths 3 468 ⌀ | readme stringlengths 13 565k ⌀ | label int64 0 1 |
|---|---|---|---|---|
GDG-Korea/HelloRx | RxAndroid (RxJava) examples | null | # HelloRx
RxAndroid examples
| 0 |
zonbeka/Cplex-Examples | null | null | examples
========
| 0 |
pcgrenier/nifi-examples | Apache Nifi Examples by http://www.nifi.rocks | null | null | 0 |
dasniko/keycloak-extensions-demo | Demos, examples and playground for Keycloak extensions, providers, SPI implementations, etc. | examples extensions iam java keycloak oidc spi sso | # Keycloak Extensions Demo
Demos, examples and playground for [Keycloak](https://www.keycloak.org) extensions, providers, SPI implementations, etc.
[](https://github.com/dasniko/keycloak-extensions-demo/actions/workflows/maven.yml)


This repository contains the following extensions, and probably (most likely 😉) more...
## Keycloak User Storage Provider
[Flintstones](./flintstones-userprovider) - Demo user storage provider, providing some members of the Flintstones family, through an HTTP-base API and in writable mode, also possible to add new users.
## Keycloak Authenticators
[MagicLink Authenticator](./magiclink) - demo authenticator which sends a magic link to the user with which the user can login without needing to provide a password.
[Captcha Authenticator](./captcha) - demo authenticator in which the user needs to solve a math task and submit the result, before successful authentication.
[MFA Authenticator](./mfa-authenticator) - very simple(!!!) demo authenticator which prints a generated OTP to stdout.
[Conditional Authenticator](./conditional-headers-authenticator) - conditions for authenticators which will decide upon
* a header and given value (or negated value) if `true`/`false`
* a authentication session note and given value (or negated value) if `true`/`false`
## Keycloak Event Listeners
### Session Restrictor
[Highlander](./event-listener) - demo event listener for Keycloak, allowing only the last session to survive (_Highlander mode - there must only be one!_), if a user logs in on multiple browsers/devices.
_(This was for long time not possible in Keycloak ootb, thus this event listener; since KC v19(?) this is natively supported.)_
### Event Forwarder
[AWS SNS Publisher](./event-listener) - demo event listener for Keycloak, simply forwarding/publishing all events to an AWS SNS topic.
### User Attribute Updater
[LastLoginTime](./event-listener) - demo event listener for Keycloak, storing the most recent login time in an user attribute.
## Custom Keycloak OIDC protocol token mapper
[LuckyNumberMapper](./tokenmapper) - example custom token mapper for Keycloak using the OIDC protocol.
## Keycloak REST endpoint/resource extension
[Custom Rest Resource](./rest-endpoint) - demo implementation for custom REST resources within Keycloak, public (unauthenticated) and secured (authenticated) endpoints.
## Custom Required Action
[MobileNumberRequiredAction](./requiredaction) - example which enforces the user to update its mobile phone number, if not already set.
## Custom Email Template & Sender Provider
[Email Provider](./email) for custom templates in JSON format (no actual emal, but for processing through external/3rd party services) and sending emails via a vendor specific (here: AWS SES) protocol, instead of SMTP.
## Demo Docker Compose Environment
There's a `docker-compose.yml` definition to use with Docker Compose. No Warranties, use at your own risk and fortune, I'm not giving any support to this!
Build and run all the stuff with:
& ./mvnw clean package -DskipTests && docker compose up
| 0 |
techatspree/jbosscc-as7-examples | JBoss AS 7 Example Projects | null | null | 1 |
kittylyst/javanut6-examples | Example Code for Java in a Nutshell (6th Edition) | null | # javanut6-examples
Example Code for Java in a Nutshell (6th Edition)
This is the example programs and samples from Java in a Nutshell (6th Edition)
written by Ben Evans and published by O'Reilly.
The initial code drop is incomplete - rather than spending a lot of time tidying
up the code from how it was actually written (& in several cases, the code
examples dated back to an older version of the text and have to be manually
extracted from the book text), I felt it better to get something out there and
in use, and add to it a bit at a time.
If you have specific requests, or suggestions for improvement, or possible
examples you'd like to see, please leave a Github issue. Pull requests are
also very welcome, but please ensure that they are formatted to Netbeans
default Java style before sending.
Special thanks to James Gough for his contributions to the Ch09 examples, and to
the other members of the London JSR 310 project team for making this API happen
in time for JDK 8.
Thanks,
-Ben (@kittylyst)
| 1 |
gstreamer-java/gst1-java-examples | Repository for examples of using gst1-java-core | null | GStreamer Java examples
=======================
This repository contains a series of example projects for using
[GStreamer 1.x][gstreamer] with Java via the [GStreamer Java][gstreamer-java]
libraries, including [gst1-java-core][gst1-core] and extensions.
The code steps in each project source file are documented. Any questions, please
use the [mailing list][gstreamer-java-group].
## Requirements
All examples are self-contained Gradle projects. They should work inside your IDE
or via `./gradlew run` on the command line.
All the examples require an [installation of GStreamer][gstreamer-download] itself.
Windows users installing GStreamer should select the complete profile, rather than
the typical one.
Most examples work with JDK 8+. The JavaFX integration example requires JDK 11+
(and uses JavaFX 15).
## Examples
Inside each example there is an identical `Utils.java` file that contains some
useful code for setting up native paths for an installed version of GStreamer.
This code, and all the example code (aside from some files in the archive), is
free to adapt for your own usage.
### Getting started
- **BasicPipeline** : getting started running a video test source into a GStreamer
output window.
### Desktop (Swing / JavaFX)
- **SwingCamera** : using a camera (or test source) inside a Swing application,
using `gst1-java-swing`.
- **SwingPlayer** : a simple media player with Swing UI, including file selection,
playback controls, seeking and volume meters.
- **FXCamera** : using a camera (or test source) inside a JavaFX application,
using `gst1-java-fx`.
- **FXPlayer** : a simple media player with JavaFX UI, including file selection,
playback controls, seeking and volume meters.
### Server / Internet
- **HLS** : using HTTP Live Streaming to stream live video with Java2D rendered
overlay to browser using Javalin framework.
- **WebRTCSendRecv** : example of sending and receiving via WebRTC using the test
page at https://webrtc.nirbheek.in This is the test server used in upstream
GStreamer examples. You may need to configure permissions in the browser to
always allow audio for that site. You need to pass in the session ID from the
page on the CLI. If running in the terminal via Gradle, it is recommended to
use `./gradlew --console=plain run`.
### Miscellaneous
- **BufferProbe** : using a buffer probe to draw an animation on top of the video
stream using Java2D.
- **Controllers** : configuring controllers to control element properties (ported
from an upstream C example).
### Archive
Inside the archive folder are all the previously available examples, some of which
have not yet been adapted into self-contained example projects.
[gstreamer]: https://gstreamer.freedesktop.org/
[gstreamer-download]: https://gstreamer.freedesktop.org/download/
[gstreamer-java]: https://github.com/gstreamer-java
[gstreamer-java-group]: https://groups.google.com/forum/#!forum/gstreamer-java
[gst1-core]: https://github.com/gstreamer-java/gst1-java-core
| 0 |
Simsilica/Examples | Example applications for various Simsilica libraries, singly or in combination. | null | # Examples
Example applications for various Simsilica libraries, singly or in combination.
## simple-jme
A simple JME "blue cube" example using a gradle build file and an asset project setup.
To run: `gradle run`
## zay-es-net-basic
A non-UI, non-graphical, example of using the zay-es-net networking layer for zay-es.
To run the server: `gradle runServer`
To run the client: `gradle runClient`
## network-basic
A base template project for network games. Provides a simple main menu that includes
options for hosting a local game or connecting to a remote game. Sets up the client/server
code but otherwise provides absolutely no game logic. A blank canvas ready for 'game'.
To run: `gradle run`
## sim-eth-basic
A simple space ships 'game' built on JME, Lemur, SpiderMonkey, and the SimEthereal real-time
object synching library.
To run: `gradle run`
## sim-eth-es
A simple space ships 'game' built on JME, Lemur, Zay-ES, Zay-ES-Net, SpiderMonkey, and the SimEthereal real-time
object synching library. This modifies the sim-eth-basic to be ES based using the Zay-ES library.
To run: `gradle run`
| 1 |
amitrp/spring-examples | Contains Spring and Spring Boot Code Samples used in https://www.amitph.com/ tutorials | hibernate jpa-hibernate spring spring-boot spring-data-jdbc spring-data-jpa spring-data-rest spring-mvc | # Spring Tutorials and Examples
Examples of using Spring Framework and Spring Boot
These examples are part of Spring & Spring Boot Tutorials on https://www.amitph.com/
## List of few relevant tutorials
- [Spring Data REST CRUD Example](https://www.amitph.com/spring-data-rest-example/)
- [Spring Data REST Projections and Excerpts](https://www.amitph.com/spring-data-rest-projections-and-excerpts/)
- [Spring Data JDBC Tutorial with Examples](https://www.amitph.com/introduction-spring-data-jdbc/)
- [Unit Tests for Spring Data JDBC Repositories](https://www.amitph.com/testing-spring-data-jdbc/)
- [How to Write a non-web Application with Spring Boot](https://www.amitph.com/non-web-application-spring-boot/)
- [CRUD REST Service With Spring Boot, Hibernate, and JPA](https://www.amitph.com/spring-boot-crud-hibernate-jpa/)
- [Understand Http PUT vs PATCH with Examples](https://www.amitph.com/http-put-vs-patch/)
- [Enable Spring Boot ApplicationStartup Metrics to Diagnose Slow Startup](https://www.amitph.com/spring-boot-startup-monitoring/)
- [Scheduled Tasks in Spring with @Scheduled](https://www.amitph.com/scheduled-tasks-in-spring/)
- [Spring Data JPA Composite Key with @EmbeddedId](https://www.amitph.com/spring-data-jpa-embeddedid/)
- [Spring Data JPA find by @EmbeddedId Partially](https://www.amitph.com/spring-data-jpa-find-by-embeddedid-partially/)
- [Spring Boot Actuator with Spring Boot 2](https://www.amitph.com/spring-boot-actuator-spring-boot-2/)
- [Custom Health Check in Spring Boot Actuator](https://www.amitph.com/custom-health-check-spring-boot-actuator/)
- [Introduction to Spring Boot Admin Server with Example](https://www.amitph.com/spring-boot-admin-server/)
- [How to Secure Spring Boot Actuator Endpoints](https://www.amitph.com/how-to-secure-spring-boot-actuator-endpoints/)
- [Spring Boot Admin Server Example](https://www.amitph.com/spring-boot-admin-server/)
- [Spring Data and JPA Tutorial](https://www.amitph.com/spring-data-and-jpa-tutorial/)
- [Wildcard Queries with Spring Data JPA](https://www.amitph.com/spring-data-and-jpa-tutorial/)
- [Spring Boot Runners – Application Runner and Command Line Runner](https://www.amitph.com/spring-boot-runners/)
- [Spring Boot Rest Service](https://www.amitph.com/spring-boot-rest-service/)
- [Downloading Large Files using Spring WebClient](https://www.amitph.com/spring-webclient-large-file-download/)
- [Spring @RequestParam Annotation with Examples](https://www.amitph.com/spring-requestparam-annotation/)
- [Introduction to Spring WebClient](https://www.amitph.com/introduction-to-spring-webclient/)
- [Configure timeout for Spring WebFlux WebClient](https://www.amitph.com/spring-webflux-timeouts/)
- [How to Read JSON Data with WebClient](https://www.amitph.com/spring-webclient-read-json-data/)
- [Add URI Parameters to Spring WebClient Requests](https://www.amitph.com/spring-webclient-request-parameters/)
- [Spring Boot - Spring Data JPA - MySQL Example](https://www.amitph.com/spring-boot-data-jpa-mysql/)
- [Spring Boot - Spring Data JPA - Postgres Example](https://www.amitph.com/spring-boot-data-jpa-postgres/)
- [Spring Boot Exit Codes Examples with Exception Mapping](https://www.amitph.com/spring-boot-exit-codes/)
- [Using @ConfigurationProperties in Spring Boot](https://www.amitph.com/spring-boot-configuration-properties/)
- [Reading Nested Properties in Spring Boot](https://www.amitph.com/spring-boot-nested-configuration-properties/)
- [Reading HTTP Headers in Spring REST Controller](https://www.amitph.com/spring-rest-http-header/)
- [YAML to Map with Spring Boot](https://www.amitph.com/spring-boot-yaml-to-map/)
- [YAML to Java List of Objects in Spring Boot](https://www.amitph.com/spring-boot-yaml-to-list/)
- [Validations with @ConfigurationProperties in Spring Boot](https://www.amitph.com/spring-boot-configuration-properties-validation/)
- [Parallel Requests with Spring WebClient](https://www.amitph.com/spring-webclient-concurrent-calls/)
- [Custom Banners with Spring Boot](https://www.amitph.com/spring-boot-custom-banner/)
| 0 |
tomekkaczanowski/junit-put-examples | Code examples for Practical Unit Testing with JUnit and Mockito" book" | null | null | 0 |
loretoparisi/tensorflow-java | Tensorflow Java examples | deeplearning deeplearning-java java tensorflow tensorflow-java | # tensorflow-java
Tensorflow Java pipeline and examples. This simple Java pipeline for TensorFlow Java API supports *Tensorflow >= 1.4* and it has been tested with Tensorflow from *TF 1.4.0* to *TF 1.13.1*. :new:
## How To Install
You need to run the `jni.sh` to install the right Java bindings for your platform and the `download.sh` script that will download the `inception5` model in order to be ready to run a simple examples:
```bash
git clone https://github.com/loretoparisi/tensorflow-java.git \
cd tensorflow-java \
sh jni.sh \
sh download.sh \
```
## A simple Hello World example
Create a simple Java class with a main to be executable and import `org.tensorflow.TensorFlow`
```java
import org.tensorflow.TensorFlow;
public class TensorFlowExample {
public static void main(String[] args) {
System.out.println("TensorFlowExample using TensorFlow version: " + TensorFlow.version());
}
}
```
Save it and then from command line compile and run
```bash
cd tensorflow-java
javac -cp lib/libtensorflow-1.13.1.jar TensorFlowExample.java
java -cp lib/libtensorflow-1.13.1.jar:. -Djava.library.path=./jni TensorFlowExample
```
If you get the TensorFlow version as output it worked!
```bash
TensorFlowExample using TensorFlow version: 1.13.1
```
## Real world (Inception) example
We use the `LabelImage` official Tensorflow example to label an example image with the inception graph model.
```
$ javac -cp lib/libtensorflow-1.13.1.jar LabelImage.java
$ java -cp lib/libtensorflow-1.13.1.jar:. -Djava.library.path=./jni LabelImage models/ images/example-400x288.jpg
BEST MATCH: lakeside (19,00% likely)
```
## Disclaimer
This example is provided as it is and it is based on the official Tensorflow Java JNI wrapper and example available [here](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java).
| 0 |
habren/JavaDesignPattern | Examples for Java Design Pattern | null | Java设计模式
---
本项目主要记录《Java设计模式》系列文章对应的实例代码,具体的文章详见[作者个人博客](http://www.jasongj.com)[http://www.jasongj.com](http://www.jasongj.com)
- [Java设计模式(一) 简单工厂模式不简单](http://www.jasongj.com/design_pattern/simple_factory/)
- [Java设计模式(二) 工厂方法模式](http://www.jasongj.com/design_pattern/factory_method/)
- [Java设计模式(三) 抽象工厂模式](http://www.jasongj.com/design_pattern/abstract_factory/)
- [Java设计模式(四) 观察者模式 ](http://www.jasongj.com/design_pattern/observer/)
- [Java设计模式(五) 组合模式](http://www.jasongj.com/design_pattern/composite/)
- [Java设计模式(六) 代理模式 VS. 装饰模式](http://www.jasongj.com/design_pattern/proxy_decorator/)
| 0 |
haoxiaoyong1014/springboot-redis-examples | redis 使用场景及实例 | null | # springboot-redis-example
2018/6/12 添加 springboot-redis-docker(<a href="https://github.com/haoxiaoyong1014/springboot-examples/tree/master/springboot-redis-docker">Docker 部署 SpringBoot 项目整合 Redis 镜像做访问计数(PV)Demo</a>)
2018/07/27 添加springboot-redis-ranking (<a href="https://github.com/haoxiaoyong1014/springboot-redis-examples/tree/master/springboot-redis-ranking">基于Redis实现商品排行榜</a>)
2018/08/01 添加 springboot-redis-fridends (<a href="https://github.com/haoxiaoyong1014/springboot-redis-examples/tree/master/springboot-redis-friends">基于Redis实现查询共同好友</a>,
结合前端vue.js,前端项目地址: <a href="https://github.com/haoxiaoyong1014/common-friends">common-friends</a>)
2018/11/16 添加 redis-manage(<a href="https://github.com/haoxiaoyong1014/redis-manage">Redis的后台管理</a>,结合前端项目<a href="https://github.com/haoxiaoyong1014/redis-manage-view">redis-manage-view</a>)
2019/8/16 添加 springboot-idempotent(<a href="https://github.com/haoxiaoyong1014/springboot-examples/tree/master/springboot-idempotent">springboot + redis + 注解 + 拦截器 实现接口幂等性校验</a>)
2019/9/14 添加 springboot-mybatis-redis-cache(<a href="https://github.com/haoxiaoyong1014/springboot-redis-examples/tree/master/springboot-mybatis-redis-cache">使用redis做二级缓存</a>)
2019/10/29添加 [Redis专题(七)--基于Sentinel(哨兵)搭建实现Redis高可用集群](https://haoxiaoyong.cn/2019/10/29/2019/2019-12-03-redis-master-slave/)
2020/09/18添加 springboot-redis-range( [SpringBoot 使用 Redis Geo 实现查找附近的位置](https://github.com/haoxiaoyong1014/springboot-redis-examples/tree/master/springboot-redis-range))
持续更新中....
| 0 |
stunstunstun/awesome-spring-boot | Code based and real world examples of Spring Boot and shiny things. 😍 | awesome-spring awesome-spring-boot java spring spring-boot springboot | # <img src="http://stormpath.com/wp-content/uploads/2016/05/spring-boot-logo.jpg" width="50" align="absmiddle"/> Awesome Spring Boot
[](https://github.com/sindresorhus/awesome)
[](https://travis-ci.org/stunstunstun/awesome-spring-boot)
[]()
[]()
[]()
A curated list of amazingly examples of Spring Boot, resources and shiny things.
## Contents
<details>
<!-- toc -->
- [Tutorials](#tutorials)
- [DevOps](#devops)
- [Prerequisite](#prerequisite)
- [Test](#test)
- [Build](#build)
- [Run](#run)
- [Spring Boot Features](#spring-boot-features)
<!-- tocstop -->
</details>
## Tutorials
#### Afterwards Spring Boot works
Project | Build | Description |
---|---|----
[spring-boot-jdbc-example](https://github.com/stunstunstun/awesome-spring-boot/tree/master/spring-boot-jdbc-example) | Gradle | Integrating Spring Boot with JDBC
[spring-boot-jpa-example](https://github.com/stunstunstun/awesome-spring-boot/tree/master/spring-boot-jpa-example) | Gradle | Integrating Spring Boot with JPA
[spring-boot-mybatis-example](https://github.com/stunstunstun/awesome-spring-boot/tree/master/spring-boot-mybatis-example)| Gradle | Integrating Spring Boot with myBatis
[spring-boot-mybatis-multi-example](https://github.com/stunstunstun/awesome-spring-boot/tree/master/spring-boot-mybatis-multi-example) | Gradle | Integrating Spring Boot with multiple datasources
[spring-boot-mvc-example](https://github.com/stunstunstun/awesome-spring-boot/tree/master/spring-boot-mvc-example) | Gradle | Integrating Spring Boot with Spring MVC
#### Download
```
$ git clone https://github.com/stunstunstun/awesome-spring-boot.git
```
## DevOps
#### Prerequisite
Your operating system must have the JDK installed and it's recommended that you install the IDE to look up the source code.
#### Test
Check the test case with the `@Test` annotation.
```
$ gradlew test
```
#### Build
Build the project and create executable jar and war files.
```
$ gradlew assemble
```
It doesn't work? You should check execution permission.
```
$ chmod +x gradlew
```
#### Run
An example with spring-web-starter can be connected by Web Browser
```
$ gradlew :spring-boot-mvc-example:bootRun
```
```
GET http://localhost:8080/users
```
## Spring Boot Features
#### Bootstrap By Spring Boot CLI
`Install Spring Boot CLI`
```
$ brew tap pivotal/tap
$ brew install springboot
$ spring --version
```
`Create Project`
```
$ spring init --build=gradle --java-version=1.8 --dependencies=data-jpa spring-boot-jpa-example
```
## You can do it in yourself!
#### Spring Core
- http://vojtechruzicka.com/field-dependency-injection-considered-harmful/
#### Spring Boot Test
- https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html
- https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4
- https://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html
- http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/mock/mockito/MockBean.html
#### Spring Data REST
- https://docs.spring.io/spring-data/rest/docs/current/reference/html/
#### Data Access
- https://spring.io/guides/gs/accessing-data-jpa/
- https://spring.io/guides/gs/accessing-data-mysql/
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
#### Logging
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html
- https://www.slideshare.net/whiteship/ss-47273947
#### HTTP Client
- https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-restclient.html
#### Embedded Servlet Containers
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html
#### Profiles
- https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
#### Actuator
- https://spring.io/guides/gs/actuator-service/
- https://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-actuator.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html
#### Hotswapping
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-hotswapping.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html
- https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3
#### Deploy To AWS, Cloud Foundry
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/cloud-deployment.html
#### Spring Boot Book
- https://www.manning.com/books/spring-boot-in-practice
| 0 |
salaboy/Drools_jBPM5-Training-Examples | jBPM5 & Drools - Community Training Course - Examples | null | null | 0 |
jgperrin/net.jgp.labs.spark | Apache Spark examples exclusively in Java | data-ingestion dataframe ingestion java spark udf | # Some Java examples for Apache Spark
## Welcome
Welcome to this project I started several years ago with this simple idea: let's use **Apache Spark with Java** and not learn all those complex stuff like Hadoop or Scala. I am not that smart anyway...
## A book!
This project has evolved in a book, named "**[Spark in Action, 2nd edition](https://jgp.ai/sia)**" published by Manning Publications. If you want to know more, and be guided through your Spark learning process, I can only recommend to read the book at Manning. Find out more about [Spark in Action, 2nd edition, on the Manning website](https://jgp.ai/sia). The book contains more examples, more explanation, is professionally written and edited.
Spark in Action, 2e covers using Spark with Java, Python (PySpark), and Scala.
All Spark in Action's examples are on GitHub. Here are the repos with the book examples:
[Chapter 1](https://github.com/jgperrin/net.jgp.books.spark.ch01) So, what is Spark, anyway? _An introduction to Spark with a simple ingestion example._
[Chapter 2](https://github.com/jgperrin/net.jgp.books.spark.ch02) Architecture and flows _Mental model around Spark and exporting data to PostgreSQL from Spark._
[Chapter 3](https://github.com/jgperrin/net.jgp.books.spark.ch03) The majestic role of the dataframe.
[Chapter 4](https://github.com/jgperrin/net.jgp.books.spark.ch04) Fundamentally lazy.
[Chapter 5](https://github.com/jgperrin/net.jgp.books.spark.ch05) Building a simple app for deployment _and_ Deploying your simple app.
[Chapter 7](https://github.com/jgperrin/net.jgp.books.spark.ch07) Ingestion from files.
[Chapter 8](https://github.com/jgperrin/net.jgp.books.spark.ch08) Ingestion from databases.
[Chapter 9](https://github.com/jgperrin/net.jgp.books.spark.ch09) Advanced ingestion: finding data sources & building your own.
[Chapter 10](https://github.com/jgperrin/net.jgp.books.spark.ch10) Ingestion through structured streaming.
[Chapter 11](https://github.com/jgperrin/net.jgp.books.spark.ch11) Working with Spark SQL.
[Chapter 12](https://github.com/jgperrin/net.jgp.books.spark.ch12) Transforming your data.
[Chapter 13](https://github.com/jgperrin/net.jgp.books.spark.ch13) Transforming entire documents.
[Chapter 14](https://github.com/jgperrin/net.jgp.books.spark.ch14) Extending transformations with user-defined functions (UDFs).
[Chapter 15](https://github.com/jgperrin/net.jgp.books.spark.ch15) Aggregating your data.
[Chapter 16](https://github.com/jgperrin/net.jgp.books.spark.ch16) Cache and checkpoint: enhancing Spark’s performances.
[Chapter 17](https://github.com/jgperrin/net.jgp.books.spark.ch17) Exporting data & building full data pipelines.
In the meanwhile, this project is still live, with more raw-level examples, that may (or may not) work.
## This repo
This project is still live as I add experiments and answers to StackOverflow. I try to keep this project up to date with the version of Spark, but I must admit I only validate for compilations.
### Environment
These labs rely on:
* Apache Spark v3.2.0 (based on Scala v2.12).
* Java 8.
### Notes on Branches
The master branch will always contain the latest version of Spark, currently v3.2.0.
### Labs
A few labs around Apache Spark, exclusively in Java.
Organization is now in sub packages:
* l000_ingestion: Data ingestion from various sources.
* l020\_streaming: Data ingestion via streaming. Special note on [Streaming](src/main/java/net/jgp/labs/spark/l020_streaming/README.md).
* l050_connection: Connect to Spark.
* l100_checkpoint: Checkpoint introduced in Spark v2.1.0.
* l150_udf: UDF (User Defined Functions).
* l200_join: added join examples.
* l240_foreach: foreach() on a dataframe.
* l250_map: map (in the context of mapping, not always linked to map/reduce).
* l300_reduce: reduce.
* l400\_industry\_formats: working with industry formats, limited, for now, to HL7 and FHIR.
* l500_misc: other examples.
* l600_ml: ML (Machine Learning).
* l700_save: saving your results.
* l800_concurrency: labs around concurrency access, work in progress.
* l900_analytics: More complex examples of using Spark for Analytics.
* l900_analytics: More complex examples of using Spark for Analytics.
### Contribute
* If you would like to see more labs, send your request to jgp at jgp dot net or [@jgperrin](https://twitter.com/jgperrin) on Twitter.
* Contact me as well if you want to add some of your examples to this repo (or simply do a pull request).
| 0 |
sdaschner/coffee-testing | Code examples for effective enterprise testing | null | null | 0 |
Syncleus/aparapi-examples | A framework for executing native Java code on the GPU. | null | 
[](http://www.apache.org/licenses/LICENSE-2.0.html)
[](https://maven-badges.herokuapp.com/maven-central/com.aparapi/aparapi-examples/)
[](https://gitter.im/Syncleus/aparapi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A framework for executing native Java code on the GPU.
**Licensed under the Apache Software License v2**
This project is a collection of examples for the Aparapi project. For more information see the Aparapi [website](http://Aparapi.com) or the [QOTO GitLab repository](https://git.qoto.org/aparapi/aparapi-examples). An up-to-date mirror of this repository is also maintained on [Github](https://github.com/Syncleus/aparapi-examples).
For detailed documentation see [Aparapi.com](http://Aparapi.com).
For support please use [Gitter](https://gitter.im/Syncleus/aparapi) or the [official Aparapi mailing list and Discourse forum](https://discourse.qoto.org/c/PROJ/APA).
Please file bugs and feature requests at [QOTO GitLab](https://git.qoto.org/aparapi/aparapi-examples); a mirror of older issues can be found at [Github](https://github.com/Syncleus/aparapi-examples/issues).
## Prerequisites
The examples should run on any system as-is. For GPU acceleration support you must have OpenCL installed and a compatible graphics card.
**Aparapi runs on all operating systems and platforms, however GPU acceleration support is currently provided for the following platforms: Windows 64bit, Windows 32bit, Mac OSX 64bit, Linux 64bit, and Linux 32bit.**
## Obtaining the Source
The official source repository for Aparapi Examples is located in the Syncleus Github repository and can be cloned using the
following command.
```bash
git clone https://git.qoto.org/aparapi/aparapi-examples.git
```
## Running
To run the examples simply checkout the git tag for the version you want to run and execute it through maven. Unless you
specifically want to try the latest snapshot it is important you checkout a specific git tag instead of the master
branch. To use the snapshot in the master branch you will have to manually install the core aparapi snapshot that
matches it since snapshots do not appear in maven central.
```bash
git checkout v3.0.0
mvn clean package exec:java
```
| 0 |
F4bwDP6a6W/spring-mvc-mini | Spring MVC Example Project, light weight, no Database | null | Spring-mvc-mini是一个完整的,轻量、简单的Java项目,基于Spring MVC.
里面有基本的增删改查的功能。而且无需修改任何内容,就可以直接跑起来。
另外我有一个Spring MVC的RESTful项目,数据库是Mysql,请参看:https://github.com/hot13399/spring-mvc-REST
-------------------
在这个项目里主要实现了以下技术:
* spring-webmvc
* svnkit
* jgit
* javax.mail
* jasypt
* dom4j
* spring scheduler
如何运行:
-------------------
在Windows的CMD:
$ cd spring-mvc-mini
$ mvn tomcat7:run [-Dmaven.tomcat.port=<port no.>] (In case 8080 is busy]
通过浏览器打开:http://localhost:8080/spring-mvc-mini
如果你想要学习或贡献和这个项目:
就通过maven把它build成一个IDE项目,执行以下命令,打开CMD:
$ cd spring-mvc-mini
$ mvn eclipse:eclipse or mvn idea:idea
通过Eclipse或IDEA导入即可。
Note:
-------------------
如果你要在Linux环境运行,以下的文件需要修改。
$ spring-oss-mini\src\main\webapp\WEB-INF\spring\appServlet\servlet-context.xml:<context:property-placeholder
$ location="file:/opt/web/spring-mvc-mini/resources/application.properties"/>
$ spring-oss-mini\src\main\resources\logback.xml
$ spring-oss-mini\resources\application.properties
最后通过Maven build一个war包部署即可。
--------------------
Spring-mvc-mini is a mini project using Spring MVC.
In this project, you can see the code of:
* spring-webmvc
* svnkit
* javax.mail
* jasypt
* dom4j
* spring scheduler
To run the application:
From the command line with Maven:
$ cd spring-mvc-mini
$ mvn tomcat7:run [-Dmaven.tomcat.port=<port no.>] (In case 8080 is busy]
Access the deployed web application at: http://localhost:8080/spring-mvc-mini
To contribute to this project:
In your preferred IDE such as Eclipse:
$ cd spring-mvc-mini
$ mvn eclipse:eclipse
Import spring-mvc-mini as a Maven Project
If you want to deploy this project to Linux server, you might need to edit conf files:
$ spring-oss-mini\src\main\webapp\WEB-INF\spring\appServlet\servlet-context.xml:<context:property-placeholder
$ location="file:/opt/web/spring-mvc-mini/resources/application.properties"/>
$ spring-oss-mini\src\main\resources\logback.xml
$ spring-oss-mini\resources\application.properties
| 1 |
kousen/mockito-hamcrest | Examples for Mockito and Hamcrest Matchers course | null | # mockito-hamcrest
Examples for Mockito and Hamcrest Matchers course
| 0 |
asc-lab/java-cqrs-intro | Examples of implementation CQRS with Event Sourcing - evolutionary approach | cqrs java-11 | # CQRS and Event Sourcing Intro for Developers
We live in a world of dynamically changing technologies. New ways of architecturing our solutions, new frameworks and libraries seem to appear on almost daily basis.
**But good software engineering is not about fancy frameworks and solutions aggressively promoted by their vendors.** It is not about doing something because Netflix or Google did it. It is about taking well-thought-out decisions based on facts and knowledge. That’s why it is important to be familiar basic architectural concepts like CQRS. It is one of the tools we use in our software house every day. We mentioned CQRS in the article which is part of the series about [Microservices on .NET Core](https://altkomsoftware.pl/en/blog/building-microservices-on-net-core-1/), but it was presented from technical perspective and here we want to focus on basics concepts explanation with visualisation and examples.
[Check our article!](https://altkomsoftware.pl/en/blog/cqrs-event-sourcing/)
## No CQRS
<p align="center">
<img alt="No CQRS" src="https://raw.githubusercontent.com/asc-lab/java-cqrs-intro/master/readme-images/1_no_cqrs.png" />
</p>
## Separate Commands and Queries
<p align="center">
<img alt="Separate Commands and Queries" src="https://raw.githubusercontent.com/asc-lab/java-cqrs-intro/master/readme-images/2_separe_commands_queries.png" />
</p>
## Separate Models Commands and Queries
<p align="center">
<img alt="Separate Models Commands and Queries" src="https://raw.githubusercontent.com/asc-lab/java-cqrs-intro/master/readme-images/3_separate_models_commands_queries.png" />
</p>
## Separate Storage Engines
<p align="center">
<img alt="Separate Storage Engines" src="https://raw.githubusercontent.com/asc-lab/java-cqrs-intro/master/readme-images/4_separate_storage_engines.png" />
</p>
## Event Sourcing
<p align="center">
<img alt="Event Sourcing" src="https://raw.githubusercontent.com/asc-lab/java-cqrs-intro/master/readme-images/5_event_sourcing.png" />
</p>
| 0 |
nitsanw/jmh-samples | JMH examples with my own examples + jar etc | null | jmh-samples
===========
<b>NOTE: As of 15/06/2013 the jar/samples were up to date. JMH has come a long way since and is much easier to play with.<br/>
I have now removed the old jar/samples and use the maven hosted dependency instead.<br/></b>
JMH samples.<br/>
This was setup to support my 2 blog posts about JMH:<br/>
http://psy-lob-saw.blogspot.com/2013/05/using-jmh-to-benchmark-multi-threaded.html<br/>
http://psy-lob-saw.blogspot.com/2013/04/writing-java-micro-benchmarks-with-jmh.html<br/>
And contains the examples discussed under the psy.lob.saw package.<br/>
The JMH framework is hosted here: http://openjdk.java.net/projects/code-tools/jmh/<br/>
The JMH samples are a MUST read (and are always up to date): http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/<br/>
| 0 |
camunda-community-hub/camunda-8-examples | null | camunda-8 | [](https://github.com/camunda-community-hub/community)
# Camunda 8 Examples
A collection of examples related to the usage of Camunda 8.
## Table of Contents
1. **[Async Service Task Example](async-service-task/README.md)** : Implementation of an asynchronous service task with handling for an asynchronous service call.
2. **[Multi-instance Processing of a (Very) Large Sequence](large-multi-instance-example/README.md)** : Example demonstrating the processing of a very large sequence of entities using multi-instance subprocesses.
3. **[Payment Example Process Application](payment-example-process-application/README.md)** : Example of a process application containing a payment process and the required workers, forms, and dummy services.
- **Deployment Example on Kubernetes**: [Available](payment-example-process-application/kube/README.md)
4. **[Integrate Camunda 8 with Microsoft PowerApps Dataverse](powerapps-dataverse/README.md)** : Guide for connecting the Camunda 8 REST Connector to Microsoft PowerApps Dataverse via OAuth2 to query data from tables.
5. **[Rollback on Error Example](rollback-on-error-example/README.md)** : Example of rollback on error in a process where two actions need to be executed synchronously.
6. **[Example for synchronous responses from processes](synchronous-response-springboot/README.md)** : Example of synchronous response from Camunda 8 processes.
7. **[Timer Testing](timer-testing/README.md)** : Example demonstrating how to test timers in Zeebe.
8. **[Pyzeebe & Connectors Example](weatherinfo-pyzeebe-connectors/README.md)** : Project containing a process, user form, Python worker using the pyzeebe client, and a custom worker template.
9. **[Zeebe Java Client Examples](zeebe-client-plain-java/README.md)** : Maven project containing several examples using the Zeebe Java client.
## How to use
Check out the repo. Navigate to the project you are interested in. Each project should contain:
* an introduction to the purpose
* a brief description of the functionality
* a guide on how to setup and test the example
## Report problems
If problems occur, please file an issue containing:
* which project should be used
* what did not work out
* which environment was used (java version, build tool, ...)
| 0 |
cirosantilli/java-cheat | Java minimal examples. Asserts used wherever possible. Cheatsheets, tutorials. | null | # Java Cheat 
[](https://travis-ci.org/cirosantilli/java-cheat)
Java minimal examples. Asserts used wherever possible.
1. [Getting started](getting-started.md)
1. Code
1. [Main.java](Main.java)
1. [Hello world](HelloWorld.java)
1. Language
1. Types
1. Floating point
1. [NaN](Nan.java)
1. [Array](ArrayCheat.java)
1. Classes
1. [Constructor](ConstructorCheat.java)
1. [super](SuperCheat.java)
1. [Nested class](NestedClassCheat.java)
1. [Generics](GenericsCheat.java)
1. Branching
1. [Exceptions](ExceptionCheat.java)
1. Standard library
1. [Collection](CollectionCheat.java)
1. [Collections](CollectionsCheat.java)
1. [List](ListCheat.java)
1. [Map](MapCheat.java)
1. [StringBuilder](StringBuilderCheat.java)
1. Streams
1. [BufferedReader](BufferedReaderCheat.java)
1. lang
1. [String](StringCheat.java)
1. [Wrappers](WrappersCheat.java)
1. [Integer pool](IntegerPoolCheat.java)
1. [interactive](interactive/)
1. [Binary compatibility](binary-compatibility/)
1. [ClassNotFoundException](class-not-found/)
1. [JNI](jni/)
1. [WatchService](watch-service/)
1. [instrument](instrument/)
1. Introduction
1. [Standards](standards.md)
1. [Versions](versions.md)
1. [Implementations](implementations.md)
1. [OpenJDK](openjdk.md)
1. [Classpath](classpath.md)
1. [Style guides](style-guides.md)
1. Tools
1. [java utility](java-utility.md)
1. [Javadoc](javadoc/)
1. [javac](javac/)
1. [JAR](jar.md)
1. [JVM](jvm.md)
1. [Bytecode](bytecode.md)
1. Third party
1. [JUnit](junit/)
1. Build tools
1. [Maven](maven/)
1. [Ant](ant.md)
1. [Gradle](gradle.md)
1. [Tomcat](tomcat.md)
1. [update-java-alternatives](update-java-alternatives.md)
1. [Bibliography](bibliography.md)
## WIP
1. Code
1. [Java 8](java8/)
1. [JMX](jmx.md)
1. Tools
1. [jconsole](jconsole.md)
1. [JAVA_HOME](java-home.md)
1. [JDB](jdb.md)
1. [javap](javap.md)
1. Third party
1. [Spring](spring/)
1. [Jasmin](jasmin/)
1. [Java Decompiler](java-decompiler.md)
1. [Mockito](mockito/)
1. [Formal verification](formal-verification.md)
| 0 |
codecentric/java8-examples | Some examples for the features introduced in Java 8 | null | This repository contains some examples for the new features introuced in Java 8, such as:
* Default Methods
* Method References
* Lambdas
* Streaming API
* Time API (JSR-310)
You can get Java 8 from www.jdk8.java.net/download.html
IDE-Support with Spring Tool Suite
* Download STS 3.4.0 http://spring.io/tools/sts/all
* Install Java 8 Support via Update Site http://dist.springsource.com/snapshot/TOOLS/java8/e43 | 0 |
waylife/DemoCollections | Some demos, examples | null | null | 0 |
afsalashyana/JavaFX-Tutorial-Codes | General program examples that I use for tutorials in 'GenuineCoder' YouTube channel | demo demo-app excercises genuine tutorial tutorial-code | # Genuine Coder Tutorial Code Collection
This repository contains general program examples that I use for my tutorial videos and blogs.
## [YouTube Tutorials](https://www.youtube.com/channel/UCCXbhmjID-T2I0KfuDPbi6A)
### [JavaFX Scene Transition](https://youtu.be/cqskg3DYH8g)
Tutorial about JavaFX scene transition with slide effect.
<p align="left">
<img height=300 src=https://i.imgur.com/gxk3XU9.gif>
</p>
### [JavaFX Navigation Drawer](https://youtu.be/tgV8dDP9DtM)
JavaFX navigation drawer using JFXDrawer component from JFoenix library.
<p align="left">
<img height=300 src=https://i.imgur.com/hpLZYDT.gif>
</p>
### [Ikonli with Java Swing](https://youtu.be/VHGxY-aR0ws)
Creating dynamic icons in Java Swing with Ikonli library.
<p align="left">
<img height=300 src=https://i.imgur.com/dbwteVM.png>
</p>
### [JavaFX Circular Scene Transition](https://youtu.be/cIrCNl02lDc)
Tutorial about JavaFX scene transition with circular-reveal effect.
<p align="left">
<img height=450 src=.gif/JavaFXCircularReveal.gif>
</p>
### [JavaFX Custom Shape Buttons](https://youtu.be/QsQQ5D4TARw)
Creating JavaFX components with custom shapes.
<p align="left">
<img height=300 src=https://i.imgur.com/qIQBO5m.gif>
</p>
### [JavaFX Observable](https://youtu.be/JaqExzdJhEI)
Example of using JavaFX Observable and Bindings
<p align="left">
<img height=300 src=https://i.imgur.com/oXI5Qnq.gif>
</p>
### [JavaFX Calculator](https://youtu.be/r1qowt6yYm8)
Sample JavaFX calculator with CSS styling
<p align="left">
<img height=300 src=https://i.imgur.com/WVcMqsg.gif>
</p>
### [Java Swing Text Editor](http://www.genuinecoder.com/text-editor-java-with-source-notepad-html/)
Java swing based basic text editor
<p align="left">
<img height=300 src=https://i.imgur.com/qiboR4J.gif>
</p>
### [Java Sorting Animation](https://youtu.be/Slo18MgCWYY)
Sorting algorithm execution animation using JavaFX charts
<p align="left">
<img height=300 src=https://i.imgur.com/s8yJdiY.gif>
</p>
### JavaFX Self Writing Letter
Realtime letter writing animation using JavaFX
<p align="left">
<img height=300 src=https://i.imgur.com/Rmv16MK.gif>
</p>
### [JavaFX Background Task](https://youtu.be/pdRX6CLP0tM)
Tutorial about JavaFX background tasks to asynchronously execute business logic in the background thread.
<p align="left">
<img height=200 src=.gif/JavaFXBackgroundTask.gif>
</p>
## [JavaFX Blog Posts](https://genuinecoder.com/category/javafx/)
* [JavaFX Image Button Tutorial](https://genuinecoder.com/javafx-image-button-tutorial/)
* [JavaFX ObservableList Tutorial](https://genuinecoder.com/javafx-observable-list-tutorial/)
* [JavaFX CheckComboBox Tutorial](https://genuinecoder.com/javafx-checkcombobox-with-example/)
* [JavaFX Custom Shaped Buttons](https://genuinecoder.com/javafx-buttons-with-custom-shape/)
* [JavaFX DatePicker Tutorial](https://genuinecoder.com/javafx-datepicker-tutorial-with-date-formatting-and-css-styling/)
* [JavaFX Stage Icons](https://genuinecoder.com/javafx-application-icon-setup/)
* [JavaFX 3D Tutorial](https://genuinecoder.com/javafx-3d/)
* [JavaFX Communication between FXML Controllers](https://genuinecoder.com/javafx-communication-between-controllers/)
* [JavaFX Splash Screen](https://genuinecoder.com/javafx-splash-screen-loading-screen/)
* [JavaFX Animation Tutorial with Examples](https://genuinecoder.com/javafx-animation-tutorial/)
* [Custom Shapes for JavaFX Components](https://genuinecoder.com/custom-shapes-for-javafx-ui-components/)
* [JavaFX Scene Builder Tutorial](https://genuinecoder.com/javafx-scene-builder-tutorial-for-beginners/)
* [JavaFX Observables and Bindings](https://genuinecoder.com/javafx-observables-and-bindings/)
* [JavaFX Get Screen Size Programmatically](https://genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/)
* [JavaFX Scene Switching Animation](https://genuinecoder.com/javafx-scene-switch-change-animation/)
* [JavaFX FileChooser for Saving File](https://genuinecoder.com/save-files-javafx-filechooser/)
* [Library Management System Development Tutorial using JavaFX](https://genuinecoder.com/javafx-complete-project-tutorial-library-management-system-html/)
## [Java Blog Posts](https://genuinecoder.com/category/java/)
* [Create Animated GIF from still images in Java](https://genuinecoder.com/how-to-create-gif-from-multiple-images-in-java/)
* [Create Excel Spreadsheet in Java](https://genuinecoder.com/how-to-create-excel-xlsx-spreadsheet-files-in-java/)
* [Java with WebP images](https://genuinecoder.com/java-webp-image-read-save-tutorial/)
* [Open Native File Explorer with Java](https://genuinecoder.com/how-to-open-file-explorer-in-java/)
* [Java/JavaFX TrayIcon Tutorial](https://genuinecoder.com/java-trayicon-tutorial-with-popupmenu-and-images/)
* [Downloading a file from Spring Boot Controller](https://genuinecoder.com/downloading-a-file-from-spring-controller-with-spring-boot/)
* [Make EXE from Java JAR](https://genuinecoder.com/convert-java-jar-to-exe/)
| 0 |
aspose-slides/Aspose.Slides-for-Java | Aspose.Slides for Java Examples | null |  
# Java PowerPoint API
[Aspose.Slides](https://products.aspose.com/slides/java) a Java PowerPoint API for presentation manipulation and management. It allows developers to read, write, convert and manipulate PowerPoint presentations in Java applications with the ability to manipulate all document elements such as slides, tables, text, charts, shapes, images and SmartArt diagrams and more.
<p align="center">
<a title="Download complete Aspose.Slides for Java source code" href="https://github.com/asposeslides/Aspose_Slides_Java/archive/master.zip">
<img src="https://raw.github.com/AsposeExamples/java-examples-dashboard/master/images/downloadZip-Button-Large.png" />
</a>
</p>
Directory | Description
--------- | -----------
[Examples](https://github.com/aspose-slides/Aspose.Slides-for-Java/tree/master/Examples) | A collection of Java examples that help you learn how to use product features.
[Plugins](https://github.com/aspose-slides/Aspose.Slides-for-Java/tree/master/Plugins) | Plugins to help integrate Aspose.Slides for Java in different environments.
## PowerPoint File Manipulation via Java
Checkout the [product overview](https://docs.aspose.com/slides/java/product-overview/) to know all about Aspose.Slides for Java.
- Load & convert presentations to other formats.
- Create presentations from scratch.
- Manipulate all of presentation elements via intuitive object model.
- Create or embed charts.
- Create or manipulate shapes.
## Read & Write Presentations
**Microsoft PowerPoint:** PPT, PPTX, PPS, POT, PPSX, PPTM, PPSM, POTX, POTM\
**OpenOffice:** ODP, OTP
## Save Presentations As
**Fixed Layout:** PDF, PDF/A, XPS
**Image:** JPEG, PNG, BMP, TIFF, GIF, SVG
**Web:** HTML, SWF
## Supported Environments
- **Microsoft Windows:** Windows Desktop & Server (x86, x64)
- **macOS:** Mac OS X
- **Linux:** Ubuntu, OpenSUSE, CentOS, and others
- **Java Versions:** `J2SE 6.0 (1.6)` or above
## Get Started with Aspose.Slides for Java
Aspose hosts all Java APIs at the [Aspose Repository](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides). You can easily use Aspose.Slides for Java API directly in your Maven projects with simple configurations. For the detailed instructions please visit [Installing Aspose.Slides for Java from Maven Repository](https://docs.aspose.com/slides/java/installation/) documentation page.
## Convert Presentation to PDF
```java
// instantiate a Presentation object that represents a presentation file
Presentation pres = new Presentation("demo.pptx");
try {
// save the presentation to PDF with default options
pres.save("output.pdf", SaveFormat.Pdf);
} finally {
if (pres != null) pres.dispose();
}
```
## Create Presentation from Scratch
```java
// instantiate Presentation
Presentation pres = new Presentation();
try {
// get the first slide
ISlide sld = (ISlide) pres.getSlides().get_Item(0);
// add an AutoShape of Rectangle type
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// add ITextFrame to the Rectangle
ashp.addTextFrame("Hello World");
// change the text color to Black (which is White by default)
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.setFillType(FillType.Solid);
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat()
.getSolidFillColor().setColor(java.awt.Color.BLACK);
// change the line color of the rectangle to White
ashp.getShapeStyle().getLineColor().setColor(java.awt.Color.WHITE);
// remove any fill formatting in the shape
ashp.getFillFormat().setFillType(FillType.NoFill);
// save the presentation to disk
pres.save("output.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
```
[Home](https://www.aspose.com/) | [Product Page](https://products.aspose.com/slides/java) | [Docs](https://docs.aspose.com/slides/java/) | [Demos](https://products.aspose.app/slides/family) | [API Reference](https://apireference.aspose.com/slides/java) | [Examples](https://github.com/aspose-slides/Aspose.Slides-for-Java) | [Blog](https://blog.aspose.com/category/slides/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/slides) | [Temporary License](https://purchase.aspose.com/temporary-license)
| 0 |
openzipkin/brave-example | A collection of examples how to use brave instrumentation in various frameworks and libraries. | brave distributed-tracing openzipkin zipkin | # Basic example showing distributed tracing across Java applications
This is an example app where two Java services collaborate on a request.
Notably, these services send data to [Zipkin](https://zipkin.io/), a
distributed tracing system. Zipkin allows you to see the how long the operation
took, as well how much time was spent in each service.
Here's an example of what it looks like:
<img width="979" alt="zipkin screen shot" src="https://user-images.githubusercontent.com/64215/95572045-f98cfb80-0a5b-11eb-9d3b-9a1b9b1db6b4.png">
# Implementation Overview
This example has two services: frontend and backend. Both are [instrumented](https://github.com/openzipkin/brave/tree/master/instrumentation)
to send tracing data to a third service [Zipkin](https://zipkin.io/). [Brave](https://github.com/openzipkin/brave)
performs this function.
# Running the example
To setup the demo, you need to start Frontend, Backend and Zipkin. You can do
this using Java commands or Docker.
Once the services start, open http://localhost:8081/
* This calls the backend (http://127.0.0.1:9000/api) and shows its result: a formatted date.
Afterward, you can view traces that went through the backend via http://127.0.0.1:9411/zipkin?serviceName=backend
* This is a locally run zipkin service which keeps traces in memory
## Tips
There are some interesting details that apply to all examples:
* If you pass the header `user_name` Brave will automatically propagate it to the backend!
* `curl -s localhost:8081 -H'user_name: JC'`
* The below Logback pattern adds trace and span identifiers into log output
* `%d{HH:mm:ss.SSS} [%thread] [%X{userName}] [%X{traceId}/%X{spanId}] %-5level %logger{36} - %msg%n`
## Example projects
Here are the example projects you can try:
* [armeria](armeria) `BRAVE_EXAMPLE=armeria docker-compose up`
* Runtime: Armeria, SLF4J 1.7, JRE 21
* Trace Instrumentation: [Armeria](https://armeria.dev/), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](armeria/src/main/java/brave/example/HttpTracingFactory.java)
* You can also use Eureka discovery like this:
* `BRAVE_EXAMPLE=armeria docker-compose -f docker-compose.yml -f docker-compose-eureka.yml up`
* [armeria-kafka](armeria-kafka) `BRAVE_EXAMPLE=armeria-kafka docker-compose -f docker-compose.yml -f docker-compose-kafka.yml up`
* Runtime: Armeria, Kafka Clients and Streams 2.7, SLF4J 1.7, JRE 21
* Trace Instrumentation: [Armeria](https://armeria.dev/), [Kafka Clients](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-clients), [Kafka Streams](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-streams), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](armeria/src/main/java/brave/example/HttpTracingFactory.java)
* [jersey2-cassandra3](jersey2-cassandra3) `BRAVE_EXAMPLE=jersey2-cassandra3 docker-compose up`
* Runtime: JaxRS 2, Jersey 2, DataStax Java Driver 3, Apache Cassandra 4, SLF4J 1, JRE 8
* Trace Instrumentation: [Jersey Server](https://github.com/openzipkin/brave/tree/master/instrumentation/jersey-server), [DataStax Java Driver](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra-driver), [Apache Cassandra](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [XML](jersey2-cassandra3/src/main/webapp/WEB-INF/tracing.xml)
* [netty4-grpc](netty4-grpc) `BRAVE_EXAMPLE=netty4-grpc docker-compose up`
* Runtime: Netty 4.1, Google gRPC 1.34 , SLF4J 1.7, JRE 21
* Trace Instrumentation: [Netty Codec HTTP](https://github.com/openzipkin/brave/tree/master/instrumentation/netty-codec-http), [Google gRPC](https://github.com/openzipkin/brave/tree/master/instrumentation/grpc), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](netty4-grpc/src/main/java/brave/example/TracingConfiguration.java)
* [webflux5-sleuth](webflux5-sleuth) `BRAVE_EXAMPLE=webflux5-sleuth docker-compose up`
* Runtime: Spring 5, Reactor Netty 0.9, Spring Boot 2.3, Spring Cloud Sleuth 2.2, Log4J 2.13, JRE 21
* Trace Instrumentation: [WebFlux Server](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFilter.java), [WebFlux Client](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientBeanPostProcessor.java), [Reactor Context](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/reactor/ScopePassingSpanSubscriber.java), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Spring Cloud Sleuth](https://github.com/spring-cloud/spring-cloud-sleuth/tree/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig) [Properties](webflux5-sleuth/src/main/resources/application.properties)
* You can also use Eureka discovery like this:
* `BRAVE_EXAMPLE=webflux5-sleuth docker-compose -f docker-compose.yml -f docker-compose-eureka.yml up`
* [webflux6-micrometer](webflux6-micrometer) `BRAVE_EXAMPLE=webflux6-micrometer docker-compose up`
* Runtime: Spring 6, Reactor Netty, Spring Boot 3, Micrometer, Log4J 2, JRE 21
* Trace Configuration: [Spring Boot Actuator](https://github.com/spring-projects/spring-boot/blob/3.2.x/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java)
* [webmvc25-jetty](webmvc25-jetty) `BRAVE_EXAMPLE=webmvc25-jetty docker-compose up`
* Runtime: Spring 2.5, Apache HttpClient 4.3, Servlet 2.5, Jetty 7.6, Log4J 1.2, JRE 6
* Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Apache HttpClient](https://github.com/openzipkin/brave/tree/master/instrumentation/httpclient), [Log4J 1.2](https://github.com/openzipkin/brave/tree/master/context/log4j12)
* Trace Configuration: [Brave Spring Beans](https://github.com/openzipkin/brave/tree/master/spring-beans#configuration) [XML](webmvc25-jetty/src/main/webapp/WEB-INF/applicationContext.xml)
* [webmvc3-jetty](webmvc3-jetty) `BRAVE_EXAMPLE=webmvc3-jetty docker-compose up`
* Runtime: Spring 3.2, Apache HttpClient 4.3, Servlet 3.0, Jetty 8.1, Log4J 1.2, JRE 7
* Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [Apache HttpClient](https://github.com/openzipkin/brave/tree/master/instrumentation/httpclient), [Log4J 1.2](https://github.com/openzipkin/brave/tree/master/context/log4j12)
* Trace Configuration: [Brave Spring Beans](https://github.com/openzipkin/brave/tree/master/spring-beans#configuration) [XML](webmvc3-jetty/src/main/webapp/WEB-INF/applicationContext.xml)
* [webmvc4-jetty](webmvc4-jetty) `BRAVE_EXAMPLE=webmvc4-jetty docker-compose up`
* Runtime: Spring 4.3, OkHttp 3.12, Jetty 9.2, Servlet 3.1, SLF4J 1.7, JRE 8
* Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [OkHttp](https://github.com/openzipkin/brave/tree/master/instrumentation/okhttp3), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Spring Java Config](webmvc4-jetty/src/main/java/brave/example/TracingConfiguration.java)
* [webmvc4-boot](webmvc4-boot) `BRAVE_EXAMPLE=webmvc4-boot docker-compose up`
* Runtime: Spring 4.3, OkHttp 3.14, Spring Boot 1.5, Servlet 3.1, Jetty 9.4, SLF4J 1.7, JRE 8
* Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [OkHttp](https://github.com/openzipkin/brave/tree/master/instrumentation/okhttp3), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)
* Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Spring Boot AutoConfiguration](webmvc4-boot/src/main/java/brave/example/TracingAutoConfiguration.java)
## Starting the services with Docker
[Docker Compose](https://docs.docker.com/compose/) is the easiest way to start.
Just run `docker-compose up`.
Armeria starts by default. To use a different version of the project, set the `VERSION` variable.
Ex. `VERSION=webmvc25-jetty docker-compose up`
## Starting the services from source
When not using Docker, you'll need to start services according to the frameworks used.
First, start [Zipkin](https://zipkin.io/). This stores and queries traces
reported by the example services.
Starting Zipkin with Java:
```bash
curl -sSL https://zipkin.io/quickstart.sh | bash -s
java -jar zipkin.jar
```
### Java
In a separate tab or window, start each of `brave.example.Frontend` and `brave.example.Backend`.
Ex.
```bash
$ cd armeria
$ mvn compile exec:java -Dexec.mainClass=brave.example.Backend
$ mvn compile exec:java -Dexec.mainClass=brave.example.Frontend
```
### Servlet
In a separate tab or window, start a Jetty container for "backend" and "frontend".
Ex.
```bash
$ cd webmvc4-jetty
$ mvn jetty:run -Pfrontend
$ mvn jetty:run -Pbackend
```
| 0 |
realwear/Developer-Examples | This repository contains a number of examples with full documentation to help developers create applications for the HMT-1 | null |
## Introduction
The code in the Developer Examples app provide clear explanations of how to use the key features that the HMT-1 provides.
Some of the techniques use standard Android practices and are documented here to show common solutions for the HMT-1. Others techniques are unique to the HMT-1 and allow a developer to take advantage of the full WearHF system.
## [Tutorial](https://realwear.github.io/Developer-Examples/tutorial)
The following tutorial shows how to use the Developer Examples app.
## [Release Notes](https://realwear.github.io/Developer-Examples/release-notes)
The release notes are available to show all the changes for each version of the Developer Examples app.
| 0 |
serezhka/java-airplay-server-examples | null | null | # java-airplay-server-examples
[](https://github.com/serezhka/java-airplay-server-examples/actions/workflows/build.yaml)

[](http://opensource.org/licenses/MIT)
#### <br><br><br> 14.12.2022: Check out new java-airplay project: https://github.com/serezhka/java-airplay <br><br><br>
All examples were tested with iPhone X (iOS 14.0.1)
## gstreamer-player
09.06.2022 supports both video and audio (alac + aac_eld)
Gstreamer installation required (see https://github.com/gstreamer-java/gst1-java-core)
<details>
<summary>video demo</summary>
https://user-images.githubusercontent.com/476359/173236828-204a64c0-54da-4020-93c7-2987c4f9301c.mp4
</details>
TODO description
## tcp-forwarder
Forwards video and audio data to TCP
Play it with [GStreamer](https://gstreamer.freedesktop.org/) or [FFmpeg](https://www.ffmpeg.org/)
```Shell
cd tcp-forwarder/
gradle bootRun
gst-launch-1.0 -v tcpclientsrc port=5002 ! h264parse ! avdec_h264 ! autovideosink
or
ffplay -f h264 -codec:v h264 -i tcp://localhost:5002 -v debug
ffplay -autoexit -f s16le -ar 44100 -ac 2 tcp://localhost:5003
```
You need to compile [lib-fdk-aac](https://github.com/serezhka/fdk-aac-jni) for aac-eld decoding
<details>
<summary>gif demo</summary>
<img src="https://github.com/serezhka/java-airplay-server-examples/blob/media/gstreamer_playback.gif" width="600">
</details>
## h264-dump
Saves video data stream to .h264 file, decoded audio to .pcm file
```Shell
cd h264-dump/
gradle bootRun
ffplay -autoexit -f s16le -ar 44100 -ac 2 dump.pcm
```
You need to compile [lib-fdk-aac](https://github.com/serezhka/fdk-aac-jni) for aac-eld decoding
## vlcj-player
Playback screen mirroring in embedded vlc\
Install VLC (https://github.com/caprica/vlcj)
```Shell
cd vlcj-player/
gradle bootRun
```
<details>
<summary>gif demo</summary>
<img src="https://github.com/serezhka/java-airplay-server/blob/media/vlcj_player_demo.gif" width="600">
</details>
## jmuxer-player
Playback screen mirroring with [jmuxer](https://github.com/samirkumardas/jmuxer)
```Shell
cd vlcj-player/
gradle bootRun
```
open index-h264.html in browser
<details>
<summary>gif demo</summary>
<img src="https://github.com/serezhka/java-airplay-server/blob/media/jmuxer_player_demo.gif" width="600">
</details>
| 0 |
isaolmez/javabyexamples | Code examples for javabyexamples.com | null | # Java By Examples
Code examples for javabyexamples.com
| 0 |
CircleCI-Public/circleci-demo-java-spring | Example Java application running on CircleCI | circleci circleci-demos java | # CircleCI 2.0 Java Demo Application using Gradle and Spring [](https://circleci.com/gh/CircleCI-Public/circleci-demo-java-spring)
**Note:** This project is currently under substantial development to include additional use cases and show off more features of CircleCI.
If you are coming here form the [Java Language Guide](https://circleci.com/docs/2.0/language-java/#config-walkthrough) please follow along at [this revision](https://github.com/CircleCI-Public/circleci-demo-java-spring/tree/9dcdae5e2988b207e0ac9b6bb9cf8ed711fba4ad) before major changes began to take place.
This message will be removed once the CircleCI documentation matches this repository again.
---
This is an example application showcasing how to run a Java app on CircleCI 2.0.
This application uses the following tools:
* Gradle
* Java 11
* PostgreSQL
* Spring Boot
* Thymeleaf
You can follow along with this project by reading the [documentation](https://circleci.com/docs/2.0/language-java/).
An older version of this sample project that uses Maven is accessible [here](https://github.com/CircleCI-Public/circleci-demo-java-spring/tree/maven) though it is no longer being actively maintained.
## Local Development
### Starting the application
```
./gradlew bootRunDev
```
Navigate to http://localhost:8080

We use the [H2 Database](https://www.h2database.com/html/main.html) in memory for
local development. You can access the datbase UI at [http://localhost:8080/h2-console](http://localhost:8080/h2-console)
with the following credentials.
```
username: `sa`
password: `password`
JDBC URL: jdbc:h2:mem:testdb
```
## License
Copyright © 2019 CircleCI
Distributed under the MIT license, see the file LICENSE.
| 1 |
szaza/tensorflow-java-examples-spring | Tensorflow Java tutorial with Spring and Gradle. This is a simple example application, which uses Yolo with TF Java API and Spring Framework. | java spring tensorflow tutorial | # TensorFlow Java tutorial with Spring Framework and Gradle
Object detection server side application sample program written in Java. It uses the TensorFlow Java API with a trained YOLOv2 model. The server application is implemented with Spring Framework and it is built by Gradle.
#### How it works?
It provides a web user interface to upload images and detect objects.
<img src="https://github.com/szaza/java-tensorflow-spring/blob/master/sample/home-page.jpg" alt="TensorFlow Java API home page" title="TensorFlow Java API home page" width="600"/><br/>
Step1: upload your image
<img src="https://github.com/szaza/java-tensorflow-spring/blob/master/sample/object-detection-page.jpg" alt="TensorFlow Java API object detection page" title="TensorFlow Java API object detection page" width="600"/><br/>Step2: display the recognized objects
#### Compile and run
Preconditions:
- Java JDK 1.8 or greater;
- TensorFlow 1.6 or grater;
- Git version control system;
Strongly recommended to install:
- nVidia CUDA Toolkit 8.0 or higher version;
- nVidia cuDNN GPU accelerated deep learning framework;
**Download the frozen graph and the label file**
Before compiling the source code you have to place the frozen graph and the label file into the `./graph/YOLO` directory. Download one of my graphs from my [google drive](https://drive.google.com/drive/folders/1GfS1Yle7Xari1tRUEi2EDYedFteAOaoN). There are two graphs: tiny-yolo-voc.pb and yolo-voc.pb. The tiny-yolo.pb has a lower size, however it is less accurate than the yolo-voc.pb. Modify the [application.yml](https://github.com/szaza/tensorflow-java-examples-spring/blob/master/src/main/resources/application.yml) configuration file if it is necessary. Here you can increase the file upload limit also.
**Compile with Gradle**
Compile the code by typing `./gradlew clean build` in the terminal window.<br/>
Run it with the command `./gradlew bootRun`
Open the [http://localhost:8080](http://localhost:8080) and you should see the webpage.<br/>
#### Demo application
Deployed to **Heroku** with a tiny-yolo model: https://still-crag-64816.herokuapp.com/
Have a look at my previous project for better understanding of the object detection part: [Tensorflow Java API example application](https://github.com/szaza/tensorflow-example-java) or visit my site: https://sites.google.com/view/tensorflow-example-java-api.
## News about YoloV3 support
The current solution doesn't support the YoloV3 model and unfortunately, I do not have time to implement it, however I would be very happy if I could help to implement and I could review a PR with this feture.
For this reason I've started a new branch here: https://github.com/szaza/tensorflow-java-examples-spring/tree/feature/add-yolov3-support; If you are interested in this feature and you would like to be a collabortor, please add a comment for this thread: https://github.com/szaza/tensorflow-java-examples-spring/issues/2;
Many-many thank for any support!
| 1 |
jboss-developer/jboss-eap-quickstarts | The quickstarts demonstrate JBoss EAP, Jakarta EE 10 and a few additional technologies. They provide small, specific, working examples that can be used as a reference for your own project. | null | null | 0 |
coyarzun89/FabTransitionActivity | Example of fab animation | null | # FabTransitionActivity
[](https://android-arsenal.com/details/1/2763)
It is based on [FabTransitionLayout](https://github.com/bowyer-app/FabTransitionLayout)

Warning: The new version 0.2.0 have minSdkVersion 15 because the [CircularReveal](https://github.com/ozodrukh/CircularReveal) project has moved from 14 to 15
Usage
====
### build.gradle
```
//this is very important, don't forget it
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
}
defaultConfig {
minSdkVersion 15
}
dependencies {
compile 'com.github.coyarzun89:fabtransitionactivity:0.2.0'
}
```
### Layout XML
```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_actionbar"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ToolBarStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
app:titleTextAppearance="@style/ToolbarTitle"
android:minHeight="56dp"
android:paddingLeft="36dp"
android:elevation="2dp" />
<ListView
android:id="@+id/list_mails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar_actionbar"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_edit_white_24dp"
app:borderWidth="0dp"
app:fabSize="normal"
app:rippleColor="@color/primary"/>
<com.github.fabtransitionactivity.SheetLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:ft_container_gravity="center"
app:ft_color="@color/primary"
android:elevation="2dp"/>
</RelativeLayout>
```
### Set up
```java
public class MainActivity extends BaseActivity implements SheetLayout.OnFabAnimationEndListener {
@Bind(R.id.bottom_sheet) SheetLayout mSheetLayout;
@Bind(R.id.fab) FloatingActionButton mFab;
private static final int REQUEST_CODE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mSheetLayout.setFab(mFab);
mSheetLayout.setFabAnimationEndListener(this);
}
@OnClick(R.id.fab)
void onFabClick() {
mSheetLayout.expandFab();
}
@Override
public void onFabAnimationEnd() {
Intent intent = new Intent(this, AfterFabAnimationActivity.class);
startActivityForResult(intent, REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE){
mSheetLayout.contractFab();
}
}
```
# Credits
This library use following libraries.
* [CircularReveal](https://github.com/ozodrukh/CircularReveal)
| 1 |
in28minutes/JavaTutorialForBeginners | Java Tutorial for Beginners with examples | java java-8 | # Title of the Best Course in the world
## Caption for the course.
* [Installing Eclipse, Maven and Java](#installing-tools)
* [Running Examples](#running-examples)
* [Course Overview](#course-overview)
- [Course Steps](#step-list)
- [Expectations](#expectations)
* [About in28Minutes](#about-in28minutes)
- [Our Beliefs](#our-beliefs)
- [Our Approach](#our-approach)
- [Find Us](#useful-links)
- [Other Courses](#other-courses)
## Getting Started
- Eclipse - https://courses.in28minutes.com/p/eclipse-tutorial-for-beginners
- Maven - https://courses.in28minutes.com/p/maven-tutorial-for-beginners-in-5-steps
- JUnit - https://courses.in28minutes.com/p/junit-tutorial-for-beginners
- Mockito - https://courses.in28minutes.com/p/mockito-for-beginner-in-5-steps
## Installing Tools
- PDF : https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf
- Video : https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3
- GIT Repository : https://github.com/in28minutes/getting-started-in-5-steps
## Running Examples
- Download the zip or clone the Git repository.
- Unzip the zip file (if you downloaded one)
- Open Command Prompt and Change directory (cd) to folder containing pom.xml
- Installation Video : https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3
- For help : use our installation guide - https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf
## Course Overview
- I'm Ranga Karanam. I've so and so much experience with ...
- In this course, You will learn the *** Framework step by step with (*** functionality) using (*** framework features)
- You will learn the basics like *** and move on to the advanced concepts like ***.
- You will use
- ... todo ...
- Maven for dependency management, building and running the application in tomcat.
- Eclipse IDE.
### Introduction
Developing your first application with XYZ Framework is fun.
Introduction to XYZ Framework..
In this course, you will learn the basics developing a Basic Todo Management Application using XYZ Framework.
You will build the application step by step - in more than 25 steps. This course would be a perfect first step as an introduction to XYZ Framework.
You will be using Spring (Dependency Management), Spring MVC, Spring Boot, Spring Security (Authentication and Authorization), BootStrap (Styling Pages), Maven (dependencies management), Eclipse (IDE) and Tomcat Embedded Web Server. We will help you set up each one of these.
You will learn about
- Topic No 1
- Topic No 1
- Topic No 1
- Topic No 1
- Topic No 1
### Step Wise Details
- Step 01: Learn to Dance
- Step 02:
- Step 03:
- Step 04:
- Step 05:
- Step 06:
- Step 07:
- Step 08:
- Step 09:
- Step 10:
- Step 11:
- Step 12:
- Step 13:
- Step 14:
- Step 15:
- Step 16:
- Step 17:
- Step 18:
- Step 19:
- Step 20:
- Step 21:
- Step 22:
- Step 23:
- Step 24:
- Step 25:
### Expectations
- You should know ***.
- You should know ***.
- You are NOT expected to have any experience with Eclipse,Maven or Tomcat.
- We will help you install Eclipse and get up and running with Maven and Tomcat.
## Let's have some fun
- What are we waiting for?
- Let's have some fun with *** in 25 Steps.
- I had fun creating this course and hope you would too.
- Thanks for your interest in Our Course
- I hope you’re as excited as I am!
- If you’re ready to learn more and sign up for the course,
- go ahead and hit that Enroll button,
- or take a test drive by using the Free Preview feature.
- See you in the course!
## Exercises
- TODO
## Future Things To Do
- TODO
## Conclusion
- Thats a lot of ground you have covered over the last so and so..
- To find out more about *** use these References
- I had fun creating this course and I'm sure you had some fun too.
- Good Luck and Bye from the team here at in28Minutes
- Do not forget to leave us a review.
## About in28Minutes
At in28Minutes, we ask ourselves one question everyday
> How do we create more amazing course experiences?
> We use 80-20 Rule. We discuss 20% things used 80% of time in depth.
We are creating amazing learning experiences for learning Spring Boot with AWS, Azure, GCP, Docker, Kubernetes and Full Stack. 300,000 Learners rely on our expertise. [Find out more.... ](https://github.com/in28minutes/learn#best-selling-courses)

| 1 |
tdziurko/Guava-Lessons | Various examples of usage Google Guava API. | null | null | 0 |
mianshenglee/my-example | example code for my article | null | # 1. 说明
在写文章过程中,经常会使用一些示例工程来辅助说明,本仓库用于存放一些示例工程,以便于读者可以参考。
# 2. 示例说明
## 2.1 java应用监测:`java-monitor-example`
用于[java监测技术文章](https://mianshenglee.github.io/)的示例说明,此示例是一个`spring boot`工程,里面包含简单的`controller`和`service`类,`OOM`的接口等功能。
文章列表如下:
- [java应用监测(1)-java程序员应该知道的应用监测技术](https://mianshenglee.github.io/2019/08/23/java-monitor-1.html)
- [java应用监测(2)-java命令的秘密]( https://mianshenglee.github.io/2019/08/24/java-monitor-2.html )
- [java应用监测(3)-这些命令行工具你掌握了吗]( https://mianshenglee.github.io/2019/08/25/java-monitor-3.html )
- [java应用监测(4)-线上问题排查套路]( https://mianshenglee.github.io/2019/08/26/java-monitor-4.html )
- [java应用监测(5)-可视化监测工具]( https://mianshenglee.github.io/2019/08/27/java-monitor-5.html )
- [java应用监测(6)-第三方内存分析工具MAT]( https://mianshenglee.github.io/2019/08/29/java-monitor-6.html )
- [java应用监测(7)-在线动态诊断神器BTrace]( https://mianshenglee.github.io/2019/08/30/java-monitor-7.html )
- [java应用监测(8)-阿里诊断工具arthas]( https://mianshenglee.github.io/2019/08/31/java-monitor-8.html )
## 2.2 Swagger企业实践:`springboot-swagger-demo`
基于springboot2+swagger2,结合在企业中的实践,对接口文档的编写进行详细说明。
1. `hello-swagger-demo`
- 示例功能: 包括swagger介绍及文档生成说明,构建示例工程及配置描述,使用注解添加文档内容说明,使用全局参数进行接口认证。
- 文章:[springboot+swagger接口文档企业实践(上)](https://mianshenglee.github.io/2019/11/13/springboot-swagger1.html)
2. `advance-sagger-demo`
- 示例功能:包含对接口进行动态过滤,结合easymock进行数据模拟,对接口文档进行离线文档输出等功能。
- 文章:[springboot+swagger接口文档企业实践(下)](https://mianshenglee.github.io/2019/11/21/springboot-swagger2.html)
## 2.3 logback企业实践:`springboot-logback-demo`
基于springboot+logback,对日志输出框架的使用示例,结合在企业中的实践进行详细说明。
1. `logback-simple-demo`
- 示例功能: 使用springboot+logback构建示例工程及配置描述,对logback配置文件的详述及使用,实现按日志级别输出到文件功能。
- 文章:[springboot+logback日志输出企业实践(上)](https://mianshenglee.github.io/2019/11/28/logback1.html)
2. `logback-advance-demo`
- 示例功能:对 logback 的进阶使用进行描述,主要包括日志异步输出,多环境日志配置以及使用MDC进行分布式系统请求追踪。
- 文章:[springboot+logback日志输出企业实践(下)]( https://mianshenglee.github.io/2019/11/29/logback2.html )
## 2.4 java动态代理:`dynamic-proxy-demo`
对java的动态代理技术的使用示例,示例中包含了java反射、静态代理、动态代理、Spring AOP的使用实例。配套以下文章进行学习:
- 文章:[java开发必学知识:动态代理](https://mianshenglee.github.io/2019/12/20/dynamicproxy.html)
## 2.5 多数据源处理: `multi-datasource`
基于 Spring Boot 2+MyBatis Plus ,对多数据源的处理代码。
1. `basic-multi-datasource`
- 示例功能: 使用多套数据源的策略,实现一主一从的数据库逻辑。
- 文章:[搞定SpringBoot多数据源(1):多套源策略](https://mianshenglee.github.io/2020/01/13/multi-datasource-1.html)
2. `dynamic-datasource`
- 示例功能: 使用动态数据源策略进行数据源切换,也可使用 AOP 方式进行数据源切换,实现一主一从的数据库逻辑。
- 文章:[搞定SpringBoot多数据源(2):动态数据源](https://mianshenglee.github.io/2020/01/13/multi-datasource-2.html)
3. `parametric-dynamic-datasource`
- 示例功能: 根据参数动态添加数据源以及切换数据源,解决不确定数据源的问题。
- 文章:[搞定SpringBoot多数据源(3):参数化变更源](https://mianshenglee.github.io/2020/01/13/multi-datasource-3.html)
## 2.6 使用python自动化生成数据库说明文档:` python/tool-gen-db-doc `
通过使用 SQL 读取数据库表及字段元信息,然后输出到 excel 文档的思路,以 python 的实现方式完成自动生成文档功能
- 文章:[还在手工生成数据库文档?3个步骤自动完成了解一下](https://mianshenglee.github.io/2020/08/30/db-doc-python.html)
# 如何找到我的更多文章
- [我的Blog](https://mianshenglee.github.io):`https://mianshenglee.github.io/`
- 我的公众号(搜索`Mason技术记录`):

- 各大博客平台(CSDN,掘金,开源中国,博客园,语雀,segmentfault,开发者头条),搜索`Mason技术记录`也可以找到
| 1 |
langmi/spring-batch-examples-readers | null | null | null | 0 |
mayanhui/hadoop-hbase-examples | hadoop hbase use case and examples, inclusing MR,HBaseUtil... | null | Applications based on hadoop & hbase
#1. hadoop mapreduce application
(1) multi-jobs
(2) distribute cache
(3) split file size
#2. hbase application
(1) bulk load vv to hbase
(2) bulk load search keyword to hbase
(3) bulk load ads
#3. Redis read & write
(1) random read
(2) mapreduce bulk load
(3) hash type data bulk load
| 0 |
datumbox/datumbox-framework-examples | Code examples on how to use the Datumbox Machine Learning Framework. | null | Code Examples for Datumbox Machine Learning Framework
=====================================================
[](http://www.datumbox.com/)
This project provides examples on how to use the [Datumbox Machine Learning Framework](https://github.com/datumbox/datumbox-framework/) v0.8.3-SNAPSHOT (Build 20201014).
Copyright & License
-------------------
Copyright (c) 2013-2020 [Vasilis Vryniotis](http://blog.datumbox.com/author/bbriniotis/).
The code is licensed under the [Apache License, Version 2.0](./LICENSE).
How to use
----------
The code uses Maven Project Structure and contains the following code examples:
- [Classification.java](./src/main/java/com/datumbox/examples/Classification.java): Contains an example on how to perform Classification.
- [Clustering.java](./src/main/java/com/datumbox/examples/Clustering.java): It is an example that runs Cluster Analysis.
- [Regression.java](./src/main/java/com/datumbox/examples/Regression.java): Shows how to run Regression Analysis.
- [DataModeling.java](./src/main/java/com/datumbox/examples/DataModeling.java): Explains how to use the convenience Modeler class.
- [TextClassification.java](./src/main/java/com/datumbox/examples/TextClassification.java): Uses the convenience TextClassifier class.
All of the above files contain a main() method. To use it just clone the project on your workspace and run any of the above files.
The project contains also 5 configuration files in the resources folder:
- [datumbox.configuration.properties](./src/main/resources/datumbox.configuration.properties): It defines for the default storage engine (required).
- [datumbox.concurrencyconfiguration.properties](./src/main/resources/datumbox.concurrencyconfiguration.properties): It controls the concurrency levels (required).
- [datumbox.inmemoryconfiguration.properties](./src/main/resources/datumbox.inmemoryconfiguration.properties): It contains the configurations for the InMemory storage engine (required).
- [datumbox.mapdbconfiguration.properties](./src/main/resources/datumbox.mapdbconfiguration.properties): It contains the configurations for the MapDB storage engine (optional).
- [logback.xml](./src/main/resources/logback.xml): It contains the configuration file for the logger (optional).
Finally in the resources folder there are several [real world datasets](./src/main/resources/datasets/) which are used for testing.
Useful Links
------------
- [Datumbox Machine Learning Framework](https://github.com/datumbox/datumbox-framework/)
- [Datumbox Zoo: Pre-trained models](https://github.com/datumbox/datumbox-framework-zoo/)
- [Datumbox.com](http://www.datumbox.com/)
- [Machine Learning Blog](http://blog.datumbox.com/)
| 0 |
mp911de/spring-cloud-vault-config-samples | Examples for Spring Vault and Spring Cloud Vault Config | samples spring spring-cloud-vault spring-vault vault | null | 0 |
Gsantomaggio/rabbitmqexample | RabbitMQ Examples | null | rabbitmqexample
===============
Here some RabbitMQ example.
1. webSocketPython : How to redirect RabbitMQ messages to web-page using http://www.tornadoweb.org/.
To get ready you need pika and tornado in this way:
```
pip install pika
pip install tornado
```
Execute my-server.py and open a web page on http://localhost:8888/
Try to send a message to "my_queue" on rabbitmq (or simply use sendtest.py) , it will be redirected to all connected clients.
| 0 |
bonigarcia/selenium-webdriver-java | Examples of the O'Reilly book Hands-On Selenium WebDriver with Java"" | docker gradle java junit4 junit5 maven selenium selenium-jupiter selenium-webdriver selenium4 testng | [](https://github.com/bonigarcia/selenium-webdriver-java/actions)
[](https://www.oracle.com/java/technologies/downloads/)
[](https://www.apache.org/licenses/LICENSE-2.0)
[](https://stackoverflow.com/questions/tagged/selenium-webdriver)
[](https://twitter.com/boni_gg)
# Hands-On Selenium WebDriver with Java [![][Logo]][GitHub Repository]
This repository contains a comprehensive collection of examples about [Selenium] 4 using [Java] as language binding. These examples are explained in the O'Reilly book [Hands-On Selenium WebDriver with Java].
[![][Cover]][Hands-On Selenium WebDriver with Java]
This repo has been implemented as a multi-module project (using [Maven] and [Gradle] as build tools) composed of tests based on different frameworks: [JUnit 4], [JUnit 5] (alone or extended with [Selenium-Jupiter]), and [TestNG].
## Practice site
This repo also contains a [Practice site], i.e., a representative set of sample web pages used as the system under test (SUT) in the Selenium WebDriver test examples. This site is hosted using [GitHub Pages].
## Tags
This repo uses Git tags to track the evolution of the codebase in time. These tags are the following:
* `1.0.0`: The examples of the first version of the book (released in April 2022) are based on this tag.
* `1.1.0`: Bump to Java 11, due to the incompatibility of TestNG 7.6.0 (released on May 18, 2022) with Java 8.
* `1.2.0`: Remove GitHub token from the workflow setup, not required anymore since WebDriverManager 5.3.0 (released on August 21, 2022).
* `1.3.0`: Bump to Java 17, due to the incompatibility of Spring Boot 3.0.0 (released on Nov 24, 2022) with Java 11.
## About
selenium-webdriver-java (Copyright © 2021-2024) is an open-source project created and maintained by [Boni Garcia], licensed under the terms of [Apache 2.0 License].
[Logo]: https://bonigarcia.dev/selenium-webdriver-java/img/hands-on-icon.png
[GitHub Repository]: https://github.com/bonigarcia/selenium-webdriver-java/
[Apache 2.0 License]: https://www.apache.org/licenses/LICENSE-2.0
[Boni Garcia]: https://bonigarcia.dev/
[Gradle]: https://gradle.org/
[Java]: https://www.java.com/
[JUnit 4]: https://junit.org/junit4/
[JUnit 5]: https://junit.org/junit5/docs/current/user-guide/
[Maven]: https://maven.apache.org/
[Selenium]: https://www.selenium.dev/
[Selenium-Jupiter]: https://bonigarcia.dev/selenium-jupiter/
[TestNG]: https://testng.org/doc/
[Hands-On Selenium WebDriver with Java]: https://oreil.ly/1E7CX
[Cover]: https://bonigarcia.dev/img/hands-on-selenium-webdriver-java.png
[Practice site]: https://bonigarcia.dev/selenium-webdriver-java/
[GitHub Pages]: https://pages.github.com/
| 0 |
matzuk/Clean-multimodel-arch | Multimodel architecture example | null | null | 1 |
esanchezros/quickfixj-spring-boot-starter-examples | QuickFixJ Spring Boot Starter Examples | null | null | 0 |
halysongoncalves/Material-Design-Example | Material-Design-Example | null | Material Design Example
========================
[](https://android-arsenal.com/details/3/1296)
Material Design Example is a sample application for the new design concept made by Google, Material Design. Besides the design, we have the new APIs introduced in Android SDK Lollipop:
* Custom theme colors
* Circular reveal
* Activity transitions
* Toolbar
* Recycler View
* Card View
* Floating Action Button
* ObservableScrollView
Pre-requisites
--------------
* Android SDK v14
* Android Support Repository
Screenshots
-------------
<img src="art/MaterialExampleDesign1.png" height="400" alt="Screenshot"/>
<img src="art/MaterialExampleDesign2.png" height="400" alt="Screenshot"/>
Getting Started
---------------
This sample uses the Gradle build system. To build this project, use the
"gradlew build" command or use "Import Project" in Android Studio.
Support
-------
If you've found an error in this sample, please file an issue:
https://github.com/halysongoncalves/Material-Design-Example
Patches are encouraged, and may be submitted by forking this project and
submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
Contributions
---------------
Any contributions are welcome!
Please check the [contributing guideline](https://github.com/halysongoncalves/Material-Design-Example/blob/master/CONTRIBUTING.md) before submitting a new issue.
Credits
---------------
* Inspired by `ObservableScrollView` in [romannurik-code](https://code.google.com/p/romannurik-code/).
* Inspired by `Android-ObservableScrollView` in [ksoichiro](https://github.com/ksoichiro/Android-ObservableScrollView).
Samples
---------------
[](https://play.google.com/store/apps/details?id=br.com.halyson.materialdesign)
<h2>Copyright</h2>
Copyright 2014 Halyson Gonçalves. All rights reserved.
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.
| 0 |
jrodenbostel/beyond-the-examples | Code to support the Beyond The Examples series of blog posts at http://justinrodenbostel.com | null | beyond-the-examples
===================
A series of projects intended to provide a step-by-step walkthrough of Spring-Boot, building an application from provided examples to something more useful in a real-world setting.
| 0 |
sandeep0402/technicalsand.com-examples | All the examples mention in https://technicalsand.com | null | # technicalsand.com-examples
All the examples mention in https://technicalsand.com
| 0 |
senbox-org/snap-examples | SNAP example projects showing how to extend SNAP or build new applications on SNAP | null | # snap-examples
SNAP example projects showing how to extend SNAP or build new applications on SNAP
## TOC
* **snap-desktop-basic-single** - Template for a basic SNAP desktop extension that generates a single plugin (@snap dev team: keep this simple as possible!)
* **snap-desktop-basic-multi** - Template for a basic SNAP desktop extension that generates multiple plugins (@snap dev team: keep this simple as possible!)
* **snap-engine-python-operator** - Template for a basic SNAP engine extension that generates a single plugin comprising one or more data processing operators written in Python
| 1 |
xumingming/storm-lib | hold storm examples, tests etc here. | null | storm-lib
=========
hold storm examples, tests etc here. | 0 |
eclipse/hawkbit-examples | null | null | <img src=hawkbit_logo.png width=533 height=246 />
# Eclipse hawkBit™ - Examples collection
Example projects that show how [hawkBit](https://github.com/eclipse/hawkbit) can be customized or hawkBit compatible APIs leveraged.
[](https://circleci.com/gh/eclipse/hawkbit-examples)
## API client examples
- `hawkbit-example-ddi-feign-client` : Example client based on the feign project for hawkBit's [Direct Device Integration API](https://www.eclipse.org/hawkbit/apis/ddi_api).
- `hawkbit-example-mgmt-feign-client` : Example client based on the feign project for hawkBit's [Management API](https://www.eclipse.org/hawkbit/apis/management_api)
## Simulators
- `hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options.
- `hawkbit-example-mgmt-simulator` : Example client simulation for the _hawkBit_ Management API based on Spring Boot and the hawkbit-example-mgmt-feign-client.
## Customization examples
- `hawkbit-custom-theme-example` : Example for a customized theme for [Management UI](https://www.eclipse.org/hawkbit/ui).
| 0 |
wildfly/wildfly-archetypes | WildFly maven archetypes & examples | null | WildFly archetypes
==================
This project contains Maven Archetypes to generate Maven projects to develop Jakarta EE applications with [WildFly](https://wildfly.org/)
* [wildfly-jakartaee-webapp-archetype](/wildfly-jakartaee-webapp-archetype/) generates a Maven project to develop a simple Web Archive (WAR) with WildFly
* [wildfly-jakartaee-ear-archetype](/wildfly-jakartaee-ear-archetype/) generates a Maven project to develop a Entreprise Archive (EAR) with WildFly. It generates an EJB and WAR modules to compose the EAR
* [wildfly-subsystem-archetype](/wildfly-subsystem-archetype/) generates a Maven project to develop a WildFly subsystem to extend the capabilities of WildFly.
## Component dependencies
The versions of all dependencies and plugins that are used by this archetype are configured in the parent's `pom.xml`.
To update the archetypes to new versions:
* update to latest "org.jboss:jboss-parent" version found at https://repo.maven.apache.org/maven2/org/jboss/jboss-parent/
* update the version property named "version.wildfly.bom"
* update the version property named "version.wildfly.core" to the version bundled with WildFly (found in "%WILDFLY_HOME%/modules/system/layers/base/org/jboss/as/controller/main").
* check whether dependencies have changed.
* check the plugin versions and update if necessary:
* wildfly-maven-plugin: https://repo.maven.apache.org/maven2/org/wildfly/plugins/wildfly-maven-plugin/
* maven-compiler-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/
* maven-surefire-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/
* maven-failsafe-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-failsafe-plugin/
* maven-war-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/
* maven-ear-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-ear-plugin/
* maven-ejb-plugin: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-ejb-plugin/
### Injection of dependencies in the archetypes resources
The versions of all dependencies and plugins that are used by this archetype are configured in the parent's `pom.xml`.
For each archetype, their archetype-resources `pom.xml` is still in Git but in a separate source tree (e.g. `wildfly-jakartaee-ear-archetype/src/main/resources-filtered/archetype-resources/pom.xml`).
When the archetypes are built, their `pom.xml` are filtered with the property values from the parent pom (so their own `version.wildfly.bom` will have the *actual* value of the parent's `version.wildfly.bom`).
The reason of this structure is that we want to evaluate some property values when we built the archetype (for the versions) and keep others that will be evaluate when the project is generated by the archetypes (eg `${rootArtifactId}`) . The latter properties are escaped from filtering by prepending a `/`. | 0 |
cescoffier/reactive-systems-in-java | Reactive Systems in Java Code Examples | null | # Reactive Systems in Java book examples
Welcome World!
These are the working examples for Reactive Systems in Java from O'Reilly and written by Clement Escoffier and Ken Finnigan.
## How to open and run the examples?
Readers of the book should directly open projects from sub-folders: they are all independent and self-contained.
You will find Maven build descriptors for each project, so you can load the projects with text editors or integrated development environments such as IntelliJ IDEA, Eclipse IDE or Microsoft Visual Studio Code.
As an example if you want to build the code example from the chapter 2, open a terminal and run:
```shell script
$ cd chapter-2
$ mvn package # or ./mvnw package
```
The book examples work best using some Unix environment: Linux, macOS or the Windows Subsystem for Linux from Microsoft.
## What is the structure of the repository?
The following folders are available:
* [Chapter 2 - Introduction to Quarkus](./chapter-2)
* [Chapter 3 - Distributed Systems: What the heck?](./chapter-3)
* [Chapter 4 - Design Principles of Reactive Systems](./chapter-4)
* [Chapter 5 - Reactive Programming: Taming the Asynchronicity](./chapter-5)
* [Chapter 7 - Mutiny: An Event-Driven Reactive Programming API](./chapter-7)
* [Chapter 8 - HTTP with Reactive in Mind](./chapter-8)
* [Chapter 9 - Accessing Data Reactively](./chapter-9)
* [Chapter 10 - Reactive Messaging: The Connective Tissue](./chapter-10)
* [Chapter 11 - The Event Bus: The Backbone](./chapter-11)
* [Chapter 12 - Reactive REST Client: Connecting with HTTP Endpoints](./chapter-12)
* [Chapter 13 - Observing Reactive and Event-Driven Architectures](./chapter-13)
The _main_ branch is where you must look for working examples.
| 0 |
Wikidata/Wikidata-Toolkit-Examples | Examples showing how to use Wikidata Toolkit as a Maven library in your project | null | # Wikidata Toolkit Examples
This is an example project that shows how to set up a Java project that
uses [Wikidata Toolkit](https://github.com/Wikidata/Wikidata-Toolkit).
It contains several simple example programs and bots in the source directory.
What's found in this repository
-------------------------------
The individual examples are documented in the README file of each package.
Running examples using an IDE
-----------------------------
You can import the project into any Java IDE that supports Maven (and maybe git)
and run the example programs from there. Wikidata Toolkit provides detailed
[instructions on how to set up Eclipse for using Maven and git](https://www.mediawiki.org/wiki/Wikidata_Toolkit/Eclipse_setup).
Running examples directly using Maven
-------------------------------------
You can also run the code directly using Maven from the command line. For this,
you need to have Maven and (obviously) Java installed. To compile the project
and obtain necessary dependencies, run
```mvn compile```
Thereafter, you can run any individual example using its Java class name, for
example:
```mvn exec:java -Dexec.mainClass="examples.FetchOnlineDataExample"```
Credits and License
-------------------
This project is copied from the [Wikidata Toolkit](https://github.com/Wikidata/Wikidata-Toolkit) examples module.
Authors can be found there.
License: [Apache 2.0](LICENSE)
| 0 |
algorithmica-repository/top20 | It consists of all the code examples of Top-20(problem solving) course taken at algorithmica | null | top20
=====
It consists of all the code examples of Top-20(Problem solving) course taken up at Algorithmica across all years. You can use/redistribute this code for academic purpose only.
| 0 |
YugabyteDB-Samples/orm-examples | Examples showing how to use various ORMs with YSQL | null | # Using ORMs with YugabyteDB
This repository has examples showing build a simple REST API server using ORMs on top of YugabyteDB (using the YSQL API). The scenario modelled is that of a simple online e-commerce store. It consists of the following.
* The users of the ecommerce site are stored in the `users` table.
* The `products` table contains a list of products the ecommerce site sells.
* The orders placed by the users are populated in the `orders` table. An order can consist of multiple line items, each of these are inserted in the `orderline` table.
## Step 1. Install YugabyteDB
You should first [install YugabyteDB](https://docs.yugabyte.com/latest/quick-start/), which is a distributed SQL database compatible with the PostgreSQL language.
## Step 2. Bring up the REST API server
The same REST APIs are implemented using various ORMs. Each of these is present in one of the sub-directories in this repo. For example, to start the REST API server using `Spring`, simply go to the appropriate directory and follow the instructions there.
By default, the REST API server listens on `localhost` port `8080`.
| Directory | ORM |
| ------------- | ------------- |
| [Java - Spring](https://github.com/YugaByte/orm-examples/blob/master/java/spring) | Spring Data JPA (uses Hibernate internally) |
| [Core Java - Hibernate](https://github.com/YugaByte/orm-examples/blob/master/java/hibernate) | Core Java - Hibernate Example |
| [Java - Mybatis](https://github.com/YugaByte/orm-examples/blob/master/java/mybatis) | Java - Mybatis Example |
| [Scala - Play](https://github.com/YugaByte/orm-examples/blob/master/java/ebean) | Play Framework Example |
| [Golang - Gorm](https://github.com/YugaByte/orm-examples/blob/master/golang/gorm) | Gorm |
| [NodeJS - Sequelize](https://github.com/YugaByte/orm-examples/blob/master/node/sequelize) | Sequelize |
| [Python - SQLAlchemy](https://github.com/YugaByte/orm-examples/blob/master/python/sqlalchemy) | SQL Alchemy |
| [Python - django](https://github.com/YugaByte/orm-examples/blob/master/python/django) | Django |
| [Ruby on Rails - ActiveRecord](https://github.com/YugaByte/orm-examples/tree/master/ruby/ror) | ActiveRecord |
| [Rust - Diesel](https://github.com/YugaByte/orm-examples/blob/master/rust/diesel) | Rust Diesel |
| [C# - Dapper](https://github.com/YugaByte/orm-examples/blob/master/csharp/dapper) | Dapper |
| [Php - Laravel](https://github.com/YugaByte/orm-examples/blob/master/php/laravel/) | Php Laravel |
## Step 3. Create a user
You can create a user named `John Smith` and email `jsmith@example.com` as follows:
```
$ curl --data '{ "firstName" : "John", "lastName" : "Smith", "email" : "jsmith@example.com" }' \
-v -X POST -H 'Content-Type:application/json' http://localhost:8080/users
```
This will return the inserted record as a JSON document:
```
{
"userId": "1",
"firstName": "John",
"lastName": "Smith",
"email": "jsmith@example.com"
}
```
You can connect to YugabyteDB using `psql` and select these records:
```
postgres=# select * from users;
user_id | first_name | last_name | user_email
---------+------------+-----------+---------------
1 | John | Smith | jsmith@example.com(1 row)
```
## Step 4. List all users
You can list the current set of users by running the following:
```
$ curl http://localhost:8080/users
```
You should see the following output:
```
{
"content": [
{
"userId":"1",
"email":"jsmith@example.com",
"firstName":"John",
"lastName":"Smith"
}
],
...
}
```
## Step 5. Create a product
You can create a product listing as follows:
```
$ curl \
--data '{ "productName": "Notebook", "description": "200 page notebook", "price": 7.50 }' \
-v -X POST -H 'Content-Type:application/json' http://localhost:8080/products
```
You should see the following return value:
```
{
"productId": "1",
"productName": "Notebook",
"description": "200 page, hardbound, blank notebook",
"price": 7.5}
```
## Step 6. List all products
You can do this as follows:
```
$ curl http://localhost:8080/products
```
You should see an output as follows:
```
{
"content":[
{
"productId": "1",
"productName": "Notebook","description":"200 page, hardbound, blank notebook",
"price": 7.5
}
],
...
}
```
## Step 7. Create an order
Creating an order involves a user id ordering a particular product, this can be achieved as follows:
```
$ curl \
--data '{ "userId": "1", "products": [ { "productId": 1, "units": 2 } ] }' \
-v -X POST -H 'Content-Type:application/json' http://localhost:8080/orders
```
You should see the following return value:
```
TBD
```
Note that you can check out multiple products in one order. As an example, the following POST payload makes one user (id=1) checkout two products (id=1 and id=2) by creating the following payload:
```
{ "userId": "1", "products": [ { "productId": 1, "units": 2 }, { "productId": 2, "units": 4 } ] }
```
| 0 |
ttddyy/datasource-proxy-examples | examples for how to use datasource-proxy | null | # datasource-proxy example projects
Requires Java 17 to compile.
[**jndi-embedded-example**](jndi-embedded-example/README.md)
- JNDI lookup with *embedded* tomcat
[**jndi-external-example**](jndi-external-example/README.md)
- JNDI lookup with *external* tomcat
[**spring-javaconfig-example**](spring-javaconfig-example/README.md)
- programmatic `ProxyDataSource` creation
[**spring-xml-example**](spring-xml-example/README.md)
- programmatic `ProxyDataSource` creation
[**Hibernate-5-example**](hibernate-5-example/README.md)
- programmatic `ProxyDataSource` creation
[**Hibernate-6-example**](hibernate-6-example/README.md)
- programmatic `ProxyDataSource` creation
[**springboot-autoconfig-example**](springboot-autoconfig-example/README.md)
- programmatic `ProxyDataSource` creation
| 0 |
rd-1-2022/ai-openai-helloworld | Simple HelloWorld examples | null | # Spring AI with OpenAI
This project contains a web service that will accept HTTP GET requests at
`http://localhost:8080/ai/simple`.
There is optional `message` parameter whose default value is "Tell me a joke".
The response to the request is from the OpenAI ChatGPT Service.
## Prerequisites
Before using the AI commands, make sure you have a developer token from OpenAI.
Create an account at [OpenAI Signup](https://platform.openai.com/signup) and generate the token at [API Keys](https://platform.openai.com/account/api-keys).
The Spring AI project defines a configuration property named `spring.ai.openai.api-key` that you should set to the value of the `API Key` obtained from `openai.com`.
Exporting an environment variable is one way to set that configuration property.
```shell
export SPRING_AI_OPENAI_API_KEY=<INSERT KEY HERE>
```
Setting the API key is all you need to run the application.
However, you can find more information on setting started in the [Spring AI reference documentation section on OpenAI Chat](https://docs.spring.io/spring-ai/reference/api/clients/openai-chat.html).
## Building and running
```
./mvnw spring-boot:run
```
## Access the endpoint
To get a response to the default request of "Tell me a joke"
```shell
curl localhost:8080/ai/simple
```
A sample response is
```text
Sure, here's a classic one for you:
Why don't scientists trust atoms?
Because they make up everything!
```
Now using the `message` request parameter
```shell
curl --get --data-urlencode 'message=Tell me a joke about a cow.' localhost:8080/ai/simple
```
A sample response is
```text
Why did the cow go to space?
Because it wanted to see the mooooon!
```
Alternatively use the [httpie](https://httpie.io/) client
```shell
http localhost:8080/ai/simple message=='Tell me a joke about a cow.'
```
| 0 |
oskardudycz/EventSourcing.JVM | Examples and Tutorials of Event Sourcing in JVM languages | cqrs eventsourcing java jvm spring | [](https://github.com/sponsors/oskardudycz/) [](https://event-driven.io/?utm_source=event_sourcing_jvm) [](https://www.architecture-weekly.com/?utm_source=event_sourcing_jvm) [](https://www.linkedin.com/in/oskardudycz/)
# EventSourcing.JVM
Tutorial, practical samples and other resources about Event Sourcing in JVM. See also my similar repositories for [.NET](https://github.com/oskardudycz/EventSourcing.NetCore) and [NodeJS](https://github.com/oskardudycz/EventSourcing.NodeJS).
- [EventSourcing.JVM](#eventsourcingjvm)
- [Event Sourcing](#event-sourcing)
- [What is Event Sourcing?](#what-is-event-sourcing)
- [What is Event?](#what-is-event)
- [What is Stream?](#what-is-stream)
- [Event representation](#event-representation)
- [Retrieving the current state from events](#retrieving-the-current-state-from-events)
- [Event Store](#event-store)
- [Videos](#videos)
- [Practical introduction to Event Sourcing with Spring Boot and EventStoreDB](#practical-introduction-to-event-sourcing-with-spring-boot-and-eventstoredb)
- [Let's build the worst Event Sourcing system!](#lets-build-the-worst-event-sourcing-system)
- [The Light and The Dark Side of the Event-Driven Design](#the-light-and-the-dark-side-of-the-event-driven-design)
- [Conversation with Yves Lorphelin about CQRS](#conversation-with-yves-lorphelin-about-cqrs)
- [How to deal with privacy and GDPR in Event-Sourced systems](#how-to-deal-with-privacy-and-gdpr-in-event-sourced-systems)
- [Support](#support)
- [Introduction to Event Sourcing self-paced kit](#introduction-to-event-sourcing-self-paced-kit)
- [Exercises](#exercises)
- [Samples](#samples)
- [Event Sourcing with Spring Boot and EventStoreDB](#event-sourcing-with-spring-boot-and-eventstoredb)
- [Overview](#overview)
- [Main assumptions](#main-assumptions)
- [Prerequisites](#prerequisites)
- [Tools used](#tools-used)
- [Event Versioning](#event-versioning)
- [Uniqueness](#uniqueness)
- [Distributed Processes](#distributed-processes)
- [Articles](#articles)
## Event Sourcing
### What is Event Sourcing?
Event Sourcing is a design pattern in which results of business operations are stored as a series of events.
It is an alternative way to persist data. In contrast with state-oriented persistence that only keeps the latest version of the entity state, Event Sourcing stores each state change as a separate event.
Thanks for that, no business data is lost. Each operation results in the event stored in the databse. That enables extended auditing and diagnostics capabilities (both technically and business-wise). What's more, as events contains the business context, it allows wide business analysis and reporting.
In this repository I'm showing different aspects, patterns around Event Sourcing. From the basic to advanced practices.
Read more in my article:
- 📝 [How using events helps in a teams' autonomy](https://event-driven.io/en/how_using_events_help_in_teams_autonomy/?utm_source=event_sourcing_jvm)
- 📝 [When not to use Event Sourcing?](https://event-driven.io/en/when_not_to_use_event_sourcing/?utm_source=event_sourcing_jvm)
### What is Event?
Events, represent facts in the past. They carry information about something accomplished. It should be named in the past tense, e.g. _"user added"_, _"order confirmed"_. Events are not directed to a specific recipient - they're broadcasted information. It's like telling a story at a party. We hope that someone listens to us, but we may quickly realise that no one is paying attention.
Events:
- are immutable: _"What has been seen, cannot be unseen"_.
- can be ignored but cannot be retracted (as you cannot change the past).
- can be interpreted differently. The basketball match result is a fact. Winning team fans will interpret it positively. Losing team fans - not so much.
Read more in my articles:
- 📝 [What's the difference between a command and an event?](https://event-driven.io/en/whats_the_difference_between_event_and_command/?utm_source=event_sourcing_jvm)
- 📝 [Events should be as small as possible, right?](https://event-driven.io/en/whats_the_difference_between_event_and_command/?utm_source=event_sourcing_jvm)
### What is Stream?
Events are logically grouped into streams. In Event Sourcing, streams are the representation of the entities. All the entity state mutations ends up as the persisted events. Entity state is retrieved by reading all the stream events and applying them one by one in the order of appearance.
A stream should have a unique identifier representing the specific object. Each event has its own unique position within a stream. This position is usually represented by a numeric, incremental value. This number can be used to define the order of the events while retrieving the state. It can be also used to detect concurrency issues.
### Event representation
Technically events are messages.
They may be represented, e.g. in JSON, Binary, XML format. Besides the data, they usually contain:
- **id**: unique event identifier.
- **type**: name of the event, e.g. _"invoice issued"_.
- **stream id**: object id for which event was registered (e.g. invoice id).
- **stream position** (also named _version_, _order of occurrence_, etc.): the number used to decide the order of the event's occurrence for the specific object (stream).
- **timestamp**: representing a time at which the event happened.
- other metadata like `correlation id`, `causation id`, etc.
Sample event JSON can look like:
```json
{
"id": "e44f813c-1a2f-4747-aed5-086805c6450e",
"type": "invoice-issued",
"streamId": "INV/2021/11/01",
"streamPosition": 1,
"timestamp": "2021-11-01T00:05:32.000Z",
"data":
{
"issuedTo": {
"name": "Oscar the Grouch",
"address": "123 Sesame Street",
},
"amount": 34.12,
"number": "INV/2021/11/01",
"issuedAt": "2021-11-01T00:05:32.000Z"
},
"metadata":
{
"correlationId": "1fecc92e-3197-4191-b929-bd306e1110a4",
"causationId": "c3cf07e8-9f2f-4c2d-a8e9-f8a612b4a7f1"
}
}
```
### Retrieving the current state from events
In Event Sourcing, the state is stored in events. Events are logically grouped into streams. Streams can be thought of as the entities' representation. Traditionally (e.g. in relational or document approach), each entity is stored as a separate record.
| Id | IssuerName | IssuerAddress | Amount | Number | IssuedAt |
| -------- | ---------------- | ----------------- | ------ | -------------- | ---------- |
| e44f813c | Oscar the Grouch | 123 Sesame Street | 34.12 | INV/2021/11/01 | 2021-11-01 |
In Event Sourcing, the entity is stored as the series of events that happened for this specific object, e.g. `InvoiceInitiated`, `InvoiceIssued`, `InvoiceSent`.
```json
[
{
"id": "e44f813c-1a2f-4747-aed5-086805c6450e",
"type": "invoice-initiated",
"streamId": "INV/2021/11/01",
"streamPosition": 1,
"timestamp": "2021-11-01T00:05:32.000Z",
"data":
{
"issuedTo": {
"name": "Oscar the Grouch",
"address": "123 Sesame Street",
},
"amount": 34.12,
"number": "INV/2021/11/01",
"initiatedAt": "2021-11-01T00:05:32.000Z"
}
},
{
"id": "5421d67d-d0fe-4c4c-b232-ff284810fb59",
"type": "invoice-issued",
"streamId": "INV/2021/11/01",
"streamPosition": 2,
"timestamp": "2021-11-01T00:11:32.000Z",
"data":
{
"issuedTo": "Cookie Monster",
"issuedAt": "2021-11-01T00:11:32.000Z"
}
},
{
"id": "637cfe0f-ed38-4595-8b17-2534cc706abf",
"type": "invoice-sent",
"streamId": "INV/2021/11/01",
"streamPosition": 3,
"timestamp": "2021-11-01T00:12:01.000Z",
"data":
{
"sentVia": "email",
"sentAt": "2021-11-01T00:12:01.000Z"
}
}
]
```
All of those events shares the stream id (`"streamId": "INV/2021/11/01"`), and have incremented stream position.
We can get to conclusion that in Event Sourcing entity is represented by stream, so sequence of event correlated by the stream id ordered by stream position.
To get the current state of entity we need to perform the stream aggregation process. We're translating the set of events into a single entity. This can be done with the following the steps:
1. Read all events for the specific stream.
2. Order them ascending in the order of appearance (by the event's stream position).
3. Construct the empty object of the entity type (e.g. with default constructor).
4. Apply each event on the entity.
This process is called also _stream aggregation_ or _state rehydration_.
Read more in my article:
- 📝 [Why Partial<Type> is an extremely useful TypeScript feature?](https://event-driven.io/en/partial_typescript/?utm_source=event_sourcing_jvm)
- 📝 [How to get the current entity state from events?](https://event-driven.io/en/how_to_get_the_current_entity_state_in_event_sourcing/?utm_source=event_sourcing_jvm)
### Event Store
Event Sourcing is not related to any type of storage implementation. As long as it fulfils the assumptions, it can be implemented having any backing database (relational, document, etc.). The state has to be represented by the append-only log of events. The events are stored in chronological order, and new events are appended to the previous event. Event Stores are the databases' category explicitly designed for such purpose.
In the further samples, I'll use [EventStoreDB](https://developers.eventstore.com/). It's the battle-tested OSS database created and maintained by the Event Sourcing authorities. It supports many dev environments via gRPC clients, including JVM.
Read more in my article:
- 📝 [What if I told you that Relational Databases are in fact Event Stores?](https://event-driven.io/en/relational_databases_are_event_stores/=event_sourcing_jvm)
## Videos
### Practical introduction to Event Sourcing with Spring Boot and EventStoreDB
<a href="https://www.youtube.com/watch?v=LaUSPtwFLSg" target="_blank"><img src="https://img.youtube.com/vi/LaUSPtwFLSg/0.jpg" alt="Practical introduction to Event Sourcing with Spring Boot and EventStoreDB" width="320" height="240" border="10" /></a>
### Facts and Myths about CQRS
<a href="https://www.youtube.com/watch?v=9COWKz1E32w" target="_blank"><img src="https://img.youtube.com/vi/9COWKz1E32w/0.jpg" alt="Facts and Myths about CQRS" width="320" height="240" border="10" /></a>
### Let's build the worst Event Sourcing system!
<a href="https://www.youtube.com/watch?v=Lu-skMQ-vAw" target="_blank"><img src="https://img.youtube.com/vi/Lu-skMQ-vAw/0.jpg" alt="Let's build the worst Event Sourcing system!" width="320" height="240" border="10" /></a>
### The Light and The Dark Side of the Event-Driven Design
<a href="https://www.youtube.com/watch?v=ZGugOiYcq8k" target="_blank"><img src="https://img.youtube.com/vi/ZGugOiYcq8k/0.jpg" alt="The Light and The Dark Side of the Event-Driven Design" width="320" height="240" border="10" /></a>
### Conversation with [Yves Lorphelin](https://github.com/ylorph/) about CQRS
<a href="https://www.youtube.com/watch?v=D-3N2vQ7ADE" target="_blank"><img src="https://img.youtube.com/vi/D-3N2vQ7ADE/0.jpg" alt="Event Store Conversations: Yves Lorphelin talks to Oskar Dudycz about CQRS (EN)" width="320" height="240" border="10" /></a>
### How to deal with privacy and GDPR in Event-Sourced systems
<a href="https://www.youtube.com/watch?v=7NGlYgobTyY" target="_blank"><img src="https://img.youtube.com/vi/7NGlYgobTyY/0.jpg" alt="How to deal with privacy and GDPR in Event-Sourced systems" width="320" height="240" border="10" /></a>
## Support
Feel free to [create an issue](https://github.com/oskardudycz/EventSourcing.JVM/issues/new) if you have any questions or request for more explanation or samples. I also take **Pull Requests**!
💖 If this repository helped you - I'd be more than happy if you **join** the group of **my official supporters** at:
👉 [Github Sponsors](https://github.com/sponsors/oskardudycz)
⭐ Star on GitHub or sharing with your friends will also help!
## [Introduction to Event Sourcing self-paced kit](./workshops/introduction-to-event-sourcing/)
Event Sourcing is perceived as a complex pattern. Some believe that it's like Nessie, everyone's heard about it, but rarely seen it. In fact, Event Sourcing is a pretty practical and straightforward concept. It helps build predictable applications closer to business. Nowadays, storage is cheap, and information is priceless. In Event Sourcing, no data is lost.
The workshop aims to build the knowledge of the general concept and its related patterns for the participants. The acquired knowledge will allow for the conscious design of architectural solutions and the analysis of associated risks.
The emphasis will be on a pragmatic understanding of architectures and applying it in practice using Marten and EventStoreDB.
1. Introduction to Event-Driven Architectures. Differences from the classical approach are foundations and terminology (event, event streams, command, query).
2. What is Event Sourcing, and how is it different from Event Streaming. Advantages and disadvantages.
3. Write model, data consistency guarantees on examples from Marten and EventStoreDB.
4. Various ways of handling business logic: Aggregates, Command Handlers, functional approach.
5. Projections, best practices and concerns for building read models from events on the examples from Marten and EventStoreDB.
6. Challenges in Event Sourcing and EDA: deliverability guarantees, sequence of event handling, idempotency, etc.
8. Saga, Choreography, Process Manager, distributed processes in practice.
7. Event Sourcing in the context of application architecture, integration with other approaches (CQRS, microservices, messaging, etc.).
8. Good and bad practices in event modelling.
9. Event Sourcing on production, evolution, events' schema versioning, etc.
You can do the workshop as a self-paced kit. That should give you a good foundation for starting your journey with Event Sourcing and learning tools like Marten and EventStoreDB. If you'd like to get full coverage with all nuances of the private workshop, feel free to contact me via [email](mailto:oskar.dudycz@gmail.com).
Read also more in my article [Introduction to Event Sourcing - Self Paced Kit](https://event-driven.io/en/introduction_to_event_sourcing/?utm_source=event_sourcing_jvm).
### Exercises
1. [Events definition](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e01_events_definition).
2. [Getting State from events](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e02_getting_state_from_events).
3. Appending Events:
* [EventStoreDB](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e03_appending_event/esdb)
* _TODO: Axon Server_
4. Getting State from events
* [EventStoreDB](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e04_getting_state_from_events)
* _TODO: Axon Server_
5. Business logic:
* [General](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e05_business_logic)
* [EventStoreDB](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e06_business_logic/esdb)
* _TODO: Axon Server_
6. Optimistic Concurrency:
* [EventStoreDB](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e07_optimistic_concurrency/esdb)
* _TODO: Axon Server_
7. Projections:
* [General](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e08_projections_singlestream)
* [Idempotency](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e09_projections_singlestream_idempotency)
* [Eventual Consistency](./workshops/introduction-to-event-sourcing/exercises/src/test/java/io/eventdriven/introductiontoeventsourcing/e10_projections_singlestream_eventual_consistency)
## Samples
See also fully working, real-world samples of Event Sourcing and CQRS applications in [Samples folder](./samples/event-sourcing-esdb-simple).
Samples are using CQRS architecture. They're sliced based on the business modules and operations. Read more about the assumptions in ["How to slice the codebase effectively?"](https://event-driven.io/en/how_to_slice_the_codebase_effectively/?utm_source=event_sourcing_jvm).
### Event Sourcing with Spring Boot and EventStoreDB
#### Overview
Sample is showing basic Event Sourcing flow. It uses [EventStoreDB](https://developers.eventstore.com/) for event storage and [Spring Data JPA](https://spring.io/projects/spring-data-jpa) backed with [PostgreSQL](https://www.postgresql.org/) for read models.
The presented use case is Shopping Cart flow:
1. The customer may add a product to the shopping cart only after opening it.
2. When selecting and adding a product to the basket customer needs to provide the quantity chosen. The product price is calculated by the system based on the current price list.
3. The customer may remove a product with a given price from the cart.
4. The customer can confirm the shopping cart and start the order fulfilment process.
5. The customer may also cancel the shopping cart and reject all selected products.
6. After shopping cart confirmation or cancellation, the product can no longer be added or removed from the cart.
Technically it's modelled as Web API written in [Spring Boot](https://spring.io/projects/spring-boot) and [Java 17](https://www.oracle.com/java/technologies/downloads/).
There are two variations of those samples:
- [Event Sourcing with Spring Boot and EventStoreDB](./samples/event-sourcing-esdb-simple)
- [Event Sourcing with Spring Boot and EventStoreDB using Aggregate pattern](./samples/event-sourcing-esdb-aggregates)
#### Main assumptions
- explain basics of Event Sourcing, both from the write model ([EventStoreDB](https://developers.eventstore.com/)) and read model part ([PostgreSQL](https://www.postgresql.org/) and [Spring Data JPA](https://spring.io/projects/spring-data-jpa)),
- present that you can join classical approach with Event Sourcing without making a massive revolution,
- [CQRS](https://event-driven.io/en/cqrs_facts_and_myths_explained/) architecture sliced by business features, keeping code that changes together at the same place. Read more in [How to slice the codebase effectively?](https://event-driven.io/en/how_to_slice_the_codebase_effectively/),
- clean, composable (pure) functions for command, events, projections, query handling, minimising the need for marker interfaces. Thanks to that testability and easier maintenance.
- easy to use and self-explanatory fluent API for registering commands and projections with possible fallbacks,
- registering everything into regular DI containers to integrate with other application services.
- pushing the type/signature enforcement on edge, so when plugging to DI.
#### Prerequisites
For running the Event Store examples you need to have:
1. Java JDK 17 (or later) installed - https://www.oracle.com/java/technologies/downloads/.
2. Installed IntelliJ, Eclipse, VSCode or other preferred IDE.
3. [Docker](https://store.docker.com/search?type=edition&offering=community) installed.
#### Tools used
1. [EventStoreDB](https://eventstore.com) - Event Store
2. [PostgreSQL](https://www.postgresql.org/) - Read Models
3. [Spring Boot](https://spring.io/projects/spring-boot) - Web Application framework
### [Event Versioning](./samples/events-versioning)
Shows how to handle basic event schema versioning scenarios using event and stream transformations (e.g. upcasting):
- [Simple mapping](./samples/events-versioning/#simple-mapping)
- [New not required property](./samples/events-versioning/#new-not-required-property)
- [New required property](./samples/events-versioning/#new-required-property)
- [Renamed property](./samples/events-versioning/#renamed-property)
- [Upcasting](./samples/events-versioning/#upcasting)
- [Changed Structure](./samples/events-versioning/#changed-structure)
- [New required property](./samples/events-versioning/#new-required-property-1)
- [Downcasters](./samples/events-versioning/#downcasters)
- [Events Transformations](./samples/events-versioning/#events-transformations)
- [Stream Transformation](./samples/events-versioning/#stream-transformation)
- [Summary](./samples/events-versioning/#summary)
- 📝 [Simple patterns for events schema versioning](https://event-driven.io/en/simple_events_versioning_patterns/?utm_source=event_sourcing_jvm)
### [Uniqueness](./samples/uniqueness/)
Shows how to handle unique constraint checks in an event-sources system. Explains various techniques, like:
- talking to business,
- stream id design,
- reservation pattern.
Read more in [How to ensure uniqueness in Event Sourcing](https://event-driven.io/en/uniqueness-in-event-sourcing/?utm_source=event_sourcing_jvm).
### [Distributed Processes](./samples/distributed-processes/)
Shows how to handle distributed processes in Event Sourcing in practice. Explains various use cases, like:
- batch processing,
- saga vs process managers,
- distributed processes in the single module and across boundaries,
- internal vs external events,
- compensating failures,
- implementation of command and event bus in EventStoreDB.
Read more in [How to ensure uniqueness in Event Sourcing](https://event-driven.io/en/uniqueness-in-event-sourcing/?utm_source=event_sourcing_jvm).
## Articles
Read also more on the **Event Sourcing** and **CQRS** topics in my [blog](https://event-driven.io/?utm_source=event_sourcing_jvm) posts:
- 📝 [What's the difference between a command and an event?](https://event-driven.io/en/whats_the_difference_between_event_and_command/?utm_source=event_sourcing_jvm)
- 📝 [Event Streaming is not Event Sourcing!](https://event-driven.io/en/event_streaming_is_not_event_sourcing/?utm_source=event_sourcing_jvm)
- 📝 [Events should be as small as possible, right?](https://event-driven.io/en/events_should_be_as_small_as_possible/?utm_source=event_sourcing_jvm)
- 📝 [How to get the current entity state from events?](https://event-driven.io/en/how_to_get_the_current_entity_state_in_event_sourcing/?utm_source=event_sourcing_jvm)
- 📝 [How to ensure uniqueness in Event Sourcing](https://event-driven.io/en/uniqueness-in-event-sourcing/?utm_source=event_sourcing_jvm)
- 📝 [Anti-patterns in event modelling - Property Sourcing](https://event-driven.io/en/property-sourcing/?utm_source=event_sourcing_jvm)
- 📝 [Anti-patterns in event modelling - State Obsession](https://event-driven.io/en/state-obsession/?utm_source=event_sourcing_jvm)
- 📝 [Why a bank account is not the best example of Event Sourcing?](https://event-driven.io/en/bank_account_event_sourcing/?utm_source=event_sourcing_jvm)
- 📝 [When not to use Event Sourcing?](https://event-driven.io/en/when_not_to_use_event_sourcing/?utm_source=event_sourcing_jvm)
- 📝 [CQRS facts and myths explained](https://event-driven.io/en/cqrs_facts_and_myths_explained/?utm_source=event_sourcing_jvm)
- 📝 [How to slice the codebase effectively?](https://event-driven.io/en/how_to_slice_the_codebase_effectively/?utm_source=event_sourcing_jvm)
- 📝 [Generic does not mean Simple](https://event-driven.io/en/generic_does_not_mean_simple/?utm_source=event_sourcing_jvm)
- 📝 [Can command return a value?](https://event-driven.io/en/can_command_return_a_value/?utm_source=event_sourcing_jvm)
- 📝 [Twelve things I learned about Java during my last code review](https://event-driven.io/pl/12_things_I_learned_on_last_pull_request_review/?utm_source=event_sourcing_jvm)
- 📝 [How to use ETag header for optimistic concurrency](https://event-driven.io/en/how_to_use_etag_header_for_optimistic_concurrency/?utm_source=event_sourcing_jvm)
- 📝 [Dealing with Eventual Consistency and Idempotency in MongoDB projections](https://event-driven.io/en/dealing_with_eventual_consistency_and_idempotency_in_mongodb_projections/?utm_source=event_sourcing_jvm)
- 📝 [Long-polling, how to make our async API synchronous](https://event-driven.io/en/long_polling_and_eventual_consistency/?utm_source=event_sourcing_jvm)
- 📝 [A simple trick for idempotency handling in the Elastic Search read model](https://event-driven.io/en/simple_trick_for_idempotency_handling_in_elastic_search_readm_model/?utm_source=event_sourcing_jvm)
- 📝 [How to (not) do the events versioning?](https://event-driven.io/en/how_to_do_event_versioning/?utm_source=event_sourcing_jvm)
- 📝 [Simple patterns for events schema versioning](https://event-driven.io/en/simple_events_versioning_patterns/?utm_source=event_sourcing_jvm)
- 📝 [How to create projections of events for nested object structures?](https://event-driven.io/en/how_to_create_projections_of_events_for_nested_object_structures/?utm_source=event_sourcing_jvm)
- 📝 [How to scale projections in the event-driven systems?](https://event-driven.io/en/how_to_scale_projections_in_the_event_driven_systems/?utm_source=event_sourcing_jvm)
- 📝 [Immutable Value Objects are simpler and more useful than you think!](https://event-driven.io/en/immutable_value_objects/?utm_source=event_sourcing_jvm)
- 📝 [How using events helps in a teams' autonomy](https://event-driven.io/en/how_using_events_help_in_teams_autonomy/?utm_source=event_sourcing_jvm)
- 📝 [What texting your Ex has to do with Event-Driven Design?](https://event-driven.io/en/what_texting_ex_has_to_do_with_event_driven_design/?utm_source=event_sourcing_jvm)
- 📝 [What if I told you that Relational Databases are in fact Event Stores?](https://event-driven.io/en/relational_databases_are_event_stores/?utm_source=event_sourcing_jvm)
- 📝 [Are Temporal Tables an alternative to Event Sourcing?](https://event-driven.io/en/temporal_tables_and_event_sourcing/?utm_source=event_sourcing_jvm)
- 📝 [Optimistic concurrency for pessimistic times](https://event-driven.io/en/optimistic_concurrency_for_pessimistic_times/?utm_source=event_sourcing_jvm)
- 📝 [Outbox, Inbox patterns and delivery guarantees explained](https://event-driven.io/en/outbox_inbox_patterns_and_delivery_guarantees_explained/?utm_source=event_sourcing_jvm)
- 📝 [Saga and Process Manager - distributed processes in practice](https://event-driven.io/en/saga_process_manager_distributed_transactions/?utm_source=event_sourcing_jvm)
**EventSourcing.JVM** is Copyright © 2022 [Oskar Dudycz](http://event-driven.io) and other contributors under the [MIT license](LICENSE).
| 0 |
eazybytes/openapi | OpenAPI Specification & Swagger Tools : Zero To Master - Code Examples | openapi-specification openapi3 swagger3 | # OpenAPI Specification & Swagger Tools - Zero To Master
[](https://www.udemy.com/course/openapi-specification-swagger-tools-zero-to-master/?referralCode=F002A9A799DB126CD189)
**'OpenAPI Specification & Swagger Tools - Zero To Master'** course will help in understanding about Open API Specification and how to describe, document APIs using OpenAPI & Swagger tools.
## Topics covered in the course
1) Designing APIs with OpenAPI Specifications and Swagger Tools
2) Describing, Documenting APIs details using OpenAPI Specifications
3) History of OpenAPI & Swagger and relation between them
4) Details about Swagger tools like Swagger Editor, Swagger UI,SwaggerHub,SwaggerHub Explore,Swagger Codegen etc.
5) How to get started with OpenAPI in code first & Design first scenarios
6) How to write a valid OpenAPI document using YAML syntax
7) Writing re-usable content inside Open API specification with components
8) Data types supported by Open API specification & their details
9) Inheritance & polymorphism inside OpenAPI with keywords oneOf, anyOf, allOf and not
10 ) How to describe APIs security inside Open API specification
11) How to mock APIs with Open API specification & Prism mock server
12) How to generate client code & server stubs using OpenAPI for various popular programming languages & frameworks
13) Deploying & Hosting Open API specification inside a GitHub page along with Swagger UI
14) Providing examples data for the APIs inside Open API specification
15) Advantages of using Open API specification
16) Providing better documentation using CommonMark syntax inside Open API specification
## Pre-requisite for the course
- Basic knowledge on APIs
- Interest to learn and explore about OpenAPI & Swagger tools
# Important Links
- Open API Website - https://www.openapis.org
- Swagger Website - https://swagger.io
- Swagger Editor - https://editor.swagger.io
- SwaggerHub Explore - https://explore.swaggerhub.com/
- OpenAPI Map - https://openapi-map.apihandyman.io/
- OpenAPI & SpringBoot library - https://springdoc.org
- List of OpenAPI tools - https://openapi.tools/
- Prism Mock server - https://stoplight.io/open-source/prism
- SWAPI The Star Wars API - https://swapi.dev/
- REQRES Mock APIs - https://reqres.in
| 0 |
zuo26/BlogSample | blog example. | null | ### 持续更新,欢迎 star
- example41: 汉字笔顺动画
- example40: Espresso UI 自动化实践
- example39: AIDL 使用实践
- example38: 自定义 ClassLoader 使用实践
- example19: 编译 so 库实战
- example18: Lottie 使用
- example17: Activity 过渡动画实践
- example16: 矢量可绘制动画、裁剪视图动画、布局过渡动画
- example13: 带回弹效果的 RecyclerView 实战
- example11: 可拖拽工具类 ViewDragHelper 使用
- example10: 嵌套滑动实战 | 0 |
AdoptOpenJDK/jdk9-jigsaw | Examples and exercises based on some of the features of jigsaw in JDK9/Jigsaw (Early Access builds) | challenge code-examples examples exercises java java9 jdk9 jigsaw jlink jshell modular modularisation modules | # jdk9-jigsaw
Ver la [versión en Español](es/README.md) (See [Spanish version](es/README.md))
Examples of some of the features of Jigsaw released in the Early Access build of JDK9.
Many of the examples here are directly from the Project Jigsaw: Module System Quick-Start Guide, see [http://openjdk.java.net/projects/jigsaw/quick-start](http://openjdk.java.net/projects/jigsaw/quick-start) but we have also contributions from the Java community.
___
#### Please note you are in the `master` branch which contains exercises which need to be solved by looking at documentation or resources provided in this repo. Hints may be provided within the source or script files. If you hit a roadblock and really want to see a possible solution you can switch to the `exercise-solutions` branch for that.
#### Looking at the solutions can take away the challenge behind solving the exercises. Stay on the `master` branch in case you would like to continue to have fun solving the exercises and working through the challenges.
___
## Setup (all platforms)
See [Download, install and verify JDK](setupAndVerifyJDK.md) and return to this page to continue with the rest of the steps.
#### Download and install `git` or `git-bash`
- Ensure you have a `git` client installed on your local machine/VM/vagrant box, for Windows users `git-bash` is recommended
#### Download and install the `tree` and `wget` command
See [Download and install tree and wget](setupTreeAndWget.md) and return to this page to continue with the rest of the steps.
#### Vagrant box
- Alternatively a Vagrant box is available at https://github.com/ali-ince/LJC_April2017_Hackday, please make use of this facility (thanks @ali-ince).
#### (Optional) Install JDK 9 compliant IDE
- Install the latest IDE (IntelliJ, Eclipse, NetBeans - paid or community version) that supports JDK 9 EA, once installed configure the IDE to pickup the JDK 9 EA installed in the previous steps.
See [Download, install and configure Eclipse Oxygen for JDK9](setupEclipseOxygen.md).
#### Other preparations
- Get familiar with the command-line a bit as we will be using much of it during the weekend
- Prepare your VMs or cloud instances with the above, in case your local machine is not up for any installation or configurations
**Note:** the bash files provided should work on Linux and in theory on the MacOS as well.
##### Windows users
- if you use `git-bash` (recommended) or `cgywin` should work for you - run the `.sh` scripts in one of the the environments. In the worst case scenario, we would have to manually convert the `.sh` files into `.bat`, with minor tweaks should also work there. Happy to receive a pull request for it. Or you could use **bach**, a platform independent Java Shell Builder. It's usage is explained in `session-3-jshell`.
- check if the literal JDK path (or `%JAVA_HOME%`) has been added to the `PATH` environment variable or add it manually
- ensure the JDK is installed in a folder where the name does not have a space in it
- in case folder name looks something `C:\Program files...`, ensure that (name does not contain spaces):
- the path to the JDK in `JAVA_HOME` has `C:\Program~1` instead of `C:\Program files...`
- the environment variable `PATH` refers to the `JAVA_HOME` environment variable
- the environment variable `CLASSPATH` refers to the `JAVA_HOME` environment variable
- in some instances `jlink` was not yet available when JDK is installed via the `.exe` file, even after the above path settings were applied (please verify beforehand)
##### MacOSX users
- `jlink` is not yet available when JDK is installed via the `.dmg` file (please verify beforehand)
## Exercises / examples covered
Please ensure you have verified that the necessary JDK programs work in your environment with the help of the [Download, install and verify JDK](setupAndVerifyJDK.md) resource.
- Session 1: Jigsaw Introduction
- Greetings [./session-1-jigsaw-intro/01_Greetings](./session-1-jigsaw-intro/01_Greetings)
- Greetings world [./session-1-jigsaw-intro/02_GreetingsWorld](./session-1-jigsaw-intro/02_GreetingsWorld)
- Multi-module compilation [./session-1-jigsaw-intro/03_MultiModuleCompilation](./session-1-jigsaw-intro/03_MultiModuleCompilation)
- Packaging [./session-1-jigsaw-intro/04_Packaging](./session-1-jigsaw-intro/04_Packaging)
- Missing requires [./session-1-jigsaw-intro/05_Missing_requires](./session-1-jigsaw-intro/05_Missing_requires)
- Missing exports [./session-1-jigsaw-intro/05_Missing_exports](./session-1-jigsaw-intro/05_Missing_exports)
- Services [./session-1-jigsaw-intro/06_Services](./session-1-jigsaw-intro/06_Services)
- javac --patch-module option [./session-1-jigsaw-intro/07_patch_module_option](session-1-jigsaw-intro/07_patch_module_option)
- Modules export conflict [./session-1-jigsaw-intro/08_ModulesExportConflict](session-1-jigsaw-intro/08_ModulesExportConflict)
- Automatic modules [./session-1-jigsaw-intro/09_Automodules](session-1-jigsaw-intro/09_Automodules)
- Session 2: JLink
- JLink example [./session-2-jlink/01_JLink](session-2-jlink/01_JLink)
- JMod example [./session-2-jlink/02_JMod](session-2-jlink/02_JMod)
- Session 3: JShell
- JShell quick tutorial [./session-3-jshell/](./session-3-jshell/)
- JShell examples [./session-3-jshell/JShell-Examples](./session-3-jshell/JShell-Examples)
- shellFX [./session-3-jshell/shellFX/](./session-3-jshell/shellFX/)
- teamshell [./session-3-jshell/teamshell/](./session-3-jshell/teamshell/)
- bach - Java Shell Builder [./session-3-jshell/bach-building-with-jshell](./session-3-jshell/bach-building-with-jshell)
- Session 3: Refactoring/migration sessions
- Junit 5 migration to Java 9 modules [./session-3-refactoring-migration/01_junit5_to_java_9](session-3-refactoring-migration/01_junit5_to_java_9)
- Building Java 9 Modules using Gradle (from monolith to modular) [./session-3-refactoring-migration/02_monolith_to_modular_using_gradle](session-3-refactoring-migration/02_monolith_to_modular_using_gradle)
- ServiceMonitor - Migration from Java 8 to Java 9 [./session-3-refactoring-migration/03_ServiceMonitor_migration_to_java_9](session-3-refactoring-migration/03_ServiceMonitor_migration_to_java_9)
- ServiceMonitor - Modularisation to Java 9 Modules (Maven project) [./session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9](session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9)
- Session 4: Multirelease JARs
- Create multirelease JAR file [./session-4-multirelease-jars/01_Create_multirelease_jar/](./session-4-multirelease-jars/01_Create_multirelease_jar/)
- Session 5: Reactive streams API
- Create Flow subscriber [./session-5-reactive-api/01_Create_subscriber/](./session-5-reactive-api/01_Create_subscriber/)
- Session 6: Security enhancements
- Basic ALPN [./session-6-security/01_Basic_ALPN/](./session-6-security/01_Basic_ALPN/)
- Custom ALPN [./session-6-security/02_Custom_ALPN2/](./session-6-security/02_Custom_ALPN2/)
Each example is enclosed in a folder of its own containing bash scripts to compile, package and run the respective examples. Use these scripts for each of the examples.
## Community contributions
See [guidelines on how to contribute](CONTRIBUTING.md).
## License
See [License](LICENSE) document to find out about the licensing terms and conditions.
## Resources
### Must reads
- [The State of the Module System](http://openjdk.java.net/projects/jigsaw/spec/sotms/)
- [JEP 261](http://openjdk.java.net/jeps/261)
- [http://mail.openjdk.java.net/pipermail/adoption-discuss/2015-September/001053.html](http://mail.openjdk.java.net/pipermail/adoption-discuss/2015-September/001053.html) <br/>
- [http://mail.openjdk.java.net/pipermail/adoption-discuss/2015-September/001056.html](http://mail.openjdk.java.net/pipermail/adoption-discuss/2015-September/001056.html)
### Other resources
- [Module System JSR (376)](https://www.jcp.org/en/jsr/detail?id=376)
- [JDK 9 / Jigsaw Resources](./Java-9-Resources.md)
- [Adopt OpenJDK homepage](https://adoptopenjdk.java.net/)
- [Adopt OpenJDK: Getting Started Kit](http://bit.ly/1NUkPWw)
---

| 0 |
laolunsi/spring-boot-examples-old | old - :smile:Spring/SpringBoot/SpringCloud系列快速上手教程、源码学习、实战示例代码,新仓库在 https://github.com/laolunsi/spring-boot-examples | null | # SpringBoot系列基本教程
---
**本仓库不再更新,请移步新仓库[https://github.com/laolunsi/spring-boot-stack](https://github.com/laolunsi/spring-boot-stack)**
---
该仓库为springboot快速上手教程对应的示例代码,主要讲解SpringBoot相关的技术,后续计划包括SpringSecurity、SpringCloud、Spring源码等内容。
如果该系列教程对您有所帮助的话,还请点个star给予支持!感谢!
---
补充:
> 1. 后缀为demo,表示技术示例、问题解决方案,专注实际问题解决
> 2. 后缀为study,表示对某类问题的深入学习,更关心源码层面
---
## SpringBoot教程
1. ssm-demo: [SSM框架整合](https://blog.csdn.net/qq_28379809/article/details/83218797)
2. spring-boot-admin-demo: [SpringBoot Admin监控应用健康状况](https://blog.csdn.net/qq_28379809/article/details/102593592)
3. spring-boot-mongo-demo: [SpringBoot整合MongoDB](https://blog.csdn.net/qq_28379809/article/details/102952974)
4. spring-boot-redis-demo: [SpringBoot整合Redis](https://blog.csdn.net/qq_28379809/article/details/102961559)
5. spring-boot-swagger-demo: [SpringBoot使用Swagger构建RestApi接口文档](https://blog.csdn.net/qq_28379809/article/details/103008307)
6. spring-boot-config: [SpringBoot配置深入学习](http://www.eknown.cn/index.php/spring-boot/config.html)
7. spring-boot-application-study: [SpringBoot Application深入学习](http://www.eknown.cn/index.php/spring-boot/spring-boot-application.html)
8. spring-boot-params-time-demo: [SpringBoot项目接收时间类型参数完整解决方案](http://www.eknown.cn/index.php/spring-boot/params-time.html)
9. spring-boot-exception-demo: [SpringBoot统一异常处理](http://www.eknown.cn/index.php/spring-boot/exception-handler.html)
10. spring-boot-logback-demo: [SpringBoot日志管理之Logback](http://www.eknown.cn/index.php/spring-boot/logback.html)
11. spring-boot-mail-demo: [SpringBoot发送邮件](http://www.eknown.cn/index.php/spring-boot/email.html)
---
## SpringSecurity教程
1. sso-auth2-demo: [SpringSecurity+OAuth2实现单点登录系统](https://blog.csdn.net/qq_28379809/article/details/102734384)
持续更新中...
---
## 加入微信群
添加我的个人微信,备注 **加群** 即可。欢迎大家加入,一起分享学习和开发中遇到的问题!

## 关注公众号
关注公众号:猿生物语。每周分享**干货**技术文章。可免费获取云盘学习资料。
如果大家想要实时关注我的文章和分享动态的话,可以关注一下!

| 0 |
SomMeri/org.meri.jpa.tutorial | Examples and test cases for JPA tutorial. | null | null | 0 |
mraible/java-webapp-security-examples | Example projects showing how to configure security with Java EE, Spring Security and Apache Shiro. | null | # Java Web Application Security Examples
Example projects showing how to configure security with Java EE, Spring Security and Apache Shiro.
| 1 |
lidong1665/seata-spring-boot-dubbo-nacos-shardingsphere-examples | 如何进行seata1.2.0、sharding-sphere4.1.0和dubbo2.7.5 的整合,以及使用nacos作为我们的配置中心和注册中心 | null | ### 1.介绍
本篇将介绍,如何进行seata1.2.0、sharding-sphere4.1.0和dubbo2.7.5 的整合,以及使用nacos作为我们的配置中心和注册中心。如果你还是一个初学者,先建议学习一下,陈建斌的[七步带你集成Seata 1.2 高可用搭建](https://mp.weixin.qq.com/s/2KSidJ72YsovpJ94P1aK1g),这篇文章清楚的阐述了初学者容易遇到的5个问题,并且都提供完整的解决思路。
### 2.环境配置
- mysql: 5.7.12
- nacos: 1.2.1
- spring-boot: 2.2.6.RELEASE
- seata: 1.2.0
- dubbo:2.7.5
- sharding-sphere: 4.1.0
- 开发环境: jdk1.8.0
#### 2.1 nacos安装
nacos下载:[https://github.com/alibaba/nacos/releases/tag/1.2.1](https://github.com/alibaba/nacos/releases/tag/1.2.1)
Nacos 快速入门:[https://nacos.io/en-us/docs/quick-start.html](https://nacos.io/en-us/docs/quick-start.html)
```shell
sh startup.sh -m standalone
```
在浏览器打开Nacos web 控制台:http://127.0.0.1:8848/nacos/index.html
输入nacos的账号和密码 分别为`nacos:nacos`

这是时候naocs 就正常启动了。
#### 2.2 seata1.2.0安装
##### 2.2.1 在 [Seata Release](https://github.com/seata/seata/releases/tag/v1.2.0) 下载最新版的 Seata Server 并解压得到如下目录:
```shell
.
├──bin
├──conf
└──lib
```
##### 2.2.2 修改 conf/registry.conf 配置,
目前seata支持如下的file、nacos 、apollo、zk、consul的注册中心和配置中心。这里我们以`nacos` 为例。
将 type 改为 nacos
```bash
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "127.0.0.1:8848"
namespace = "40508bb4-179e-4c98-a2f1-c2c031c20b3c"
cluster = "default"
username = "worker2"
password = "xxxxxxx"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "127.0.0.1:8848"
namespace = "40508bb4-179e-4c98-a2f1-c2c031c20b3c"
group = "SEATA_GROUP"
username = "worker2"
password = "xxxxxxx"
}
}
```
- serverAddr = "127.0.0.1:8848" :nacos 的地址
- namespace = "" :nacos的命名空间默认为``
- cluster = "default" :集群设置未默认 `default`
##### 2.2.3 修改 conf/config.txt配置
```
service.vgroupMapping.order-service-seata-service-group=default
service.vgroupMapping.account-service-seata-service-group=default
service.vgroupMapping.storage-service-seata-service-group=default
service.vgroupMapping.business-service-seata-service-group=default
store.mode=db
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.datasource=druid
store.db.dbType=mysql
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true
store.db.user=root
store.db.password=123456
store.db.minConn=1
store.db.maxConn=3
store.db.global.table=global_table
store.db.branch.table=branch_table
store.db.query-limit=100
store.db.lockTable=lock_table
```
配置的详细说明参考官网:[https://seata.io/zh-cn/docs/user/configurations.html](https://seata.io/zh-cn/docs/user/configurations.html)
这里主要修改了如下几项:
- store.mode :存储模式 默认file 这里我修改为db 模式 ,并且需要三个表`global_table`、`branch_table`和`lock_table`
- store.db.driverClassName: 0.8.0版本默认没有,会报错。添加了 `com.mysql.jdbc.Driver`
- store.db.datasource=dbcp :数据源 dbcp
- store.db.db-type=mysql : 存储数据库的类型为`mysql`
- store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true : 修改为自己的数据库`url`、`port`、`数据库名称`
- store.db.user=lidong :数据库的账号
- store.db.password=cwj887766@@ :数据库的密码
- service.vgroupMapping.order-service-seata-service-group=default
- service.vgroupMapping.account-service-seata-service-group=default
- service.vgroupMapping.storage-service-seata-service-group=default
- service.vgroupMapping.business-service-seata-service-group=default
##### 2.2.4 db模式下的所需的三个表
数据库脚本位于[https://github.com/seata/seata/tree/develop/script/server/db](https://github.com/seata/seata/tree/develop/script/server/db)

这里我用的是mysql数据库,直接下载mysq.sql就可以了。
`global_table`的表结构
```sql
CREATE TABLE `global_table` (
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(64) DEFAULT NULL,
`transaction_service_group` varchar(64) DEFAULT NULL,
`transaction_name` varchar(64) DEFAULT NULL,
`timeout` int(11) DEFAULT NULL,
`begin_time` bigint(20) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`,`status`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```
`branch_table`的表结构
```sql
CREATE TABLE `branch_table` (
`branch_id` bigint(20) NOT NULL,
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`resource_group_id` varchar(32) DEFAULT NULL,
`resource_id` varchar(256) DEFAULT NULL,
`lock_key` varchar(128) DEFAULT NULL,
`branch_type` varchar(8) DEFAULT NULL,
`status` tinyint(4) DEFAULT NULL,
`client_id` varchar(64) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`branch_id`),
KEY `idx_xid` (`xid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```
`lock_table`的表结构
```sql
create table `lock_table` (
`row_key` varchar(128) not null,
`xid` varchar(96),
`transaction_id` long ,
`branch_id` long,
`resource_id` varchar(256) ,
`table_name` varchar(32) ,
`pk` varchar(32) ,
`gmt_create` datetime ,
`gmt_modified` datetime,
primary key(`row_key`)
);
```
##### 2.2.5 将 Seata 配置添加到 Nacos 中
nacos导入脚本位于[https://github.com/seata/seata/tree/develop/script/config-center/nacos](https://github.com/seata/seata/tree/develop/script/config-center/nacos)

使用方法:
```bash
sh ${SEATAPATH}/script/config-center/nacos/nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 40508bb4-179e-4c98-a2f1-c2c031c20b3c -u worker-w xxxxxx
```
参数描述:
- -h: host, 默认值 localhost.
- -p: port, 默认值 is 8848.
- -g: 配置分组 默认值 'SEATA_GROUP'.
- -t: 命名空间.
- -u: 用户名, nacos 1.2.0+ 之后添加权限验证 默认为“”
- -w: 密码, nacos 1.2.0+ 之后添加权限验证 默认为“”
-
在 Nacos 管理页面应该可以看到Group 为SEATA_GROUP的配置

这样seata-sever就搭建完成。
### 3.sharding-sphere中seata柔性事务实现
#### 3.1 实现原理
整合`Seata AT`事务时,需要把`TM`,`RM`,`TC`的模型融入到`ShardingSphere` 分布式事务的`SPI`的生态中。在数据库资源上,`Seata`通过对接`DataSource`接口,让`JDBC`操作可以同`TC`进行`RPC`通信。同样,`ShardingSphere`也是面向`DataSource`接口对用户配置的物理`DataSource`进行了聚合,因此把物理`DataSource`二次包装为`Seata `的`DataSource`后,就可以把`Seata AT`事务融入到`ShardingSphere`的分片中。
#### 3.2实现原理图

#### 3.3 实现的步骤
1. Init(Seata引擎初始化)
包含Seata柔性事务的应用启动时,用户配置的数据源会按seata.conf的配置,适配为Seata事务所需的DataSourceProxy,并且注册到RM中。
2. Begin(开启Seata全局事务)
TM控制全局事务的边界,TM通过向TC发送Begin指令,获取全局事务ID,所有分支事务通过此全局事务ID,参与到全局事务中;全局事务ID的上下文存放在当前线程变量中。
3. 执行分片物理SQL
处于Seata全局事务中的分片SQL通过RM生成undo快照,并且发送participate指令到TC,加入到全局事务中。ShardingSphere的分片物理SQL是按多线程方式执行,因此整合Seata AT事务时,需要在主线程和子线程间进行全局事务ID的上下文传递,这同服务间的上下文传递思路完全相同。
5. Commit/rollback(提交Seata事务)
提交Seata事务时,TM会向TC发送全局事务的commit和rollback指令,TC根据全局事务ID协调所有分支事务进行commit和rollback。
### 4.sharding-sphere中seata的整合
##### 4.1使用Spring-boot引入Maven依赖
```xml
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<!-- 使用BASE事务时,需要引入此模块 -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-transaction-base-seata-at</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
```
##### 4.2.Seata的AT模式使用的BASE柔性事务管理器
在每一个分片数据库实例中执创建undo_log表(以MySQL为例)
```sql
CREATE TABLE IF NOT EXISTS `undo_log`
(
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT 'increment id',
`branch_id` BIGINT(20) NOT NULL COMMENT 'branch transaction id',
`xid` VARCHAR(100) NOT NULL COMMENT 'global transaction id',
`context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
`rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
`log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
`log_created` DATETIME NOT NULL COMMENT 'create datetime',
`log_modified` DATETIME NOT NULL COMMENT 'modify datetime',
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';
```
##### 4.3.在classpath中增加seata.conf
```shell
client {
application.id = example ## 应用唯一id
transaction.service.group = my_test_tx_group ## 所属事务组
}
```
##### 4.4业务方发起全局事务,配置柔性事务类型
```java
@GlobalTransactional(timeoutMills = 300000, name = "dubbo-gts-seata-example")
@Override
public ObjectResponse handleBusiness(BusinessDTO businessDTO) {
TransactionTypeHolder.set(TransactionType.BASE);
//执行业务逻辑
}
```
**备注**:也可是使用注解` @ShardingTransactionType`的形式
```java
@GlobalTransactional(timeoutMills = 300000, name = "dubbo-gts-seata-example")
@ShardingTransactionType(TransactionType.BASE)
@Override
public ObjectResponse handleBusiness(BusinessDTO businessDTO) {
//执行业务逻辑
}
```
### 5.案例实现
参考官网中用户购买商品的业务逻辑。整个业务逻辑由4个微服务提供支持:
- 库存服务:扣除给定商品的存储数量。
- 订单服务:根据购买请求创建订单。
- 帐户服务:借记用户帐户的余额。
- 业务服务:处理业务逻辑。
请求逻辑架构

#### 5.1 源码地址
- samples-common :公共模块
- samples-account :用户账号模块
- samples-order :订单模块
- samples-storage :库存模块
- samples-business :业务模块
#### 5.2 数据库
注意: MySQL必须使用`InnoDB engine`.
如下,并且每个库中都需要一个undo_log表

#### 5.3 以账号服务为例
分析需要项目中所需要的配置
##### 5.3.1 引入的依赖
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<artifactId>seata-spring-boot-dubbo-nacos-shardingsphere-examples</artifactId>
<packaging>pom</packaging>
<name>seata-spring-boot-dubbo-nacos-shardingsphere-examples</name>
<groupId>io.seata</groupId>
<version>1.2.0</version>
<description>Demo project for Spring Boot Dubbo</description>
<modules>
<module>samples-common-service</module>
<module>samples-account-service</module>
<module>samples-order-service</module>
<module>samples-storage-service</module>
<module>samples-business-service</module>
</modules>
<properties>
<springboot.verison>2.2.6.RELEASE</springboot.verison>
<java.version>1.8</java.version>
<mybatis-plus.version>2.3</mybatis-plus.version>
<nacos.version>0.2.3</nacos.version>
<lombok.version>1.16.22</lombok.version>
<dubbo.version>2.7.5</dubbo.version>
<nacos-client.verison>1.2.1</nacos-client.verison>
<seata.version>1.2.0</seata.version>
<netty.version>4.1.32.Final</netty.version>
<sharding-sphere.version>4.1.0</sharding-sphere.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot.verison}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${springboot.verison}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot.verison}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
<exclusions>
<exclusion>
<artifactId>spring</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-config-spring -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-nacos</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata-report-nacos</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.seata/seata-all -->
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>${seata.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client.verison}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.verison}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-core</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-transaction-base-seata-at</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
注意:
- `seata-spring-boot-starter`: 这个是spring-boot seata 所需的主要依赖,1.0.0版本开始加入支持。
- `dubbo-spring-boot-starter`: springboot dubbo的依赖
- `sharding-transaction-base-seata-at` :sharding和seata整合的依赖
其他的就不一一介绍,其他的一目了然,就知道是干什么的。
##### 5.3.2 application.yml配置
```yml
server:
port: 8102
spring:
shardingsphere:
datasource:
names: ds0
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://127.0.0.1:3306/ds0?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: 123456
sharding:
tables:
t_account:
actual-data-nodes: ds0.t_account$->{0..1}
table-strategy:
inline:
sharding-column: id
algorithm-expression: t_account$->{id % 2}
props:
sql.show: true
#====================================Dubbo config===============================================
dubbo:
application:
id: dubbo-account-example
name: dubbo-account-example
qosEnable: false
protocol:
id: dubbo
name: dubbo
port: 20883
registry:
id: dubbo-account-example-registry
address: nacos://127.0.0.1:8848?namespace=40508bb4-179e-4c98-a2f1-c2c031c20b3c
config-center:
address: nacos://127.0.0.1:8848?namespace=40508bb4-179e-4c98-a2f1-c2c031c20b3c
metadata-report:
address: nacos://127.0.0.1:8848?namespace=40508bb4-179e-4c98-a2f1-c2c031c20b3c
#====================================mybatis-plus config===============================================
mybatis-plus:
mapperLocations: classpath*:/mapper/*.xml
typeAliasesPackage: io.seata.samples.integration.*.entity
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
#====================================Seata Config===============================================
seata:
enabled: true
application-id: account-seata-example
tx-service-group: account-service-seata-service-group # 事务群组(可以每个应用独立取名,也可以使用相同的名字)
registry:
file:
name: file.conf
type: nacos
nacos:
server-addr: localhost:8848
namespace: 40508bb4-179e-4c98-a2f1-c2c031c20b3c
cluster: default
config:
file:
name: file.conf
type: nacos
nacos:
namespace: 40508bb4-179e-4c98-a2f1-c2c031c20b3c
server-addr: localhost:8848
group: SEATA_GROUP
enable-auto-data-source-proxy: true
use-jdk-proxy: true
```
##### 5.3.3 在classpath中增加seata.conf
```bash
client {
application.id = account-seata-example ## 应用唯一id
transaction.service.group = account-service-seata-service-group ## 所属事务组
}
```
##### 5.3.4 启动所有的sample模块
启动 `samples-account-service`、`samples-order-service`、`samples-storage-service`、`samples-business-service`
并且在nocos的控制台查看注册情况: http://192.168.10.200:8848/nacos/#/serviceManagement

我们可以看到上面的服务都已经注册成功。
### 6.测试结果
### 6. 1 发送一个下单请求(正常情况)
使用postman 发送 :[http://localhost:8104/business/dubbo/buy](http://localhost:8104/business/dubbo/buy)
请求参数:
```json
{
"userId": 1,
"commodityCode":"C201901140001",
"name":"fan",
"count":50,
"amount":"100"
}
```
返回参数
```json
{
"status": 200,
"message": "成功",
"data": null
}
```
这时候控制台:
##### 6.1.1 BusinessService 服务日志
```bash
2020-05-22 09:15:54.763 INFO 13384 --- [nio-8104-exec-4] i.s.s.i.c.controller.BusinessController : 请求参数:BusinessDTO(userId=1, commodityCode=C201901140001, name=fan, count=50, amount=100)
2020-05-22 09:15:54.794 INFO 13384 --- [nio-8104-exec-4] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [192.168.10.107:8091:2012243535]
2020-05-22 09:15:54.794 INFO 13384 --- [nio-8104-exec-4] i.s.s.i.c.service.BusinessServiceImpl : 开始全局事务,XID = 192.168.10.107:8091:2012243535
2020-05-22 09:15:55.527 INFO 13384 --- [nio-8104-exec-4] i.seata.tm.api.DefaultGlobalTransaction : [192.168.10.107:8091:2012243535] commit status: Committed
```
##### 6.1.2 AccountService 服务日志
```bash
2020-05-22 09:15:54.959 INFO 8792 --- [:20883-thread-3] i.s.s.i.a.dubbo.AccountDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243535
Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29020a6b]
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@23fa611b] will be managed by Spring
==> Preparing: update t_account set amount = amount-100.0 where id = 1
==> Parameters:
2020-05-22 09:15:54.960 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Logic SQL: SELECT id, amount FROM t_account WHERE id = 1 FOR UPDATE
2020-05-22 09:15:54.960 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@60fae881, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@66f8eb00), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@66f8eb00, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=16, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@5f10e4e6, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@57d40a06, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@27d65b5e, containsSubquery=false)
2020-05-22 09:15:54.960 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, amount FROM t_account1 WHERE id = 1 FOR UPDATE
2020-05-22 09:15:54.962 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Logic SQL: update t_account set amount = amount-100.0 where id = 1
2020-05-22 09:15:54.962 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@5ba704b6, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@294b424c), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@294b424c)
2020-05-22 09:15:54.962 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: update t_account1 set amount = amount-100.0 where id = 1
2020-05-22 09:15:54.964 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Logic SQL: SELECT id, amount FROM t_account WHERE id in (?)
2020-05-22 09:15:54.964 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@697bcc02, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@299ee29), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@299ee29, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=16, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@1b05b402, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@68afcc0c, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@4352f7f9, containsSubquery=false)
2020-05-22 09:15:54.964 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, amount FROM t_account1 WHERE id in (?) ::: [1]
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29020a6b]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29020a6b]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29020a6b]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29020a6b]
2020-05-22 09:15:55.078 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:15:55.079 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@354923b3, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2ebdd5c8), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2ebdd5c8, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@5fd3f282, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@2e3bb335], parameters=[2012243539, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@d4e81a62, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:15:55.079 INFO 8792 --- [:20883-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243539, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@d4e81a62, 0]
2020-05-22 09:15:55.562 INFO 8792 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243535,branchId=2012243539,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds0,applicationData=null
2020-05-22 09:15:55.563 INFO 8792 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.10.107:8091:2012243535 2012243539 jdbc:mysql://127.0.0.1:3306/ds0 null
2020-05-22 09:15:55.564 INFO 8792 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
2020-05-22 09:15:56.217 INFO 8792 --- [ AsyncWorker_1] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?)
2020-05-22 09:15:56.217 INFO 8792 --- [ AsyncWorker_1] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@5b1d0b10, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@5f2284ab), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@5f2284ab)
2020-05-22 09:15:56.217 INFO 8792 --- [ AsyncWorker_1] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?) ::: [2012243539, 192.168.10.107:8091:2012243535]
```
##### 6.1.3 StorageService 服务日志
```bash
2020-05-22 09:15:54.796 INFO 9580 --- [:20888-thread-3] i.s.s.i.s.dubbo.StorageDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243535
Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@42cfeb03] will be managed by Spring
==> Preparing: SELECT id,commodity_code,name,count FROM t_storage WHERE (commodity_code = ?)
==> Parameters: C201901140001(String)
2020-05-22 09:15:54.798 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Logic SQL: SELECT id,commodity_code,name,count FROM t_storage
WHERE (commodity_code = ?)
2020-05-22 09:15:54.798 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@5ec9be76, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7cd6d3e), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7cd6d3e, projectionsContext=ProjectionsContext(startIndex=8, stopIndex=35, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=name, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@738d41ac, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@3680c897, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@b2abab7, containsSubquery=false)
2020-05-22 09:15:54.798 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id,commodity_code,name,count FROM t_storage0
WHERE (commodity_code = ?) ::: [C201901140001]
2020-05-22 09:15:54.798 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id,commodity_code,name,count FROM t_storage1
WHERE (commodity_code = ?) ::: [C201901140001]
<== Columns: id, commodity_code, name, count
<== Row: 1, C201901140001, 水杯, 650
<== Total: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073] from current transaction
==> Preparing: update t_storage set count = count-50 where id = 1
==> Parameters:
2020-05-22 09:15:54.802 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Logic SQL: SELECT id, count FROM t_storage WHERE id = 1 FOR UPDATE
2020-05-22 09:15:54.802 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@1460703d, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@63ac0932), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@63ac0932, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=15, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@44882968, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@7694cb15, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@15dbf90b, containsSubquery=false)
2020-05-22 09:15:54.802 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, count FROM t_storage1 WHERE id = 1 FOR UPDATE
2020-05-22 09:15:54.804 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Logic SQL: update t_storage set count = count-50 where id = 1
2020-05-22 09:15:54.804 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@7029adff, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7341e361), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7341e361)
2020-05-22 09:15:54.804 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: update t_storage1 set count = count-50 where id = 1
2020-05-22 09:15:54.817 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Logic SQL: SELECT id, count FROM t_storage WHERE id in (?)
2020-05-22 09:15:54.817 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@44300acf, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4680ebc4), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4680ebc4, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=15, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@3e86252e, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@42a08374, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@e1a5a04, containsSubquery=false)
2020-05-22 09:15:54.817 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, count FROM t_storage1 WHERE id in (?) ::: [1]
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48378073]
2020-05-22 09:15:54.885 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:15:54.885 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@23a45738, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6d82d00), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6d82d00, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@10b328c0, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@48eb75ea], parameters=[2012243537, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@d6553184, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:15:54.885 INFO 9580 --- [:20888-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243537, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@d6553184, 0]
2020-05-22 09:15:55.528 INFO 9580 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243535,branchId=2012243537,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds2,applicationData=null
2020-05-22 09:15:55.529 INFO 9580 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.10.107:8091:2012243535 2012243537 jdbc:mysql://127.0.0.1:3306/ds2 null
2020-05-22 09:15:55.529 INFO 9580 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
2020-05-22 09:15:55.532 INFO 9580 --- [ AsyncWorker_1] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?)
2020-05-22 09:15:55.532 INFO 9580 --- [ AsyncWorker_1] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@6eb59ea6, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6a8a17a8), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6a8a17a8)
2020-05-22 09:15:55.532 INFO 9580 --- [ AsyncWorker_1] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?) ::: [2012243537, 192.168.10.107:8091:2012243535]
```
##### 6.1.4 OrderService 服务日志
```bash
2020-05-22 09:15:54.956 INFO 6268 --- [:20880-thread-3] i.s.s.i.o.dubbo.OrderDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243535
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@23bc1e40] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@2d7be447] will not be managed by Spring
==> Preparing: insert into t_order values(?,?,1,?,50,100.0)
==> Parameters: 1263639694564524034(String), 4e7d738e311a40cd8176795aafb8a247(String), C201901140001(String)
2020-05-22 09:15:55.132 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Logic SQL: insert into t_order values(?,?,1,?,50,100.0)
2020-05-22 09:15:55.132 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@385e4984, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@29447530), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@29447530, columnNames=[id, order_no, user_id, commodity_code, count, amount], insertValueContexts=[InsertValueContext(parametersCount=3, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=27, stopIndex=27, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=29, stopIndex=29, parameterMarkerIndex=1), LiteralExpressionSegment(startIndex=31, stopIndex=31, literals=1), ParameterMarkerExpressionSegment(startIndex=33, stopIndex=33, parameterMarkerIndex=2), LiteralExpressionSegment(startIndex=35, stopIndex=36, literals=50), LiteralExpressionSegment(startIndex=38, stopIndex=42, literals=100.0)], parameters=[1263639694564524034, 4e7d738e311a40cd8176795aafb8a247, C201901140001])], generatedKeyContext=Optional.empty)
2020-05-22 09:15:55.132 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: insert into t_order1 values(?, ?, 1, ?, 50, 100.0) ::: [1263639694564524034, 4e7d738e311a40cd8176795aafb8a247, C201901140001]
2020-05-22 09:15:55.135 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Logic SQL: SELECT * FROM t_order WHERE id in (?)
2020-05-22 09:15:55.135 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@64adbefc, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@5de023c8), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@5de023c8, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=order_no, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@578730b1, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@c691133, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@7ecd35e7, containsSubquery=false)
2020-05-22 09:15:55.135 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order0 WHERE id in (?) ::: [1263639694564524034]
2020-05-22 09:15:55.135 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order1 WHERE id in (?) ::: [1263639694564524034]
2020-05-22 09:15:55.202 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:15:55.202 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@79890300, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1f521715), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1f521715, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@6d458949, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@3204530f], parameters=[2012243541, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@c45d57c1, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:15:55.203 INFO 6268 --- [:20880-thread-3] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243541, 192.168.10.107:8091:2012243535, serializer=jackson, javax.sql.rowset.serial.SerialBlob@c45d57c1, 0]
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@23bc1e40]
2020-05-22 09:15:55.596 INFO 6268 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243535,branchId=2012243541,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds1,applicationData=null
2020-05-22 09:15:55.597 INFO 6268 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.10.107:8091:2012243535 2012243541 jdbc:mysql://127.0.0.1:3306/ds1 null
2020-05-22 09:15:55.597 INFO 6268 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
2020-05-22 09:15:56.526 INFO 6268 --- [ AsyncWorker_1] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?)
2020-05-22 09:15:56.526 INFO 6268 --- [ AsyncWorker_1] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@3d80f8b5, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1c45d32), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1c45d32)
2020-05-22 09:15:56.526 INFO 6268 --- [ AsyncWorker_1] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id IN (?) AND xid IN (?) ::: [2012243541, 192.168.10.107:8091:2012243535]
```
### 6. 2 发送一个下单请求(异常回滚情况)
我们`samples-business`将`BusinessServiceImpl`的`handleBusiness2` 下面的代码去掉注释
```java
if (!flag) {
throw new RuntimeException("测试抛异常后,分布式事务回滚!");
}
```
使用postman 发送 :[http://localhost:8104/business/dubbo/buy2](http://localhost:8104/business/dubbo/buy2)
```json
{
"userId":1,
"commodityCode":"C201901140001",
"name":"fan",
"count":50,
"amount":"100"
}
```
响应结果:
```json
{
"timestamp": "2020-05-22T01:27:53.517+0000",
"status": 500,
"error": "Internal Server Error",
"message": "测试抛异常后,分布式事务回滚!",
"path": "/business/dubbo/buy2"
}
```
##### 6.2.1 BusinessService 服务日志
```shell
2020-05-22 09:27:52.386 INFO 13384 --- [nio-8104-exec-7] i.s.s.i.c.controller.BusinessController : 请求参数:BusinessDTO(userId=1, commodityCode=C201901140001, name=fan, count=50, amount=100)
2020-05-22 09:27:52.422 INFO 13384 --- [nio-8104-exec-7] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [192.168.10.107:8091:2012243545]
2020-05-22 09:27:52.422 INFO 13384 --- [nio-8104-exec-7] i.s.s.i.c.service.BusinessServiceImpl : 开始全局事务,XID = 192.168.10.107:8091:2012243545
2020-05-22 09:27:53.515 INFO 13384 --- [nio-8104-exec-7] i.seata.tm.api.DefaultGlobalTransaction : [192.168.10.107:8091:2012243545] rollback status: Rollbacked
2020-05-22 09:27:53.516 ERROR 13384 --- [nio-8104-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: 测试抛异常后,分布式事务回滚!] with root cause
java.lang.RuntimeException: 测试抛异常后,分布式事务回滚!
at io.seata.samples.integration.call.service.BusinessServiceImpl.handleBusiness2(BusinessServiceImpl.java:99) ~[classes/:na]
at io.seata.samples.integration.call.service.BusinessServiceImpl$$FastClassBySpringCGLIB$$2ab3d645.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at io.seata.spring.annotation.GlobalTransactionalInterceptor$1.execute(GlobalTransactionalInterceptor.java:109) ~[seata-all-1.2.0.jar:1.2.0]
at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:104) ~[seata-all-1.2.0.jar:1.2.0]
at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:106) ~[seata-all-1.2.0.jar:1.2.0]
at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:83) ~[seata-all-1.2.0.jar:1.2.0]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at io.seata.samples.integration.call.service.BusinessServiceImpl$$EnhancerBySpringCGLIB$$11be97b5.handleBusiness2(<generated>) ~[classes/:na]
at io.seata.samples.integration.call.controller.BusinessController.handleBusiness2(BusinessController.java:48) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594) [tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.33.jar:9.0.33]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.33.jar:9.0.33]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
```
##### 6.2.2 AccountService 服务日志
```bash
2020-05-22 09:27:52.635 INFO 8792 --- [:20883-thread-4] i.s.s.i.a.dubbo.AccountDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243545
Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58622fda]
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@529a44aa] will be managed by Spring
==> Preparing: update t_account set amount = amount-100.0 where id = 1
==> Parameters:
2020-05-22 09:27:52.637 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Logic SQL: SELECT id, amount FROM t_account WHERE id = 1 FOR UPDATE
2020-05-22 09:27:52.637 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@60fae881, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1798d09d), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1798d09d, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=16, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@5ecd214b, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@2645a0de, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@26fa0fa8, containsSubquery=false)
2020-05-22 09:27:52.637 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, amount FROM t_account1 WHERE id = 1 FOR UPDATE
2020-05-22 09:27:52.640 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Logic SQL: update t_account set amount = amount-100.0 where id = 1
2020-05-22 09:27:52.640 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@5ba704b6, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@73f934c4), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@73f934c4)
2020-05-22 09:27:52.640 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: update t_account1 set amount = amount-100.0 where id = 1
2020-05-22 09:27:52.643 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Logic SQL: SELECT id, amount FROM t_account WHERE id in (?)
2020-05-22 09:27:52.643 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@697bcc02, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@38a68471), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@38a68471, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=16, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@77bfb086, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@4ddaf5a1, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@13ea38b2, containsSubquery=false)
2020-05-22 09:27:52.643 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, amount FROM t_account1 WHERE id in (?) ::: [1]
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58622fda]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58622fda]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58622fda]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58622fda]
2020-05-22 09:27:52.757 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:27:52.757 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@354923b3, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4d520553), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4d520553, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@5fd3f282, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@2e3bb335], parameters=[2012243550, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@4e4593ee, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:27:52.757 INFO 8792 --- [:20883-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243550, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@4e4593ee, 0]
2020-05-22 09:27:53.190 INFO 8792 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243545,branchId=2012243550,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds0,applicationData=null
2020-05-22 09:27:53.190 INFO 8792 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.10.107:8091:2012243545 2012243550 jdbc:mysql://127.0.0.1:3306/ds0
2020-05-22 09:27:53.191 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE
2020-05-22 09:27:53.191 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@6481a025, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@59a7b23f), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@59a7b23f, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=branch_id, alias=Optional.empty), ColumnProjection(owner=null, name=xid, alias=Optional.empty), ColumnProjection(owner=null, name=context, alias=Optional.empty), ColumnProjection(owner=null, name=rollback_info, alias=Optional.empty), ColumnProjection(owner=null, name=log_status, alias=Optional.empty), ColumnProjection(owner=null, name=log_created, alias=Optional.empty), ColumnProjection(owner=null, name=log_modified, alias=Optional.empty), ColumnProjection(owner=null, name=ext, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@5760477b, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@535fd94f, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@165d4d40, containsSubquery=false)
2020-05-22 09:27:53.191 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE ::: [2012243550, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:53.193 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM t_account WHERE id in (?)
2020-05-22 09:27:53.193 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@761b9b19, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2781f95b), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2781f95b, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@a39c945, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@7672b20f, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@7de97fec, containsSubquery=false)
2020-05-22 09:27:53.194 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_account1 WHERE id in (?) ::: [1]
2020-05-22 09:27:53.195 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: UPDATE t_account SET amount = ? WHERE id = ?
2020-05-22 09:27:53.195 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@4df03ffe, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@113d823e), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@113d823e)
2020-05-22 09:27:53.195 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: UPDATE t_account1 SET amount = ? WHERE id = ? ::: [3600.0, 1]
2020-05-22 09:27:53.212 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id = ? AND xid = ?
2020-05-22 09:27:53.212 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@2baab4f5, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@723ca8dc), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@723ca8dc)
2020-05-22 09:27:53.212 INFO 8792 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id = ? AND xid = ? ::: [2012243550, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:53.286 INFO 8792 --- [atch_RMROLE_1_8] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.10.107:8091:2012243545 branch 2012243550, undo_log deleted with GlobalFinished
2020-05-22 09:27:53.287 INFO 8792 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
```
##### 6.2.3 StorageService 服务日志
```bash
2020-05-22 09:27:52.425 INFO 9580 --- [:20888-thread-4] i.s.s.i.s.dubbo.StorageDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243545
Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@3052f6a2] will be managed by Spring
==> Preparing: SELECT id,commodity_code,name,count FROM t_storage WHERE (commodity_code = ?)
==> Parameters: C201901140001(String)
2020-05-22 09:27:52.428 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Logic SQL: SELECT id,commodity_code,name,count FROM t_storage
WHERE (commodity_code = ?)
2020-05-22 09:27:52.428 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@5ec9be76, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@75506ecc), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@75506ecc, projectionsContext=ProjectionsContext(startIndex=8, stopIndex=35, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=name, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@1b7a39b9, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@44efbcfd, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@632fb524, containsSubquery=false)
2020-05-22 09:27:52.428 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id,commodity_code,name,count FROM t_storage0
WHERE (commodity_code = ?) ::: [C201901140001]
2020-05-22 09:27:52.428 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id,commodity_code,name,count FROM t_storage1
WHERE (commodity_code = ?) ::: [C201901140001]
<== Columns: id, commodity_code, name, count
<== Row: 1, C201901140001, 水杯, 600
<== Total: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2] from current transaction
==> Preparing: update t_storage set count = count-50 where id = 1
==> Parameters:
2020-05-22 09:27:52.432 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Logic SQL: SELECT id, count FROM t_storage WHERE id = 1 FOR UPDATE
2020-05-22 09:27:52.432 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@1460703d, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@782b9d5a), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@782b9d5a, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=15, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@1131e855, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@585126e2, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@2209f5bf, containsSubquery=false)
2020-05-22 09:27:52.432 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, count FROM t_storage1 WHERE id = 1 FOR UPDATE
2020-05-22 09:27:52.433 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Logic SQL: update t_storage set count = count-50 where id = 1
2020-05-22 09:27:52.433 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@7029adff, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@18814e21), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@18814e21)
2020-05-22 09:27:52.433 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: update t_storage1 set count = count-50 where id = 1
2020-05-22 09:27:52.445 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Logic SQL: SELECT id, count FROM t_storage WHERE id in (?)
2020-05-22 09:27:52.445 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@44300acf, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@247fbd61), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@247fbd61, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=15, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@41198f32, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@53fb3176, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@2a5b57d9, containsSubquery=false)
2020-05-22 09:27:52.445 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id, count FROM t_storage1 WHERE id in (?) ::: [1]
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3aaa9dd2]
2020-05-22 09:27:52.541 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:27:52.541 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@23a45738, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7401fc21), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@7401fc21, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@10b328c0, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@48eb75ea], parameters=[2012243547, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@e6006345, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:27:52.541 INFO 9580 --- [:20888-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243547, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@e6006345, 0]
2020-05-22 09:27:53.340 INFO 9580 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243545,branchId=2012243547,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds2,applicationData=null
2020-05-22 09:27:53.340 INFO 9580 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.10.107:8091:2012243545 2012243547 jdbc:mysql://127.0.0.1:3306/ds2
2020-05-22 09:27:53.340 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE
2020-05-22 09:27:53.340 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@361d5f71, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@12dcbe90), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@12dcbe90, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=branch_id, alias=Optional.empty), ColumnProjection(owner=null, name=xid, alias=Optional.empty), ColumnProjection(owner=null, name=context, alias=Optional.empty), ColumnProjection(owner=null, name=rollback_info, alias=Optional.empty), ColumnProjection(owner=null, name=log_status, alias=Optional.empty), ColumnProjection(owner=null, name=log_created, alias=Optional.empty), ColumnProjection(owner=null, name=log_modified, alias=Optional.empty), ColumnProjection(owner=null, name=ext, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@1c1b52bb, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@1824d5e0, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@5d265880, containsSubquery=false)
2020-05-22 09:27:53.341 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE ::: [2012243547, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:53.343 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM t_storage WHERE id in (?)
2020-05-22 09:27:53.343 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@19c73cee, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6c3144f4), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6c3144f4, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=name, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@52840747, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@3d09a7cf, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@5dbcf0f1, containsSubquery=false)
2020-05-22 09:27:53.343 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_storage1 WHERE id in (?) ::: [1]
2020-05-22 09:27:53.344 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: UPDATE t_storage SET count = ? WHERE id = ?
2020-05-22 09:27:53.344 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: UpdateStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.UpdateStatement@2c4d9b68, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@49808f57), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@49808f57)
2020-05-22 09:27:53.344 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: UPDATE t_storage1 SET count = ? WHERE id = ? ::: [600, 1]
2020-05-22 09:27:53.346 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id = ? AND xid = ?
2020-05-22 09:27:53.346 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@9b8689c, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@39477e77), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@39477e77)
2020-05-22 09:27:53.346 INFO 9580 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id = ? AND xid = ? ::: [2012243547, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:53.399 INFO 9580 --- [atch_RMROLE_1_8] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.10.107:8091:2012243545 branch 2012243547, undo_log deleted with GlobalFinished
2020-05-22 09:27:53.399 INFO 9580 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
```
##### 6.2.4 OrderService 服务日志
```bash
2020-05-22 09:27:52.615 INFO 6268 --- [:20880-thread-4] i.s.s.i.o.dubbo.OrderDubboServiceImpl : 全局事务id :192.168.10.107:8091:2012243545
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3be964] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@efc0713] will not be managed by Spring
==> Preparing: insert into t_order values(?,?,1,?,50,100.0)
==> Parameters: 1263642704673898497(String), 72ac94267b7f4f729b42ff72e641a0c4(String), C201901140001(String)
2020-05-22 09:27:52.799 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Logic SQL: insert into t_order values(?,?,1,?,50,100.0)
2020-05-22 09:27:52.799 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@385e4984, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@ac38214), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@ac38214, columnNames=[id, order_no, user_id, commodity_code, count, amount], insertValueContexts=[InsertValueContext(parametersCount=3, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=27, stopIndex=27, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=29, stopIndex=29, parameterMarkerIndex=1), LiteralExpressionSegment(startIndex=31, stopIndex=31, literals=1), ParameterMarkerExpressionSegment(startIndex=33, stopIndex=33, parameterMarkerIndex=2), LiteralExpressionSegment(startIndex=35, stopIndex=36, literals=50), LiteralExpressionSegment(startIndex=38, stopIndex=42, literals=100.0)], parameters=[1263642704673898497, 72ac94267b7f4f729b42ff72e641a0c4, C201901140001])], generatedKeyContext=Optional.empty)
2020-05-22 09:27:52.799 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: insert into t_order1 values(?, ?, 1, ?, 50, 100.0) ::: [1263642704673898497, 72ac94267b7f4f729b42ff72e641a0c4, C201901140001]
2020-05-22 09:27:52.802 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Logic SQL: SELECT * FROM t_order WHERE id in (?)
2020-05-22 09:27:52.802 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@64adbefc, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@68010a02), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@68010a02, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=order_no, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@2feef267, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@4a8eb7b2, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@13b4c98b, containsSubquery=false)
2020-05-22 09:27:52.802 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order0 WHERE id in (?) ::: [1263642704673898497]
2020-05-22 09:27:52.802 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order1 WHERE id in (?) ::: [1263642704673898497]
2020-05-22 09:27:52.875 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Logic SQL: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now())
2020-05-22 09:27:52.875 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : SQLStatement: InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@79890300, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2160f297), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2160f297, columnNames=[branch_id, xid, context, rollback_info, log_status, log_created, log_modified], insertValueContexts=[InsertValueContext(parametersCount=5, valueExpressions=[ParameterMarkerExpressionSegment(startIndex=109, stopIndex=109, parameterMarkerIndex=0), ParameterMarkerExpressionSegment(startIndex=112, stopIndex=112, parameterMarkerIndex=1), ParameterMarkerExpressionSegment(startIndex=115, stopIndex=115, parameterMarkerIndex=2), ParameterMarkerExpressionSegment(startIndex=118, stopIndex=118, parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=121, stopIndex=121, parameterMarkerIndex=4), org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@6d458949, org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment@3204530f], parameters=[2012243552, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@582376a0, 0])], generatedKeyContext=Optional.empty)
2020-05-22 09:27:52.875 INFO 6268 --- [:20880-thread-4] ShardingSphere-SQL : Actual SQL: ds0 ::: INSERT INTO undo_log (branch_id, xid, context, rollback_info, log_status, log_created, log_modified) VALUES (?, ?, ?, ?, ?, now(), now()) ::: [2012243552, 192.168.10.107:8091:2012243545, serializer=jackson, javax.sql.rowset.serial.SerialBlob@582376a0, 0]
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3be964]
2020-05-22 09:27:52.980 INFO 6268 --- [atch_RMROLE_1_8] i.s.core.rpc.netty.RmMessageListener : onMessage:xid=192.168.10.107:8091:2012243545,branchId=2012243552,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/ds1,applicationData=null
2020-05-22 09:27:52.980 INFO 6268 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.10.107:8091:2012243545 2012243552 jdbc:mysql://127.0.0.1:3306/ds1
2020-05-22 09:27:52.980 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE
2020-05-22 09:27:52.980 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@24965d4, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1a720567), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@1a720567, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=branch_id, alias=Optional.empty), ColumnProjection(owner=null, name=xid, alias=Optional.empty), ColumnProjection(owner=null, name=context, alias=Optional.empty), ColumnProjection(owner=null, name=rollback_info, alias=Optional.empty), ColumnProjection(owner=null, name=log_status, alias=Optional.empty), ColumnProjection(owner=null, name=log_created, alias=Optional.empty), ColumnProjection(owner=null, name=log_modified, alias=Optional.empty), ColumnProjection(owner=null, name=ext, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@14b5e859, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@108a6e17, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@5588e262, containsSubquery=false)
2020-05-22 09:27:52.981 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM undo_log WHERE branch_id = ? AND xid = ? FOR UPDATE ::: [2012243552, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:52.983 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: SELECT * FROM t_order WHERE id in (?)
2020-05-22 09:27:52.983 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@64adbefc, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6497500b), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6497500b, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=order_no, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=commodity_code, alias=Optional.empty), ColumnProjection(owner=null, name=count, alias=Optional.empty), ColumnProjection(owner=null, name=amount, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@272e6058, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@35a71d2d, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@369b70d4, containsSubquery=false)
2020-05-22 09:27:52.983 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order0 WHERE id in (?) ::: [1263642704673898497]
2020-05-22 09:27:52.983 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT * FROM t_order1 WHERE id in (?) ::: [1263642704673898497]
2020-05-22 09:27:52.985 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: DELETE FROM t_order WHERE id = ?
2020-05-22 09:27:52.985 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@2f28ed8, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2778c7cc), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@2778c7cc)
2020-05-22 09:27:52.985 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM t_order0 WHERE id = ? ::: [1263642704673898497]
2020-05-22 09:27:52.985 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM t_order1 WHERE id = ? ::: [1263642704673898497]
2020-05-22 09:27:53.022 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Logic SQL: DELETE FROM undo_log WHERE branch_id = ? AND xid = ?
2020-05-22 09:27:53.022 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : SQLStatement: DeleteStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@15c0ff43, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4cfe761d), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@4cfe761d)
2020-05-22 09:27:53.022 INFO 6268 --- [atch_RMROLE_1_8] ShardingSphere-SQL : Actual SQL: ds0 ::: DELETE FROM undo_log WHERE branch_id = ? AND xid = ? ::: [2012243552, 192.168.10.107:8091:2012243545]
2020-05-22 09:27:53.127 INFO 6268 --- [atch_RMROLE_1_8] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.10.107:8091:2012243545 branch 2012243552, undo_log deleted with GlobalFinished
2020-05-22 09:27:53.128 INFO 6268 --- [atch_RMROLE_1_8] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
```
我们查看数据库数据,已经回滚,和上面的数据一致。
到这里一个简单的`seata1.2.0`、`sharding-sphere4.1.0`和`dubbo2.7.5` 的整合案例基本就分析结束。感谢你的学习。如果想交流的可以私信我。
| 0 |
cloudsimplus/cloudsimplus | State-of-the-art Framework 🏗 for Cloud Computing ⛅️ Simulation: a modern, full-featured, easier-to-use, highly extensible 🧩, faster 🚀 and more accurate ☕️ Java 17+ tool for cloud computing research 🎓. Examples: https://github.com/cloudsimplus/cloudsimplus-examples | auto-scaling cloud-computing cloud-infrastructure cloud-simulation cloudsim cloudsim-simulator cloudsimplus google-cluster-data iaas java java-17 load-balancing paas research saas simulation simulation-framework test-bed trace workload | <a id="top"></a>
<p align="center">
<b><a href="#overview">Overview</a></b>
|
<b><a href="#exclusive-features">Exclusive Features</a></b>
|
<b><a href="#structure">Structure</a></b>
|
<b><a href="#usage">How to use</a></b>
|
<b><a href="#example">Example</a></b>
|
<b><a href="#docs-help">Docs and Help</a></b>
|
<b><a href="#consulting">Consulting</a></b>
|
<b><a href="#general-features">General Features</a></b>
|
<b><a href="#publications">Publications</a></b>
|
<b><a href="#projects">Related Projects</a></b>
|
<b><a href="#license">License</a></b>
|
<b><a href="#contributing">Contributing</a></b>
</p>
<a id="overview"></a>
# 1. Overview
[](#consulting) [](https://github.com/cloudsimplus/cloudsimplus/actions/workflows/build.yml) [](https://www.codacy.com/gh/cloudsimplus/cloudsimplus/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cloudsimplus/cloudsimplus&utm_campaign=Badge_Grade) [](https://www.codacy.com/gh/manoelcampos/cloudsimplus/dashboard?utm_source=github.com&utm_medium=referral&utm_content=manoelcampos/cloudsimplus&utm_campaign=Badge_Coverage) [](https://central.sonatype.com/search?q=cloudsimplus&namespace=org.cloudsimplus) [](http://cloudsimplus.rtfd.io/en/latest/?badge=latest) [](http://www.gnu.org/licenses/gpl-3.0) [](https://github.com/cloudsimplus/cloudsimplus) [](http://twitter.com/cloudsimplus)
CloudSim Plus is a modern, up-to-date, full-featured and fully documented **Java 17** simulation framework. It's easy to use and extend, enabling modeling, simulation, and experimentation of Cloud computing infrastructures and application services.
It allows developers to focus on specific system design issues to be investigated, without concerning the low-level details related to Cloud-based infrastructures and services.
CloudSim Plus is a fork of CloudSim 3, re-engineered primarily to avoid code duplication, provide code reuse and ensure compliance with software engineering principles and recommendations for extensibility improvements and accuracy. It's currently the state-of-the-art in cloud computing simulation framework.
The efforts dedicated to this project have been recognized by the [EU/Brasil Cloud FORUM](https://eubrasilcloudforum.eu).
A post about CloudSim Plus is available at
[this page of the Forum](https://eubrasilcloudforum.eu/en/instituto-federal-de-educação-do-tocantins-brazil-instituto-de-telecomunicações-portugal-and), including a White Paper available in the [Publications Section](#publications).
CloudSim Plus started through a partnership between the [Instituto de Telecomunicações (IT, Portugal)](http://www.it.pt),
the [Universidade da Beira Interior (UBI, Portugal)](http://www.ubi.pt)
and the [Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil)](http://www.ifto.edu.br).
It was partially supported by the Portuguese [Fundação para a Ciência e a Tecnologia (FCT)](https://www.fct.pt)
and by the [Brazilian foundation Coordenação de Aperfeiçoamento de Pessoal de Nível Superior (CAPES)](http://www.capes.gov.br).
> **Note**
> If you are using CloudSim Plus in your research, please make sure you cite this paper: M. C. Silva Filho, R. L. Oliveira, C. C. Monteiro, P. R. M. Inácio, and M. M. Freire. [CloudSim Plus: a Cloud Computing Simulation Framework Pursuing Software Engineering Principles for Improved Modularity, Extensibility and Correctness,](https://doi.org/10.23919/INM.2017.7987304) in IFIP/IEEE International Symposium on Integrated Network Management, 2017, p. 7.
**IMPORTANT**
---
- Developing and maintaining this project takes a huge effort. This way, any kind of [contribution](#contributing) is encouraged. Show your support by giving it a star :star: using the button at the top of the GitHub page. It takes no time, helps promoting the project and keeps it evolving. Thanks in advance :clap:.
- If you are not intending to make changes and contribute back to the project, you shouldn't fork it. Your fork become obsolete as the project is updated.
- If you're willing to use the framework to develop your own project on top of it, creating a fork is the worst way. You aren't supposed to change the framework code to implement your project, but to extend it by creating some subclasses. Unless you are planning to contribute your changes back, you'll end up with an incompatible and obsolete version of the framework. The project is constantly evolving and bugfixes are a priority. Your fork with personal changes will miss those updates and high performance improvements.
---
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="exclusive-features"></a>
# 2. Main Exclusive Features 🧰
CloudSim Plus provides lots of exclusive features, from the most basic ones to build simple simulations,
to advanced features for simulating more realistic cloud scenarios:
1. It is easier to use. [A complete and easy-to-understand simulation scenario can be built in few lines of code.](#example)
1. Multi-cloud simulations with inter-datacenter VM migrations ([#361](https://github.com/cloudsimplus/cloudsimplus/issues/361)).
1. Creation of joint power- and network-aware simulations ([#45](https://github.com/cloudsimplus/cloudsimplus/issues/45)).
1. Vertical ([#7](https://github.com/cloudsimplus/cloudsimplus/issues/7)) and Horizontal VM scaling ([#41](https://github.com/cloudsimplus/cloudsimplus/issues/41)).
1. [Highly accurate power usage computation](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/power/PowerExampleSchedulingInterval.java) ([#153](https://github.com/cloudsimplus/cloudsimplus/issues/153)).
1. [Built-in computation of CPU utilization history and energy consumption for VMs (and Hosts)](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/power/PowerExample.java) ([#168](https://github.com/cloudsimplus/cloudsimplus/issues/168)).
1. [Virtual Memory and Reduced bandwidth allocation](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/resourceusage/VirtualMemoryForRequestedRamHigherThanAvailableExample.java) when RAM and BW are oversubscribed. ([#170](https://github.com/cloudsimplus/cloudsimplus/issues/170)).
1. [Automatically power Hosts on and off according to demand](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/power/HostActivationExample.java) ([#128](https://github.com/cloudsimplus/cloudsimplus/issues/128)) and support defining a startup and shutdown delay/power consumption ([#238](https://github.com/cloudsimplus/cloudsimplus/issues/238)).
1. [Parallel execution of simulations in multi-core computers](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/ParallelSimulationsExample.java), allowing multiple simulations to be run simultaneously in an isolated way ([#38](https://github.com/cloudsimplus/cloudsimplus/issues/38)).
1. Delay creation of submitted VMs and [Cloudlets](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCloudletsArrival1.java), enabling simulation of dynamic arrival of tasks ([#11](https://github.com/cloudsimplus/cloudsimplus/issues/11), [#23](https://github.com/cloudsimplus/cloudsimplus/issues/23)).
1. [Allow dynamic creation of VMs and Cloudlets in runtime](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/dynamic/DynamicCreationOfVmsAndCloudletsExample.java), enabling VMs to be created on-demand ([#43](https://github.com/cloudsimplus/cloudsimplus/issues/43)).
1. [Listeners](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/listeners) to enable simulation configuration, monitoring and data collection.
1. Create [simulations](https://github.com/cloudsimplus/cloudsimplus-examples/tree/master/src/main/java/org/cloudsimplus/examples/traces/google) from [Google Cluster Data](https://github.com/google/cluster-data/blob/master/ClusterData2011_2.md)
trace files. ([#149](https://github.com/cloudsimplus/cloudsimplus/issues/149)).
1. Strongly object-oriented, allowing chained calls such as `cloudlet.getVm().getHost().getDatacenter()` without even worrying about `NullPointerException` ([#10](https://github.com/cloudsimplus/cloudsimplus/issues/10)).
1. Classes and interfaces for implementing [heuristics](http://en.wikipedia.org/wiki/Heuristic) such as [Tabu Search](http://en.wikipedia.org/wiki/Tabu_search), [Simulated Annealing](http://en.wikipedia.org/wiki/Simulated_annealing), [Ant Colony Systems](http://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms) and so on ([example here](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/brokers/DatacenterBrokerHeuristicExample.java)).
1. [Implementation of the Completely Fair Scheduler](https://en.wikipedia.org/wiki/Completely_Fair_Scheduler) used in recent versions of the Linux Kernel ([example here](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/schedulers/LinuxCompletelyFairSchedulerExample.java)) ([#58](https://github.com/cloudsimplus/cloudsimplus/issues/58)).
1. [Host Fault Injection and Recovery Mechanism](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/HostFaultInjectionExample1.java) to enable injection of random failures into Hosts CPU cores and replication of failed VMs ([#81](https://github.com/cloudsimplus/cloudsimplus/issues/81)).
1. [Creation of Hosts at Simulation Runtime](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/dynamic/DynamicHostCreation.java) to enable physical expansion of Datacenter capacity ([#124](https://github.com/cloudsimplus/cloudsimplus/issues/124)).
1. [Enables the simulation to keep running, waiting for dynamic and even random events such as the arrival of Cloudlets and VMs](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/dynamic/KeepSimulationRunningExample.java) ([#130](https://github.com/cloudsimplus/cloudsimplus/issues/130)).
1. TableBuilder objects that are used in all examples and enable printing simulation results in different formats such as Markdown Table, CSV or HTML.
1. Colors log messages and enables filtering the level of messages to print ([#24](https://github.com/cloudsimplus/cloudsimplus/issues/24)).  If you want to just see messages from warning level, call `Log.setLevel(ch.qos.logback.classic.Level.WARN);`
1. [Enables running the simulation synchronously, making it easier to interact with it and collect data inside a loop, as the simulation goes on](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/synchronous/SynchronousSimulationExample1.java). This brings freedom to implement your simulations ([#205](https://github.com/cloudsimplus/cloudsimplus/issues/205)).
1. [Allows placing a group of VMs into the same Host.](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/VmGroupPlacementExample1.java) ([#90](https://github.com/cloudsimplus/cloudsimplus/issues/90)).
1. [Enables Broker to try selecting the closest Datacenter to place VMs, according to their time zone.](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/brokers/DatacenterSelectionByTimeZoneExample.java) ([#212](https://github.com/cloudsimplus/cloudsimplus/issues/212)).
1. Non-Live VM migration from/to public-cloud datacenters ([#437](https://github.com/cloudsimplus/cloudsimplus/issues/437)).
1. Support VM startup/shutdown delay and boot overhead ([#435](https://github.com/cloudsimplus/cloudsimplus/issues/435))
1. It outperforms CloudSim 4, as can be seen [here](docs/performance.md).
<a id="structure"></a>
# 3. Project's Structure 🏗
CloudSim Plus has a simpler structure to make it ease to use and understand. It consists of 4 modules, 2 of which are new, as presented below.

- cloudsimplus (this module): the CloudSim Plus cloud simulation framework API, which is used by all other modules.
It is the main and only required module you need to write cloud simulations.
- [cloudsimplus-examples](https://github.com/cloudsimplus/cloudsimplus-examples): includes a series of different examples, since minimal simulation scenarios using basic
CloudSim Plus features, to complex scenarios using workloads from trace files or Vm migration examples. This is an excellent starting point for learning how to build cloud simulations using CloudSim Plus.
- [cloudsimplus-testbeds](https://github.com/cloudsimplus/cloudsimplus-testbeds): enables implementation of simulation testbeds in a repeatable manner,
allowing a researcher to execute several simulation runs for a given experiment and collect statistical data using a scientific approach.
- [cloudsimplus-benchmarks](https://github.com/cloudsimplus/cloudsimplus-benchmarks): a new module used just internally to implement micro benchmarks to assess framework performance.
It also has a better package organization,
improving [Separation of Concerns (SoC)](https://en.wikipedia.org/wiki/Separation_of_concerns)
and making it easy to know where a desired class is and what is inside each package.
The figure below presents the new package organization.
The dark yellow packages are new in CloudSim Plus and include its exclusive interfaces and classes.
The light yellow ones were introduced just to better organize existing CloudSim classes and interfaces.

<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="usage"></a>
## 4. Project Requirements
CloudSim Plus is a Java 17 project that uses maven for build and dependency management. To build and run the project, you need JDK 17+ installed and an updated version of maven (such as 3.8.6+). Maven is already installed on your IDE. Unless it's out-of-date or you want to build the project from the command line, you need to install maven into your operating system. All project dependencies are download automatically by maven.
# 5. How to Use CloudSim Plus 👩🏽💻
> **Warning**
> Before trying to use this project, make sure you have JDK 17 installed.
There are 2 ways to use CloudSim Plus:
- creating your own project and add it as a dependency. This way, it will be downloaded directly from [Maven Central](https://maven-badges.herokuapp.com/maven-central/org.cloudsimplus/cloudsimplus).
- downloading the [cloudsimplus-examples](https://github.com/cloudsimplus/cloudsimplus-examples) project and following the instructions there.
Check sections below if you want to add CloudSim Plus as a dependency into your own Maven or Gradle project. This way you can start building your simulations from scratch.
## 5.1 Maven
Add the following dependency into the pom.xml file of your own Maven project.
```xml
<dependency>
<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsimplus</artifactId>
<!-- Set a specific version or use the latest one -->
<version>LATEST</version>
</dependency>
```
## 5.2 Gradle
Add the following dependency into the build.gradle file of your own Gradle project.
```groovy
dependencies {
//Set a specific version or use the latest one
implementation 'org.cloudsimplus:cloudsimplus:LATEST'
}
```
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="example"></a>
# 6. Building CloudSim Plus
CloudSim Plus is a maven project. The previuos section just showed that you don't need to download the project sources to understand how the project works or to create your own experiments or tool on top of CloudSim Plus. You can just download the [example's project](https://github.com/cloudsimplus/cloudsimplus-examples) and start your experiments or a new simulation framewework from there. Anyway, if you want to build CloudSim Plus, you have two ways:
## 6.1 Using some IDE
Open the project on your favorite IDE and click the build button and that is it.
## 6.2 Using a terminal
Open a terminal at the project root directory and type one of the following commands:
on Linux/macOS
```bash
./mvnw clean install
```
on Windows
```bash
mvnw.cmd clean install
```
# 7. A Minimal but Complete Simulation Example ⚙️
In order to build a simulation scenario, you have to create at least:
- a datacenter with a list of physical machines (Hosts);
- a broker that allows submission of VMs and Cloudlets to be executed, on behalf of a given customer, into the cloud infrastructure;
- a list of customer's virtual machines (VMs);
- and a list of customer's cloudlets (objects that model resource requirements of different applications).
Due to the simplicity provided by CloudSim Plus, all the code to create a minimal simulation scenario can be as simple as presented below.
A more adequate and reusable example is available
[here](https://github.com/cloudsimplus/cloudsimplus-examples/blob/master/src/main/java/org/cloudsimplus/examples/BasicFirstExample.java),
together with other ones available in the [cloudsimplus-examples](https://github.com/cloudsimplus/cloudsimplus-examples) repository.
```java
//Enables just some level of logging.
//Make sure to import org.cloudsimplus.util.Log;
//Log.setLevel(ch.qos.logback.classic.Level.WARN);
//Creates a CloudSimPlus object to initialize the simulation.
var simulation = new CloudSimPlus();
//Creates a Broker that will act on behalf of a cloud user (customer).
var broker0 = new DatacenterBrokerSimple(simulation);
//Host configuration
long ram = 10000; //in Megabytes
long storage = 100000; //in Megabytes
long bw = 100000; //in Megabits/s
//Creates one host with a specific list of CPU cores (PEs).
//Uses a PeProvisionerSimple by default to provision PEs for VMs
//Uses ResourceProvisionerSimple by default for RAM and BW provisioning
//Uses VmSchedulerSpaceShared by default for VM scheduling
var host0 = new HostSimple(ram, bw, storage, List.of(new PeSimple(20000)));
//Creates a Datacenter with a list of Hosts.
//Uses a VmAllocationPolicySimple by default to allocate VMs
var dc0 = new DatacenterSimple(simulation, List.of(host0));
//Creates one VM with one CPU core to run applications.
//Uses a CloudletSchedulerTimeShared by default to schedule Cloudlets
var vm0 = new VmSimple(1000, 1);
vm0.setRam(1000).setBw(1000).setSize(1000);
//Creates Cloudlets that represent applications to be run inside a VM.
//It has a length of 1000 Million Instructions (MI) and requires 1 CPU core
//UtilizationModel defining the Cloudlets use only 50% of any resource all the time
var utilizationModel = new UtilizationModelDynamic(0.5);
var cloudlet0 = new CloudletSimple(10000, 1, utilizationModel);
var cloudlet1 = new CloudletSimple(10000, 1, utilizationModel);
var cloudletList = List.of(cloudlet0, cloudlet1);
broker0.submitVmList(List.of(vm0));
broker0.submitCloudletList(cloudletList);
/*Starts the simulation and waits all cloudlets to be executed, automatically
stopping when there is no more events to process.*/
simulation.start();
/*Prints the results when the simulation is over
(you can use your own code here to print what you want from this cloudlet list).*/
new CloudletsTableBuilder(broker0.getCloudletFinishedList()).build();
```
The presented results are structured and clear to allow better understanding.
For example, the image below shows the output for a simulation with two cloudlets (applications).

## 7.1 Comparison with CloudSim
A complete, side-by-side [comparison between CloudSim and CloudSim
Plus Java simulation scenarios
is available
here](http://cloudsimplus.org/docs/CloudSim-and-CloudSimPlus-Comparison.html).
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="docs-help"></a>
# 8. Documentation and Help 📘🆘
The project documentation originated from CloudSim was entirely updated and extended.
You can see the javadoc documentation for classes and their elements directly on your IDE.
The documentation is available online at [ReadTheDocs](http://cloudsimplus.rtfd.io/en/latest/?badge=latest),
which includes a FAQ and guides.
CloudSim Plus has extended documentation of classes and interfaces and also includes extremely helpful
package documentation that can be viewed directly on your IDE or at the link provided above.
Such a package documentation gives a general overview of the classes used to build a cloud simulation. Also, check the [publications](#publications) section to access published CloudSim Plus papers.
A Google Group forum is available at <https://groups.google.com/group/cloudsimplus> and you can also use the [Discussions page here](https://github.com/cloudsimplus/cloudsimplus/discussions).
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="consulting"></a>
# 9. Consulting and Professional Support 👨🏽🏫
If you are doing research on cloud computing simulation and facing challenging issues, I've started to offer my consulting services.
I can help you with different kinds of issues and provide specific features for your simulations, including resource allocation, task scheduling, VM placement and migration, metrics computation, process automation, debugging, results analysis, validation and more.
If you have a CloudSim project and want to migrate to CloudSim Plus to benefit from its extensive documentation, active development and support, exclusive features, great accuracy and performance, the consulting can be fit for you too.
**Get the [contact e-mail here](https://github.com/manoelcampos).**
<a id="general-features"></a>
# 10. General Features of the Framework 🛠
CloudSim Plus supports modeling and simulation of:
* large scale Cloud computing data centers;
* virtualized server hosts, with customizable policies for provisioning host resources to virtual machines;
* data center network topologies and message-passing applications;
* federated clouds;
* user-defined policies for allocation of hosts to virtual machines and policies for allocation of host resources to virtual machines.
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="publications"></a>
# 11. CloudSim Plus Publications 📝
1. M. C. Silva Filho, R. L. Oliveira, C. C. Monteiro, P. R. M. Inácio, and M. M. Freire. [CloudSim Plus: a Cloud Computing Simulation Framework Pursuing Software Engineering Principles for Improved Modularity, Extensibility and Correctness,](https://doi.org/10.23919/INM.2017.7987304) in IFIP/IEEE International Symposium on Integrated Network Management, 2017, p. 7. If you are using CloudSim Plus in your research, please make sure you cite that paper. You can check the paper presentation [here](http://cloudsimplus.org/docs/presentation/).
2. White Paper. [CloudSim Plus: A Modern Java 17+ Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services](https://cloudsimplus.github.io/cloudsimplus-whitepaper). 2016.
3. R. L. Oliveira. [Virtual Machine Allocation in Cloud Computing Environments based on Service Level Agreements](https://doi.org/10400.6/7839) (only in Portuguese). Master's Dissertation. University of Beira Interior, 2017 (Supervisor: M. M. Freire).
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="projects"></a>
# 12. Related Projects 🧩
Here, it's presented a list of some projects based on CloudSim Plus, which trust in its accuracy, performance, maintainability and extensibility.
If you want your project to be listed here, send us a Pull Request. Make sure your project has a descriptive README.
1. [CloudSim Plus Py4j gateway](https://github.com/pkoperek/cloudsimplus-gateway): building CloudSim Plus simulations in Python
1. [PySDNSim](https://github.com/ulfaric/PySDNSim): a Python simulation tool for microservice-based SDN using CloudSim Plus as the underlying framework.
1. [RECAP Discrete Event Simulation Framework:](https://bitbucket.org/RECAP-DES/recap-des/) an extension for CloudSimPlus
1. [CloudSim Plus Automation](https://github.com/cloudsimplus/cloudsimplus-automation): defining CloudSim Plus simulation scenarios into a YAML file.
1. [LEAF](https://github.com/dos-group/leaf-java): Simulator for modeling Large Energy-Aware Fog computing environments.
1. [EPCSAC](https://github.com/TNanukem/EPCSAC): Extensible Platform for Cloud Scheduling Algorithm Comparison.
1. [SatEdgeSim](https://github.com/wjy491156866/SatEdgeSim): A Toolkit for Modeling and Simulation of Performance Evaluation in Satellite Edge Computing Environments.
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="license"></a>
# 13. License ⚖️
This project is licensed under [GNU GPLv3](http://www.gnu.org/licenses/gpl-3.0), as defined inside CloudSim 3 source files.
<p align="right"><a href="#top">:arrow_up:</a></p>
<a id="contributing"></a>
# 14. Contributing 🤝
You are welcome to contribute to the project.
However, make sure you read the [contribution guide](https://github.com/cloudsimplus/.github/blob/main/CONTRIBUTING.md) before starting.
The guide provides information on the different ways you can contribute,
such as by requesting a feature, reporting an issue, fixing a bug or providing some new feature.
<p align="right"><a href="#top">:arrow_up:</a></p>
| 0 |
b4w/Education | Directory with lerning examples and programms. | null | # Education
Directory with lerning examples and programms.
# [Notes](https://github.com/b4w/Education/tree/master/Notes "Notes")
Some notes for online cources and more.
* [android](https://github.com/b4w/Education/tree/master/Notes/android "android")
* [databases](https://github.com/b4w/Education/tree/master/Notes/databases "databases")
* [devops](https://github.com/b4w/Education/tree/master/Notes/devops "devops")
* [java](https://github.com/b4w/Education/tree/master/Notes/java "java")
# [Projects](https://github.com/b4w/Education/tree/master/Progects "Projects")
* [Spring / Spring boot](https://github.com/b4w/Education/tree/master/Progects/Java/Spring "spring")
# [Wiki](https://github.com/b4w/Education/wiki "wiki")
Notes for Stepic online course.
| 0 |
bezkoder/spring-boot-spring-security-jwt-authentication | Spring Boot + Security: Token Based Authentication example with JWT, Authorization, Spring Data & MySQL | jwt jwt-authentication spring-boot spring-boot-2 spring-boot-security spring-boot-server spring-data spring-security spring-security-jwt | # Spring Boot JWT Authentication example with Spring Security & Spring Data JPA
## User Registration, User Login and Authorization process.
The diagram shows flow of how we implement User Registration, User Login and Authorization process.

## Spring Boot Server Architecture with Spring Security
You can have an overview of our Spring Boot Server with the diagram below:

## Dependency
– If you want to use PostgreSQL:
```xml
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
```
– or MySQL:
```xml
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
```
## Configure Spring Datasource, JPA, App properties
Open `src/main/resources/application.properties`
- For PostgreSQL:
```
spring.datasource.url= jdbc:postgresql://localhost:5432/testdb
spring.datasource.username= postgres
spring.datasource.password= 123
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto= update
# App Properties
bezkoder.app.jwtSecret= bezKoderSecretKey
bezkoder.app.jwtExpirationMs= 86400000
```
- For MySQL
```
spring.datasource.url=jdbc:mysql://localhost:3306/testdb_spring?useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
# App Properties
bezkoder.app.jwtSecret= ======================BezKoder=Spring===========================
bezkoder.app.jwtExpirationMs=86400000
```
## Run Spring Boot application
```
mvn spring-boot:run
```
## Run following SQL insert statements
```
INSERT INTO roles(name) VALUES('ROLE_USER');
INSERT INTO roles(name) VALUES('ROLE_MODERATOR');
INSERT INTO roles(name) VALUES('ROLE_ADMIN');
```
For more detail, please visit:
> [Secure Spring Boot with Spring Security & JWT Authentication](https://bezkoder.com/spring-boot-jwt-authentication/)
> [For MongoDB](https://bezkoder.com/spring-boot-jwt-auth-mongodb/)
## Refresh Token

For instruction: [Spring Boot Refresh Token with JWT example](https://bezkoder.com/spring-boot-refresh-token-jwt/)
## More Practice:
> [Spring Boot JWT Authentication example using HttpOnly Cookie](https://www.bezkoder.com/spring-boot-login-example-mysql/)
> [Spring Boot File upload example with Multipart File](https://bezkoder.com/spring-boot-file-upload/)
> [Exception handling: @RestControllerAdvice example in Spring Boot](https://bezkoder.com/spring-boot-restcontrolleradvice/)
> [Spring Boot Repository Unit Test with @DataJpaTest](https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/)
> [Spring Boot Pagination & Sorting example](https://www.bezkoder.com/spring-boot-pagination-sorting-example/)
> Validation: [Spring Boot Validate Request Body](https://www.bezkoder.com/spring-boot-validate-request-body/)
> Documentation: [Spring Boot and Swagger 3 example](https://www.bezkoder.com/spring-boot-swagger-3/)
> Caching: [Spring Boot Redis Cache example](https://www.bezkoder.com/spring-boot-redis-cache-example/)
Associations:
> [Spring Boot One To Many example with Spring JPA, Hibernate](https://www.bezkoder.com/jpa-one-to-many/)
> [Spring Boot Many To Many example with Spring JPA, Hibernate](https://www.bezkoder.com/jpa-many-to-many/)
> [JPA One To One example with Spring Boot](https://www.bezkoder.com/jpa-one-to-one/)
Deployment:
> [Deploy Spring Boot App on AWS – Elastic Beanstalk](https://www.bezkoder.com/deploy-spring-boot-aws-eb/)
> [Docker Compose Spring Boot and MySQL example](https://www.bezkoder.com/docker-compose-spring-boot-mysql/)
## Fullstack Authentication
> [Spring Boot + Vue.js JWT Authentication](https://bezkoder.com/spring-boot-vue-js-authentication-jwt-spring-security/)
> [Spring Boot + Angular 8 JWT Authentication](https://bezkoder.com/angular-spring-boot-jwt-auth/)
> [Spring Boot + Angular 10 JWT Authentication](https://bezkoder.com/angular-10-spring-boot-jwt-auth/)
> [Spring Boot + Angular 11 JWT Authentication](https://bezkoder.com/angular-11-spring-boot-jwt-auth/)
> [Spring Boot + Angular 12 JWT Authentication](https://www.bezkoder.com/angular-12-spring-boot-jwt-auth/)
> [Spring Boot + Angular 13 JWT Authentication](https://www.bezkoder.com/angular-13-spring-boot-jwt-auth/)
> [Spring Boot + Angular 14 JWT Authentication](https://www.bezkoder.com/angular-14-spring-boot-jwt-auth/)
> [Spring Boot + Angular 15 JWT Authentication](https://www.bezkoder.com/angular-15-spring-boot-jwt-auth/)
> [Spring Boot + Angular 16 JWT Authentication](https://www.bezkoder.com/angular-16-spring-boot-jwt-auth/)
> [Spring Boot + Angular 17 JWT Authentication](https://www.bezkoder.com/angular-17-spring-boot-jwt-auth/)
> [Spring Boot + React JWT Authentication](https://bezkoder.com/spring-boot-react-jwt-auth/)
## Fullstack CRUD App
> [Vue.js + Spring Boot + H2 Embedded database example](https://www.bezkoder.com/spring-boot-vue-js-crud-example/)
> [Vue.js + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-vue-js-mysql/)
> [Vue.js + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-vue-js-postgresql/)
> [Angular 8 + Spring Boot + Embedded database example](https://www.bezkoder.com/angular-spring-boot-crud/)
> [Angular 8 + Spring Boot + MySQL example](https://bezkoder.com/angular-spring-boot-crud/)
> [Angular 8 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-spring-boot-postgresql/)
> [Angular 10 + Spring Boot + MySQL example](https://bezkoder.com/angular-10-spring-boot-crud/)
> [Angular 10 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-10-spring-boot-postgresql/)
> [Angular 11 + Spring Boot + MySQL example](https://bezkoder.com/angular-11-spring-boot-crud/)
> [Angular 11 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-11-spring-boot-postgresql/)
> [Angular 12 + Spring Boot + Embedded database example](https://www.bezkoder.com/angular-12-spring-boot-crud/)
> [Angular 12 + Spring Boot + MySQL example](https://www.bezkoder.com/angular-12-spring-boot-mysql/)
> [Angular 12 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/angular-12-spring-boot-postgresql/)
> [Angular 13 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-13-crud/)
> [Angular 13 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-13-mysql/)
> [Angular 13 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-13-postgresql/)
> [Angular 14 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-14-crud/)
> [Angular 14 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-14-mysql/)
> [Angular 14 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-14-postgresql/)
> [Angular 15 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-15-crud/)
> [Angular 15 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-15-mysql/)
> [Angular 15 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-15-postgresql/)
> [Angular 16 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-16-crud/)
> [Angular 16 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-16-mysql/)
> [Angular 16 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-16-postgresql/)
> [Angular 17 + Spring Boot + H2 Embedded Database example](https://www.bezkoder.com/spring-boot-angular-17-crud/)
> [Angular 17 + Spring Boot + MySQL example](https://www.bezkoder.com/spring-boot-angular-17-mysql/)
> [Angular 17 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-17-postgresql/)
> [React + Spring Boot + MySQL example](https://bezkoder.com/react-spring-boot-crud/)
> [React + Spring Boot + PostgreSQL example](https://bezkoder.com/spring-boot-react-postgresql/)
> [React + Spring Boot + MongoDB example](https://bezkoder.com/react-spring-boot-mongodb/)
Run both Back-end & Front-end in one place:
> [Integrate Angular with Spring Boot Rest API](https://bezkoder.com/integrate-angular-spring-boot/)
> [Integrate React.js with Spring Boot Rest API](https://bezkoder.com/integrate-reactjs-spring-boot/)
> [Integrate Vue.js with Spring Boot Rest API](https://bezkoder.com/integrate-vue-spring-boot/)
| 1 |
bitmovin/bitmovin-api-sdk-examples | Set of encoding workflow examples highlighting the use of the Bitmovin API SDKs | null | <p align="center">
<a href="https://www.bitmovin.com">
<img alt="Bitmovin API SDK Examples Header" src="https://cdn.bitmovin.com/frontend/encoding/openapi-clients/readme-headers/Readme_OpenApi_Header.png" >
</a>
<h4 align="center">This repository provides examples demonstrating usage of the <br><a href="https://bitmovin.com/docs/encoding/sdks" target="_blank">Bitmovin API SDKs</a> in different programming languages.</h4>
<p align="center">
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"></img></a>
</p>
</p>
### 💡 Getting started
You'll need an active Bitmovin API key for these examples to work.
> Don't have an account yet? [Sign up for a free Bitmovin trial plan](https://dashboard.bitmovin.com/signup)!
If you are new to the topic, we suggest reading our tutorial [Understanding the Bitmovin Encoding Object Model](https://bitmovin.com/docs/encoding/tutorials/understanding-the-bitmovin-encoding-object-model) to get a basic idea of the building blocks that make up an encoding.
For instructions how to set up the configuration environment and run examples, consult the `README.md` file in the subfolder for your preferred programming language.
For full documentation of all available API endpoints, see the [Bitmovin API reference](https://bitmovin.com/docs/encoding/api-reference).
### Overview
+ [Fixed Bitrate Ladder Encoding](#fixed-bitrate-ladder-encoding)
Generate multiple MP4 renditions from a single input file using a fixed set of resolutions and target bitrates
+ [Generating Default Manifests](#generating-default-manifests)
Generate basic DASH and HLS manifests tailored to your encoding output
+ [Per-Title Encoding](#per-title-encoding)
Generate optimized renditions by letting the Per-Title algorithm choose resolutions and bitrates based on the complexity of your content
+ [Multi Codec Encoding](#multi-codec-encoding)
Run a multi-codec workflow following the best practices.
+ [Multi-language Broadcast TS Encoding](#multi-language-broadcast-ts-encoding)
Add multiple audio streams to a Broadcast TS muxing
+ [Applying Filters](#applying-filters)
Enhance and manipulate content by applying pre-defined video or audio filters
+ [Server-Side Ad Insertion (SSAI)](#server-side-ad-insertion-ssai)
Prevent blocking of ads by delivering a continuous content stream
+ [RTMP Live Encoding](#rtmp-live-encoding)
Start a live encoding using an RTMP stream as input
+ [RTMP Live HD Encoding](#rtmp-live-hd-encoding)
Start a live encoding with HD option using an RTMP stream as input
+ [Batch Encoding](#batch-encoding)
Efficiently start and track a large number of encodings
+ [Multiple Inputs Concatenation](#multiple-inputs-concatenation)
Combine multiple input files into a single output using concatenation and trimming
+ [HDR SDR Conversion](#hdr-sdr-conversion)
Convert dynamic range format between DolbyVision, HDR10, HLG and SDR.
+ [CDN](#cdn)
Use the Bitmovin CDN Streaming storage to distribute your assets.
+ **Content Protection**
+ [Applying CENC DRM Content Protection](#applying-cenc-drm-content-protection)
Encrypt output to prevent unauthorized playback
+ [Applying Content Protection with SPEKE](#applying-drm-content-protection-with-speke)
Obtain DRM keys from a SPEKE server
+ **Audio Manipulations**
Map, mix and merge audio streams and channels from one or multiple sources
+ [Simple Handling - Implicit Mapping](#simple-handling---implicit-mapping)
+ [Simple Handling - Distinct Input Files](#simple-handling---distinct-input-files)
+ [Channel Mixing - Swapping Channels](#channel-mixing---swapping-channels)
+ [Channel Mixing - Downmixing](#channel-mixing---downmixing)
+ [Stream Mapping - Mono Input Tracks](#stream-mapping---mono-input-tracks)
+ [Stream Merging - Multiple Streams](#stream-merging---background-audio)
### More examples?
For more code snippets, and sometimes complete scripts, please have a look at our [tutorials](https://bitmovin.com/docs/encoding/tutorials) and our [Community pages](https://community.bitmovin.com/docs?tags=code-example%7Cbitmovin-encoding&utm_source=github&utm_medium=bitmovin-api-sdk-examples&utm_campaign=dev-community)
---
### Fixed Bitrate Ladder Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/FixedBitrateLadder.cs">C#</a> -
<a href="java/src/main/java/FixedBitrateLadder.java">Java</a> -
<a href="javascript/src/FixedBitrateLadder.ts">TS/JS</a> -
<a href="php/src/FixedBitrateLadder.php">PHP</a> -
<a href="python/src/fixed_bitrate_ladder.py">Python</a>
This example demonstrates how to create multiple MP4 renditions in a single encoding, using a fixed resolution- and bitrate ladder.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Generating Default Manifests
<a href="dotnet/Bitmovin.Api.Sdk.Examples/DefaultManifest.cs">C#</a> -
<a href="java/src/main/java/DefaultManifests.java">Java</a> -
<a href="javascript/src/DefaultManifest.ts">TS/JS</a> -
<a href="php/src/DefaultManifest.php">PHP</a> -
<a href="python/src/default_manifest.py">Python</a>
This example demonstrates how to create basic DASH and HLS manifests for an encoding. Default manifests will try include all the encoding's features that are supported by the respective manifest type.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Per-Title Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/PerTitleEncoding.cs">C#</a> -
<a href="java/src/main/java/PerTitleEncoding.java">Java</a> -
<a href="javascript/src/PerTitleEncoding.ts">TS/JS</a> -
<a href="php/src/PerTitleEncoding.php">PHP</a> -
<a href="python/src/per_title_encoding.py">Python</a>
This example shows how to do a Per-Title encoding with default manifests.
A Per-Title encoding automatically detects the optimal codec settings for your video assets.
Visit https://bitmovin.com/per-title-encoding/ to get an insight what Per-Title encoding is and how it works.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Multi Codec Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/MultiCodecEncoding.cs">C#</a> -
<a href="java/src/main/java/MultiCodecEncoding.java">Java</a> -
<a href="javascript/src/MultiCodecEncoding.ts">TS/JS</a> -
<a href="php/src/MultiCodecEncoding.php">PHP</a> -
<a href="python/src/multi_codec_encoding.py">Python</a>
This example showcases how to run a multi-codec workflow following the best practices.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Multi-language Broadcast TS Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/MultiLanguageBroadcastTs.cs">C#</a> -
<a href="java/src/main/java/MultiLanguageBroadcastTs.java">Java</a> -
<a href="javascript/src/MultiLanguageBroadcastTs.ts">TS/JS</a> -
<a href="php/src/MultiLanguageBroadcastTs.php">PHP</a> -
<a href="python/src/multi_language_broadcast_ts.py">Python</a>
This example demonstrates how multiple audio streams can be included in a BroadcastTS muxing. BroadcastTS muxings are [MPEG transport stream](https://en.wikipedia.org/wiki/MPEG_transport_stream) muxings which allow setting custom properties such as [PCR](https://en.wikipedia.org/wiki/MPEG_transport_stream#PCR) interval and [PID](https://en.wikipedia.org/wiki/MPEG_transport_stream#Packet_identifier_(PID))s for transmission to traditional broadcast targets like set top boxes, QAM streamers and similar devices. This muxing is not generally used for streaming to IP devices such as browsers, iOS, or Android devices.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Applying Filters
<a href="dotnet/Bitmovin.Api.Sdk.Examples/Filters.cs">C#</a> -
<a href="java/src/main/java/Filters.java">Java</a> -
<a href="javascript/src/Filters.ts">TS/JS</a> -
<a href="php/src/Filters.php">PHP</a> -
<a href="python/src/filters.py">Python</a>
This example demonstrates how to apply filters to a video stream. Filters will manipulate the content of a stream, e.g. remove noise or add a watermark image. See the [Encoding Filters API Reference](https://bitmovin.com/docs/encoding/api-reference/sections/filters) for a complete list of available filters.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
+ `WATERMARK_IMAGE_PATH` ([?](#WATERMARK_IMAGE_PATH))
+ `TEXT_FILTER_TEXT` ([?](#TEXT_FILTER_TEXT))
---
### Server-Side Ad Insertion (SSAI)
<a href="dotnet/Bitmovin.Api.Sdk.Examples/ServerSideAdInsertion.cs">C#</a> -
<a href="java/src/main/java/ServerSideAdInsertion.java">Java</a> -
<a href="javascript/src/ServerSideAdInsertion.ts">TS/JS</a> -
<a href="php/src/ServerSideAdInsertion.php">PHP</a> -
<a href="python/src/server_side_ad_insertion.py">Python</a>
This example demonstrates how to create multiple fMP4 renditions with Server Side Ad Insertion (SSAI).
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### RTMP Live Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveEncoding.cs">C#</a> -
<a href="java/src/main/java/RtmpLiveEncoding.java">Java</a> -
<a href="javascript/src/RtmpLiveEncoding.ts">TS/JS</a> -
<a href="php/src/RtmpLiveEncoding.php">PHP</a> -
<a href="python/src/rtmp_live_encoding.py">Python</a>
This example shows how to configure and start a live encoding using default DASH and HLS manifests.
For more information see: https://bitmovin.com/live-encoding-live-streaming
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### RTMP Live HD Encoding
<a href="java/src/main/java/RtmpLiveHdEncoding.java">Java</a> -
<a href="dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveHdEncoding.cs">C#</a> -
<a href="javascript/src/RtmpLiveHdEncoding.ts">TS/JS</a> -
<a href="php/src/RtmpLiveHdEncoding.php">PHP</a> -
<a href="python/src/rtmp_live_hd_encoding.py">Python</a>
This example shows how to configure and start a live encoding with HD option using default DASH and HLS manifests.
For more information see: https://bitmovin.com/live-encoding-live-streaming
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### Batch Encoding
<a href="dotnet/Bitmovin.Api.Sdk.Examples/BatchEncoding.cs">C#</a> -
<a href="java/src/main/java/BatchEncoding.java">Java</a> -
<a href="javascript/src/BatchEncoding.ts">TS/JS</a> -
<a href="php/src/BatchEncoding.php">PHP</a> -
<a href="python/src/batch_encoding.py">Python</a>
This example demonstrates how to efficiently execute a large batch of encodings in parallel. In
order to keep the startup time for each encoding to a minimum, it is advisable to constantly have
some encodings queued. Encodings will therefore be started in a way to maintain a constant queue
size.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### CDN
<a href="java/src/main/java/EncodingWithCdnOutput.java">Java</a> -
<a href="javascript/src/EncodingWithCdnOutput.ts">TS/JS</a> -
<a href="python/src/encoding_with_cdn_output.py">Python</a>
This example demonstrates how to use the Bitmovin CDN Streaming storage to distribute your assets to end users.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
---
### Multiple Inputs Concatenation
<a href="dotnet/Bitmovin.Api.Sdk.Examples/ConcatenationMultipleInputs.cs">C#</a> -
<a href="java/src/main/java/ConcatenationMultipleInputs.java">Java</a> -
<a href="javascript/src/ConcatenationMultipleInputs.ts">TS/JS</a> -
<a href="php/src/ConcatenationMultipleInputs.php">PHP</a> -
<a href="python/src/concatenation_multiple_inputs.py">Python</a>
This example demonstrates how to use concatenation and trimming to combine multiple input files into a single output.
This script is the full version of the script documented in the tutorial on concatenation and trimming https://bitmovin.com/docs/encoding/tutorials/stitching-and-trimming-part-1-the-basics
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `HTTP_INPUT_BUMPER_FILE_PATH` ([?](#HTTP_INPUT_BUMPER_FILE_PATH))
+ `HTTP_INPUT_PROMO_FILE_PATH` ([?](#HTTP_INPUT_PROMO_FILE_PATH))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
---
### HDR SDR Conversion
<a href="python/src/hdr_conversions.py">Python</a> -
<a href="java/src/main/java/HdrConversions.java">Java</a> -
<a href="javascript/src/HdrConversions.ts">TS/JS</a>
This example demonstrates how to convert dynamic range format between DolbyVision, HDR10, HLG and SDR.
The supported HDR/SDR conversions are as follows. If the target output format is either DolbyVision, HDR10 or HLG, this example adds SDR renditions automatically. This example works only with Bitmovin Encoder version 2.98.0 or later.
- Input: DolbyVision
- Output:
- DolbyVision and SDR
- HDR10 and SDR
- Input: HDR10
- Output:
- HDR10 and SDR
- HLG and SDR
- Input: HLG
- Output:
- HLG and SDR
- HDR10 and SDR
- Input: SDR
- Output:
- HDR10 and SDR
- HLG and SDR
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `HTTP_INPUT_AUDIO_FILE_PATH` ([?](#HTTP_INPUT_AUDIO_FILE_PATH))
+ `HDR_CONVERSION_INPUT_FORMAT` ([?](#HDR_CONVERSION_INPUT_FORMAT))
+ `HDR_CONVERSION_OUTPUT_FORMAT` ([?](#HDR_CONVERSION_OUTPUT_FORMAT))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
If you want to load a DolbyVision metadata as a sidecar XML file, the following parameter also needs to be specified. If that parameter is not provided for a DolbyVision encoding, the example assumes the corresponding metadata is embedded into the DolbyVision input mezzanine file itself.
+ `HTTP_INPUT_DOLBY_VISION_METADATA_FILE_PATH` ([?](#HTTP_INPUT_DOLBY_VISION_METADATA_FILE_PATH))
---
### Content Protection
#### Applying CENC DRM Content Protection
<a href="dotnet/Bitmovin.Api.Sdk.Examples/CencDrmContentProtection.cs">C#</a> -
<a href="java/src/main/java/CencDrmContentProtection.java">Java</a> -
<a href="javascript/src/CencDrmContentProtection.ts">TS/JS</a> -
<a href="php/src/CencDrmContentProtection.php">PHP</a> -
<a href="python/src/cenc_drm_content_protection.py">Python</a>
<a href="go/cmd/cenc_drm_content_protection.go">Go</a>
This example shows how DRM content protection can be applied to a fragmented MP4 muxing. DRM is used to prevent playback on unauthorized devices (piracy) and requires integration with a key server.
The encryption is configured to be compatible with both FairPlay and Widevine, using the [MPEG Common Encryption](https://en.wikipedia.org/wiki/MPEG_Common_Encryption) standard.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
+ `DRM_KEY` ([?](#DRM_KEY))
+ `DRM_FAIRPLAY_IV` ([?](#DRM_FAIRPLAY_IV))
+ `DRM_FAIRPLAY_URI` ([?](#DRM_FAIRPLAY_URI))
+ `DRM_WIDEVINE_KID` ([?](#DRM_WIDEVINE_KID))
+ `DRM_WIDEVINE_PSSH` ([?](#DRM_WIDEVINE_PSSH))
---
#### Applying DRM Content Protection with SPEKE
<a href="java/src/main/java/DrmContentProtectionWithSpeke.java">Java</a> -
<a href="javascript/src/DrmContentProtectionWithSpeke.ts">TS/JS</a> -
<a href="python/src/drm_content_protection_with_speke.py">Python</a>
This example builds on the previous one, but shows how keys for DRM content protection
can be obtained from a SPEKE server, and adds FairPlay DRM. Manifests are built
from scratch, with DASH for CENC protected outputs, and HLS for FairPlay
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
+ `SPEKE_URL` ([?](#SPEKE_URL))
+ and for AWS IAM authentication
+ `SPEKE_ARN` ([?](#SPEKE_ARN))
+ `SPEKE_GATEWAY_REGION` ([?](#SPEKE_GATEWAY_REGION))
+ or for simple credentials
+ `SPEKE_USERNAME` ([?](#SPEKE_USERNAME))
+ `SPEKE_PASSWORD` ([?](#SPEKE_PASSWORD))
Optional Parameters
+ `DRM_FAIRPLAY_IV` ([?](#DRM_FAIRPLAY_IV))
+ `DRM_CONTENT_ID` ([?](#DRM_CONTENT_ID))
+ `DRM_KEY_ID` ([?](#DRM_KEY_ID))
---
### Audio Manipulations
A set of examples that demonstrate how to perform audio stream and channel manipulations.
They are provided as illustrations of the [tutorial on audio manipulations]
(https://bitmovin.com/docs/encoding/tutorials/separating-and-combining-audio-streams)
#### Simple Handling - Implicit Mapping
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/SimpleHandlingImplicitMapping.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/SimpleHandling_ImplicitMapping.java">Java</a> -
<a href="javascript/src/AudioManipulations/SimpleHandlingImplicitMapping.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/SimpleHandling_ImplicitMapping.php">PHP</a> -
<a href="python/src/audio_manipulations/simple_handling_implicit_mapping.py">Python</a>
This example demonstrates the simplest mechanism to include a stereo audio stream in an output
MP4, from an input file containing a stereo audio stream (and a video stream), with the use of a
single IngestInputStream.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH_STEREO_SOUND` ([?](#HTTP_INPUT_FILE_PATH_STEREO_SOUND))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
#### Simple Handling - Distinct Input Files
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/SimpleHandlingDistinctInputFiles.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/SimpleHandling_DistinctInputFiles.java">Java</a> -
<a href="javascript/src/AudioManipulations/SimpleHandlingDistinctInputFiles.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/SimpleHandling_DistinctInputFiles.php">PHP</a> -
<a href="python/src/audio_manipulations/simple_handling_distinct_input_files.py">Python</a>
This example demonstrates how to combine and map audio streams from multiple input files into a
single output MP4 file with multiple audio streams/tracks, with multiple IngestInputStreams.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH` ([?](#HTTP_INPUT_FILE_PATH))
+ `HTTP_INPUT_FILE_PATH_STEREO_SOUND` ([?](#HTTP_INPUT_FILE_PATH_STEREO_SOUND))
+ `HTTP_INPUT_FILE_PATH_SURROUND_SOUND` ([?](#HTTP_INPUT_FILE_PATH_SURROUND_SOUND))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
#### Channel Mixing - Swapping Channels
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/ChannelMixingSwappingChannels.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/ChannelMixing_SwappingChannels.java">Java</a> -
<a href="javascript/src/AudioManipulations/ChannelMixingSwappingChannels.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/ChannelMixing_SwappingChannels.php">PHP</a> -
<a href="python/src/audio_manipulations/channel_mixing_swapping_channels.py">Python</a>
This example demonstrates how to swap 2 audio channels from a stereo input, using a simple
AudioMixInputStream configuration.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH_STEREO_SOUND` ([?](#HTTP_INPUT_FILE_PATH_STEREO_SOUND))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
#### Channel Mixing - Downmixing
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/ChannelMixingDownmixing.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/ChannelMixing_Downmixing.java">Java</a> -
<a href="javascript/src/AudioManipulations/ChannelMixingDownmixing.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/ChannelMixing_Downmixing.php">PHP</a> -
<a href="python/src/audio_manipulations/channel_mixing_downmixing.py">Python</a>
This example demonstrates one mechanism to downmix a 5.1 stream down to 2.0.
It uses an advanced AudioMixInputStream configuration with gain adjusted on each input channel.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH_SURROUND_SOUND` ([?](#HTTP_INPUT_FILE_PATH_SURROUND_SOUND))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
#### Stream Mapping - Mono Input Tracks
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/StreamMappingMonoInputTracks.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/StreamMapping_MonoInputTracks.java">Java</a> -
<a href="javascript/src/AudioManipulations/StreamMappingMonoInputTracks.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/StreamMapping_MonoInputTracks.php">PHP</a> -
<a href="python/src/audio_manipulations/stream_mapping_mono_input_tracks.py">Python</a>
This example demonstrates one mechanism to create single output tracks from multiple mono input
tracks, using multiple IngestInputStreams (by position in the source),
and mapping them to output channels (by type).
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH_MULTIPLE_MONO_AUDIO_TRACKS` ([?](#HTTP_INPUT_FILE_PATH_MULTIPLE_MONO_AUDIO_TRACKS))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
#### Stream Merging - Background Audio
<a href="dotnet/Bitmovin.Api.Sdk.Examples/AudioManipulations/StreamMergingBackgroundAudio.cs">C#</a> -
<a href="java/src/main/java/AudioManipulations/StreamMerging_BackgroundAudio.java">Java</a> -
<a href="javascript/src/AudioManipulations/StreamMergingBackgroundAudio.ts">TS/JS</a> -
<a href="php/src/AudioManipulations/StreamMerging_BackgroundAudio.php">PHP</a> -
<a href="python/src/audio_manipulations/stream_merging_background_audio.py">Python</a>
This example demonstrates how to merge multiple stereo streams (from a single file, but this can
easily be extended to select them from separate input files), adjusting gain on the second stream
to turn it into a background effect.
Required configuration parameters:
+ `BITMOVIN_API_KEY` ([?](#BITMOVIN_API_KEY))
+ `BITMOVIN_TENANT_ORG_ID` ([?](#BITMOVIN_TENANT_ORG_ID))
+ `HTTP_INPUT_HOST` ([?](#HTTP_INPUT_HOST))
+ `HTTP_INPUT_FILE_PATH_TWO_STEREO_TRACKS` ([?](#HTTP_INPUT_FILE_PATH_TWO_STEREO_TRACKS))
+ `S3_OUTPUT_BUCKET_NAME` ([?](#S3_OUTPUT_BUCKET_NAME))
+ `S3_OUTPUT_ACCESS_KEY` ([?](#S3_OUTPUT_ACCESS_KEY))
+ `S3_OUTPUT_SECRET_KEY` ([?](#S3_OUTPUT_SECRET_KEY))
+ `S3_OUTPUT_BASE_PATH` ([?](#S3_OUTPUT_BASE_PATH))
## Configuration Parameters
These are the parameters that need to be supplied for the examples to work.
They can be defined in a file, set as environment variables or passed directly to the `run-example` script.
**Note!** See the `README.md` of the API SDK examples in your preferred programming language on how to configure parameters.
<a name="BITMOVIN_API_KEY">**`BITMOVIN_API_KEY`**</a> - Your API key for the Bitmovin API
<a name="BITMOVIN_TENANT_ORG_ID">**`BITMOVIN_TENANT_ORG_ID`**</a> - The ID of the Organisation in which you want to perform the encoding. Only required if working with a multi-tenant account.
<a name="HTTP_INPUT_HOST">**`HTTP_INPUT_HOST`**</a> - The Hostname or IP address of the HTTP server hosting your input files
Example: `my-storage.biz`
<a name="HTTP_INPUT_FILE_PATH">**`HTTP_INPUT_FILE_PATH`**</a> - The path to your input file on the HTTP host
Example: `videos/1080p_Sintel.mp4`
<a name="HTTP_INPUT_BUMPER_FILE_PATH">**`HTTP_INPUT_BUMPER_FILE_PATH`**</a> - The path to your input file on the provided HTTP server to be concatenated before HTTP_INPUT_FILE_PATH
Example: `videos/bumper.mp4`
<a name="HTTP_INPUT_PROMO_FILE_PATH">**`HTTP_INPUT_PROMO_FILE_PATH`**</a> - The path to your input file on the provided HTTP server to be concatenated after HTTP_INPUT_FILE_PATH
Example: `videos/promo.mp4`
<a name="HTTP_INPUT_AUDIO_FILE_PATH">**`HTTP_INPUT_AUDIO_FILE_PATH`**</a> - The path to your audio input file on the provided HTTP server. It's used when you want to load audio stream from a separated input file.
Example: `audio/aac.mp4`
<a name="HTTP_INPUT_DOLBY_VISION_METADATA_FILE_PATH">**`HTTP_INPUT_DOLBY_VISION_METADATA_FILE_PATH`**</a> - The path to your DolbyVision metadata file. This parameter is required only when using a DolbyVision input file with a separated sidecar XML metadata file.
<a name="HDR_CONVERSION_INPUT_FORMAT">**`HDR_CONVERSION_INPUT_FORMAT`**</a> - The input dynamic range format. Either DolbyVision, HDR10, HLG, or SDR can be specified. This parameter needs to be matched with the actual dynamic range format of the input file.
Example: `DolbyVision`, `HDR10`, `HLG`, `SDR`.
<a name="HDR_CONVERSION_OUTPUT_FORMAT">**`HDR_CONVERSION_OUTPUT_FORMAT`**</a> - The output dynamic range format to be converted from the input file.
If the input dynamic range is `DolbyVision`, the supported output dynamic range format is either `DolbyVision`, `HDR10` or `SDR`.
If the input dynamic range is `HDR10`, the supported output dynamic range format is either `HDR10`, `HLG` or `SDR`.
If the input dynamic range is `HLG`, the supported output dynamic range format is either `HDR10`, `HLG` or `SDR`.
If the input dynamic range is `SDR`, the supported output dynamic range format is either `HDR10`, `HLG` or `SDR`.
Example: `DolbyVision`, `HDR10`, `HLG`, `SDR`.
<a name="HTTP_INPUT_FILE_PATH_STEREO_SOUND">**`HTTP_INPUT_FILE_PATH_STEREO_SOUND`**</a> - the path to a file containing a video with a single audio stereo stream
Example: `videos/1080p_Sintel_Stereo.mp4`
<a name="HTTP_INPUT_FILE_PATH_SURROUND_SOUND">**`HTTP_INPUT_FILE_PATH_SURROUND_SOUND`**</a> - the path and filename for a file containing a video with a 5.1 audio stream
Example: `videos/1080p_Sintel_Surround.mp4`
<a name="HTTP_INPUT_FILE_PATH_MULTIPLE_MONO_AUDIO_TRACKS">**`HTTP_INPUT_FILE_PATH_MULTIPLE_MONO_AUDIO_TRACKS`**</a> - the path to a file containing a video with multiple mono audio tracks
Example: `videos/1080p_Sintel_8_Mono_Audio_Tracks.mp4`
<a name="HTTP_INPUT_FILE_PATH_TWO_STEREO_TRACKS">**`HTTP_INPUT_FILE_PATH_TWO_STEREO_TRACKS`**</a> - the path to a file containing a video with 2 stereo tracks
Example: `videos/1080p_Sintel_Two_Stereos.mp4`
<a name="S3_OUTPUT_BUCKET_NAME">**`S3_OUTPUT_BUCKET_NAME`**</a> - The name of your S3 output bucket
Example: `my-s3-bucket-name`
<a name="S3_OUTPUT_ACCESS_KEY">**`S3_OUTPUT_ACCESS_KEY`**</a> - The access key of your S3 output bucket
Example: `AKIAIOSFODNN7EXAMPLE`
<a name="S3_OUTPUT_SECRET_KEY">**`S3_OUTPUT_SECRET_KEY`**</a> - The secret key of your S3 output bucket
Example: `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
<a name="S3_OUTPUT_BASE_PATH">**`S3_OUTPUT_BASE_PATH`**</a> - The base path on your S3 output bucket where content will be written
Example: `/outputs`
<a name="WATERMARK_IMAGE_PATH">**`WATERMARK_IMAGE_PATH`**</a> - The path to the watermark image
Example: `http://my-storage.biz/logo.png`
<a name="TEXT_FILTER_TEXT">**`TEXT_FILTER_TEXT`**</a> - The text to be displayed by the text filter
<a name="DRM_KEY">**`DRM_KEY`**</a> - 16 byte encryption key, represented as 32 hexadecimal characters
Example: `cab5b529ae28d5cc5e3e7bc3fd4a544d`
<a name="DRM_FAIRPLAY_IV">**`DRM_FAIRPLAY_IV`**</a> - 16 byte initialization vector, represented as 32 hexadecimal characters
Example: `08eecef4b026deec395234d94218273d`
<a name="DRM_FAIRPLAY_URI">**`DRM_FAIRPLAY_URI`**</a> - URI of the licensing server
Example: `skd://userspecifc?custom=information`
<a name="DRM_WIDEVINE_KID">**`DRM_WIDEVINE_KID`**</a> - 16 byte encryption key id, represented as 32 hexadecimal characters
Example: `08eecef4b026deec395234d94218273d`
<a name="DRM_WIDEVINE_PSSH">**`DRM_WIDEVINE_PSSH`**</a> - Base64 encoded PSSH payload
Example: `QWRvYmVhc2Rmc2FkZmFzZg==`
<a name="DRM_CONTENT_ID">**`DRM_CONTENT_ID`**</a> - An optional content ID used to register the DRM keys with the SPEKE provider
Example: `my-content-id`
<a name="DRM_KEY_ID">**`DRM_KEY_ID`**</a> - An optional 16-byte hex key ID used to refer to a key stored in the DRM provider system (in particular with SPEKE)
Example: `d94238436e2fe421a27a7d5dd3d26f31`
<a name="SPEKE_URL">**`SPEKE_URL`**</a> - The URL of the SPEKE server
Example: `https://my-speke-server.com/v1.0/vod`
<a name="SPEKE_ARN">**`SPEKE_ARN`**</a> - For AWS IAM authentication, the role ARN for the user providing access to the SPEKE server
Example: `arn:aws:iam::1234567890:role/speke_role_assumption`
<a name="SPEKE_GATEWAY_REGION">**`SPEKE_GATEWAY_REGION`**</a> - For AWS IAM authentication, the AWS Gateway region hosting the SPEKE server
Example: `eu-west-1`
<a name="SPEKE_USERNAME">**`SPEKE_USERNAME`**</a> - For basic authentication with the SPEKE server
<a name="SPEKE_PASSWORD">**`SPEKE_PASSWORD`**</a> - For basic authentication with the SPEKE server
You may also add your own parameters in your configuration. The ConfigProvider class in each example offers a generic function to get the value of the parameter by its name.
| 0 |
cincheo/jsweet-examples | A set of simple examples to show what can be done with the JSweet transpiler (Java to JavaScript) | null | # JSweet examples [](https://github.com/cincheo/jsweet-examples/actions)
A set of simple examples to show what can be done in Java with the [JSweet transpiler](https://github.com/cincheo/jsweet).
All these example are written in Java using the JSweet APIs (candies)] They are then transpiled to JavaScript by the JSweet transpiler.
- Simple canvas drawing (`canvasdrawing`): demonstrates the use of HTML5 canvas. [browse](http://examples.jsweet.org/jsweet-examples/webapp/canvasdrawing/index.html)
- Simple HTML form control (`inputcontrol`): demonstrates the use of HTML5 forms and inputs. [browse](http://examples.jsweet.org/jsweet-examples/webapp/inputcontrol/index.html)
- Simple jQuery (`jquery`): demonstrates the use of JQuery with JSweet. [browse](http://examples.jsweet.org/jsweet-examples/webapp/jquery/index.html)
- Simple Angular (`angularjs`): demonstrates the use of Angular with JSweet. [browse](http://examples.jsweet.org/jsweet-examples/webapp/angularjs/index.html)
- Simple Knockout (`knockoutjs`): demonstrates the use of Knockout with JSweet. [browse](http://examples.jsweet.org/jsweet-examples/webapp/knockoutjs/index.html)
- Ray tracer (`raytracer`): draws a 3D scene, adapted from the TypeScript example page. [browse](http://examples.jsweet.org/jsweet-examples/webapp/raytracer/index.html)
- Todos (`todomvc`): demonstrates the use of Backbone and Underscore with JSweet, adapted from the TypeScript example page. [browse](http://examples.jsweet.org/jsweet-examples/webapp/todomvc/index.html)
- Blocks game (`blocksgame`): demonstrates how to write an HTML5 mobile game with JSweet. [browse](http://examples.jsweet.org/jsweet-examples/webapp/blocksgame/index.html)
- Promises (`promises`): demonstrates the use of the latest EcmaScript6 Promise API. [browse](http://examples.jsweet.org/jsweet-examples/webapp/promises/index.html)
Visit the live JSweet's example page (http://www.jsweet.org/examples) to browse the examples, run them and debug the Java code within your favorite browser. Note that all these examples are responsive and should work as well on a Web browser and on a mobile.
Visit also https://github.com/cincheo/jsweet-examples-threejs for some examples using the Threejs framework (WebGL-powered 3D)]
## Usage
```
> git clone https://github.com/cincheo/jsweet-examples.git
> cd jsweet-examples
```
### Build with Gradle
```
./gradlew jsweetClean jsweet (--refresh-dependencies) (--info)
```
### Build with Maven
```
mvn clean generate-sources
```
### Build with Ant
```
ant
```
### Run in your favorite browser
```
> firefox webapp/${example-name}/index.html
```
## Prerequisites
The `node` and `npm` executables must be in the path (https://nodejs.org)]
Install Maven (https://maven.apache.org/install.html)]
| 0 |
atduskgreg/Processing-Shader-Examples | Experiments working with shaders in Processing. Click the link below for formatted notes. | null | null | 0 |
ramalho/python-patterns-examples | A collection of Design Patters implemented in Python | null | # python-patterns-examples
A collection of Design Patters imlemented in Python
| 0 |
aalmiray/javatrove | Code examples for The Java Trove series | null | null | 0 |
Hemant-Jain-Author/Problem-Solving-in-Data-Structures-Algorithms-using-Java | Code examples of Problem Solving in Data Structures and Algorithms using Java | null | # Problem-Solving-in-Data-Structures-Algorithms-using-Java
**This is the code repository of book "Problem Solving in Data Structures & Algorithms Using Java".**

**About The Book**
- This textbook provides in depth coverage of various Data Structures and Algorithms.
- Concepts are discussed in easy to understand manner.
- Large number of diagrams are provided to grasp concepts easily.
- Time and Space complexities of various algorithms are discussed.
- Helpful for interviews preparation and competitive coding.
- Large number of interview questions are solved.
- Java solutions are provided with input and output.
- Guide you through how to solve new problems in programming interview of various software companies.
**Table of Contents**
- Chapter 0: How to use this book.
- Chapter 1: Algorithms Analysis
- Chapter 2: Approach to solve algorithm design problems
- Chapter 3: Abstract Data Type & JAVA Collections
- Chapter 4: Searching
- Chapter 5: Sorting
- Chapter 6: Linked List
- Chapter 7: Stack
- Chapter 8: Queue
- Chapter 9: Tree
- Chapter 10: Priority Queue
- Chapter 11: Hash-Table
- Chapter 12: Graphs
- Chapter 13: String Algorithms
- Chapter 14: Algorithm Design Techniques
- Chapter 15: Brute Force Algorithm
- Chapter 16: Greedy Algorithm
- Chapter 17: Divide & Conquer
- Chapter 18: Dynamic Programming
- Chapter 19: Backtracking
- Chapter 20: Complexity Theory
| 0 |
4xes/FlipAnimation | Simple example for flip animation | null | ### Simple flip animation demo.
<img src="/art/readme_demo.gif?raw=true" width=360 height=640 alt="Quick Demo"> | 1 |
eventuate-tram/eventuate-tram-examples-customers-and-orders-redis | Microservices, Choreography-based saga, CQRS and Redis! | null | null | 0 |
matsim-org/matsim-example-project | A small example of how to use MATSim as a library. | null | # matsim-example-project
A small example of how to use MATSim as a library.
By default, this project uses the latest (pre-)release. In order to use a different version, edit `pom.xml`.
A recommended directory structure is as follows:
* `src` for sources
* `original-input-data` for original input data (typically not in MATSim format)
* `scenarios` for MATSim scenarios, i.e. MATSim input and output data. A good way is the following:
* One subdirectory for each scenario, e.g. `scenarios/mySpecialScenario01`.
* This minimally contains a config file, a network file, and a population file.
* Output goes one level down, e.g. `scenarios/mySpecialScenario01/output-from-a-good-run/...`.
### Import into eclipse
1. download a modern version of eclipse. This should have maven and git included by default.
1. `file->import->git->projects from git->clone URI` and clone as specified above. _It will go through a
sequence of windows; it is important that you import as 'general project'._
1. `file->import->maven->existing maven projects`
Sometimes, step 3 does not work, in particular after previously failed attempts. Sometimes, it is possible to
right-click to `configure->convert to maven project`. If that fails, the best thing seems to remove all
pieces of the failed attempt in the directory and start over.
### Import into IntelliJ
`File -> New -> Project from Version Control` paste the repository url and hit 'clone'. IntelliJ usually figures out
that the project is a maven project. If not: `Right click on pom.xml -> import as maven project`.
### Java Version
The project uses Java 11. Usually a suitable SDK is packaged within IntelliJ or Eclipse. Otherwise, one must install a
suitable sdk manually, which is available [here](https://openjdk.java.net/)
### Building and Running it locally
You can build an executable jar-file by executing the following command:
```sh
./mvnw clean package
```
or on Windows:
```sh
mvnw.cmd clean package
```
This will download all necessary dependencies (it might take a while the first time it is run) and create a file `matsim-example-project-0.0.1-SNAPSHOT.jar` in the top directory. This jar-file can either be double-clicked to start the MATSim GUI, or executed with Java on the command line:
```sh
java -jar matsim-example-project-0.0.1-SNAPSHOT.jar
```
### Licenses
(The following paragraphs need to be adjusted according to the specifications of your project.)
The **MATSim program code** in this repository is distributed under the terms of the [GNU General Public License as published by the Free Software Foundation (version 2)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html). The MATSim program code are files that reside in the `src` directory hierarchy and typically end with `*.java`.
The **MATSim input files, output files, analysis data and visualizations** are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a><br /> MATSim input files are those that are used as input to run MATSim. They often, but not always, have a header pointing to matsim.org. They typically reside in the `scenarios` directory hierarchy. MATSim output files, analysis data, and visualizations are files generated by MATSim runs, or by postprocessing. They typically reside in a directory hierarchy starting with `output`.
**Other data files**, in particular in `original-input-data`, have their own individual licenses that need to be individually clarified with the copyright holders.
| 1 |
sujee/hbase-mapreduce | map reduce examples on HBaase | null | null | 0 |
puniverse/comsat-examples | Comsat Examples | null | # COMSAT Examples
This project includes some examples that makes use of an embedded Jetty servers and several others that are packaged into WAR files and can be deployed to servlet containers.
## Running the Jetty examples
In the shell:
```sh
gradle :comsat-examples-embeddedjetty:run
```
A Jetty web actors example can be run with:
```sh
gradle :comsat-examples-jetty-webactor:run
```
A Dropwizard example can be run with:
```sh
gradle :comsat-examples-dropwizard:runSimple
```
## Non-web examples
```sh
gradle :comsat-examples-db:runSimple
gradle :comsat-examples-retrofit:runSimple
```
## Running the WAR examples
For convenience, we've included a tiny program (`embedded-tomcat`) that runs a Tomcat server, creates a database, and compiles and deploys all WAR examples.
In the shell, type:
```sh
gradle :embedded-tomcat:run
```
Then, in a web browser, access any of the following links:
* [http://localhost:8080/comsat-examples-servlet/fiberservlet](http://localhost:8080/comsat-examples-servlet/fiberservlet) - a servlet that runs in a fiber.
* [http://localhost:8080/comsat-examples-jaxrs/rest/myresource](http://localhost:8080/comsat-examples-jaxrs/rest/myresource) - a JAX-RS REST service that runs in a fiber (the first time this is accessed, it will take a while as Jersey is initialized).
* [http://localhost:8080/comsat-examples-webactors/webactor](http://localhost:8080/comsat-examples-webactors/webactor) - a WebActors example
### Hot Code Swapping
1. Open an new shell and build the upgrade module:
```sh
gradle :comsat-examples-webactors-codeswap:jar
```
2. Run and access [http://localhost:8080/comsat-examples-webactors/webactor](http://localhost:8080/comsat-examples-webactors/webactor) as explained above.
3. Copy the upgrade module jar file into the `modules/` directory:
```sh
cp comsat-examples-webactors-codeswap/build/libs/comsat-examples-webactors-codeswap.jar modules
```
You will now see the new actor behave differently in the test web page.
## Running Spaceships
Stop the server if running and uncomment the following line in `embedded-tomcat/build.gradle`:
```
from project(":comsat-examples-spaceships").war
```
Restart the server with:
```sh
gradle :embedded-tomcat:run
```
Then, open [http://localhost:8080/comsat-examples-spaceships/login](http://localhost:8080/comsat-examples-spaceships/login) in your browser.
## License
These examples are released under the [MIT license](http://opensource.org/licenses/MIT).
Copyright (c) 2014-2015 Parallel Universe
| 0 |
juneau001/GenericsExamples | null | null | null | 0 |
bibryam/camel-message-routing-examples | Instant Apache Camel Message Routing Examples | null | ### Instant Apache Camel Message Routing Examples
Creating a Camel project
Routing messages to different destinations
Using components
Connecting routes
Removing unwanted messages
Transforming messages
Splitting a message into many
Aggregating multiple messages into one
Reorganizing messages
Multicasting messages
Error handling and monitoring
Testing messaging applications
#### Run the examples with: mvn test
| 0 |
s4/examples | Example applications | null | S4 Example Applications
=======================
This is a set of example applications using S4. To build and deploy an example
1. Read the example's README file for build instructions
2. Refer to the [Getting Started](http://wiki.s4.io/Tutorials/GettingStarted) wiki for instructions on how to deploy and run the application
Realtime Twitter Topic Count
----------------------------
This application detects popular hashtags on Twitter by listening to the
Twitter gardenhose.
Build instructions: twittertopiccount/README.md
| 1 |
eventuate-tram/eventuate-tram-core-examples-basic | Basic examples for Eventuate Tram | null | null | 0 |
yandex-qatools/htmlelements-examples | Getting started examples for HtmlElements framework on java | null | ## HtmlElements Examples
You can find some examples in *test* dir of modules:
### HtmlElements Thucydides Example
[Examples of thucydides + HtmlElements](https://github.com/yandex-qatools/htmlelements-examples/tree/master/htmlelements-thucydides-example/src/test/java/my/company/web)
### HtmlElements JUnit Example
[Getting Started (RU)](https://github.com/yandex-qatools/htmlelements-examples/blob/master/htmlelements-junit-example/src/site/junit-example.md)
[Examples of simple JUnit + HtmlElements source](https://github.com/yandex-qatools/htmlelements-examples/blob/master/htmlelements-junit-example/src/test/java/my/company/web/)
| 0 |
douglascraigschmidt/CS892 | This contains the source code examples and programming assignments for my CS 282 class | null | null | 0 |
little-hands/ddd-examples | null | null | # ddd-examples
DDDのサンプルコードを掲載しています
## パッケージ構成
* com.littlehands
* task_management: シンプルなDDD事例として、タスク管理のサンプルコードです
* aggregate: 集約のサンプルコードです
| 0 |
joinfaces/joinfaces-maven-jar-example | JoinFaces Maven Jar Example | angularfaces bootsfaces butterfaces jetty joinfaces jsf mojarra myfaces primefaces spring-boot tomcat undertow | JoinFaces Example
=====
[](https://github.com/joinfaces/joinfaces-maven-jar-example/actions)
[](https://codecov.io/gh/joinfaces/joinfaces-maven-jar-example)
[](https://sonarcloud.io/dashboard?id=joinfaces_joinfaces-maven-jar-example)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
This SAP (Single Page Application) illustrates JSF usage inside JAR packaged Spring Boot Application.
[JoinFaces](https://joinfaces.org) autoconfigures
[PrimeFaces](https://primefaces.org/),
[PrimeFaces Extensions](https://primefaces-extensions.github.io/),
[Apache MyFaces Tobago](https://github.com/apache/myfaces-tobago),
[OmniFaces](https://omnifaces.org/),
[AdminFaces](https://adminfaces.github.io/site/),
[Mojarra](https://eclipse-ee4j.github.io/mojarra/) and
[MyFaces](http://myfaces.apache.org) libraries to run at embedded
[Tomcat](https://tomcat.apache.org/),
[Jetty](https://www.eclipse.org/jetty) or
[Undertow](https://undertow.io/).
It autoconfigures [Weld](https://weld.cdi-spec.org),
[Apache OpenWebBeans](https://openwebbeans.apache.org/) and
[Rewrite](https://www.ocpsoft.org/rewrite/) too.
## Run Example Application locally
1- Clone this project
```Shell
git clone https://github.com/joinfaces/joinfaces-maven-jar-example.git
```
2- Build
```Shell
mvn clean install
```
3- Run
```Shell
java -jar target/joinfaces-example-5.3.x.jar
```
4- Access starter page at **http://localhost:8080/** This page can help you to choose the JoinFaces Starter that fits your needs. You may log in with credentials
| User | Password | Roles |
|------------|----------|------------|
| persapiens | 123 | ROLE_ADMIN |
| nyilmaz | qwe | ROLE_USER |
Optional: If your IDE is showing build errors install [Lombok](https://projectlombok.org/setup/overview)
## Key Files
### pom.xml
Includes joinfaces starter dependency. All other jsf dependencies are included transitively.
```xml
<properties>
<joinfaces.version>5.3.0-m3</joinfaces.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-bom</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>faces-spring-boot-starter</artifactId>
</dependency>
</dependencies>
```
Note that **security-spring-boot-starter** is included to secure the application.
```xml
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>security-spring-boot-starter</artifactId>
</dependency>
</dependencies>
```
### src/main/resources/application.yml
Configure faces.PROJECT_STATE and faces.primefaces.THEME properties.
```yml
joinfaces:
faces:
PROJECT_STAGE: Development
primefaces:
theme: overcast
```
### src/main/resources/META-INF/resources/content/starter.xhtml
Example page to help you choose the right JoinFaces Starter for you.
Note that xhtml, js, css and images files should be located at **src/main/resources/META-INF/resources** directory to JSF use them.
Look at **authorize** and **anonymous** jsf spring security facelet tags in action to secure page information.
```xhtml
<sec:authorize access="hasRole('ROLE_ADMIN')">
<p:panelGrid columns="1" rendered="#{sec:isFullyAuthenticated()}">
<p:link title="Logout" href="/logout">
<p:outputLabel value="You are logged in as an ADMIN" />
</p:link>
</p:panelGrid>
</sec:authorize>
```
### src/main/java/org/joinfaces/example/JoinFacesExampleApplication.java
Very simple spring main application. Only SpringBootApplication annotation is required.
<pre>
@SpringBootApplication
public class JoinFacesExampleApplication {
</pre>
### src/main/java/org/joinfaces/example/SecurityConfig.java
Spring Security configuration class to secure authentication with credentials to persapiens and nyilmaz users.
### src/main/java/org/joinfaces/example/view/StarterMBean.java
Managed bean using ViewScoped CDI annotation. The equivalent spring scope of ViewScoped annotation is configured automatically by JoinFaces Starter.
<pre>
@Named
<b>@ViewScoped</b>
public class StarterMBean {
</pre>
## Getting Help
* Take a look at [JoinFaces Wiki](https://github.com/joinfaces/joinfaces/wiki).
* Report questions and bugs at [github.com/joinfaces/joinfaces-example/issues](https://github.com/joinfaces/joinfaces-maven-jar-example/issues).
## Contributing
* Report documentation, features, enhancement and bugs at [github.com/joinfaces/joinfaces-example/issues](https://github.com/joinfaces/joinfaces-maven-jar-example/issues).
* Pull requests are welcome.
| 1 |
graalvm/simplelanguage | A simple example language built using the Truffle API. | null | # SimpleLanguage
A simple demonstration language built using Truffle for GraalVM.
SimpleLanguage is heavily documented to explain the how and why of writing a
Truffle language. A good way to find out more is to read the source with
comments. Start reading [here](https://github.com/graalvm/simplelanguage/blob/master/language/src/main/java/com/oracle/truffle/sl/SLLanguage.java).
We also like to encourage people to clone the repository and start hacking.
This repository is licensed under the permissive UPL licence. Fork it to begin
your own Truffle language.
For instructions on how to get started please refer to [our website](http://www.graalvm.org/docs/graalvm-as-a-platform/implement-language/)
# Building for a JVM
Build the project with `mvn package`.
To run simple language using a JDK from JAVA_HOME run `./sl`.
# Building a Native Image
Build the project with `mvn package -Pnative`.
To run simple language natively run `./standalone/target/slnative`.
| 1 |
graalvm/fastr-examples | null | null | # GraalVM Examples
A collection of examples and use-cases for the GraalVM and FastR.
[GraalVM](http://graalvm.org) is a universal virtual machine for running applications written in JavaScript,
Python 3, Ruby, R, JVM-based languages like Java, Scala, Kotlin, and LLVM-based languages
such as C and C++.
FastR is a GraalVM based implementation of the R programming language, that provides significant improvements in the performance of R code,
the embedding of the R execution engine into Java applications, and the ability to interface with other GraalVM and JVM languages including Python, Java, and Scala.
FastR is also able to utilize the [tooling support](https://medium.com/graalvm/analyzing-the-heap-of-graalvm-polyglot-applications-b9963e68a6a) provided by the
[GraalVM ecosystem](https://medium.com/graalvm/graalvm-ten-things-12d9111f307d).
* [FastR Java UI](./fastr_javaui/README.md) is a Java based Swing desktop UI application showing visualization interactively generated an by R script.
* [rJava Benchmark](./r_java_bench) shows how fast rJava can be on FastR (spoiler: orders of magnitude faster).
* [FastR Embedding](./r_java_embedding) show how to embed FastR into Java applications and pass Java objects to R scripts like if they were native R objects (e.g. R data frame).
* [Weather Predictor](./weather_predictor/README.md) is an application that performs temperature prediction using Ruby, R and Node.js.
* [FastR Scalar](./fastr_scalar/README.md) is a simple, straightforward implementation of "Conway's Game of Life" written in R.
* [Node.js & FastR](./fastr_node/README.md) is a Node.js web server showing visualization computed and generated in FastR.
## Setup
In order to run the examples, the latest GraalVM must be installed.
It can be downloaded from the [GraalVM homepage](http://www.graalvm.org/downloads/).
The examples work on both the Community and Enterprise edition of GraalVM.
Once downloaded, extract the archive, set the `GRAALVM_DIR` environment variable to point to the graalvm directory,
and install additional languages using [`./install_components.sh`](install_components.sh).
## Further information
* [GraalVM homepage](http://graalvm.org)
* [FastR reference manual](http://www.graalvm.org/docs/reference-manual/languages/r/)
* [FastR on Github](https://github.com/oracle/fastr)
## License
All the examples are licensed under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0).
## Troubleshooting
A typical problem is proxy set-up: verify that you have the `http_proxy`, `https_proxy`, and `no_proxy` environment variables set properly.
| 0 |
CuteXiaoKe/iText7-examples | iText7官网系列教程的样例,持续更新,并且自己有博客介绍程序 | null | # iText7-examples
## 介绍
iText7官网上有三本电子书的,目前已翻译完成:
1. 《iText 7 Jump-Start Tutorial》
2. 《iText 7: Building Blocks》
3. 《iText 7: Converting HTML to PDF with pdfHTML》
访问我的[CSDN博客](https://blog.csdn.net/u012397189),CSDN上面有专栏,[iText学习笔记](https://blog.csdn.net/u012397189/category_9270695.html
)对应第一本书的内容,还有一些自己的一些见解。
目前正在整理和翻译《Digital Signatures for PDF documents》,这本书是itext5版本的,正在转换成iText7版本。
还有收集网友问题、系统整理iText相关资料,自己总结。
## 系列文章
《iText 7 Jump-Start Tutorial》的翻译文章:
0. 系列导读,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/52161418) | [知乎](https://zhuanlan.zhihu.com/p/375104044)
1. 第一章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/52161461) | [知乎](https://zhuanlan.zhihu.com/p/375109293) | [公众号](https://mp.weixin.qq.com/s/O7B6o_9bnvcsEaqBLmtlWA) 代码实践:[CSDN
博客](https://blog.csdn.net/u012397189/article/details/74926755)
2. 第二章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/76726576) | [知乎](https://zhuanlan.zhihu.com/p/393654915) | [公众号](https://mp.weixin.qq.com/s/83IKa_Vr32Wy2K2tq_VjAA) 代码实践:[CSDN
博客](https://blog.csdn.net/u012397189/article/details/77119609)
3. 第三章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/77540464) | [知乎](https://zhuanlan.zhihu.com/p/397083648) | [公众号](https://mp.weixin.qq.com/s/d3T97V6jUV7cox4aeZ7MAQ) 代码实践:[CSDN
博客](https://blog.csdn.net/u012397189/article/details/77541052)
4. 第四章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/77942866) | [知乎](https://zhuanlan.zhihu.com/p/462476906) | [公众号](https://mp.weixin.qq.com/s/tEU1UoVSHmWOvzcaq-9L1A) 代码实践:[CSDN博客](https://blog.csdn.net/u012397189/article/details/77945763)
5. 第五章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78558619) | [知乎](https://zhuanlan.zhihu.com/p/481364611) | [公众号](https://mp.weixin.qq.com/s/RIHeJQMqxyT9BSz2UUvbRQ) 代码实践:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78559277)
6. 第六章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78742207) | [知乎](https://zhuanlan.zhihu.com/p/586693000) 代码实践:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78745027)
7. 第七章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78882454) | [知乎](https://zhuanlan.zhihu.com/p/587443224) 代码实践:[CSDN博客](https://blog.csdn.net/u012397189/article/details/78885790)
《iText 7: Building Blocks》的翻译文章:
0. 系列导读,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/79834501)
1. 第一章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/79888252) 代码实践:[CSDN博客](https://blog.csdn.net/u012397189/article/details/79915660)
2. 第二章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/91346951)
3. 第三章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/117649650)
4. 第四章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/125724156)
5. 第五章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/126345744)
6. 第六章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/126645769)
7. 第七章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/126837712)
《iText 7: Converting HTML to PDF with pdfHTML》的翻译文章
1. 第一章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/127058001)
2. 第二章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/127150134)
3. 第三章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/127394654)
4. 第四章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/127683350)
5. 第五章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/127976075)
6. 第六章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/128039175)
7. 第七章,文章地址:[CSDN博客](https://blog.csdn.net/u012397189/article/details/128136342)
## 目录结构
iText-start文件夹对应《iText 7 Jump-Start Tutorial》,《iText 7: Building Blocks》源码请查阅[官方源码](https://github.com/itext/i7js-highlevel),《iText 7: Converting
HTML to
PDF with
pdfHTML》请查阅[官方源码](https://github.com/itext/i7js-examples),里面每一目录都是IDEA工程,采用maven构建项目
或者直接点击[微信文章](https://mp.weixin.qq.com/s/wCcyLlLqOhay00lzuSsEUg)下载代码资源
## 运行
使用IDE打开工程,maven构建项目即可。
## 微信公众号
欢迎关注我的微信公众号:CuteXiaoKe,里面有最新的pdf相关知识和资源。

## LICENSE
本项目遵循iText7的APGL协议。 | 0 |
fishpro/spring-boot-study | about learning Spring Boot via examples. 基于 spring boot 2.x 的学习教程简洁易懂 | shiro spring spring-boot spring-boot-examples spring-boot-jwt spring-boot-mybatis spring-boot-redis spring-boot-security spring-boot-shiro spring-boot-upload-file spring-boot-webservice spring-jpa thymeleaf xmldom4j | 最近上来看了下,还有兄弟在看这个教程,不胜荣幸,我最近上 github 的实际不多,有问题请加微信号 fishpro 或 QQ 502086
# 为什么要写 Spring Boot 系列文章
好记性不如烂笔头,学习 Spring Boot 一定要自己多练练,并能够把他记录下来,当有需要的时候,可以查看自己编写功能教程,能够很快获取相关代码,使用到项目中。
本系列文章是针对 Spring Boot 各个知识点实战训练的笔记,所有代码都经过测试获取正确的结果。并且不断的添加到本系列中。
本教程适用 Spring Boot 2.x 版本,当有代码对 Spring Boot 版本有特别要求的时候的时候,示例说明中有特别说明。
**喜欢的给个 star 呗**
# Spring Boot 知识图谱-入门教程目录
本系列文章一般都是一个知识点一个独立的项目源码,综合应用可能包含多个知识点,比如动态数据源切换技术本身包括 Aop、注解、数据库访问、连接池。





## 了解 Spring Boot
- [Spring Boot 入门前的准备-Java JDK for window mac 安装](https://www.cnblogs.com/fishpro/p/spring-knowledge-graph-1-window-mac-install-jdk.html)
- [Spring Boot 入门前的准备-IntelliJ IDEA 开发工具的安装与使用](https://www.cnblogs.com/fishpro/p/spring-knowledge-graph-1-java-ide.html)
- [Spring Boot 概述](https://www.cnblogs.com/fishpro/p/11135358.html)
- [Spring Boot 特性及Spring Boot 2.0新特性](https://www.cnblogs.com/fishpro/p/11135362.html)
- [Spring Boot 学习前你应该知道的 Maven 知识](https://www.cnblogs.com/fishpro/p/11140900.html)
- [Spring Boot 学习之 IDEA 环境下多模块 Multi Modules](https://www.cnblogs.com/fishpro/p/11165827.html)
- [Spring Boot 学习之 IDEA 环境下的 github 创建提交与修改](https://www.cnblogs.com/fishpro/p/11167353.html)
- [Spring Boot 快速入门 HelloWorld示例](https://www.cnblogs.com/fishpro/p/spring-boot-study-helloworld.html)
- [Spring Boot 快速入门 HelloWorld示例详解](https://www.cnblogs.com/fishpro/p/10675293.html)
- [Spring Boot 学习方法论-如何正确的入门 Sprint Boot](https://www.cnblogs.com/fishpro/p/11144008.html)
## Spring Boot 环境及配置
- [Spring Boot 多环境配置](https://www.cnblogs.com/fishpro/p/11154872.html)
- [Spring Boot 自定义 Banner](https://www.cnblogs.com/fishpro/p/spring-boot-study-banner.html)
- Spring Boot 生产环境部署方式
- [Spring Boot 配置文件和命令行配置](https://www.cnblogs.com/fishpro/p/spring-boot-study-cfg.html)
- [Spring Boot 利用 nginx 实现生产环境的伪热更新](https://www.cnblogs.com/fishpro/p/spring-boot-study-hotstart.html)
## Spring Boot Web 开发
- [Spring Boot @Controller @RestController 使用教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-restcontroller.html)
- [SpringBoot RESTful API 架构风格实践](https://www.cnblogs.com/fishpro/p/spring-boot-study-restful.html)
- [Spring Boot RestApi 测试教程 Mock 的使用](https://www.cnblogs.com/fishpro/p/spring-boot-study-resttest-mock.html)
- [Spring Boot 集成 Swagger2 教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-swagger2.html)
## Spring Boot 基础
- [Spring Boot Log 日志管理](https://www.cnblogs.com/fishpro/p/11167469.html)
- [Spring Boot 全局异常处理](https://www.cnblogs.com/fishpro/p/11179688.html)
- [Spring Boot 使用 Aop 实现日志全局拦截](https://www.cnblogs.com/fishpro/p/11183086.html)
- Spring Boot 中的日期处理
- [Spring Boot Thymeleaf 模板引擎的使用](https://www.cnblogs.com/fishpro/p/11175391.html)
- [Spring Boot FreeMarker 使用教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-freemarker.html)
- SpringBoot使用模板 Velocity(Spring Boot 已经不支持 Velocity了
## Spring Boot 持久层技术
- [Spring Boot 数据库应用 JDBC 使用教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-jdbc.html)
- [Spring Boot 数据库应用 Mybatis使用教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-mybatis.html)
- [Spring Boot 数据库应用 使用Jpa使用教程](https://www.cnblogs.com/fishpro/p/spring-boot-study-jpa.html)
- [Spring Boot 数据库应用 动态数据源](https://www.cnblogs.com/fishpro/p/spring-boot-study-dynamicdb.html)
- [Spring Boot Kafka 入门示例](https://www.cnblogs.com/fishpro/p/12784514.html)
## Spring Boot 缓存技术
- [Spring Boot 中的缓存应用(上)使用ehcache](https://www.cnblogs.com/fishpro/p/spring-boot-study-ehcache.html)
- [Spring Boot 中的缓存应用(中)使用Redis](https://www.cnblogs.com/fishpro/p/spring-boot-study-redis.html)
- [Spring Boot 中的缓存应用(下)使用Memcached](https://www.cnblogs.com/fishpro/p/spring-boot-study-memcached.html)
## Spring Boot 安全
- [Spring Boot 权限应用 使用Shiro](https://www.cnblogs.com/fishpro/p/spring-boot-study-study.html)
- [Spring Boot 权限应用 使用Spring Security](https://www.cnblogs.com/fishpro/p/spring-boot-study-securing.html)
- [Spring Boot 权限应用 使用Jwt](https://www.cnblogs.com/fishpro/p/spring-boot-study-jwt.html)
- [Spring Boot Shiro 整合验证码]
## Spring Boot 常用操作
- [Spring Boot 文件上传](https://www.cnblogs.com/fishpro/p/spring-boot-study-upload.html)
- [Spring Boot 操作 Excel](https://www.cnblogs.com/fishpro/p/spring-boot-study-excel.html)
- [Spring Boot使用Quartz定时任务](https://www.cnblogs.com/fishpro/p/spring-boot-study-quartz.html)
- [Spring Boot 邮件发送](https://www.cnblogs.com/fishpro/p/spring-boot-study-sendemail.html)
- [Spring Boot FTP上传与下载](https://www.cnblogs.com/fishpro/p/spring-boot-study-ftpclient.html)
- [Spring Boot 中使用 HttpClient 进行 POST GET PUT DELETE](https://www.cnblogs.com/fishpro/p/spring-boot-study-httpclient.html)
- [Spring Boot 开放 WebService 服务](https://www.cnblogs.com/fishpro/p/spring-boot-study-webservice.html)
- [Spring Boot 使用 CXF 调用 WebService 服务](https://www.cnblogs.com/fishpro/p/spring-boot-study-cxfclient.html)
- [Spring Boot 使用 JAX-WS 调用 WebService 服务](https://www.cnblogs.com/fishpro/p/spring-boot-study-webservicejaxws.html)
- [Spring Boot Json应用 JackJson FastJson](https://www.cnblogs.com/fishpro/p/spring-boot-study-jackjson.html)
- [Spring Boot 使用 Dom4j XStream 操作 Xml](https://www.cnblogs.com/fishpro/p/spring-boot-study-xml.html)
## Spring Boot 生产环境实战
- [Spring Boot 利用 nginx 实现生产环境的伪热更新](https://www.cnblogs.com/fishpro/p/spring-boot-study-hotstart.html)
- [Spring Boot 多站点利用 Redis 实现 Session 共享](https://www.cnblogs.com/fishpro/p/spring-boot-study-sharedsession.html)
| 0 |
IanDarwin/patterns-demos | Examples of Design Patterns in Java | design-patterns java patterns | null | 0 |
perspilling/jdbi-examples | Some examples of using JDBI as a persistence framework | null | # JDBI examples
This repo contains some example code used to try out using [JDBI](http://jdbi.org) as a persistence framework
in Java projects.
The domain model used in the examples looks like this:
| Team | ---> | Person | -(cascade)-> | Address |
## Notes
### CGLIB issue with references
JDBI generates boilerplate code from annotated interfaces or abstract classes. When using
abstract classes it would be nice to di the following:
```java
@RegisterMapper(AddressMapper.class)
public abstract class AddressAbstractClassJdbiDao implements AddressDao {
}
...
public Foo {
private AddressDao addressDao = dbi.onDemand(AddressAbstractClassJdbiDao.class);
}
```
However, this doesn't work. You will get a null pointer exception. Instead you must use
the abstract (implementation) class as reference, like this:
```java
@RegisterMapper(AddressMapper.class)
public abstract class AddressAbstractClassJdbiDao implements AddressDao {
}
...
public Foo {
private AddressAbstractClassJdbiDao addressDao = dbi.onDemand(AddressAbstractClassJdbiDao.class);
}
```
### CGLIB issue with abstract classes
It seems that when using abstract classes with CGLIB you need to put them in a separate file,
otherwise you get the following error:
```
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at org.skife.jdbi.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721)
at org.skife.jdbi.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
```
| 0 |
beaunus/stanford-algs | Example Test Cases for Stanford's Algorithms Coursera Specialization | algorithms algorithms-stanford coursera stanford stanford-algs test-cases | # stanford-algs
## Overview
This repository contains some example test case files for Stanford's Coursera specialization [_Learn To Think Like A Computer Scientist_](https://www.coursera.org/specializations/algorithms)
## Intention
These files are intended to be used as a supplement to the above course.
In order to comply with the [Coursera Honor Code](https://www.google.com/search?q=Coursera+Honor+Code), please do not share any solutions to the _actual_ assignments from the course.
## Getting Started
If you want to know more about using this repository, check out the [wiki](https://github.com/beaunus/stanford-algs/wiki).
## Contributing
If you are interested in contributing, please read our [CONTRIBUTING](CONTRIBUTING.md) guide.
## Disclaimer
The programming assignments themselves are intellectual property of the Coursera course. The Coursera community has given permission to re-publish the assignments.
Any infringement on intellectual property rights is accidental. If you feel that this repository is out of line, please let us know and we will do our best to comply with your request.
| 1 |
Cascading/Impatient | source examples to support the Cascading for the Impatient" blog post series" | null | ## Cascading for the Impatient
Welcome to [Cascading for the Impatient](http://docs.cascading.org/impatient), a tutorial for [Cascading 3.1.x](http://www.cascading.org/) to get you started. Quickly. Like, yesterday.
This set of progressive coding examples starts with a simple file copy and builds up to a MapReduce implementation of the TF-IDF algorithm.
You can read the full series here: http://docs.cascading.org/impatient/
If you have a question or run into any problems send an email to the [cascading-user-list](https://groups.google.com/forum/#!forum/cascading-user).
### Part 1
* Implements simplest Cascading app possible
* Copies each TSV line from source tap to sink tap
* Roughly, in about a dozen lines of code
* Physical plan: 1 Mapper
### Part 2
* Implements a simple example of WordCount
* Uses a regex to split the input text lines into a token stream
* Generates a DOT file, to show the Cascading flow graphically
* Physical plan: 1 Mapper, 1 Reducer
### Part 3
* Uses a custom Function to scrub the token stream
* Discusses when to use standard Operations vs. creating custom ones
* Physical plan: 1 Mapper, 1 Reducer
### Part 4
* Shows how to use a HashJoin on two pipes
* Filters a list of stop words out of the token stream
* Physical plan: 1 Mapper, 1 Reducer
### Part 5
* Calculates TF-IDF using an ExpressionFunction
* Shows how to use a CountBy, SumBy, and a CoGroup
* Physical plan: 10 Mappers, 8 Reducers
### Part 6
* Includes unit tests in the build
* Shows how to use other TDD features: checkpoints, assertions, traps, debug
* Physical plan: 11 Mappers, 8 Reducers
### Part 7
This example is currently not implemented.
### Part 8
* Scalding equivalents of previous examples in Cascading
| 0 |
ddd-by-examples/library | A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns. | aggregate aggregate-root archunit c4 crud ddd ddd-architecture domain-driven-design event-storming events functions hexagonal-architecture ports-and-adapters spring vavr | [](https://circleci.com/gh/ddd-by-examples/library)
[](https://codecov.io/gh/ddd-by-examples/library)
# Table of contents
1. [About](#about)
2. [Domain description](#domain-description)
3. [General assumptions](#general-assumptions)
3.1 [Process discovery](#process-discovery)
3.2 [Project structure and architecture](#project-structure-and-architecture)
3.3 [Aggregates](#aggregates)
3.4 [Events](#events)
3.4.1 [Events in Repositories](#events-in-repositories)
3.5 [ArchUnit](#archunit)
3.6 [Functional thinking](#functional-thinking)
3.7 [No ORM](#no-orm)
3.8 [Architecture-code gap](#architecture-code-gap)
3.9 [Model-code gap](#model-code-gap)
3.10 [Spring](#spring)
3.11 [Tests](#tests)
4. [How to contribute](#how-to-contribute)
5. [References](#references)
## About
This is a project of a library, driven by real [business requirements](#domain-description).
We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development,
Event Storming, User Story Mapping.
## Domain description
A public library allows patrons to place books on hold at its various library branches.
Available books can be placed on hold only by one patron at any given point in time.
Books are either circulating or restricted, and can have retrieval or usage fees.
A restricted book can only be held by a researcher patron. A regular patron is limited
to five holds at any given moment, while a researcher patron is allowed an unlimited number
of holds. An open-ended book hold is active until the patron checks out the book, at which time it
is completed. A closed-ended book hold that is not completed within a fixed number of
days after it was requested will expire. This check is done at the beginning of a day by
taking a look at daily sheet with expiring holds. Only a researcher patron can request
an open-ended hold duration. Any patron with more than two overdue checkouts at a library
branch will get a rejection if trying a hold at that same library branch. A book can be
checked out for up to 60 days. Check for overdue checkouts is done by taking a look at
daily sheet with overdue checkouts. Patron interacts with his/her current holds, checkouts, etc.
by taking a look at patron profile. Patron profile looks like a daily sheet, but the
information there is limited to one patron and is not necessarily daily. Currently a
patron can see current holds (not canceled nor expired) and current checkouts (including overdue).
Also, he/she is able to hold a book and cancel a hold.
How actually a patron knows which books are there to lend? Library has its catalogue of
books where books are added together with their specific instances. A specific book
instance of a book can be added only if there is book with matching ISBN already in
the catalogue. Book must have non-empty title and price. At the time of adding an instance
we decide whether it will be Circulating or Restricted. This enables
us to have book with same ISBN as circulated and restricted at the same time (for instance,
there is a book signed by the author that we want to keep as Restricted)
## General assumptions
### Process discovery
The first thing we started with was domain exploration with the help of Big Picture EventStorming.
The description you found in the previous chapter, landed on our virtual wall:

The EventStorming session led us to numerous discoveries, modeled with the sticky notes:

During the session we discovered following definitions:

This made us think of real life scenarios that might happen. We discovered them described with the help of
the **Example mapping**:

This in turn became the base for our *Design Level* sessions, where we analyzed each example:

Please follow the links below to get more details on each of the mentioned steps:
- [Big Picture EventStorming](./docs/big-picture.md)
- [Example Mapping](docs/example-mapping.md)
- [Design Level EventStorming](docs/design-level.md)
### Project structure and architecture
At the very beginning, not to overcomplicate the project, we decided to assign each bounded context
to a separate package, which means that the system is a modular monolith. There are no obstacles, though,
to put contexts into maven modules or finally into microservices.
Bounded contexts should (amongst others) introduce autonomy in the sense of architecture. Thus, each module
encapsulating the context has its own local architecture aligned to problem complexity.
In the case of a context, where we identified true business logic (**lending**) we introduced a domain model
that is a simplified (for the purpose of the project) abstraction of the reality and utilized
hexagonal architecture. In the case of a context, that during Event Storming turned out to lack any complex
domain logic, we applied CRUD-like local architecture.

If we are talking about hexagonal architecture, it lets us separate domain and application logic from
frameworks (and infrastructure). What do we gain with this approach? Firstly, we can unit test most important
part of the application - **business logic** - usually without the need to stub any dependency.
Secondly, we create ourselves an opportunity to adjust infrastructure layer without the worry of
breaking the core functionality. In the infrastructure layer we intensively use Spring Framework
as probably the most mature and powerful application framework with an incredible test support.
More information about how we use Spring you will find [here](#spring).
As we already mentioned, the architecture was driven by Event Storming sessions. Apart from identifying
contexts and their complexity, we could also make a decision that we separate read and write models (CQRS).
As an example you can have a look at **Patron Profiles** and *Daily Sheets*.
### Aggregates
Aggregates discovered during Event Storming sessions communicate with each other with events. There is
a contention, though, should they be consistent immediately or eventually? As aggregates in general
determine business boundaries, eventual consistency sounds like a better choice, but choices in software
are never costless. Providing eventual consistency requires some infrastructural tools, like message broker
or event store. That's why we could (and did) start with immediate consistency.
> Good architecture is the one which postpones all important decisions
... that's why we made it easy to change the consistency model, providing tests for each option, including
basic implementations based on **DomainEvents** interface, which can be adjusted to our needs and
toolset in future. Let's have a look at following examples:
* Immediate consistency
```groovy
def 'should synchronize Patron, Book and DailySheet with events'() {
given:
bookRepository.save(book)
and:
patronRepo.publish(patronCreated())
when:
patronRepo.publish(placedOnHold(book))
then:
patronShouldBeFoundInDatabaseWithOneBookOnHold(patronId)
and:
bookReactedToPlacedOnHoldEvent()
and:
dailySheetIsUpdated()
}
boolean bookReactedToPlacedOnHoldEvent() {
return bookRepository.findBy(book.bookId).get() instanceof BookOnHold
}
boolean dailySheetIsUpdated() {
return new JdbcTemplate(datasource).query("select count(*) from holds_sheet s where s.hold_by_patron_id = ?",
[patronId.patronId] as Object[],
new ColumnMapRowMapper()).get(0)
.get("COUNT(*)") == 1
}
```
_Please note that here we are just reading from database right after events are being published_
Simple implementation of the event bus is based on Spring application events:
```java
@AllArgsConstructor
public class JustForwardDomainEventPublisher implements DomainEvents {
private final ApplicationEventPublisher applicationEventPublisher;
@Override
public void publish(DomainEvent event) {
applicationEventPublisher.publishEvent(event);
}
}
```
* Eventual consistency
```groovy
def 'should synchronize Patron, Book and DailySheet with events'() {
given:
bookRepository.save(book)
and:
patronRepo.publish(patronCreated())
when:
patronRepo.publish(placedOnHold(book))
then:
patronShouldBeFoundInDatabaseWithOneBookOnHold(patronId)
and:
bookReactedToPlacedOnHoldEvent()
and:
dailySheetIsUpdated()
}
void bookReactedToPlacedOnHoldEvent() {
pollingConditions.eventually {
assert bookRepository.findBy(book.bookId).get() instanceof BookOnHold
}
}
void dailySheetIsUpdated() {
pollingConditions.eventually {
assert countOfHoldsInDailySheet() == 1
}
}
```
_Please note that the test looks exactly the same as previous one, but now we utilized Groovy's
**PollingConditions** to perform asynchronous functionality tests_
Sample implementation of event bus is following:
```java
@AllArgsConstructor
public class StoreAndForwardDomainEventPublisher implements DomainEvents {
private final JustForwardDomainEventPublisher justForwardDomainEventPublisher;
private final EventsStorage eventsStorage;
@Override
public void publish(DomainEvent event) {
eventsStorage.save(event);
}
@Scheduled(fixedRate = 3000L)
@Transactional
public void publishAllPeriodically() {
List<DomainEvent> domainEvents = eventsStorage.toPublish();
domainEvents.forEach(justForwardDomainEventPublisher::publish);
eventsStorage.published(domainEvents);
}
}
```
To clarify, we should always aim for aggregates that can handle a business operation atomically
(transactionally if you like), so each aggregate should be as independent and decoupled from other
aggregates as possible. Thus, eventual consistency is promoted. As we already mentioned, it comes
with some tradeoffs, so from the pragmatic point of view immediate consistency is also a choice.
You might ask yourself a question now: _What if I don't have any events yet?_. Well, a pragmatic
approach would be to encapsulate the communication between aggregates in a _Service-like_ class,
where you could call proper aggregates line by line explicitly.
### Events
Talking about inter-aggregate communication, we must remember that events reduce coupling, but don't remove
it completely. Thus, it is very vital to share(publish) only those events, that are necessary for other
aggregates to exist and function. Otherwise there is a threat that the level of coupling will increase
introducing **feature envy**, because other aggregates might start using those events to perform actions
they are not supposed to perform. A solution to this problem could be the distinction of domain events
and integration events, which will be described here soon.
### Events in Repositories
Repositories are one of the most popular design pattern. They abstract our domain model from data layer.
In other words, they deal with state. That said, a common use-case is when we pass a new state to our repository,
so that it gets persisted. It may look like so:
```java
public class BusinessService {
private final PatronRepository patronRepository;
void businessMethod(PatronId patronId) {
Patron patron = patronRepository.findById(patronId);
//do sth
patronRepository.save(patron);
}
}
```
Conceptually, between 1st and 3rd line of that business method we change state of our Patron from A to B.
This change might be calculated by dirty checking or we might just override entire Patron state in the database.
Third option is _Let's make implicit explicit_ and actually call this state change A->B an **event**.
After all, event-driven architecture is all about promoting state changes as domain events.
Thanks to this our domain model may become immutable and just return events as results of invoking a command like so:
```java
public BookPlacedOnHold placeOnHold(AvailableBook book) {
...
}
```
And our repository might operate directly on events like so:
```java
public interface PatronRepository {
void save(PatronEvent event) {
}
```
### ArchUnit
One of the main components of a successful project is technical leadership that lets the team go in the right
direction. Nevertheless, there are tools that can support teams in keeping the code clean and protect the
architecture, so that the project won't become a Big Ball of Mud, and thus will be pleasant to develop and
to maintain. The first option, the one we proposed, is [ArchUnit](https://www.archunit.org/) - a Java architecture
test tool. ArchUnit lets you write unit tests of your architecture, so that it is always consistent with initial
vision. Maven modules could be an alternative as well, but let's focus on the former.
In terms of hexagonal architecture, it is essential to ensure, that we do not mix different levels of
abstraction (hexagon levels):
```java
@ArchTest
public static final ArchRule model_should_not_depend_on_infrastructure =
noClasses()
.that()
.resideInAPackage("..model..")
.should()
.dependOnClassesThat()
.resideInAPackage("..infrastructure..");
```
and that frameworks do not affect the domain model
```java
@ArchTest
public static final ArchRule model_should_not_depend_on_spring =
noClasses()
.that()
.resideInAPackage("..io.pillopl.library.lending..model..")
.should()
.dependOnClassesThat()
.resideInAPackage("org.springframework..");
```
### Functional thinking
When you look at the code you might find a scent of functional programming. Although we do not follow
a _clean_ FP, we try to think of business processes as pipelines or workflows, utilizing functional style through
following concepts.
_Please note that this is not a reference project for FP._
#### Immutable objects
Each class that represents a business concept is immutable, thanks to which we:
* provide full encapsulation and objects' states protection,
* secure objects for multithreaded access,
* control all side effects much clearer.
#### Pure functions
We model domain operations, discovered in Design Level Event Storming, as pure functions, and declare them in
both domain and application layers in the form of Java's functional interfaces. Their implementations are placed
in infrastructure layer as ordinary methods with side effects. Thanks to this approach we can follow the abstraction
of ubiquitous language explicitly, and keep this abstraction implementation-agnostic. As an example, you could have
a look at `FindAvailableBook` interface and its implementation:
```java
@FunctionalInterface
public interface FindAvailableBook {
Option<AvailableBook> findAvailableBookBy(BookId bookId);
}
```
```java
@AllArgsConstructor
class BookDatabaseRepository implements FindAvailableBook {
private final JdbcTemplate jdbcTemplate;
@Override
public Option<AvailableBook> findAvailableBookBy(BookId bookId) {
return Match(findBy(bookId)).of(
Case($Some($(instanceOf(AvailableBook.class))), Option::of),
Case($(), Option::none)
);
}
Option<Book> findBy(BookId bookId) {
return findBookById(bookId)
.map(BookDatabaseEntity::toDomainModel);
}
private Option<BookDatabaseEntity> findBookById(BookId bookId) {
return Try
.ofSupplier(() -> of(jdbcTemplate.queryForObject("SELECT b.* FROM book_database_entity b WHERE b.book_id = ?",
new BeanPropertyRowMapper<>(BookDatabaseEntity.class), bookId.getBookId())))
.getOrElse(none());
}
}
```
#### Type system
_Type system - like_ modelling - we modelled each domain object's state discovered during EventStorming as separate
classes: `AvailableBook`, `BookOnHold`, `CheckedOutBook`. With this approach we provide much clearer abstraction than
having a single `Book` class with an enum-based state management. Moving the logic to these specific classes brings
Single Responsibility Principle to a different level. Moreover, instead of checking invariants in every business method
we leave the role to the compiler. As an example, please consider following scenario: _you can place on hold only a book
that is currently available_. We could have done it in a following way:
```java
public Either<BookHoldFailed, BookPlacedOnHoldEvents> placeOnHold(Book book) {
if (book.status == AVAILABLE) {
...
}
}
```
but we use the _type system_ and declare method of following signature
```java
public Either<BookHoldFailed, BookPlacedOnHoldEvents> placeOnHold(AvailableBook book) {
...
}
```
The more errors we discover at compile time the better.
Yet another advantage of applying such type system is that we can represent business flows and state transitions
with functions much easier. As an example, following functions:
```
placeOnHold: AvailableBook -> BookHoldFailed | BookPlacedOnHold
cancelHold: BookOnHold -> BookHoldCancelingFailed | BookHoldCanceled
```
are much more concise and descriptive than these:
```
placeOnHold: Book -> BookHoldFailed | BookPlacedOnHold
cancelHold: Book -> BookHoldCancelingFailed | BookHoldCanceled
```
as here we have a lot of constraints hidden within function implementations.
Moreover if you think of your domain as a set of operations (functions) that are being executed on business objects
(aggregates) you don't think of any execution model (like async processing). It is fine, because you don't have to.
Domain functions are free from I/O operations, async, and other side-effects-prone things, which are put into the
infrastructure layer. Thanks to this, we can easily test them without mocking mentioned parts.
#### Monads
Business methods might have different results. One might return a value or a `null`, throw an exception when something
unexpected happens or just return different objects under different circumstances. All those situations are typical
to object-oriented languages like Java, but do not fit into functional style. We are dealing with this issues
with monads (monadic containers provided by [Vavr](https://www.vavr.io)):
* When a method returns optional value, we use the `Option` monad:
```java
Option<Book> findBy(BookId bookId) {
...
}
```
* When a method might return one of two possible values, we use the `Either` monad:
```java
Either<BookHoldFailed, BookPlacedOnHoldEvents> placeOnHold(AvailableBook book) {
...
}
```
* When an exception might occur, we use `Try` monad:
```java
Try<Result> placeOnHold(@NonNull PlaceOnHoldCommand command) {
...
}
```
Thanks to this, we can follow the functional programming style, but we also enrich our domain language and
make our code much more readable for the clients.
#### Pattern Matching
Depending on a type of a given book object we often need to perform different actions. Series of if/else or switch/case statements
could be a choice, but it is the pattern matching that provides the most conciseness and flexibility. With the code
like below we can check numerous patterns against objects and access their constituents, so our code has a minimal dose
of language-construct noise:
```java
private Book handleBookPlacedOnHold(Book book, BookPlacedOnHold bookPlacedOnHold) {
return API.Match(book).of(
Case($(instanceOf(AvailableBook.class)), availableBook -> availableBook.handle(bookPlacedOnHold)),
Case($(instanceOf(BookOnHold.class)), bookOnHold -> raiseDuplicateHoldFoundEvent(bookOnHold, bookPlacedOnHold)),
Case($(), () -> book)
);
}
```
### (No) ORM
If you run `mvn dependency:tree` you won't find any JPA implementation. Although we think that ORM solutions (like Hibernate)
are very powerful and useful, we decided not to use them, as we wouldn't utilize their features. What features are
talking about? Lazy loading, caching, dirty checking. Why don't we need them? We want to have more control
over SQL queries and minimize the object-relational impedance mismatch ourselves. Moreover, thanks to relatively
small aggregates, containing as little data as it is required to protect the invariants, we don't need the
lazy loading mechanism either.
With Hexagonal Architecture we have the ability to separate domain and persistence models and test them
independently. Moreover, we can also introduce different persistence strategies for different aggregates.
In this project, we utilize both plain SQL queries and `JdbcTemplate` and use new and very promising
project called Spring Data JDBC, that is free from the JPA-related overhead mentioned before.
Please find below an example of a repository:
```java
interface PatronEntityRepository extends CrudRepository<PatronDatabaseEntity, Long> {
@Query("SELECT p.* FROM patron_database_entity p where p.patron_id = :patronId")
PatronDatabaseEntity findByPatronId(@Param("patronId") UUID patronId);
}
```
At the same time we propose other way of persisting aggregates, with plain SQL queries and `JdbcTemplate`:
```java
@AllArgsConstructor
class BookDatabaseRepository implements BookRepository, FindAvailableBook, FindBookOnHold {
private final JdbcTemplate jdbcTemplate;
@Override
public Option<Book> findBy(BookId bookId) {
return findBookById(bookId)
.map(BookDatabaseEntity::toDomainModel);
}
private Option<BookDatabaseEntity> findBookById(BookId bookId) {
return Try
.ofSupplier(() -> of(jdbcTemplate.queryForObject("SELECT b.* FROM book_database_entity b WHERE b.book_id = ?",
new BeanPropertyRowMapper<>(BookDatabaseEntity.class), bookId.getBookId())))
.getOrElse(none());
}
...
}
```
_Please note that despite having the ability to choose different persistence implementations for aggregates
it is recommended to stick to one option within the app/team_
### Architecture-code gap
We put a lot of attention to keep the consistency between the overall architecture (including diagrams)
and the code structure. Having identified bounded contexts we could organize them in modules (packages, to
be more specific). Thanks to this we gain the famous microservices' autonomy, while having a monolithic
application. Each package has well defined public API, encapsulating all implementation details by using
package-protected or private scopes.
Just by looking at the package structure:
```
└── library
├── catalogue
├── commons
│ ├── aggregates
│ ├── commands
│ └── events
│ └── publisher
└── lending
├── book
│ ├── application
│ ├── infrastructure
│ └── model
├── dailysheet
│ ├── infrastructure
│ └── model
├── librarybranch
│ └── model
├── patron
│ ├── application
│ ├── infrastructure
│ └── model
└── patronprofile
├── infrastructure
├── model
└── web
```
you can see that the architecture is screaming that it has two bounded contexts: **catalogue**
and **lending**. Moreover, the **lending context** is built around five business objects: **book**,
**dailysheet**, **librarybranch**, **patron**, and **patronprofile**, while **catalogue** has no subpackages,
which suggests that it might be a CRUD with no complex logic inside. Please find the architecture diagram
below.

Yet another advantage of this approach comparing to packaging by layer for example is that in order to
deliver a functionality you would usually need to do it in one package only, which is the aforementioned
autonomy. This autonomy, then, could be transferred to the level of application as soon as we split our
_context-packages_ into separate microservices. Following this considerations, autonomy can be given away
to a product team that can take care of the whole business area end-to-end.
### Model-code gap
In our project we do our best to reduce _model-code gap_ to bare minimum. It means we try to put equal attention
to both the model and the code and keep them consistent. Below you will find some examples.
#### Placing on hold

Starting with the easiest part, below you will find the model classes corresponding to depicted command and events:
```java
@Value
class PlaceOnHoldCommand {
...
}
```
```java
@Value
class BookPlacedOnHold implements PatronEvent {
...
}
```
```java
@Value
class MaximumNumberOfHoldsReached implements PatronEvent {
...
}
```
```java
@Value
class BookHoldFailed implements PatronEvent {
...
}
```
We know it might not look impressive now, but if you have a look at the implementation of an aggregate,
you will see that the code reflects not only the aggregate name, but also the whole scenario of `PlaceOnHold`
command handling. Let us uncover the details:
```java
public class Patron {
public Either<BookHoldFailed, BookPlacedOnHoldEvents> placeOnHold(AvailableBook book) {
return placeOnHold(book, HoldDuration.openEnded());
}
...
}
```
The signature of `placeOnHold` method screams, that it is possible to place a book on hold only when it
is available (more information about protecting invariants by compiler you will find in [Type system section](#type-system)).
Moreover, if you try to place available book on hold it can **either** fail (`BookHoldFailed`) or produce some events -
what events?
```java
@Value
class BookPlacedOnHoldEvents implements PatronEvent {
@NonNull UUID eventId = UUID.randomUUID();
@NonNull UUID patronId;
@NonNull BookPlacedOnHold bookPlacedOnHold;
@NonNull Option<MaximumNumberOfHoldsReached> maximumNumberOfHoldsReached;
@Override
public Instant getWhen() {
return bookPlacedOnHold.when;
}
public static BookPlacedOnHoldEvents events(BookPlacedOnHold bookPlacedOnHold) {
return new BookPlacedOnHoldEvents(bookPlacedOnHold.getPatronId(), bookPlacedOnHold, Option.none());
}
public static BookPlacedOnHoldEvents events(BookPlacedOnHold bookPlacedOnHold, MaximumNumberOfHoldsReached maximumNumberOfHoldsReached) {
return new BookPlacedOnHoldEvents(bookPlacedOnHold.patronId, bookPlacedOnHold, Option.of(maximumNumberOfHoldsReached));
}
public List<DomainEvent> normalize() {
return List.<DomainEvent>of(bookPlacedOnHold).appendAll(maximumNumberOfHoldsReached.toList());
}
}
```
`BookPlacedOnHoldEvents` is a container for `BookPlacedOnHold` event, and - if patron has 5 book placed on hold already -
`MaximumNumberOfHoldsReached` (please mind the `Option` monad). You can see now how perfectly the code reflects
the model.
It is not everything, though. In the picture above you can also see a big rectangular yellow card with rules (policies)
that define the conditions that need to be fulfilled in order to get the given result. All those rules are implemented
as functions **either** allowing or rejecting the hold:

```java
PlacingOnHoldPolicy onlyResearcherPatronsCanHoldRestrictedBooksPolicy = (AvailableBook toHold, Patron patron, HoldDuration holdDuration) -> {
if (toHold.isRestricted() && patron.isRegular()) {
return left(Rejection.withReason("Regular patrons cannot hold restricted books"));
}
return right(new Allowance());
};
```

```java
PlacingOnHoldPolicy overdueCheckoutsRejectionPolicy = (AvailableBook toHold, Patron patron, HoldDuration holdDuration) -> {
if (patron.overdueCheckoutsAt(toHold.getLibraryBranch()) >= OverdueCheckouts.MAX_COUNT_OF_OVERDUE_RESOURCES) {
return left(Rejection.withReason("cannot place on hold when there are overdue checkouts"));
}
return right(new Allowance());
};
```

```java
PlacingOnHoldPolicy regularPatronMaximumNumberOfHoldsPolicy = (AvailableBook toHold, Patron patron, HoldDuration holdDuration) -> {
if (patron.isRegular() && patron.numberOfHolds() >= PatronHolds.MAX_NUMBER_OF_HOLDS) {
return left(Rejection.withReason("patron cannot hold more books"));
}
return right(new Allowance());
};
```

```java
PlacingOnHoldPolicy onlyResearcherPatronsCanPlaceOpenEndedHolds = (AvailableBook toHold, Patron patron, HoldDuration holdDuration) -> {
if (patron.isRegular() && holdDuration.isOpenEnded()) {
return left(Rejection.withReason("regular patron cannot place open ended holds"));
}
return right(new Allowance());
};
```
#### Spring
Spring Framework seems to be the most popular Java framework ever used. Unfortunately it is also quite common
to overuse its features in the business code. What you find in this project is that the domain packages
are fully focused on modelling business problems, and are free from any DI, which makes it easy to
unit-test it which is invaluable in terms of code reliability and maintainability. It does not mean,
though, that we do not use Spring Framework - we do. Below you will find some details:
- Each bounded context has its own independent application context. It means that we removed the runtime
coupling, which is a step towards extracting modules (and microservices). How did we do that? Let's have
a look:
```java
@SpringBootConfiguration
@EnableAutoConfiguration
public class LibraryApplication {
public static void main(String[] args) {
new SpringApplicationBuilder()
.parent(LibraryApplication.class)
.child(LendingConfig.class).web(WebApplicationType.SERVLET)
.sibling(CatalogueConfiguration.class).web(WebApplicationType.NONE)
.run(args);
}
}
```
- As you could see above, we also try not to use component scan wherever possible. Instead we utilize
`@Configuration` classes where we define module specific beans in the infrastructure layer. Those
configuration classes are explicitly declared in the main application class.
### Tests
Tests are written in a BDD manner, expressing stories defined with Example Mapping.
It means we utilize both TDD and Domain Language discovered with Event Storming.
We also made an effort to show how to create a DSL, that enables to write
tests as if they were sentences taken from the domain descriptions. Please
find an example below:
```groovy
def 'should make book available when hold canceled'() {
given:
BookDSL bookOnHold = aCirculatingBook() with anyBookId() locatedIn anyBranch() placedOnHoldBy anyPatron()
and:
PatronEvent.BookHoldCanceled bookHoldCanceledEvent = the bookOnHold isCancelledBy anyPatron()
when:
AvailableBook availableBook = the bookOnHold reactsTo bookHoldCanceledEvent
then:
availableBook.bookId == bookOnHold.bookId
availableBook.libraryBranch == bookOnHold.libraryBranchId
availableBook.version == bookOnHold.version
}
```
_Please also note the **when** block, where we manifest the fact that books react to
cancellation event_
## How to contribute
The project is still under construction, so if you like it enough to collaborate, just let us
know or simply create a Pull Request.
## How to Build
### Requirements
* Java 11
* Maven
### Quickstart
You can run the library app by simply typing the following:
```console
$ mvn spring-boot:run
...
...
2019-04-03 15:55:39.162 INFO 18957 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-04-03 15:55:39.425 INFO 18957 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-04-03 15:55:39.428 INFO 18957 --- [ main] io.pillopl.library.LibraryApplication : Started LibraryApplication in 5.999 seconds (JVM running for 23.018)
```
### Build a Jar package
You can build a jar with maven like so:
```console
$ mvn clean package
...
...
[INFO] Building jar: /home/pczarkowski/development/spring/library/target/library-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
```
### Build with Docker
If you've already built the jar file you can run:
```console
docker build -t spring/library .
```
Otherwise you can build the jar file using the multistage dockerfile:
```console
docker build -t spring/library -f Dockerfile.build .
```
Either way once built you can run it like so:
```console
$ docker run -ti --rm --name spring-library -p 8080:8080 spring/library
```
### Production ready metrics and visualization
To run the application as well as Prometheus and Grafana dashboard for visualizing metrics you can run all services:
```console
$ docker-compose up
```
If everything goes well, you can access the following services at given location:
* http://localhost:8080/actuator/prometheus - published Micrometer metrics
* http://localhost:9090 - Prometheus dashboard
* http://localhost:3000 - Grafana dashboard
In order to see some metrics, you must create a dashboard. Go to `Create` -> `Import` and select attached `jvm-micrometer_rev8.json`. File has been pulled from
`https://grafana.com/grafana/dashboards/4701`.
Please note application will be run with `local` Spring profile to setup some initial data.
## References
1. [Introducing EventStorming](https://leanpub.com/introducing_eventstorming) by Alberto Brandolini
2. [Domain Modelling Made Functional](https://pragprog.com/book/swdddf/domain-modeling-made-functional) by Scott Wlaschin
3. [Software Architecture for Developers](https://softwarearchitecturefordevelopers.com) by Simon Brown
4. [Clean Architecture](https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164) by Robert C. Martin
5. [Domain-Driven Design: Tackling Complexity in the Heart of Software](https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215) by Eric Evans
| 1 |
janbodnar/Java-Swing-Examples | Java Swing code examples | gui java swing | # Java-Swing-Examples
Java Swing code examples from Java Swing tutorial
Built with OpenJDK 13
https://zetcode.com/javaswing/
### Advanced Java Swing e-book
https://zetcode.com/ebooks/advancedjavaswing/
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.