AngularJS Read URL Property File JBoss Environment

AngularJS Read URL Property File JBoss Environment

In this demo you will see how to read URL value dynamically from property file based on JBoss server hosted location.

Use case:

  • Dynamic web application has been created using AngularJS framework which will consume data from multiple RESTFul services
  • RESTFul server hosted separately on different servers
  • AngularJS page need to replace service HTTP URL dynamically based on the service environment
  • AngularJS web application will be deployed on JBoss server

Solutions:

  • Create property file inside AngularJS application
  • Set system property in JBoss server deploy folder in properties-service.xml
  • Create utility servlet which will pull system environment specific property
  • Make http GET call from AngularJS to utility servlet and based on environment load properties file and replace service URL.

Detail Implementation and tools needed:

  • Eclipse Kepler (You could use any version of eclipse. Here we are using Kepler because it comes with in-built maven plug-in)
  • JBoss server 6.1 community edition (You could use any version of JBoss)
  • JDK 1.5 or above

Steps:

  • Create maven project name: JavaHonkAngularJSJBoss
  • Final project structure:

AngularJS Read URL Property File JBoss Environment

  • To add System properties on JBoss Properties MBean Service go to JBoss deployment folder look for “properties-service.xml” file .Below is properties-service.xml updated file:

  • As you see above file we have added

  • system.properties:

  • UtilitySevlet.java to read System property:

  • index.html:

  • Configure and run this application and If you are not sure how to configure and run JBoss inside eclipse please use this tutorial. Now start JBoss server you will see below output:

2015-01-08_1610

download Download Project: JavaHonkAngularJSJBoss

Leave a Reply

Your email address will not be published. Required fields are marked *