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.ftp;
018
019 import java.net.URI;
020 import java.util.List;
021 import java.util.Map;
022
023 import javax.jbi.servicedesc.ServiceEndpoint;
024
025 import org.apache.servicemix.common.DefaultComponent;
026 import org.apache.servicemix.common.Endpoint;
027 import org.apache.servicemix.common.util.IntrospectionSupport;
028 import org.apache.servicemix.common.util.URISupport;
029
030 /**
031 * An FTP based component
032 *
033 * @version $Revision: $
034 * @org.apache.xbean.XBean element="component" description="FTP Component"
035 */
036 public class FtpComponent extends DefaultComponent {
037
038 private FtpEndpointType[] endpoints;
039
040 public FtpEndpointType[] getEndpoints() {
041 return endpoints;
042 }
043
044 public void setEndpoints(FtpEndpointType[] endpoints) {
045 this.endpoints = endpoints;
046 }
047
048 protected List getConfiguredEndpoints() {
049 return asList(getEndpoints());
050 }
051
052 protected Class[] getEndpointClasses() {
053 return new Class[] {FtpPollerEndpoint.class, FtpSenderEndpoint.class};
054 }
055
056 protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {
057 FtpSenderEndpoint ftpEndpoint = new FtpSenderEndpoint(this, ep);
058 URI uri = new URI(ep.getEndpointName());
059 Map map = URISupport.parseQuery(uri.getQuery());
060 IntrospectionSupport.setProperties(ftpEndpoint, map);
061 ftpEndpoint.setUri(uri);
062 ftpEndpoint.validate();
063 return ftpEndpoint;
064 }
065
066 }