-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented integration for deployed apps
- Loading branch information
Showing
17 changed files
with
552 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# we are extending everything from tomcat:8.0 image ... | ||
FROM tomcat:8.5 | ||
MAINTAINER Vladimir Orany | ||
# COPY path-to-your-application-war path-to-webapps-in-docker-tomcat | ||
|
||
RUN rm -rf /usr/local/tomcat/webapps/* | ||
ADD ./build/libs/micronaut-grails-example-3.0.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war | ||
|
||
EXPOSE 8080/tcp | ||
EXPOSE 8000/tcp | ||
|
||
ENV CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GET https://localhost:8080/test/index | ||
Accept: application/json | ||
|
||
### | ||
GET https://localhost:8080/test/context | ||
Accept: application/json | ||
|
||
### | ||
GET https://localhost:8080/test/values | ||
Accept: application/json | ||
|
||
### | ||
GET https://localhost:8080/test/managers | ||
Accept: application/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
subprojects/micronaut-grails-web-boot/micronaut-grails-web-boot.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2020 Vladimir Orany. | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
config { | ||
bintray { | ||
enabled = true | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(':micronaut-grails') | ||
api "org.grails:grails-core:$grailsVersion" | ||
|
||
compileOnly 'javax.servlet:javax.servlet-api:4.0.1' | ||
compileOnly 'org.springframework:spring-webmvc:5.2.12.RELEASE' | ||
compileOnly 'org.springframework.boot:spring-boot:2.4.1' | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
...groovy/com/agorapulse/micronaut/grails/web/boot/MicronautGrailsAppServletInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2020 Vladimir Orany. | ||
* | ||
* 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 | ||
* | ||
* https://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 com.agorapulse.micronaut.grails.web.boot; | ||
|
||
import com.agorapulse.micronaut.grails.MicronautGrailsAppBuilder; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.builder.ParentContextApplicationContextInitializer; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; | ||
import org.springframework.boot.web.servlet.support.ErrorPageFilter; | ||
import org.springframework.boot.web.servlet.support.ServletContextApplicationContextInitializer; | ||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.AnnotationUtils; | ||
import org.springframework.util.Assert; | ||
import org.springframework.web.context.WebApplicationContext; | ||
|
||
import javax.servlet.ServletContext; | ||
|
||
/** | ||
* Ensure a {@link com.agorapulse.micronaut.grails.MicronautGrailsApp} in constructed during servlet initialization. | ||
* | ||
* Inspired by {@code GrailsAppServletInitializer} | ||
* | ||
*/ | ||
public abstract class MicronautGrailsAppServletInitializer extends SpringBootServletInitializer { | ||
|
||
/* | ||
* TODO: Replace with createSpringApplicationBuilder() override when upgrading to Spring Boot 1.3 M4 and delete this method | ||
*/ | ||
|
||
protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) { | ||
SpringApplicationBuilder builder = new MicronautGrailsAppBuilder(); | ||
builder.main(getClass()); | ||
ApplicationContext parent = getExistingRootWebApplicationContext(servletContext); | ||
if (parent != null) { | ||
this.logger.info("Root context already created (using as parent)."); | ||
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null); | ||
builder.initializers(new ParentContextApplicationContextInitializer(parent)); | ||
} | ||
builder.initializers(new ServletContextApplicationContextInitializer(servletContext)); | ||
builder.contextClass(AnnotationConfigServletWebServerApplicationContext.class); | ||
builder = configure(builder); | ||
SpringApplication application = builder.build(); | ||
if (application.getAllSources().isEmpty() && AnnotationUtils.findAnnotation(getClass(), Configuration.class) != null) { | ||
application.getSources().add(getClass().getName()); | ||
} | ||
Assert.state( | ||
application.getAllSources().size() > 0, | ||
"No SpringApplication sources have been defined. Either override the configure method or add an @Configuration annotation" | ||
); | ||
// Ensure error pages are registered | ||
application.getSources().add(ErrorPageFilter.class.getName()); | ||
return run(application); | ||
} | ||
|
||
private ApplicationContext getExistingRootWebApplicationContext(ServletContext servletContext) { | ||
Object context = servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); | ||
if (context instanceof ApplicationContext) { | ||
return (ApplicationContext) context; | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.