Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/sdk/example-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Welcome to the Samples & Example Apps page, which showcases example applications
| [Go](https://github.com/DevCycleHQ/go-server-sdk) | [Go Reference Docs](/sdk/server-side-sdks/go.md) |
| [iOS](https://github.com/devcyclehq/ios-client-sdk) | [iOS Reference Docs](/sdk/client-side-sdks/ios/ios.md) |
| [Java (Cloud Bucketing)](https://github.com/DevCycleHQ/java-server-sdk) | [Java (Cloud Bucketing) Reference Docs](/sdk/server-side-sdks/java-cloud.md) |
| [Java (Local Bucketing)](https://github.com/DevCycleHQ/java-server-sdk) | [Java (Local Bucketing) Reference Docs](/sdk/server-side-sdks/java-local.md) |
| [Java (Local Bucketing)](https://github.com/DevCycleHQ/java-server-sdk) | [Java (Local Bucketing) Reference Docs](/sdk/server-side-sdks/java-local/java-local.md) |
| [Javascript](https://github.com/DevCycleHQ/js-sdks/tree/main/sdk/js) | [Javascript Reference Docs](/sdk/client-side-sdks/javascript/javascript.md) |
| [NodeJS](https://github.com/DevCycleHQ/js-sdks/tree/main/sdk/nodejs) | [NodeJS Reference Docs](/sdk/server-side-sdks/node.md) |
| [PHP](https://github.com/DevCycleHQ/php-server-sdk) | [PHP Reference Docs](/sdk/server-side-sdks/php/php.md) |
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/features/all-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ The DevCycle React SDK is built upon the JavaScript SDK. For more details, view

### [• .NET / C# Local SDK](/sdk/server-side-sdks/dotnet-local#getting-all-features)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#getting-all-features)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-usage#getting-all-features)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#getting-all-features)
2 changes: 1 addition & 1 deletion docs/sdk/features/all-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ The DevCycle React SDK is built upon the JavaScript SDK. For more details, view

### [• .NET / C# Local SDK](/sdk/server-side-sdks/dotnet-local#getting-all-variables)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#getting-all-variables)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-usage#getting-all-variables)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#getting-all-variables)
2 changes: 1 addition & 1 deletion docs/sdk/features/evaluating.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ If there is an error reaching DevCycle, if the requested variable does not exist

### [• PHP SDK](/sdk/server-side-sdks/php/php-usage#get-and-use-variable-by-key)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#get-and-use-variable-by-key)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-usage#get-and-use-variable-by-key)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#get-and-use-variable-by-key)
2 changes: 1 addition & 1 deletion docs/sdk/features/identify.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ As well, unlike the Client-Side SDKs, because Server-Side SDKs poll for project

### [• PHP SDK](/sdk/server-side-sdks/php/php-usage#user-object)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#user-object)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-usage#user-object)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#user-object)

Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/features/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If a variable is first read from the cache and has a listener for [realtime upda

### [• PHP SDK](/sdk/server-side-sdks/php/php-install)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#installation)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-gettingstarted)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#installation)

2 changes: 1 addition & 1 deletion docs/sdk/features/track.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The Track function in the DevCycle SDKs allows you to send up custom events whic

### [• PHP SDK](/sdk/server-side-sdks/php/php-usage#track-event)

### [• Java Local SDK](/sdk/server-side-sdks/java-local#track-event)
### [• Java Local SDK](/sdk/server-side-sdks/java-local/java-local-usage#track-event)

### [• Java Cloud SDK](/sdk/server-side-sdks/java-cloud#track-event)

2 changes: 2 additions & 0 deletions docs/sdk/server-side-sdks/java-local/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
position: 7
collapsed: true
65 changes: 65 additions & 0 deletions docs/sdk/server-side-sdks/java-local/java-local-gettingstarted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: DevCycle Java Local Server SDK Getting Started
sidebar_label: Getting Started
sidebar_position: 2
---

[![Maven](https://badgen.net/maven/v/maven-central/com.devcycle/java-server-sdk)](https://search.maven.org/artifact/com.devcycle/java-server-sdk)
[![GitHub](https://img.shields.io/github/stars/devcyclehq/java-server-sdk.svg?style=social&label=Star&maxAge=2592000)](https://github.com/DevCycleHQ/java-server-sdk)


To use the DevCycle Java SDK, initialize a client object.

```java
import com.devcycle.sdk.server.local.api.DVCLocalClient;

public class MyClass {

private DVCLocalClient dvcLocalClient;

public MyClass() {
dvcLocalClient = new DVCLocalClient("<DVC_SERVER_SDK_KEY>");
}
}
```

## Initialization Options

| DVC Option | Description |
| --- | ----------- |
| configPollingIntervalMs | Controls the polling interval in milliseconds to fetch new environment config changes, defaults to 10 seconds, minimum value is 1 second. |
| configRequestTimeoutMs | Controls the request timeout to fetch new environment config changes, defaults to 5 seconds, must be less than the configPollingIntervalMS value, minimum value is 1 second. |
| eventFlushIntervalMS | Controls the interval between flushing events to the DevCycle servers, defaults to 30 seconds. |
| maxEventQueueSize | Controls the maximum number of events in queue, defaults to 2000. |
| eventRequestChunkSize | Controls the size of the number of events per request sent to the DevCycle servers, defaults to 100. |
| configCdnBaseUrl | Controls the endpoint used to fetch the project configurations from the DevCycle CDN, defaults to "https://config-cdn.devcycle.com/". |
| eventsApiBaseUrl | Controls the endpoint used to send events to the DevCycle servers, defaults to "https://events.devcycle.com/". |
| disableAutomaticEventLogging | Disables logging of any automatic events or user data to DevCycle. |
| disableCustomEventLogging | Disables logging of any Custom Events to DevCycle. |

```java
import com.devcycle.sdk.server.local.api.DVCLocalClient;
import com.devcycle.sdk.server.local.model.DVCLocalOptions;

public class MyClass {

private DVCLocalClient dvcLocalClient;

private DVCLocalOptions dvcLocalOptions = DVCLocalOptions.builder()
.configPollingIntervalMs(60000)
.configRequestTimeoutMs(30000)
.eventFlushIntervalMS(10000)
.flushEventQueueSize(1000)
.maxEventQueueSize(2000)
.eventRequestChunkSize(100)
.configCdnBaseUrl("https://my-custom.config.com/")
.eventsApiBaseUrl("https://my-custom.events.com/")
.disableAutomaticEventLogging(false)
.disableCustomEventLogging(false)
.build();

public MyClass() {
dvcLocalClient = new DVCLocalClient("<DVC_SERVER_SDK_KEY>", dvcLocalOptions);
}
}
```
52 changes: 52 additions & 0 deletions docs/sdk/server-side-sdks/java-local/java-local-install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: DevCycle Java Local Server SDK Installation
sidebar_label: Installation
sidebar_position: 1
---

[![Maven](https://badgen.net/maven/v/maven-central/com.devcycle/java-server-sdk)](https://search.maven.org/artifact/com.devcycle/java-server-sdk)
[![GitHub](https://img.shields.io/github/stars/devcyclehq/java-server-sdk.svg?style=social&label=Star&maxAge=2592000)](https://github.com/DevCycleHQ/java-server-sdk)

## Requirements

This version of the DevCycle SDK works with Java 8 and above.

Using the Java SDK library requires [Maven](https://maven.apache.org/) or [Gradle](https://gradle.org/) >= 5.6.4 to be installed.

:::info

An x64 JDK is required for Local Bucketing with the DevCycle Java SDK.

:::


## Maven

You can use the SDK in your Maven project by adding the following to your *pom.xml*:

```xml
<dependency>
<groupId>com.devcycle</groupId>
<artifactId>java-server-sdk</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
```

:::info

Refer to the latest version of the SDK on [maven central](https://maven.org/artifact/com.devcycle/android-client-sdk) if you would not prefer Maven or Gradle to pull the latest version automatically by using `+`

:::

## Gradle
Alternatively you can use the SDK in your Gradle project by adding the following to *build.gradle*:

```yaml
implementation("com.devcycle:java-server-sdk:+")
```

## DNS Caching
The JVM, by default, caches DNS for infinity. DevCycle servers are load balanced and dynamic. To address this concern,
setting the DNS cache TTL to a short duration is recommended. The TTL is controlled by this security setting `networkaddress.cache.ttl`.
Recommended settings and how to configure them can be found [here](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-jvm-ttl.html).
Original file line number Diff line number Diff line change
@@ -1,123 +1,14 @@
---
title: Java SDK for Local Bucketing
sidebar_position: 7
title: DevCycle Java Cloud Server SDK Usage
sidebar_label: Usage
sidebar_position: 3
---

# DevCycle Java Server SDK

Welcome to the DevCycle Java SDK, which interfaces with the [DevCycle Bucketing API](/bucketing-api/#tag/devcycle).

The SDK is available as a package on MavenCentral. It is also open source and can be viewed on Github.

[![Maven](https://badgen.net/maven/v/maven-central/com.devcycle/java-server-sdk)](https://search.maven.org/artifact/com.devcycle/java-server-sdk)
[![GitHub](https://img.shields.io/github/stars/devcyclehq/java-server-sdk.svg?style=social&label=Star&maxAge=2592000)](https://github.com/DevCycleHQ/java-server-sdk)

## Requirements

This version of the DevCycle SDK works with Java 8 and above.

Using the Java SDK library requires [Maven](https://maven.apache.org/) or [Gradle](https://gradle.org/) >= 5.6.4 to be installed.

:::info

An x64 JDK is required for Local Bucketing with the DevCycle Java SDK.

:::

## Installation

### Maven

You can use the SDK in your Maven project by adding the following to your *pom.xml*:

```xml
<dependency>
<groupId>com.devcycle</groupId>
<artifactId>java-server-sdk</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
```

:::info

Refer to the latest version of the SDK on [maven central](https://maven.org/artifact/com.devcycle/android-client-sdk) if you would not prefer Maven or Gradle to pull the latest version automatically by using `+`

:::

### Gradle
Alternatively you can use the SDK in your Gradle project by adding the following to *build.gradle*:

```yaml
implementation("com.devcycle:java-server-sdk:+")
```

## DNS Caching
The JVM, by default, caches DNS for infinity. DevCycle servers are load balanced and dynamic. To address this concern,
setting the DNS cache TTL to a short duration is recommended. The TTL is controlled by this security setting `networkaddress.cache.ttl`.
Recommended settings and how to configure them can be found [here](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-jvm-ttl.html).

## Getting Started

To use the DevCycle Java SDK, initialize a client object.

```java
import com.devcycle.sdk.server.local.api.DVCLocalClient;

public class MyClass {

private DVCLocalClient dvcLocalClient;

public MyClass() {
dvcLocalClient = new DVCLocalClient("<DVC_SERVER_SDK_KEY>");
}
}
```

### Initialization Options

| DVC Option | Description |
| --- | ----------- |
| configPollingIntervalMs | Controls the polling interval in milliseconds to fetch new environment config changes, defaults to 10 seconds, minimum value is 1 second. |
| configRequestTimeoutMs | Controls the request timeout to fetch new environment config changes, defaults to 5 seconds, must be less than the configPollingIntervalMS value, minimum value is 1 second. |
| eventFlushIntervalMS | Controls the interval between flushing events to the DevCycle servers, defaults to 30 seconds. |
| maxEventQueueSize | Controls the maximum number of events in queue, defaults to 2000. |
| eventRequestChunkSize | Controls the size of the number of events per request sent to the DevCycle servers, defaults to 100. |
| configCdnBaseUrl | Controls the endpoint used to fetch the project configurations from the DevCycle CDN, defaults to "https://config-cdn.devcycle.com/". |
| eventsApiBaseUrl | Controls the endpoint used to send events to the DevCycle servers, defaults to "https://events.devcycle.com/". |
| disableAutomaticEventLogging | Disables logging of any automatic events or user data to DevCycle. |
| disableCustomEventLogging | Disables logging of any Custom Events to DevCycle. |

```java
import com.devcycle.sdk.server.local.api.DVCLocalClient;
import com.devcycle.sdk.server.local.model.DVCLocalOptions;

public class MyClass {

private DVCLocalClient dvcLocalClient;

private DVCLocalOptions dvcLocalOptions = DVCLocalOptions.builder()
.configPollingIntervalMs(60000)
.configRequestTimeoutMs(30000)
.eventFlushIntervalMS(10000)
.flushEventQueueSize(1000)
.maxEventQueueSize(2000)
.eventRequestChunkSize(100)
.configCdnBaseUrl("https://my-custom.config.com/")
.eventsApiBaseUrl("https://my-custom.events.com/")
.disableAutomaticEventLogging(false)
.disableCustomEventLogging(false)
.build();

public MyClass() {
dvcLocalClient = new DVCLocalClient("<DVC_SERVER_SDK_KEY>", dvcLocalOptions);
}
}
```

## Usage

### User Object
## User Object
The user object is required for all methods. The only required field in the user object is userId.

See the User class in [Java User model doc](https://github.com/DevCycleHQ/java-server-sdk/blob/main/docs/User.md) for all accepted fields.
Expand All @@ -128,7 +19,7 @@ User user = User.builder()
.build();
```

### Getting All Features
## Getting All Features
This method will fetch all features for a given user and return them as Map&lt;String, Feature&gt;. If the project configuration is unavailable, this will return an empty map.

```java
Expand All @@ -155,7 +46,7 @@ public class MyClass {
}
```

### Getting All Variables
## Getting All Variables
This method will fetch all variables for a given user and returned as Map&lt;String, Feature&gt;. If the project configuration is unavailable, this will return an empty map.

To get values from your Variables, the `value` field inside the variable object can be accessed.
Expand Down Expand Up @@ -184,7 +75,7 @@ public class MyClass {
}
```

### Get and Use Variable By Key
## Get and Use Variable By Key
This method will fetch a specific variable by key for a given user. The default variable will be used in cases where
the user is not segmented into a feature using that variable, or the project configuration is unavailable
to be fetched from DevCycle's CDN.
Expand Down Expand Up @@ -224,7 +115,7 @@ public class MyClass {
}
```

### Track Event
## Track Event

To POST custom event for a user, pass in the user and event object.

Expand Down Expand Up @@ -259,7 +150,7 @@ public class MyClass {
}
```

### EdgeDB
## EdgeDB

:::caution

Expand Down
10 changes: 10 additions & 0 deletions docs/sdk/server-side-sdks/java-local/java-local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Java SDK for Local Bucketing
---

Welcome to the DevCycle Java SDK, which interfaces with the [DevCycle Bucketing API](/bucketing-api/#tag/devcycle).

The SDK is available as a package on MavenCentral. It is also open source and can be viewed on Github.

[![Maven](https://badgen.net/maven/v/maven-central/com.devcycle/java-server-sdk)](https://search.maven.org/artifact/com.devcycle/java-server-sdk)
[![GitHub](https://img.shields.io/github/stars/devcyclehq/java-server-sdk.svg?style=social&label=Star&maxAge=2592000)](https://github.com/DevCycleHQ/java-server-sdk)