Search in sources :

Example 1 with ListRestEndpointsCommand

use of fish.payara.appserver.rest.endpoints.config.admin.ListRestEndpointsCommand in project Payara by payara.

the class PayaraMicroImpl method dumpFinalStatus.

private void dumpFinalStatus(long bootTime) {
    // Print instance descriptor
    InstanceDescriptor id = getRuntime().getLocalDescriptor();
    LOGGER.log(Level.INFO, id.toJsonString(showServletMappings));
    // Get Payara Micro endpoints
    StringBuilder sb = new StringBuilder();
    sb.append("\nPayara Micro URLs:\n");
    List<URL> urls = id.getApplicationURLS();
    for (URL url : urls) {
        sb.append(url.toString()).append('\n');
    }
    // Count through applications and add their REST endpoints
    try {
        ListRestEndpointsCommand cmd = gf.getService(ListRestEndpointsCommand.class);
        id.getDeployedApplications().forEach(app -> {
            Map<String, Set<String>> endpoints = null;
            try {
                endpoints = cmd.getEndpointMap(app.getName());
            } catch (IllegalArgumentException ex) {
                // The application has no endpoints
                endpoints = null;
            }
            if (endpoints != null) {
                sb.append("\n'" + app.getName() + "' REST Endpoints:\n");
                endpoints.forEach((path, methods) -> {
                    methods.forEach(method -> {
                        sb.append(method + "\t" + path + "\n");
                    });
                });
            }
        });
    } catch (GlassFishException ex) {
        // Really shouldn't happen, the command catches it's own errors most of the time
        LOGGER.log(Level.SEVERE, "Failed to get REST endpoints for application", ex);
    }
    sb.append("\n");
    // Print out all endpoints
    LOGGER.log(Level.INFO, sb.toString());
    // Print the logo if it's enabled
    if (generateLogo) {
        generateLogo();
    }
    // Print final ready message
    LOGGER.log(Level.INFO, "{0} ready in {1} (ms)", new Object[] { Version.getFullVersion(), bootTime });
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) GlassFishException(org.glassfish.embeddable.GlassFishException) Set(java.util.Set) ListRestEndpointsCommand(fish.payara.appserver.rest.endpoints.config.admin.ListRestEndpointsCommand) URL(java.net.URL)

Aggregations

ListRestEndpointsCommand (fish.payara.appserver.rest.endpoints.config.admin.ListRestEndpointsCommand)1 InstanceDescriptor (fish.payara.micro.data.InstanceDescriptor)1 URL (java.net.URL)1 Set (java.util.Set)1 GlassFishException (org.glassfish.embeddable.GlassFishException)1