Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/misc/license-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

33 changes: 33 additions & 0 deletions .github/misc/spotless-formatter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="22">
<profile kind="CodeFormatterProfile" name="Liquid Backend Services" version="13">
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8" />
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" />
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8" />
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false" />
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4" />
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120" />
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120" />
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space" />
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="1" />
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1" />
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false" />
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16" />
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1" />
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="160" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="10" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="106" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="106" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="106" />
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80" />
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
</profile>
</profiles>
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
java-version: '11'
distribution: 'temurin'
cache: maven

- name: Spotless check
run: mvn spotless:check

- name: Build with Maven
run: mvn -B package --file pom.xml

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ SDK is designed primarily for use in multi-user systems such as web servers and

Reading the short [Introduction](https://docs.featureprobe.io/reference/sdk-introduction) will help to understand the code blow more easily. [中文](https://docs.featureprobe.io/zh-CN/reference/sdk-introduction)


## How to Use This SDK

See [SDK Doc](https://docs.featureprobe.io/how-to/Server-Side%20SDKs/java-sdk) for detail. [中文](https://docs.featureprobe.io/zh-CN/how-to/Server-Side%20SDKs/java-sdk)

## Contributing

We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
We are working on continue evolving FeatureProbe core, making it flexible and easier to use.
Development of FeatureProbe happens in the open on GitHub, and we are grateful to the
community for contributing bugfixes and improvements.

Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md)
Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md)
for details on our code of conduct, and the process for taking part in improving FeatureProbe.

## License
Expand Down
140 changes: 93 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
<?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"
<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>

<groupId>com.featureprobe</groupId>
<artifactId>server-sdk-java</artifactId>
<version>1.4.0</version>
<name>server-sdk-java</name>
<url>https://github.com/FeatureProbe/server-sdk-java</url>
<description>FeatureProbe Server Side SDK for Java</description>

<developers>
<developer>
<id>KaKa</id>
<name>KaKa Jiang</name>
<roles>
<role>lead developer</role>
</roles>
</developer>
</developers>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>

<scm>
<connection>scm:git@github.com:FeatureProbe/server-sdk-java.git</connection>
<developerConnection>scm:git@github.com:FeatureProbe/server-sdk-java.git</developerConnection>
<url>https://github.com/FeatureProbe/server-sdk-java</url>
</scm>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -109,25 +82,29 @@
<scope>test</scope>
</dependency>
<!-- Optional dependencies for using Spock -->
<dependency> <!-- use a specific Groovy version rather than the one specified by spock-core -->
<dependency>
<!-- use a specific Groovy version rather than the one specified by spock-core -->
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency> <!-- enables mocking of classes (in addition to interfaces) -->
<dependency>
<!-- enables mocking of classes (in addition to interfaces) -->
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.7</version>
<scope>test</scope>
</dependency>
<dependency> <!-- enables mocking of classes without default constructor (together with ByteBuddy or CGLIB) -->
<dependency>
<!-- enables mocking of classes without default constructor (together with ByteBuddy or CGLIB) -->
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency> <!-- only required if Hamcrest matchers are used -->
<dependency>
<!-- only required if Hamcrest matchers are used -->
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
Expand All @@ -148,17 +125,6 @@
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -191,7 +157,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<useModulePath>false</useModulePath> <!-- https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
<useModulePath>false</useModulePath>
<!-- https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
<useFile>false</useFile>
<includes>
<include>**/*Test</include>
Expand All @@ -207,6 +174,48 @@
</statelessTestsetReporter>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.25.0</version>
<configuration>
<java>
<eclipse>
<file>.github/misc/spotless-formatter.xml</file>
</eclipse>
<removeUnusedImports />
<licenseHeader>
<file>.github/misc/license-header</file>
</licenseHeader>
</java>
<pom>
<sortPom>
<encoding>UTF-8</encoding>
<nrOfIndentSpace>4</nrOfIndentSpace>
<keepBlankLines>true</keepBlankLines>
<indentBlankLines>false</indentBlankLines>
<indentSchemaLocation>true</indentSchemaLocation>
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
<sortModules>false</sortModules>
<sortExecutions>false</sortExecutions>
<predefinedSortOrder>custom_1</predefinedSortOrder>
<expandEmptyElements>false</expandEmptyElements>
<sortProperties>false</sortProperties>
</sortPom>
<replace>
<name>Leading blank line</name>
<search>project</search>
<replacement>project</replacement>
</replace>
</pom>
<markdown>
<includes>
<include>**/*.md</include>
</includes>
<flexmark />
</markdown>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -226,10 +235,10 @@
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -289,10 +298,10 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
Expand Down Expand Up @@ -322,10 +331,10 @@
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>

</execution>
</executions>
Expand Down Expand Up @@ -354,4 +363,41 @@
</plugin>
</plugins>
</reporting>
<url>https://github.com/FeatureProbe/server-sdk-java</url>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>

<developers>
<developer>
<id>KaKa</id>
<name>KaKa Jiang</name>
<roles>
<role>lead developer</role>
</roles>
</developer>
</developers>

<scm>
<connection>scm:git@github.com:FeatureProbe/server-sdk-java.git</connection>
<developerConnection>scm:git@github.com:FeatureProbe/server-sdk-java.git</developerConnection>
<url>https://github.com/FeatureProbe/server-sdk-java</url>
</scm>

<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>
28 changes: 22 additions & 6 deletions src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.featureprobe.sdk.example;

import com.featureprobe.sdk.server.FPConfig;
Expand All @@ -19,19 +36,18 @@ public class FeatureProbeDemo {
// FeatureProbe server URL for local docker
private static final String FEATURE_PROBE_SERVER_URL = "http://localhost:4009/server"; // "https://featureprobe.io/server";


// Server Side SDK Key for your project and environment
public static final String FEATURE_PROBE_SERVER_SDK_KEY = "server-8ed48815ef044428826787e9a238b9c6a479f98c";

public static void main(String[] args) throws IOException {

Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.WARN);

final FPConfig config = FPConfig.builder()
.remoteUri(FEATURE_PROBE_SERVER_URL)
.startWait(5L, TimeUnit.SECONDS)
.build();
.remoteUri(FEATURE_PROBE_SERVER_URL)
.startWait(5L, TimeUnit.SECONDS)
.build();

// Init FeatureProbe, share this FeatureProbe instance in your project.
final FeatureProbe fpClient = new FeatureProbe(FEATURE_PROBE_SERVER_SDK_KEY, config);
Expand All @@ -42,7 +58,7 @@ public static void main(String[] args) throws IOException {

// Create one user.
FPUser user = new FPUser()
.with("userId", "00001"); // "userId" is used in rules, should be filled in.
.with("userId", "00001"); // "userId" is used in rules, should be filled in.

// Get toggle result for this user.
final String YOUR_TOGGLE_KEY = "campaign_allow_list";
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/featureprobe/sdk/server/AccessEvent.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.featureprobe.sdk.server;

public class AccessEvent extends Event {
Expand Down
Loading