001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.servicemix.wsn.jbi;
018    
019    import javax.jbi.component.ComponentContext;
020    
021    import org.apache.servicemix.wsn.ComponentContextAware;
022    import org.apache.servicemix.wsn.jms.JmsNotificationBroker;
023    import org.apache.servicemix.wsn.jms.JmsPublisher;
024    import org.apache.servicemix.wsn.jms.JmsSubscription;
025    
026    public class JbiNotificationBroker extends JmsNotificationBroker implements ComponentContextAware {
027    
028        private ComponentContext context;
029    
030        public JbiNotificationBroker(String name) {
031            super(name);
032        }
033    
034        @Override
035        protected JmsSubscription createJmsSubscription(String name) {
036            JbiSubscription subscription = new JbiSubscription(name);
037            // The context here should be overriden by the EndpointManager with the endpoint's context
038            subscription.setContext(context);
039            return subscription;
040        }
041    
042        @Override
043        protected JmsPublisher createJmsPublisher(String name) {
044            JbiPublisher publisher = new JbiPublisher(name);
045            // The context here should be overriden by the EndpointManager with the endpoint's context
046            publisher.setContext(context);
047            publisher.setNotificationBrokerAddress(address);
048            return publisher;
049        }
050    
051        public ComponentContext getContext() {
052            return context;
053        }
054    
055        public void setContext(ComponentContext context) {
056            this.context = context;
057        }
058    }