// Path: completable-future-jaxrs-cdi-cxf/src/main/java/org/iproduct/demo/profiler/server/resources/ProcessesRestResource.java
// @Path("/processes")
// @ApplicationScoped
// public class ProcessesRestResource {
// 	private Logger logger = LoggerFactory.getLogger(ProcessesRestResource.class);
// 
//     @Inject
//     Profiler profiler;
// 
//     @GET
//     @Produces(MediaType.APPLICATION_JSON)
//     public void getJavaProcesses(@Suspended AsyncResponse asyncResp) {
//     	CompletableFuture.supplyAsync(() -> {
//     		List<ProcessInfo> result =  profiler.getJavaProcesses(); //List.of("A", "B", "C", "D"); //.stream().reduce("", (acc, item) -> acc + item);
//     		System.out.println(result);
//     		return result;
//     	}).thenAccept(result -> asyncResp.resume(result));
//     }
// }
// 
// Path: completable-future-jaxrs-cdi-cxf/src/main/java/org/iproduct/demo/profiler/server/resources/StatsRestResource.java
// @Path("/stats")
// @ApplicationScoped
// public class StatsRestResource {
// 	private Logger logger = LoggerFactory.getLogger(StatsRestResource.class);
// 
//     private AtomicInteger i = new AtomicInteger();
//     private SseBroadcaster broadcaster;
//     private volatile Builder builder;
//     
//     @Context 
//     public void setSse(Sse sse) {
//         this.broadcaster = sse.newBroadcaster();
//         this.builder = sse.newEventBuilder();
//     }
//         
//     @GET
//     @Path("sse")
//     @Produces(MediaType.SERVER_SENT_EVENTS)
//     public void stats(@Context SseEventSink sink) {
//         broadcaster.register(sink);
//     }
//     
//     public void asyncProcessingCpuLoad(@ObservesAsync @CpuProfiling CpuLoad cpuLoad) {
//     	OutboundSseEvent sseEvent = createStatsEvent(builder, cpuLoad);
//     	broadcaster.broadcast(sseEvent);
// 
//     }
// 
//     private OutboundSseEvent createStatsEvent(final OutboundSseEvent.Builder builder, CpuLoad cpuLoad) {
//     	OutboundSseEvent event = builder
//         	.name("stats")
//             .data(CpuLoad.class, cpuLoad)
//             .mediaType(MediaType.APPLICATION_JSON_TYPE)
//             .build();
//     	return event;
//     }
// }


import org.iproduct.demo.profiler.server.resources.StatsRestResource;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.iproduct.demo.profiler.server.resources.ProcessesRestResource;

/**
 * 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 org.iproduct.demo.profiler.server.app;



@ApplicationPath("/api/*")
public class ProfilerApplication extends ResourceConfig {

	public ProfilerApplication() {

// Path: completable-future-jaxrs-cdi-cxf/src/main/java/org/iproduct/demo/profiler/server/resources/ProcessesRestResource.java
// @Path("/processes")
// @ApplicationScoped
// public class ProcessesRestResource {
// 	private Logger logger = LoggerFactory.getLogger(ProcessesRestResource.class);
// 
//     @Inject
//     Profiler profiler;
// 
//     @GET
//     @Produces(MediaType.APPLICATION_JSON)
//     public void getJavaProcesses(@Suspended AsyncResponse asyncResp) {
//     	CompletableFuture.supplyAsync(() -> {
//     		List<ProcessInfo> result =  profiler.getJavaProcesses(); //List.of("A", "B", "C", "D"); //.stream().reduce("", (acc, item) -> acc + item);
//     		System.out.println(result);
//     		return result;
//     	}).thenAccept(result -> asyncResp.resume(result));
//     }
// }
// 
// Path: completable-future-jaxrs-cdi-cxf/src/main/java/org/iproduct/demo/profiler/server/resources/StatsRestResource.java
// @Path("/stats")
// @ApplicationScoped
// public class StatsRestResource {
// 	private Logger logger = LoggerFactory.getLogger(StatsRestResource.class);
// 
//     private AtomicInteger i = new AtomicInteger();
//     private SseBroadcaster broadcaster;
//     private volatile Builder builder;
//     
//     @Context 
//     public void setSse(Sse sse) {
//         this.broadcaster = sse.newBroadcaster();
//         this.builder = sse.newEventBuilder();
//     }
//         
//     @GET
//     @Path("sse")
//     @Produces(MediaType.SERVER_SENT_EVENTS)
//     public void stats(@Context SseEventSink sink) {
//         broadcaster.register(sink);
//     }
//     
//     public void asyncProcessingCpuLoad(@ObservesAsync @CpuProfiling CpuLoad cpuLoad) {
//     	OutboundSseEvent sseEvent = createStatsEvent(builder, cpuLoad);
//     	broadcaster.broadcast(sseEvent);
// 
//     }
// 
//     private OutboundSseEvent createStatsEvent(final OutboundSseEvent.Builder builder, CpuLoad cpuLoad) {
//     	OutboundSseEvent event = builder
//         	.name("stats")
//             .data(CpuLoad.class, cpuLoad)
//             .mediaType(MediaType.APPLICATION_JSON_TYPE)
//             .build();
//     	return event;
//     }
// }


// Path: completable-future-jaxrs-cdi-jersey/src/main/java/org/iproduct/demo/profiler/server/app/ProfilerApplication.java
import org.iproduct.demo.profiler.server.resources.StatsRestResource;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.iproduct.demo.profiler.server.resources.ProcessesRestResource;

/**
 * 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 org.iproduct.demo.profiler.server.app;



@ApplicationPath("/api/*")
public class ProfilerApplication extends ResourceConfig {

	public ProfilerApplication() {

		register(ProcessesRestResource.class);
