@Override public String deploySynapseArtifact( OMElement artifactConfig, String fileName, Properties properties) { if (log.isDebugEnabled()) { log.debug("Endpoint Deployment from file : " + fileName + " : Started"); } CustomLogSetter.getInstance().setLogAppender(customLogContent); try { Endpoint ep = EndpointFactory.getEndpointFromElement(artifactConfig, false, properties); // Set the car name ep.setArtifactContainerName(customLogContent); if (ep != null) { ep.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug( "Endpoint named '" + ep.getName() + "' has been built from the file " + fileName); } ep.init(getSynapseEnvironment()); if (log.isDebugEnabled()) { log.debug("Initialized the endpoint : " + ep.getName()); } getSynapseConfiguration().addEndpoint(ep.getName(), ep); if (log.isDebugEnabled()) { log.debug("Endpoint Deployment from file : " + fileName + " : Completed"); } log.info("Endpoint named '" + ep.getName() + "' has been deployed from file : " + fileName); return ep.getName(); } else { handleSynapseArtifactDeploymentError( "Endpoint Deployment Failed. The artifact " + "described in the file " + fileName + " is not an Endpoint"); } } catch (Exception e) { handleSynapseArtifactDeploymentError( "Endpoint Deployment from the file : " + fileName + " : Failed.", e); } return null; }
@Override public String updateSynapseArtifact( OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) { Endpoint ep = EndpointFactory.getEndpointFromElement(artifactConfig, false, properties); CustomLogSetter.getInstance().setLogAppender((ep != null) ? ep.getArtifactContainerName() : ""); if (log.isDebugEnabled()) { log.debug("Endpoint update from file : " + fileName + " has started"); } try { if (ep == null) { handleSynapseArtifactDeploymentError( "Endpoint update failed. The artifact " + "defined in the file: " + fileName + " is not a valid endpoint."); return null; } ep.setFileName(new File(fileName).getName()); if (log.isDebugEnabled()) { log.debug("Endpoint: " + ep.getName() + " has been built from the file: " + fileName); } ep.init(getSynapseEnvironment()); Endpoint existingEp = getSynapseConfiguration().getDefinedEndpoints().get(existingArtifactName); if (existingArtifactName.equals(ep.getName())) { getSynapseConfiguration().updateEndpoint(existingArtifactName, ep); } else { // The user has changed the name of the endpoint // We should add the updated endpoint as a new endpoint and remove the old one getSynapseConfiguration().addEndpoint(ep.getName(), ep); getSynapseConfiguration().removeEndpoint(existingArtifactName); log.info("Endpoint: " + existingArtifactName + " has been undeployed"); } log.info("Endpoint: " + ep.getName() + " has been updated from the file: " + fileName); waitForCompletion(); existingEp.destroy(); if (existingArtifactName.equals(ep.getName())) { // If the endpoint name was same as the old one, above method call (destroy) // will unregister the endpoint MBean - So we should register it again. MBeanRegistrar.getInstance().registerMBean(ep.getMetricsMBean(), "Endpoint", ep.getName()); } return ep.getName(); } catch (DeploymentException e) { handleSynapseArtifactDeploymentError( "Error while updating the endpoint from the " + "file: " + fileName); } return null; }