src/jdk.management.rest/share/classes/jdk/internal/management/remote/rest/RestAdapterProvider.java
author hb
Fri, 19 Jan 2018 13:46:27 +0530
branchjmx-rest-api
changeset 56026 bd531f08d7c7
permissions -rw-r--r--
1. Removed all changes to Java SE APIs 2. Changed module name to jdk.management.rest 3. Rest Adapter invoked via Module service provider 4. changed package name to jdk.internal.management.remote.rest 5. rest module and httpserver module part of platform modules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56026
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     1
package jdk.internal.management.remote.rest;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     2
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     3
import jdk.internal.agent.spi.AgentProvider;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     4
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     5
import java.io.IOException;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     6
import java.util.Properties;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     7
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     8
public class RestAdapterProvider extends AgentProvider {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     9
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    10
    private static final String REST_ADAPTER_NAME = "RestAdapter";
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    11
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    12
    @Override
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    13
    public synchronized void startAgent() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    14
        try {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    15
            PlatformRestAdapter.init(null);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    16
        } catch (IOException e) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    17
            throw new RuntimeException(e);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    18
        }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    19
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    20
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    21
    @Override
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    22
    public synchronized void startAgent(Properties props) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    23
        try {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    24
            PlatformRestAdapter.init(props);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    25
        } catch (IOException e) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    26
            throw new RuntimeException(e);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    27
        }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    28
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    29
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    30
    @Override
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    31
    public synchronized void stopAgent() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    32
        PlatformRestAdapter.stop();
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    33
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    34
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    35
    @Override
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    36
    public String getName() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    37
        return REST_ADAPTER_NAME;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    38
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    39
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    40
    @Override
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    41
    public synchronized boolean isActive() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    42
        return PlatformRestAdapter.isStarted();
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    43
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    44
}