Home » synapse-1.2-src » org.apache.synapse.endpoints » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
   10    *   http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    *  Unless required by applicable law or agreed to in writing,
   13    *  software distributed under the License is distributed on an
   14    *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    *  KIND, either express or implied.  See the License for the
   16    *  specific language governing permissions and limitations
   17    *  under the License.
   18    */
   19   
   20   package org.apache.synapse.endpoints;
   21   
   22   import org.apache.synapse.MessageContext;
   23   
   24   /**
   25    * Endpoint defines the behavior common to all Synapse endpoints. Synapse endpoints should be able
   26    * to send the given Synapse message context, rather than just providing the information for sending
   27    * the message. The task a particular endpoint does in its send(...) method is specific to the endpoint.
   28    * For example a loadbalance endpoint may choose another endpoint using its load balance policy and
   29    * call its send(...) method while an address endpoint (leaf level) may send the message to an actual
   30    * endpoint url. Endpoints may contain zero or more endpoints in them and build up a hierarchical
   31    * structure of endpoints.
   32    */
   33   public interface Endpoint {
   34   
   35       /**
   36        * Sends the message context according to an endpoint specific behavior.
   37        *
   38        * @param synMessageContext MessageContext to be sent.
   39        */
   40       public void send(MessageContext synMessageContext);
   41   
   42       /**
   43        * Endpoints that contain other endpoints should implement this method. It will be called if a
   44        * child endpoint causes an exception. Action to be taken on such failure is up to the implementation.
   45        * But it is good practice to first try addressing the issue. If it can't be addressed propagate the
   46        * exception to parent endpoint by calling parent endpoint's onChildEndpointFail(...) method.
   47        *
   48        * @param endpoint          The child endpoint which caused the exception.
   49        * @param synMessageContext MessageContext that was used in the failed attempt.
   50        */
   51       public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext);
   52   
   53       /**
   54        * Sets the parent endpoint for the current endpoint.
   55        *
   56        * @param parentEndpoint parent endpoint containing this endpoint. It should handle the onChildEndpointFail(...)
   57        *                       callback.
   58        */
   59       public void setParentEndpoint(Endpoint parentEndpoint);
   60   
   61       /**
   62        * Returns the name of the endpoint.
   63        *
   64        * @return Endpoint name.
   65        */
   66       public String getName();
   67   
   68       /**
   69        * Sets the name of the endpoint. Local registry use this name as the key for storing the
   70        * endpoint.
   71        *
   72        * @param name Name for the endpoint.
   73        */
   74       public void setName(String name);
   75   
   76       /**
   77        * Returns if the endpoint is currently active or not. Messages should not be sent to inactive
   78        * endpoints.
   79        *
   80        * @param synMessageContext MessageContext for the current message. This is required for
   81        *                          IndirectEndpoints where the actual endpoint is retrieved from the MessageContext. Other
   82        *                          Endpoint implementations may ignore this parameter.
   83        * @return true if the endpoint is in active state. false otherwise.
   84        */
   85       public boolean isActive(MessageContext synMessageContext);
   86   
   87       /**
   88        * Sets the endpoint as active or inactive. If an endpoint is detected as failed, it should be
   89        * set as inactive. But endpoints may be eventually set as active by the endpoint refresher to
   90        * avoid ignoring endpoints forever.
   91        *
   92        * @param active            true if active. false otherwise.
   93        * @param synMessageContext MessageContext for the current message. This is required for
   94        *                          IndirectEndpoints where the actual endpoint is retrieved from the MessageContext. Other
   95        *                          Endpoint implementations may ignore this parameter.
   96        */
   97       public void setActive(boolean active, MessageContext synMessageContext);
   98   }

Home » synapse-1.2-src » org.apache.synapse.endpoints » [javadoc | source]