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.camel.component.atom;
018
019 import java.net.URI;
020 import java.util.Map;
021
022 import org.apache.camel.Endpoint;
023 import org.apache.camel.component.feed.FeedComponent;
024 import org.apache.camel.component.feed.FeedEndpoint;
025 import org.apache.camel.util.CastUtils;
026 import org.apache.camel.util.URISupport;
027
028 /**
029 * An <a href="http://camel.apache.org/atom.html">Atom Component</a>.
030 * <p/>
031 * Camel uses Apache Abdera as the Atom implementation.
032 *
033 * @version $Revision: 834779 $
034 */
035 public class AtomComponent extends FeedComponent {
036
037 @Override
038 protected FeedEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
039 return new AtomEndpoint(uri, this, null);
040 }
041
042 @Override
043 protected void afterConfiguration(String uri, String remaining, Endpoint endpoint, Map<String, Object> parameters) throws Exception {
044 AtomEndpoint atom = (AtomEndpoint) endpoint;
045 if (atom.getFeedUri() != null) {
046 // already set so do not change it
047 return;
048 }
049
050 // recreate feed uri after we have configured the endpoint so we can use the left over parameters
051 // for the http feed
052 String feedUri;
053 if (!parameters.isEmpty()) {
054 Map<Object, Object> params = CastUtils.cast(parameters);
055 URI remainingUri = URISupport.createRemainingURI(new URI(remaining), params);
056 feedUri = remainingUri.toString();
057 } else {
058 feedUri = remaining;
059 }
060
061 atom.setFeedUri(feedUri);
062 }
063
064 }