/** * Tests building a proxy service with an unreachable URI specified as the published wsdl url with the * 'enablePublishWSDLSafeMode' set to true. * * @throws URISyntaxException if an error occurs when converting the URI string to a URI */ public void testBuildAxisServiceWithUnreachableWsdlUriWithPublishWSDLSafeModeEnabled() throws Exception { SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration axisCfg = new AxisConfiguration(); ProxyService proxyService = new ProxyService ("unreachableWsdlUriWithPublishWSDLSafeModeEnabledProxy"); proxyService.addParameter("enablePublishWSDLSafeMode", true); URI wsdlUri = new URI("http://invalid-host/SimpleStockService.wsdl"); proxyService.setWsdlURI(wsdlUri); Assert.assertNull("Axis service returned should be null", proxyService.buildAxisService(synCfg, axisCfg)); }
@Override public void proxyServiceAdded(ProxyService proxy) { ArtifactHolder holder = new ArtifactHolder(); holder.setParent(proxy.getName()); proxy.setComponentStatisticsId(holder); proxy.getAspectConfiguration().setHashCode(holder.getHashCodeAsString()); StatisticIdentityGenerator.conclude(holder); }
private void initializeProxy(ProxyService proxy) throws DeploymentException { if (proxy.getTargetInLineEndpoint() != null) { proxy.getTargetInLineEndpoint().init(getSynapseEnvironment()); } if (proxy.getTargetInLineInSequence() != null) { proxy.getTargetInLineInSequence().init(getSynapseEnvironment()); } if (proxy.getTargetInLineOutSequence() != null) { proxy.getTargetInLineOutSequence().init(getSynapseEnvironment()); } if (proxy.getTargetInLineFaultSequence() != null) { proxy.getTargetInLineFaultSequence().init(getSynapseEnvironment()); } } }
public void proxyServiceRemoved(ProxyService proxy) { if (proxy.getArtifactContainerName() != null) { log.info("Proxy service : " + proxy.getName() + " was removed " + "from the Synapse configuration successfully - " + proxy.getArtifactContainerName()); } else { log.info("Proxy service : " + proxy.getName() + " was removed " + "from the Synapse configuration successfully"); } }
handleException("The 'name' attribute is required for a Proxy service definition"); } else { proxy = new ProxyService(name.getAttributeValue()); proxy.setTransports(transportList); proxy.setPinnedServers(pinnedServersList); if (traceValue != null) { if (traceValue.equals(XMLConfigConstants.TRACE_ENABLE)) { proxy.setTraceState(org.apache.synapse.SynapseConstants.TRACING_ON); } else if (traceValue.equals(XMLConfigConstants.TRACE_DISABLE)) { proxy.setTraceState(org.apache.synapse.SynapseConstants.TRACING_OFF); new QName(XMLConfigConstants.NULL_NAMESPACE, "startOnLoad")); if (startOnLoad != null) { proxy.setStartOnLoad(Boolean.valueOf(startOnLoad.getAttributeValue())); } else { proxy.setStartOnLoad(true); new QName(XMLConfigConstants.NULL_NAMESPACE, "serviceGroup")); if (serviceGroup != null) { proxy.setServiceGroup(serviceGroup.getAttributeValue()); new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "description")); if (descriptionElement != null) { proxy.setDescription(descriptionElement.getText().trim()); new QName(XMLConfigConstants.NULL_NAMESPACE, "inSequence"));
if (service.getName() != null) { proxy.addAttribute(fac.createOMAttribute( "name", nullNS, service.getName())); } else { handleException("Invalid proxy service. Service name is required"); String descriptionStr = service.getDescription(); if (descriptionStr != null) { OMElement description = fac.createOMElement("description", synNS); ArrayList transports = service.getTransports(); if (transports != null && !transports.isEmpty()) { String transportStr = "" + transports.get(0); if (service.getServiceGroup() != null) { proxy.addAttribute(fac.createOMAttribute( "serviceGroup", nullNS, service.getServiceGroup())); List pinnedServers = service.getPinnedServers(); if (pinnedServers != null && !pinnedServers.isEmpty()) { String pinnedServersStr = "" + pinnedServers.get(0); if (service.isStartOnLoad()) { proxy.addAttribute(fac.createOMAttribute( "startOnLoad", nullNS, "true")); String endpoint = service.getTargetEndpoint(); Endpoint inLineEndpoint = service.getTargetInLineEndpoint();
public void testDebugManagerProcessCommandSetBreakPointProxyOutSequence() throws Exception { ProxyService ps = new ProxyService("test_proxy_2"); TestMediator in1 = new TestMediator(); TestMediator in2 = new TestMediator(); TestMediator in3 = new TestMediator(); SequenceMediator inSeq = new SequenceMediator(); inSeq.addChild(in1); inSeq.addChild(in2); inSeq.addChild(in3); TestMediator out1 = new TestMediator(); TestMediator out2 = new TestMediator(); TestMediator out3 = new TestMediator(); SequenceMediator outSeq = new SequenceMediator(); outSeq.addChild(out1); outSeq.addChild(out2); outSeq.addChild(out3); ps.setTargetInLineInSequence(inSeq); ps.setTargetInLineOutSequence(inSeq); synConfig.addProxyService(ps.getName(), ps); String debug_command = "{\"command\":\"set\",\"command-argument\":\"breakpoint\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_2\",\"sequence-type\":\"proxy_outseq\"," + "\"mediator-position\":\"0\"}}}"; dm.processDebugCommand(debug_command); assertTrue(((AbstractMediator) ps.getTargetInLineOutSequence().getChild(0)).isBreakPoint()); }
public void testDebugManagerProcessCommandSetSkipProxyInSequence() throws Exception { ProxyService ps = new ProxyService("test_proxy_5"); TestMediator in1 = new TestMediator(); TestMediator in2 = new TestMediator(); TestMediator in3 = new TestMediator(); SequenceMediator inSeq = new SequenceMediator(); inSeq.addChild(in1); inSeq.addChild(in2); inSeq.addChild(in3); TestMediator out1 = new TestMediator(); TestMediator out2 = new TestMediator(); TestMediator out3 = new TestMediator(); SequenceMediator outSeq = new SequenceMediator(); outSeq.addChild(out1); outSeq.addChild(out2); outSeq.addChild(out3); ps.setTargetInLineInSequence(inSeq); ps.setTargetInLineOutSequence(inSeq); synConfig.addProxyService(ps.getName(), ps); String debug_command = "{\"command\":\"set\",\"command-argument\":\"skip\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_5\",\"sequence-type\":\"proxy_inseq\"," + "\"mediator-position\":\"0\"}}}"; dm.processDebugCommand(debug_command); assertTrue(((AbstractMediator) ps.getTargetInLineInSequence().getChild(0)).isSkipEnabled()); }
/** * Tests starting a proxy service with correct axis configuration provided. * * @throws Exception if an exception occurs while configuring the axis configuration */ public void testStart() throws Exception { String proxyServiceName = "TestStartProxy"; SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration axisCfg = new AxisConfiguration(); SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(axisCfg), synCfg); axisCfg.addParameter(SynapseConstants.SYNAPSE_ENV, synEnv); synCfg.setAxisConfiguration(axisCfg); ProxyService proxyService = new ProxyService(proxyServiceName); AxisService axisServiceForActivation = new AxisService(); axisServiceForActivation.setName(proxyServiceName); axisCfg.addToAllServicesMap(axisServiceForActivation); proxyService.setTargetInLineInSequence(new SequenceMediator()); proxyService.setTargetInLineOutSequence(new SequenceMediator()); proxyService.setTargetInLineFaultSequence(new SequenceMediator()); proxyService.start(synCfg); Assert.assertTrue("Underlying Axis service is not activated", axisServiceForActivation.isActive()); Assert.assertTrue("Proxy service is not running", proxyService.isRunning()); proxyService.stop(synCfg); }
proxy.setArtifactContainerName(customLogContent); if (proxy != null) { if (getSynapseConfiguration().getProxyService(proxy.getName()) != null) { log.warn("Hot deployment thread picked up an already deployed proxy - Ignoring"); return proxy.getName(); proxy.setFileName(proxyFile.getName()); proxy.setFilePath(proxyFile.toURI().toURL()); log.debug("ProxyService named '" + proxy.getName() + "' has been built from the file " + filePath); log.debug("Initialized the ProxyService : " + proxy.getName()); getSynapseConfiguration().addProxyService(proxy.getName(), proxy); AxisService axisService = proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration()); log.debug("Skipping proxy Startup for ProxyService : " + proxy.getName()); return proxy.getName(); log.debug("Started the ProxyService : " + proxy.getName()); log.debug("ProxyService Deployment from file : " + filePath + " : Completed"); log.info("ProxyService named '" + proxy.getName() + "' has been deployed from file : " + filePath); if (!proxy.isStartOnLoad() || !axisService.isActive()) {
boolean traceOn = proxy.getAspectConfiguration().isTracingEnabled(); boolean traceOrDebugOn = traceOn || log.isDebugEnabled(); CustomLogSetter.getInstance().setLogAppender(proxy.getArtifactContainerName()); if (isStatisticsEnabled) { statisticReportingIndex = OpenEventCollector.reportEntryEvent(synCtx, this.name, proxy.getAspectConfiguration(), ComponentType.PROXYSERVICE); proxy.getParameterMap().get(SynapseConstants.INBOUND_PROXY_SERVICE_PARAM); Object inboundMsgCtxParam = mc.getProperty(SynapseConstants.IS_INBOUND); proxy.registerFaultHandler(synCtx); if (proxy.getTargetInSequence() != null) { Mediator inSequence = synCtx.getSequence(proxy.getTargetInSequence()); if (inSequence != null) { traceOrDebug(traceOn, "Using sequence named : " + proxy.getTargetInSequence() + " for incoming message mediation"); inSequenceResult = inSequence.mediate(synCtx); + proxy.getTargetInSequence(), synCtx); } else if (proxy.getTargetInLineInSequence() != null) { traceOrDebug(traceOn, "Using the anonymous " + "in-sequence of the proxy service for mediation"); inSequenceResult = proxy.getTargetInLineInSequence().mediate(synCtx);
boolean traceOn = proxy.getTraceState() == SynapseConstants.TRACING_ON; boolean traceOrDebugOn = traceOn || log.isDebugEnabled(); proxy.getAspectConfiguration(), ComponentType.PROXYSERVICE); synCtx.setTracingState(proxy.getTraceState()); if (proxy.getTargetFaultSequence() != null) { Mediator faultSequence = synCtx.getSequence(proxy.getTargetFaultSequence()); if (faultSequence != null) { if (traceOrDebugOn) { synCtx.getSequence(proxy.getTargetFaultSequence()))); proxy.getTargetFaultSequence() + "; using default fault sequence"); synCtx.pushFaultHandler(new MediatorFaultHandler(synCtx.getFaultSequence())); } else if (proxy.getTargetInLineFaultSequence() != null) { if (traceOrDebugOn) { traceOrDebug(traceOn, "Setting specified anonymous fault-sequence for proxy"); new MediatorFaultHandler(proxy.getTargetInLineFaultSequence())); if (proxy.getTargetInSequence() != null) { Mediator inSequence = synCtx.getSequence(proxy.getTargetInSequence()); if (inSequence != null) {
/** * Tests building a proxy service with an unreachable endpoint specified as the published wsdl url with the * 'enablePublishWSDLSafeMode' set to false. * * @throws Exception if an error occurs when converting the URI string to a URI */ public void testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeEnabled() throws Exception { MessageContext synCtx = new TestMessageContext(); SynapseConfiguration synCfg = new SynapseConfiguration(); synCtx.setConfiguration(synCfg); AxisConfiguration axisCfg = new AxisConfiguration(); ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxyWithPublishWSDLSafeModeEnabled"); proxyService.setPublishWSDLEndpoint("wsdlEndPoint"); AddressEndpoint wsdlEndpoint = new AddressEndpoint(); EndpointDefinition endpointDefinition = new EndpointDefinition(); endpointDefinition.setAddress((new URI("http://invalid-host/SimpleStockService.wsdl")).toString()); wsdlEndpoint.setDefinition(endpointDefinition); proxyService.addParameter("enablePublishWSDLSafeMode", true); synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint); Assert.assertNull("Axis service built with an unreachable wsdl endpoint be null", proxyService.buildAxisService(synCfg, axisCfg)); }
List pinnedServers = proxy.getPinnedServers(); if (pinnedServers != null && !pinnedServers.isEmpty()) { if (!pinnedServers.contains(thisServerName)) { log.info("Server name not in pinned servers list." + " Not deploying Proxy service : " + proxy.getName()); continue; AxisService proxyService = proxy.buildAxisService(synapseConfiguration, configurationContext.getAxisConfiguration()); if (proxyService != null) { log.info("Deployed Proxy service : " + proxy.getName()); if (!proxy.isStartOnLoad()) { proxy.stop(synapseConfiguration); log.warn("The proxy service " + proxy.getName() + " will NOT be available"); log.warn("The proxy service " + proxy.getName() + " cannot be deployed - " + "Continue in Proxy Service fail-safe mode."); } else { handleException("The proxy service " + proxy.getName() + " : Deployment Error");
ProxyService proxy = ProxyServiceFactory.createProxy(artifactConfig, properties); if (proxy != null) { proxy.setFileName((new File(fileName)).getName()); if (log.isDebugEnabled()) { log.debug("ProxyService named '" + proxy.getName() + "' has been built from the file " + fileName); log.debug("Initialized the ProxyService : " + proxy.getName()); currentProxy.stop(getSynapseConfiguration()); getSynapseConfiguration().removeProxyService(existingArtifactName); if (!existingArtifactName.equals(proxy.getName())) { log.info("ProxyService named " + existingArtifactName + " has been Undeployed"); proxy.buildAxisService(getSynapseConfiguration(), getSynapseConfiguration().getAxisConfiguration()); if (log.isDebugEnabled()) { log.debug("Started the ProxyService : " + proxy.getName()); getSynapseConfiguration().addProxyService(proxy.getName(), proxy); if (log.isDebugEnabled()) { log.debug("ProxyService " + (existingArtifactName.equals(proxy.getName()) ? "update" : "deployment") + " from file : " + fileName + " : Completed"); log.info("ProxyService named '" + proxy.getName() + "' has been " + (existingArtifactName.equals(proxy.getName()) ? "updated" : "deployed") + " from file : " + fileName); return proxy.getName(); } else {
/** * Stop the proxy service * @param synCfg the synapse configuration */ public void stop(SynapseConfiguration synCfg) { AxisConfiguration axisConfig = synCfg.getAxisConfiguration(); if (axisConfig != null) { AxisService as = axisConfig.getServiceForActivation(this.getName()); //If an active AxisService is found if (as != null) { if (as.isActive()) { as.setActive(false); } axisConfig.notifyObservers(new AxisEvent(AxisEvent.SERVICE_STOP, as), as); } this.setRunning(false); auditInfo("Stopped the proxy service : " + name); } else { auditWarn("Unable to stop proxy service : " + name + ". Couldn't access Axis configuration"); } }
synCfg.addEntry("imported_wsdl", entry); ProxyService proxyService = new ProxyService("Test"); proxyService.setWSDLKey("root_wsdl"); ResourceMap resourceMap = new ResourceMap(); resourceMap.addResource("imported.wsdl", "imported_wsdl"); resourceMap.addResource("imported.xsd", "imported_xsd"); proxyService.setResourceMap(resourceMap); AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
if (proxy != null) { if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) { seqMediator = proxy.getTargetInLineInSequence(); } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) { seqMediator = proxy.getTargetInLineOutSequence(); } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) { seqMediator = proxy.getTargetInLineFaultSequence();
ProxyService proxyService = new ProxyService("TestRegisterFaultHandlerProxy"); MessageContext messageContext = new TestMessageContext(); SynapseConfiguration synCfg = new SynapseConfiguration(); proxyService.registerFaultHandler(messageContext); String faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()) .getFaultMediator()).getName(); proxyService.setTargetInLineFaultSequence(faultMediator); proxyService.registerFaultHandler(messageContext); faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()) .getFaultMediator()).getName(); SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(axisCfg), synCfg); messageContext.setEnvironment(synEnv); proxyService.setTargetFaultSequence("targetFaultSequence"); proxyService.registerFaultHandler(messageContext); faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()) .getFaultMediator()).getName(); proxyService.registerFaultHandler(messageContext); faultMediatorName = ((SequenceMediator) ((MediatorFaultHandler) messageContext.getFaultStack().pop()) .getFaultMediator()).getName();
/** * Test a proxy service with recursive imports and without a {@link ResourceMap}. * Regression test for SYNAPSE-442. */ public void testRecursiveImports2() throws Exception { ProxyService testService = new ProxyService("mytest"); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration axisCfg = new AxisConfiguration(); testService.setWsdlURI(getClass().getResource("SimpleStockService.wsdl").toURI()); testService.buildAxisService(synCfg, axisCfg); }