Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
PETALS - PETALS Services Platform. Copyright (c) 2007 EBM Websourcing, http://www.ebmwebsourcing.com/ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------------------- $Id$ -------------------------------------------------------------------------
 
 
 package org.ow2.petals.component.framework.api;
 
 import java.util.Map;
 
An abstract class for JBI message interceptor.

Author(s):
chamerling - EBM WebSourcing
Since:
1.0
 
 public abstract class Interceptor {

    
The JBI component of the interceptor (to enable access to all the component context)
 
     protected Component component;

    
The name of the interceptor (defined in the component descriptor). This name will be used in the service units as reference;
 
     protected String name;

    
The interceptor attributes (defined in the component descriptor). These parameters are the initial ones and are not mutable.
 
     protected Map<StringStringcomponentParameters;

    
Interceptor is always activated ie it is activated for all service units on all phases (send and accept)?
 
     protected boolean active = false;

    
The component logger
 
     protected Logger logger;

    
Creates a new instance of Interceptor
 
     public Interceptor() {
     }

    
Initialize the interceptor from its parameters. The parameters are created from the interceptor parameters defined in the JBI descriptor. The interceptor developer must implement this method if he want to initialize its interceptor from the defined parameters.

Parameters:
parameters could not be null. The parameters are loaded by the CDK. If no parameter has been found, the map is empty but not null.
 
     public final void init(Component componentString nameboolean active,
             Map<StringStringcomponentParametersLogger loggerthrows PEtALSCDKException {
         this. = component;
         this. = componentParameters;
         this. = logger;
         this. = name;
         this. = active;
 
         try {
            this.onInit();
        } catch (Exception e) {
            logger.log(."Problem during interceptor initialization");
            throw new PEtALSCDKException("Interceptor initialization failure");
        }
    }

    
Initialization callback. The developer can do extra interceptor configuration here (create configuration objects from parameters, register MBeans...)

Throws:
java.lang.Exception an exception can be raised by the interceptor developer. If an exception is raised, the interceptor will not be available in the component.
    protected void onInit() throws Exception {
    }

    
Method called before the consumer of service send a request.

Parameters:
exchange
sonsumes The Consumes configuration
additionalParameters the parameters defined in the SU for this interceptor. The user can use this map to retrieve the parameters defined in the Consume or Provide extensions.
    public abstract void handleMessageSent(Exchange exchangeConsumes consumes,
            Map<StringStringadditionalParameters);

    
Method called before the consumer of service receive its response.

Parameters:
exchange
consumes The Consumes configuration
additionalParameters the parameters defined in the SU for this interceptor. The user can use this map to retrieve the parameters defined in the Consume or Provide extensions.
    public abstract void handleMessageSentResponse(Exchange exchangeConsumes consumes,
            Map<StringStringadditionalParameters);

    
Method called before the provider of service receive its request.

Parameters:
exchange
provides The Provides configuration
additionalParameters the parameters defined in the SU for this interceptor. The user can use this map to retrieve the parameters defined in the Consume or Provide extensions.
    public abstract void handleMessageAccept(Exchange exchangeProvides provides,
            Map<StringStringadditionalParameters);

    
Method called before the provider of service send its response.

Parameters:
exchange
provides The Provides configuration
additionalParameters the parameters defined in the SU for this interceptor. The user can use this map to retrieve the parameters defined in the Consume or Provide extensions.
    public abstract void handleMessageAcceptResponse(Exchange exchangeProvides provides,
            Map<StringStringadditionalParameters);

    

Returns:
the name
    public final String getName() {
        return this.;
    }

    

Returns:
the active
    public boolean isActive() {
        return this.;
    }

    

Parameters:
active the active to set
    public void setActive(boolean active) {
        this. = active;
    }

    

Returns:
the parameters
    public Map<StringStringgetComponentParameters() {
        return this.;
    }
New to GrepCode? Check out our FAQ X