01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.ftp;
18:
19: import java.net.URI;
20: import java.util.List;
21: import java.util.Map;
22:
23: import javax.jbi.servicedesc.ServiceEndpoint;
24:
25: import org.apache.servicemix.common.DefaultComponent;
26: import org.apache.servicemix.common.Endpoint;
27: import org.apache.servicemix.jbi.util.IntrospectionSupport;
28: import org.apache.servicemix.jbi.util.URISupport;
29:
30: /**
31: * An FTP based component
32: *
33: * @version $Revision: $
34: * @org.apache.xbean.XBean element="component" description="FTP Component"
35: */
36: public class FtpComponent extends DefaultComponent {
37:
38: private FtpEndpointType[] endpoints;
39:
40: public FtpEndpointType[] getEndpoints() {
41: return endpoints;
42: }
43:
44: public void setEndpoints(FtpEndpointType[] endpoints) {
45: this .endpoints = endpoints;
46: }
47:
48: protected List getConfiguredEndpoints() {
49: return asList(getEndpoints());
50: }
51:
52: protected Class[] getEndpointClasses() {
53: return new Class[] { FtpPollerEndpoint.class,
54: FtpSenderEndpoint.class };
55: }
56:
57: protected Endpoint getResolvedEPR(ServiceEndpoint ep)
58: throws Exception {
59: FtpSenderEndpoint ftpEndpoint = new FtpSenderEndpoint(this , ep);
60: URI uri = new URI(ep.getEndpointName());
61: Map map = URISupport.parseQuery(uri.getQuery());
62: IntrospectionSupport.setProperties(ftpEndpoint, map);
63: ftpEndpoint.setUri(uri);
64: ftpEndpoint.validate();
65: ftpEndpoint.activate();
66: return ftpEndpoint;
67: }
68:
69: }
|