Pushed applications to CF or PCF you would of most likely used a manifest.yml file and at some point wanted to use variable substitution. manifest.yml files don't support that and a feature request has been asked for this as follows
https://github.com/cloudfoundry/cli/issues/820
With a recent customer we scripted the creation of a manifest.yml file from a Jenkins job which would inject the required ROUTE to the application by creating the manifest.yml through a script as follows as shown below.
manifest-demo.sh
export ROUTE=$1
echo ""
echo "Setting route to $ROUTE ..."
echo ""
cat > manifest.yml <<!
---
applications:
- name: gs-rest-service
memory: 256M
instances: 1
host: $ROUTE
path: target/gs-rest-service-0.1.0.jar
!
cat manifest.yml
Script tested as follows
pasapicella@pas-macbook:~/bin/manifest-demo$ ./manifest-demo.sh apples-route-pas
Setting route to apples-route-pas ...
---
applications:
- name: gs-rest-service
memory: 256M
instances: 1
host: apples-route-pas
path: target/gs-rest-service-0.1.0.jar
Search This Blog
Friday, 19 August 2016
Tuesday, 16 August 2016
HttpSessionListener with Spring Boot Application
I had a requirement to implement a HttpSessionListener in my Spring Boot application which has no web.xml. To achieve this I did the following
1. My HttpSessionListener was defined as follows
2. Register the listener from a @Configration class as shown below
1. My HttpSessionListener was defined as follows
package com.pivotal.pcf.mysqlweb.utils; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; import org.apache.log4j.Logger; public class SessionListener implements HttpSessionListener { protected static Logger logger = Logger.getLogger("controller"); private HttpSession session = null; public void sessionCreated(HttpSessionEvent event) { // no need to do anything here as connection may not have been established yet session = event.getSession(); logger.info("Session created for id " + session.getId()); } public void sessionDestroyed(HttpSessionEvent event) { session = event.getSession(); /* * Need to ensure Connection is closed from ConnectionManager */ ConnectionManager cm = null; try { cm = ConnectionManager.getInstance(); cm.removeConnection(session.getId()); logger.info("Session destroyed for id " + session.getId()); } catch (Exception e) { logger.info("SesssionListener.sessionDestroyed Unable to obtain Connection", e); } } }
2. Register the listener from a @Configration class as shown below
package com.pivotal.pcf.mysqlweb; import com.pivotal.pcf.mysqlweb.utils.SessionListener; import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.servlet.http.HttpSessionListener; @Configuration public class ApplicationSessionConfiguration { @Bean public ServletListenerRegistrationBean<HttpSessionListener> sessionListener() { return new ServletListenerRegistrationBean<HttpSessionListener>(new SessionListener()); } }Thats all you have to do to achieve this
Friday, 12 August 2016
Simple Spring Boot Application Deployed through Concourse UI to Pivotal Cloud Foundry
The demo below is a full working example of using Spring Boot Application which will build/deploy to Pivotal Cloud Foundry using Concourse. Concourse pipelines can easily be created within your source code as this demo shows and hence created / executed quite easily. Concourse limits itself to three core concepts: tasks, resources, and the jobs
that compose them.
https://github.com/papicella/SpringBootSimpleRest
Detailed instructions on how to setup/run this demo using Concourse see the link referenced above which is as follows
https://dl.dropboxusercontent.com/u/15829935/platform-demos/concourse-demo/index.html
It's worth reading the details on this link around Concourse Concepts
https://concourse.ci/concepts.html
More Information
https://concourse.ci/
https://github.com/papicella/SpringBootSimpleRest
Detailed instructions on how to setup/run this demo using Concourse see the link referenced above which is as follows
https://dl.dropboxusercontent.com/u/15829935/platform-demos/concourse-demo/index.html
It's worth reading the details on this link around Concourse Concepts
https://concourse.ci/concepts.html
More Information
https://concourse.ci/
Subscribe to:
Posts (Atom)