/** * On a fault, propagate to parent if any, or call into the fault handler * * @param synCtx the message at hand */ public void onFault(MessageContext synCtx) { EndpointDefinition endpointDefinition = getDefinition(); if (endpointDefinition != null && endpointDefinition.getTimeoutAction() == SynapseConstants.DISCARD) { log.info("Ignoring fault handlers since the timeout action is set to DISCARD"); } else { logSetter(); invokeNextFaultHandler(synCtx); } }
@Override public void init(SynapseEnvironment synapseEnvironment) { if (!initialized) { super.init(synapseEnvironment); } this.env = synapseEnvironment; }
@Override public void destroy() { super.destroy(); }
boolean traceOn = isTraceOn(synCtx); boolean traceOrDebugOn = isTraceOrDebugOn(traceOn); prepareForEndpointStatistics(synCtx); traceOrDebug(traceOn, "Sending message through endpoint : " + getName() + " resolving to address = " + address); traceOrDebug(traceOn, "SOAPAction: " + (synCtx.getSoapAction() != null ? synCtx.getSoapAction() : "null")); traceOrDebug(traceOn, "WSA-Action: " + (synCtx.getWSAAction() != null ? synCtx.getWSAAction() : "null")); if (traceOn && trace.isTraceEnabled()) { if (errorHandlerMediator != null) { if (traceOrDebugOn) { traceOrDebug(traceOn, "Setting the onError handler : " + errorHandler + " for the endpoint : " + endpointName); axis2Ctx.setProperty(RelayConstants.FORCE_RESPONSE_EARLY_BUILD, Boolean.TRUE); } catch (Exception e) { handleException("Error while building message", e); evaluateProperties(synCtx); MediatorProperty preserveEnv = getProperty(SynapseConstants.PRESERVE_ENVELOPE); if (preserveEnv != null && JavaUtils.isTrueExplicitly(preserveEnv.getValue() != null ? preserveEnv.getValue() : preserveEnv.getEvaluatedExpression(synCtx))) { if (traceOrDebugOn) { traceOrDebug(traceOn, "Preserving the envelope by building it before " +
/** * Creates a basic EndpointView with a given number of children added to the endpoint. * * @param numberOfChildren the child endpoints inside the endpoint attached to the end point view. If * specified as 0, the children list will be null * @return the created end point view */ private EndpointView createEndPointView(int numberOfChildren) { AbstractEndpoint endpoint = new AddressEndpoint(); MessageContext synCtx = new TestMessageContext(); synCtx.setConfiguration(new SynapseConfiguration()); SynapseEnvironment environment = new Axis2SynapseEnvironment( new ConfigurationContext(new AxisConfiguration()), synCtx.getConfiguration()); if (numberOfChildren > 0) { List<Endpoint> children = new ArrayList<>(numberOfChildren); for (int i = 0; i < numberOfChildren; i++) { AbstractEndpoint child = new AddressEndpoint(); child.init(environment); child.setEnableMBeanStats(true); child.setName("endpoint" + i); children.add(child); } endpoint.setChildren(children); } endpoint.init(environment); return new EndpointView("endpoint", endpoint); }
private void processHttpMethod(MessageContext synCtx) { if (httpMethod != null) { super.getDefinition().setHTTPEndpoint(true); synCtx.setProperty(Constants.Configuration.HTTP_METHOD, httpMethod); } // Method is not a mandatory parameter for HttpEndpoint. So httpMethod can be null. // http method from incoming message is used as the http method }
/** * Method to create mock endpoint to be used by the endpoint view. * * @param numberOfChildren the child endpoints inside the endpoint attached to the end point view. If * specified as 0, the children list will be null * @return the created end point view */ private AbstractEndpoint createMockEndPoint(int numberOfChildren) { AbstractEndpoint abstractEndpoint = Mockito.mock(AddressEndpoint.class); if (numberOfChildren > 0) { List<Endpoint> children = new ArrayList<>(); for (int i = 0; i < numberOfChildren; i++) { AbstractEndpoint child = Mockito.mock(AddressEndpoint.class); EndpointContext endpointContext = Mockito.mock(EndpointContext.class); Mockito.when(child.getContext()).thenReturn(endpointContext); children.add(child); } Mockito.when(abstractEndpoint.getChildren()).thenReturn(children); } else { Mockito.when(abstractEndpoint.getChildren()).thenReturn(null); } EndpointContext endpointContext = Mockito.mock(EndpointContext.class); Mockito.when(abstractEndpoint.getContext()).thenReturn(endpointContext); return abstractEndpoint; }
public void testContextProperties() throws Exception { SynapseXPath xpath = new SynapseXPath("$ctx:timeout"); AbstractEndpoint endpoint = new AddressEndpoint(); EndpointDefinition definition = new EndpointDefinition(); endpoint.setDefinition(definition); definition.setDynamicTimeoutExpression(xpath); MessageContext synCtx = new TestMessageContext(); synCtx.setProperty("timeout", "90000"); assertEquals(Long.valueOf((String) xpath.evaluate(synCtx)).longValue(), endpoint.getDefinition().evaluateDynamicEndpointTimeout(synCtx)); }
public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { // The check for clustering environment ClusteringAgent clusteringAgent = cc.getAxisConfiguration().getClusteringAgent(); if (clusteringAgent != null && clusteringAgent.getStateManager() != null) { isClusteringEnabled = Boolean.TRUE; } else { isClusteringEnabled = Boolean.FALSE; } context = new EndpointContext(getName(), getDefinition(), isClusteringEnabled, cc, metricsMBean); } initialized = true; if (children != null) { for (Endpoint e : children) { e.init(synapseEnvironment); } } contentAware = definition != null && ((definition.getFormat() != null && !definition.getFormat().equals(SynapseConstants.FORMAT_REST)) || definition.isSecurityOn() || definition.isAddressingOn()); }
if (!abstractEndpoint.isLeafEndpoint()) { handleException("Endpoint Type not supported"); abstractEndpoint.executeEpTypeSpecificFunctions(synapseInMsgCtx); EndpointDefinition endpointDefinition = abstractEndpoint.getDefinition(); ((AbstractEndpoint) endpoint).getDefinition().getAddress(), ex);
public void setComponentStatisticsId(ArtifactHolder holder) { if (this instanceof IndirectEndpoint) { String sequenceId = StatisticIdentityGenerator .getIdReferencingComponent(((IndirectEndpoint) (this)).getKey(), ComponentType.ENDPOINT, holder); StatisticIdentityGenerator.reportingEndEvent(sequenceId, ComponentType.ENDPOINT, holder); } else { if (definition == null) { EndpointDefinition definition = new EndpointDefinition(); this.setDefinition(definition); } if (definition.getAspectConfiguration() == null) { definition.configure(new AspectConfiguration(getReportingName())); } String sequenceId = StatisticIdentityGenerator.getIdForComponent(getReportingName(), ComponentType.ENDPOINT, holder); definition.getAspectConfiguration().setUniqueId(sequenceId); StatisticIdentityGenerator.reportingEndEvent(sequenceId, ComponentType.ENDPOINT, holder); } } }
if (!abstractEndpoint.isLeafEndpoint()) { handleException("Endpoint type not supported. Only leaf endpoints are supported"); EndpointDefinition endpointDefinition = abstractEndpoint.getDefinition(); ((AbstractEndpoint) endpoint).getDefinition().getAddress());
/** * Asserts if the the endpoint view correctly returns the number of active child endpoints included in the * endpoint associated with the view. * * @throws Exception if an error occurs while accessing child endpoints */ public void testGetActiveChildren() throws Exception { //Assert with children AbstractEndpoint endpoint = createMockEndPoint(5); Mockito.when(endpoint.getChildren().get(0).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Mockito.when(endpoint.getChildren().get(1).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(false); Mockito.when(endpoint.getChildren().get(2).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Mockito.when(endpoint.getChildren().get(3).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(false); Mockito.when(endpoint.getChildren().get(4).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); EndpointView endpointView = new EndpointView("endpoint", endpoint); Assert.assertEquals("Incorrect active children count", 3, endpointView.getActiveChildren()); //Assert when endpoint has no children EndpointView endpointViewWithoutChildren = createMockEndPointView(0); Assert.assertEquals("Incorrect active children count", 0, endpointViewWithoutChildren.getActiveChildren()); }
if (endpoint.getFileName() == null) { OMElement endpointElem = EndpointSerializer.getElementFromEndpoint(endpoint); definitions.addChild(endpointElem);
private void invokeNextFaultHandler(MessageContext synCtx) { Stack faultStack = synCtx.getFaultStack(); if (!faultStack.isEmpty()) { Object faultHandler = faultStack.pop(); if (faultHandler instanceof Endpoint) { // This is the parent . need to inform parent with fault child ((Endpoint) faultHandler).onChildEndpointFail(this, synCtx); } else if (faultHandler instanceof MediatorFaultHandler) { if(!executeLastSequenceFaultHandler(synCtx)){ ((FaultHandler) faultHandler).handleFault(synCtx); } } else { ((FaultHandler) faultHandler).handleFault(synCtx); } } else { executeLastSequenceFaultHandler(synCtx); } }
logSetter(); statisticReportingIndex = OpenEventCollector.reportEntryEvent(synCtx, getReportingName(), definition.getAspectConfiguration(), ComponentType.ENDPOINT); boolean traceOn = isTraceOn(synCtx); boolean traceOrDebugOn = isTraceOrDebugOn(traceOn); prepareForEndpointStatistics(synCtx); traceOrDebug(traceOn, "Sending message through endpoint : " + getName() + " resolving to address = " + address); traceOrDebug(traceOn, "SOAPAction: " + (synCtx.getSoapAction() != null ? synCtx.getSoapAction() : "null")); traceOrDebug(traceOn, "WSA-Action: " + (synCtx.getWSAAction() != null ? synCtx.getWSAAction() : "null")); if (traceOn && trace.isTraceEnabled()) { if (errorHandlerMediator != null) { if (traceOrDebugOn) { traceOrDebug(traceOn, "Setting the onError handler : " + errorHandler + " for the endpoint : " + endpointName); handleException("Error while building message", e); evaluateProperties(synCtx); MediatorProperty preserveEnv = getProperty(SynapseConstants.PRESERVE_ENVELOPE); if (preserveEnv != null && JavaUtils.isTrueExplicitly(preserveEnv.getValue() != null ?
if (super.getDefinition() != null) { synCtx.setProperty(EndpointDefinition.DYNAMIC_URL_VALUE, evaluatedUri);
/** * Tests if the endpoint view correctly returns the active state with and without the presence of children * endpoints. The endpoint should be inactive if and only if all child endpoints are inactive. * * @throws Exception if an error occurs while accessing the active children of the endpoint view */ public void testIsActive() throws Exception { AbstractEndpoint endpoint = createMockEndPoint(3); EndpointView endpointView = new EndpointView("endpoint", endpoint); Mockito.when(endpoint.getChildren().get(2).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Assert.assertTrue("Endpoint view is not active with active child endpoint", endpointView.isActive()); endpoint = createMockEndPoint(0); EndpointContext endpointContext = Mockito.mock(EndpointContext.class); Mockito.when(endpoint.getContext()).thenReturn(endpointContext); endpointView = new EndpointView("endpoint", endpoint); Mockito.when(endpoint.getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Assert.assertTrue("Endpoint view is not active", endpointView.isActive()); Mockito.when(endpoint.getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(false); Assert.assertFalse("Endpoint is active", endpointView.isActive()); }
public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); if (!initialized) { // The check for clustering environment ClusteringAgent clusteringAgent = cc.getAxisConfiguration().getClusteringAgent(); if (clusteringAgent != null && clusteringAgent.getStateManager() != null) { isClusteringEnabled = Boolean.TRUE; } else { isClusteringEnabled = Boolean.FALSE; } context = new EndpointContext(getName(), getDefinition(), isClusteringEnabled, cc, metricsMBean); } initialized = true; if (children != null) { for (Endpoint e : children) { e.init(synapseEnvironment); } } contentAware = definition != null && ((definition.getFormat() != null && !definition.getFormat().equals(SynapseConstants.FORMAT_REST)) || definition.isSecurityOn() || definition.isReliableMessagingOn() || definition.isAddressingOn() || definition.isUseMTOM()|| definition.isUseSwa()); }
/** * Asserts if the the endpoint view correctly returns the number of child endpoints in the ready state. * * @throws Exception if an error occurs while accessing child endpoints */ public void testGetReadyChildren() throws Exception { AbstractEndpoint endpoint = createMockEndPoint(3); EndpointView endpointView = new EndpointView("endpoint", endpoint); Mockito.when(endpoint.getChildren().get(0).getContext().readyToSend()).thenReturn(true); Assert.assertEquals("Incorrect ready children count", 1, endpointView.getReadyChildren()); endpointView = createMockEndPointView(0); Assert.assertEquals("Ready children count should be empty", 0, endpointView.getReadyChildren()); }