simter-context

System Context Interface and holder

Лицензия

Лицензия

MIT
Группа

Группа

tech.simter
Идентификатор

Идентификатор

simter-context
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

simter-context
System Context Interface and holder
Ссылка на сайт

Ссылка на сайт

https://github.com/simter/simter-context
Организация-разработчик

Организация-разработчик

simter
Система контроля версий

Система контроля версий

https://github.com/simter/simter-context.git

Скачать simter-context

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/tech.simter/simter-context/ -->
<dependency>
    <groupId>tech.simter</groupId>
    <artifactId>simter-context</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/tech.simter/simter-context/
implementation 'tech.simter:simter-context:1.1.0'
// https://jarcasting.com/artifacts/tech.simter/simter-context/
implementation ("tech.simter:simter-context:1.1.0")
'tech.simter:simter-context:jar:1.1.0'
<dependency org="tech.simter" name="simter-context" rev="1.1.0">
  <artifact name="simter-context" type="jar" />
</dependency>
@Grapes(
@Grab(group='tech.simter', module='simter-context', version='1.1.0')
)
libraryDependencies += "tech.simter" % "simter-context" % "1.1.0"
[tech.simter/simter-context "1.1.0"]

Зависимости

test (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter jar 5.5.0

Модули Проекта

Данный проект не имеет модулей.

simter-context [中文]

A simple and powerful utils class tech.simter.Context for share data during the same thread lifecycle.

This tools use thread-local variables to make each thread has its own initialized share data. You don't need to transfer context data through method arguments, just use Context.get(key) to get its value inside the method.

Installation

<dependency>
  <groupId>tech.simter</groupId>
  <artifactId>simter-context</artifactId>
  <version>1.0.0</version>
</dependency>

Requirement

  • Java 8+

Usage

// set share data anywhere
Context.set("userId", new Long(0));
Context.set("userName", "RJ");
...

void someMethodInOtherClass(){
  // get shared data by key anywhere
  Long userId = Context.get("userId");
  String userName = Context.get("userName");
  
  // or get all shared data
  Map<String, Object> all = Context.get();
  ...
}
...

// delete shared data anywhere
Context.remove("userId");
...

You can see that it just like to get a static constant value. But you need to know the difference: A static constant always has the same value even in different thread. But the context data is isolated between each thread.

Build

mvn clean package

Deploy

First take a look at simter-parent deploy config.

Deploy to LAN Nexus Repository

mvn clean deploy -P lan

Deploy to Sonatype Repository

mvn clean deploy -P sonatype

After deployed, login into https://oss.sonatype.org. Through Staging Repositories, search this package, then close and release it. After couple hours, it will be synced to Maven Central Repository.

Deploy to Bintray Repository

mvn clean deploy -P bintray

Will deploy to https://api.bintray.com/maven/simter/maven/tech.simter:simter-context/;publish=1. So first create a package https://bintray.com/simter/maven/tech.simter:simter-context on Bintray. After deployed, check it from https://jcenter.bintray.com/tech/simter/simter-context.

tech.simter

Версии библиотеки

Версия
1.1.0
1.0.0
0.4.0
0.3.0
0.1.0