/** * Allow the startup finder to act as an XMLToObjectMapper for * Startup (i.e. Startup) loaded dynamically from a Registry * * @param om to build the startup object * @param properties bag of properties with additional information * @return startup created */ public Startup getObjectFromOMNode(OMNode om, Properties properties) { if (om instanceof OMElement) { return getStartup((OMElement) om, properties); } else { handleException("Invalid configuration XML : " + om); } return null; }
/** * Allow the startup finder to act as an XMLToObjectMapper for * Startup (i.e. Startup) loaded dynamically from a Registry * * @param om to build the startup object * @param properties bag of properties with additional information * @return startup created */ public Startup getObjectFromOMNode(OMNode om, Properties properties) { if (om instanceof OMElement) { return getStartup((OMElement) om, properties); } else { handleException("Invalid configuration XML : " + om); } return null; }
public static Startup defineStartup(SynapseConfiguration config, OMElement elem, Properties properties) { Startup startup = StartupFinder.getInstance().getStartup(elem, properties); config.addStartup(startup); return startup; }
public static Startup defineStartup(SynapseConfiguration config, OMElement elem, Properties properties) { Startup startup = StartupFinder.getInstance().getStartup(elem, properties); config.addStartup(startup); return startup; }
@Override public String deploySynapseArtifact(OMElement artifactConfig, String fileName, Properties properties) { if (log.isDebugEnabled()) { log.debug("StartupTask Deployment from file : " + fileName + " : Started"); } try { Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties); st.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug("StartupTask named '" + st.getName() + "' has been built from the file " + fileName); } st.init(getSynapseEnvironment()); if (log.isDebugEnabled()) { log.debug("Initialized the StartupTask : " + st.getName()); } getSynapseConfiguration().addStartup(st); if (log.isDebugEnabled()) { log.debug("StartupTask Deployment from file : " + fileName + " : Completed"); } log.info("StartupTask named '" + st.getName() + "' has been deployed from file : " + fileName); return st.getName(); } catch (Exception e) { handleSynapseArtifactDeploymentError( "StartupTask Deployment from the file : " + fileName + " : Failed.", e); } return null; }
Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties); st.setFileName((new File(fileName)).getName());
@Override public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) { if (log.isDebugEnabled()) { log.debug("StartupTask update from file : " + fileName + " has started"); } try { Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties); st.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug("StartupTask: " + st.getName() + " has been built from the file: " + fileName); } Startup existingSt = getSynapseConfiguration().getStartup(existingArtifactName); existingSt.destroy(); st.init(getSynapseEnvironment()); if (existingArtifactName.equals(st.getName())) { getSynapseConfiguration().updateStartup(st); } else { getSynapseConfiguration().addStartup(st); getSynapseConfiguration().removeStartup(existingArtifactName); log.info("StartupTask: " + existingArtifactName + " has been undeployed"); } log.info("StartupTask: " + st.getName() + " has been updated from the file: " + fileName); return st.getName(); } catch (DeploymentException e) { handleSynapseArtifactDeploymentError("Error while updating the startup task from the " + "file: " + fileName); } return null; }
@Override public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) { if (log.isDebugEnabled()) { log.debug("StartupTask update from file : " + fileName + " has started"); } try { Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties); st.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug("StartupTask: " + st.getName() + " has been built from the file: " + fileName); } Startup existingSt = getSynapseConfiguration().getStartup(existingArtifactName); existingSt.destroy(); st.init(getSynapseEnvironment()); if (existingArtifactName.equals(st.getName())) { getSynapseConfiguration().updateStartup(st); } else { getSynapseConfiguration().addStartup(st); getSynapseConfiguration().removeStartup(existingArtifactName); log.info("StartupTask: " + existingArtifactName + " has been undeployed"); } log.info("StartupTask: " + st.getName() + " has been updated from the file: " + fileName); return st.getName(); } catch (DeploymentException e) { handleSynapseArtifactDeploymentError("Error while updating the startup task from the " + "file: " + fileName); } return null; }
public void testStartupSerializationSenarioOne() throws Exception { String inputXml = "<task class=\"org.apache.synapse.util.TestTask\" group=\"org\" " + "name=\"TestTask\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<property name=\"name\" value=\"foo\"/>" + "<trigger interval=\"5\"/></task>"; OMElement inputOM = createOMElement(inputXml); Startup startup = StartupFinder.getInstance().getStartup(inputOM, new Properties()); OMElement resultOM = StartupFinder.getInstance().serializeStartup(null, startup); assertTrue(compare(resultOM, inputOM)); }
public void testStartupSerializationSenarioTwo() throws Exception { String inputXml = "<task class=\"org.apache.synapse.util.TestTask\" group=\"org\" " + "name=\"TestTask\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<description>Test description</description>" + "<property name=\"name\" value=\"foo\"/>" + "<trigger interval=\"5\"/></task>"; OMElement inputOM = createOMElement(inputXml); Startup startup = StartupFinder.getInstance().getStartup(inputOM, new Properties()); OMElement resultOM = StartupFinder.getInstance().serializeStartup(null, startup); assertTrue(compare(resultOM, inputOM)); } }