diff --git a/quarkus/extensions/pom.xml b/quarkus/extensions/pom.xml index dcf3819fbeb..98a0652a94f 100644 --- a/quarkus/extensions/pom.xml +++ b/quarkus/extensions/pom.xml @@ -36,6 +36,29 @@ org.keycloak keycloak-services + + io.quarkus + quarkus-arc + jar + + + + + org.jboss.jandex + jandex-maven-plugin + 1.0.6 + + + make-index + + jandex + + + + + + + diff --git a/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartup.java b/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartup.java new file mode 100644 index 00000000000..502ba55b6dd --- /dev/null +++ b/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartup.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed 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.keycloak.provider.quarkus; + +import io.quarkus.arc.Arc; +import org.keycloak.services.resources.KeycloakApplication; + +public class QuarkusStartup implements KeycloakApplication.Startup { + + @Override + public void execute(Runnable command) { + QuarkusStartupObserver observer = Arc.container().instance(QuarkusStartupObserver.class).get(); + observer.setCommand(command); + } + +} diff --git a/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartupObserver.java b/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartupObserver.java new file mode 100644 index 00000000000..318be341094 --- /dev/null +++ b/quarkus/extensions/src/main/java/org/keycloak/provider/quarkus/QuarkusStartupObserver.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed 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.keycloak.provider.quarkus; + +import io.quarkus.runtime.StartupEvent; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +@ApplicationScoped +public class QuarkusStartupObserver { + + private Runnable command; + + public void setCommand(Runnable command) { + this.command = command; + } + + private void startupEvent(@Observes StartupEvent event) { + if (command != null) { + command.run(); + } + } + +} diff --git a/quarkus/extensions/src/main/resources/META-INF/services/org.keycloak.services.resources.KeycloakApplication$Startup b/quarkus/extensions/src/main/resources/META-INF/services/org.keycloak.services.resources.KeycloakApplication$Startup new file mode 100644 index 00000000000..85d0198be22 --- /dev/null +++ b/quarkus/extensions/src/main/resources/META-INF/services/org.keycloak.services.resources.KeycloakApplication$Startup @@ -0,0 +1,18 @@ +# +# Copyright 2019 Red Hat, Inc. and/or its affiliates +# and other contributors as indicated by the @author tags. +# +# Licensed 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. +# + +org.keycloak.provider.quarkus.QuarkusStartup