Deploying different types of applications

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Deploying different types of applications

yoron
Hello guys,

We have a several types of applications we deploy with glu (java applications, java web applications, python apps etc).
Currently, we have a deployment script per application type. This is causing a lot of code duplication, the scripts have some common code (sending events, logging stuff etc).

I'm in the midst of a consolidation effort, aimed at eliminating all the scripts and collapsing them into a single script. Currently, I have created a private class for each application type, but since I couldn't find any way to initialize a global variable with the proper strategy to use, I have to go through a function call each time I need to obtain the correct strategy (the strategy is selected based on some parameter in initParameters)

What would be the best way to do that?

Thanks,
Yotam.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying different types of applications

frenchyan
Administrator
Hi Yotam

From the release notes: "4.2.0 introduces the ability to package a glu script as a precompiled class (or set of classes) inside one (or more) jar file(s). As a result, a glu script can inherit from another class as well as have external (to glu) dependencies! Check Packaging a glu script for more info." (http://pongasoft.github.io/glu/docs/latest/html/glu-script.html#glu-script-packaging)

I guess this would be my recommendation: have a base class with all the common code and then a set of glu script which inherits from the base class and implement a bunch of abstract method.

Note another way of doing it (in one script) is using groovy dynamic method call dispatching...

For example, you can define closure attibutes (= functions) and invoke them dynamically depending on a string/type (in initParameters). For example:

def doThis_type1 = { args ->
  ... code for doThis for type 1 goes here
}

def doThis_type2 = { args ->
  ... code for doThis for type 2 goes here
}

def install = {
  this."doThis_${params.scriptType}"(p1: "v1")
}


Yan
Reply | Threaded
Open this post in threaded view
|

Re: Deploying different types of applications

yoron
Hi Yan,

Thanks for the fast reply, I think I'll take the jar route.

Take care,
Yotam.