diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/bootstrap/BootCommandService.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/bootstrap/BootCommandService.java index f24f15a3aeb..49f14705274 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/bootstrap/BootCommandService.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/bootstrap/BootCommandService.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2022] Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) [2016-2025] Payara Foundation and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -42,6 +42,9 @@ import com.sun.enterprise.module.bootstrap.StartupContext; import fish.payara.internal.api.PostBootRunLevel; import fish.payara.boot.runtime.BootCommands; +import org.glassfish.api.event.EventListener; +import org.glassfish.api.event.EventTypes; +import org.glassfish.api.event.Events; import org.glassfish.embeddable.CommandRunner; import org.glassfish.hk2.api.PostConstruct; import org.glassfish.hk2.runlevel.RunLevel; @@ -56,7 +59,7 @@ @Service @RunLevel(value = PostBootRunLevel.VAL) -public class BootCommandService implements PostConstruct { +public class BootCommandService implements PostConstruct, EventListener { private static final Logger LOGGER = Logger.getLogger(BootCommandService.class.getName()); @@ -66,6 +69,9 @@ public class BootCommandService implements PostConstruct { @Inject CommandRunner commandRunner; + @Inject + private Events events; + /** * Runs a series of commands from a file * @param file @@ -86,8 +92,15 @@ public void doBootCommands(String file, boolean expandValues) { } } + @Override + public void event(Event event) { + if (event.is(EventTypes.SERVER_READY)) { + doBootCommands(startupContext.getArguments().getProperty("-postbootcommandfile"), true); + } + } + @Override public void postConstruct() { - doBootCommands(startupContext.getArguments().getProperty("-postbootcommandfile"), true); + events.register(this); } }