Updated Branches: refs/heads/master efc3bab37 -> cb38cc92d
setting payload file location as a configurable parameter Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/a9714e75 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/a9714e75 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/a9714e75 Branch: refs/heads/master Commit: a9714e753f04d3e0c54ca727e91b8f686b8d1bb3 Parents: efc3bab Author: Sajith Kariyawasam <[email protected]> Authored: Mon Dec 2 13:42:26 2013 +0530 Committer: Sajith Kariyawasam <[email protected]> Committed: Mon Dec 2 13:42:26 2013 +0530 ---------------------------------------------------------------------- .../src/main/bin/event-subscriber.sh | 2 +- .../event/subscriber/ArtifactListener.java | 15 +++------ .../subscriber/CartridgeAgentConstants.java | 33 ++++++++++++++++++++ .../cartridge/agent/event/subscriber/Main.java | 7 +++-- 4 files changed, 44 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a9714e75/products/cartridge-agent/modules/event-subscriber/src/main/bin/event-subscriber.sh ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/event-subscriber/src/main/bin/event-subscriber.sh b/products/cartridge-agent/modules/event-subscriber/src/main/bin/event-subscriber.sh index 1297e12..6c05fbc 100644 --- a/products/cartridge-agent/modules/event-subscriber/src/main/bin/event-subscriber.sh +++ b/products/cartridge-agent/modules/event-subscriber/src/main/bin/event-subscriber.sh @@ -24,5 +24,5 @@ echo "Starting event subscriber..." lib_path=./../lib/ class_path=`echo ${lib_path}/*.jar | tr ' ' ':'` -java -cp "${class_path}" org.apache.stratos.cartridge.agent.event.subscriber.Main ../conf +java -cp "${class_path}" org.apache.stratos.cartridge.agent.event.subscriber.Main ../conf /opt/apache-stratos-cartridge-agent/payload/launch-params echo "Event subscriber completed" http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a9714e75/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/ArtifactListener.java ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/ArtifactListener.java b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/ArtifactListener.java index 3b1fc93..f86c5d8 100644 --- a/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/ArtifactListener.java +++ b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/ArtifactListener.java @@ -38,14 +38,10 @@ import org.apache.stratos.deployment.synchronizer.git.impl.GitBasedArtifactRepos import org.apache.stratos.messaging.event.artifact.synchronization.ArtifactUpdatedEvent; import org.apache.stratos.messaging.util.Util; -/** - * @author wso2 - * - */ + public class ArtifactListener implements MessageListener{ private static final Log log = LogFactory.getLog(ArtifactListener.class); - private String launchParams = "/opt/apache-stratos-cartridge-agent/payload/launch-params"; @Override public void onMessage(Message message) { @@ -57,13 +53,12 @@ public class ArtifactListener implements MessageListener{ try { json = receivedMessage.getText(); } catch (Exception e) { - //e.printStackTrace(); log.error("Exception is occurred " + e.getMessage(), e); } ArtifactUpdatedEvent event = (ArtifactUpdatedEvent) Util.jsonToObject(json, ArtifactUpdatedEvent.class); - String clusterIdInPayload = readParamValueFromPayload("CLUSTER_ID"); - String localRepoPath = readParamValueFromPayload("APP_PATH"); + String clusterIdInPayload = readParamValueFromPayload(CartridgeAgentConstants.CLUSTER_ID); + String localRepoPath = readParamValueFromPayload(CartridgeAgentConstants.APP_PATH); String clusterIdInMessage = event.getClusterId(); String repoURL = event.getRepoURL(); String repoPassword = decryptPassword(event.getRepoPassword()); @@ -91,7 +86,7 @@ public class ArtifactListener implements MessageListener{ private String readParamValueFromPayload(String param) { String paramValue = null; // read launch params - File file = new File(launchParams); + File file = new File(System.getProperty(CartridgeAgentConstants.PARAM_FILE_PATH)); try { Scanner scanner = new Scanner(file); @@ -118,7 +113,7 @@ public class ArtifactListener implements MessageListener{ private String decryptPassword(String repoUserPassword) { String decryptPassword = ""; - String secret = readParamValueFromPayload("CARTRIDGE_KEY"); + String secret = readParamValueFromPayload(CartridgeAgentConstants.CARTRIDGE_KEY); SecretKey key; Cipher cipher; Base64 coder; http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a9714e75/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/CartridgeAgentConstants.java ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/CartridgeAgentConstants.java b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/CartridgeAgentConstants.java new file mode 100644 index 0000000..7fceaf3 --- /dev/null +++ b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/CartridgeAgentConstants.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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 org.apache.stratos.cartridge.agent.event.subscriber; + +import java.io.Serializable; + +public class CartridgeAgentConstants implements Serializable{ + + public static final String JNDI_PROPERTIES_DIR = "jndi.properties.dir"; + public static final String PARAM_FILE_PATH = "param.file.path"; + + public static final String CARTRIDGE_KEY = "CARTRIDGE_KEY"; + public static final String CLUSTER_ID = "CLUSTER_ID"; + public static final String APP_PATH = "APP_PATH"; + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/a9714e75/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/Main.java ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/Main.java b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/Main.java index 559d102..5345e6b 100644 --- a/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/Main.java +++ b/products/cartridge-agent/modules/event-subscriber/src/main/java/org/apache/stratos/cartridge/agent/event/subscriber/Main.java @@ -28,12 +28,15 @@ import org.apache.stratos.messaging.util.Constants; * Event publisher main class. */ public class Main { - private static final Log log = LogFactory.getLog(Main.class); + + private static final Log log = LogFactory.getLog(Main.class); public static void main(String[] args) { log.info("Strating cartridge agent event subscriber"); - System.setProperty("jndi.properties.dir", args[0]); + + System.setProperty(CartridgeAgentConstants.JNDI_PROPERTIES_DIR, args[0]); + System.setProperty(CartridgeAgentConstants.PARAM_FILE_PATH, args[1]); //initialting the subscriber
