1818
1919import com .sun .enterprise .v3 .admin .AdminCommandJob ;
2020import com .sun .enterprise .v3 .admin .AsyncAdminCommandInvoker ;
21- import com .sun .enterprise .v3 .common .ActionReporter ;
21+ import com .sun .enterprise .v3 .common .PropsFileActionReporter ;
2222
2323import jakarta .ws .rs .core .Response ;
2424import jakarta .ws .rs .core .Response .ResponseBuilder ;
2525
2626import java .lang .System .Logger ;
2727
2828import org .glassfish .api .ActionReport ;
29- import org .glassfish .api .ActionReport . ExitCode ;
29+ import org .glassfish .api .admin . AdminCommandState ;
3030import org .glassfish .api .admin .CommandInvocation ;
31+ import org .glassfish .api .admin .Job ;
3132
3233import static java .lang .System .Logger .Level .TRACE ;
3334
3839public class DetachedSseAdminCommandInvoker extends AsyncAdminCommandInvoker <Response > {
3940 private static final Logger LOG = System .getLogger (DetachedSseAdminCommandInvoker .class .getName ());
4041
41- private final ActionReporter report ;
4242 private final ResponseBuilder builder ;
4343
44- public DetachedSseAdminCommandInvoker (ActionReporter idReport , CommandInvocation <AdminCommandJob > invocation , ResponseBuilder builder ) {
44+ public DetachedSseAdminCommandInvoker (CommandInvocation <AdminCommandJob > invocation , ResponseBuilder builder ) {
4545 super (invocation );
46- this .report = idReport ;
4746 this .builder = builder ;
4847 }
4948
@@ -54,8 +53,6 @@ public DetachedSseAdminCommandInvoker(ActionReporter idReport, CommandInvocation
5453 @ Override
5554 public Response start () {
5655 final AdminCommandJob job = getJob ();
57- report .setMessage (job .getId ());
58- report .setActionExitCode (ExitCode .SUCCESS );
5956 final Response response = createResponse (job );
6057 LOG .log (TRACE , "Job parameters: {0}, this: {1}" , job .getParameters (), this );
6158 startJob ();
@@ -64,10 +61,51 @@ public Response start() {
6461 }
6562
6663 private Response createResponse (AdminCommandJob job ) {
67- try (SseEventOutput eventOutput = new SseEventOutput (job )) {
64+ try (SseEventOutput eventOutput = new SseEventOutput (new DetachedAdminCommandState ( job ) )) {
6865 LOG .log (TRACE , "Writing the job id. {0}" , this );
6966 eventOutput .write ();
7067 return builder .entity (eventOutput ).build ();
7168 }
7269 }
70+
71+ private static final class DetachedAdminCommandState implements AdminCommandState {
72+
73+ private final String id ;
74+ private final String name ;
75+ private final State state ;
76+
77+ DetachedAdminCommandState (Job job ) {
78+ this .id = job .getId ();
79+ this .name = job .getName ();
80+ this .state = job .getState ();
81+ }
82+
83+ @ Override
84+ public String getId () {
85+ return id ;
86+ }
87+
88+ @ Override
89+ public String getName () {
90+ return name ;
91+ }
92+
93+ @ Override
94+ public State getState () {
95+ return state ;
96+ }
97+
98+ @ Override
99+ public ActionReport getActionReport () {
100+ ActionReport actionReport = new PropsFileActionReporter ();
101+ actionReport .setActionDescription (name + " command" );
102+ actionReport .setActionExitCode (ActionReport .ExitCode .SUCCESS );
103+ return actionReport ;
104+ }
105+
106+ @ Override
107+ public boolean isOutboundPayloadEmpty () {
108+ return true ;
109+ }
110+ }
73111}
0 commit comments