Skip to content

Instantly share code, notes, and snippets.

@karanmalhi
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karanmalhi/febed0740872d1ed7881 to your computer and use it in GitHub Desktop.
Save karanmalhi/febed0740872d1ed7881 to your computer and use it in GitHub Desktop.
Deployment Interceptor
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.mulesoft.tcat.DeploymentInterceptor;
import com.mulesoft.tcat.Application;
import com.mulesoft.tcat.Deployment;
import com.mulesoft.tcat.DeploymentInterceptor;
import com.mulesoft.tcat.DeploymentVersion;
import com.mulesoft.tcat.Server;
def c = applicationContext
// copy into a local var, referenced in closure
def logger = log
def deploymentService = c.getBean("deploymentService");
DeploymentInterceptor interceptor = new DeploymentInterceptor() {
public boolean intercept(DeploymentVersion deploymentVersion,
Server server,
Application application,
File expandedWarPath) {
try {
FileWriter writer = new FileWriter(new File(expandedWarPath, "test.txt"));
writer.write("hello");
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
};
deploymentService.addDeploymentInterceptor(interceptor);
return "Interceptor added successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment