001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.servicemix.common;
019
020 import org.apache.commons.logging.Log;
021 import org.apache.servicemix.executors.Executor;
022
023 import javax.jbi.component.Component;
024 import javax.jbi.component.ComponentContext;
025 import javax.jbi.messaging.MessageExchange;
026 import javax.jbi.messaging.MessagingException;
027 import javax.xml.namespace.QName;
028
029 /**
030 * Represents an extended JBI Component implementation which exposes some extra features
031 *
032 * @version $Revision: 695836 $
033 */
034 public interface ServiceMixComponent extends Component {
035
036 /**
037 * @return Returns the logger.
038 */
039 public Log getLogger();
040
041 /**
042 * @return Returns the registry.
043 */
044 public Registry getRegistry();
045
046 /**
047 * @return Returns the executor for this component
048 */
049 public Executor getExecutor();
050
051 /**
052 * @return Returns the components context
053 */
054 public ComponentContext getComponentContext();
055
056 /**
057 * @return the JBI container
058 */
059 public Container getContainer();
060
061 /**
062 * @return the servicemix 3 container if deployed into it
063 */
064 public Object getSmx3Container();
065
066 /**
067 * @return Returns the name of the component
068 */
069 public String getComponentName();
070
071 /**
072 * Prepare an exchange sent from the given endpoint.
073 * The caller need to send / sendSync the exchange.
074 *
075 * @param exchange the exchange to send
076 * @param endpoint the endpoint sending the exchange
077 * @throws MessagingException
078 */
079 public void prepareExchange(MessageExchange exchange, Endpoint endpoint) throws MessagingException;
080
081 /**
082 * Prepare shutting the given endpoint down by waiting for all know exchanges for
083 * this endpoint to be fully processed.
084 *
085 * @param endpoint
086 * @throws InterruptedException
087 */
088 public void prepareShutdown(Endpoint endpoint) throws InterruptedException;
089
090 /**
091 * Make the component aware of this exchange.
092 * This method needs to be called for each exchange sent or received.
093 *
094 * @param endpoint
095 * @param exchange
096 * @param add
097 */
098 public void handleExchange(Endpoint endpoint, MessageExchange exchange, boolean add);
099
100 /**
101 * @return the QName of the element used in EPR
102 */
103 public QName getEPRElementName();
104 }