Author: joed Date: Tue Feb 22 21:16:41 2011 New Revision: 1073508 URL: http://svn.apache.org/viewvc?rev=1073508&view=rev Log: CAMEL :: DNS, CamelCasing in accordance with checkstyle.
Added: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsComponent.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSComponent.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsConstants.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSDigEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsIpEndpoint.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSIPEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsLookupEndpoint.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSLookupEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsConverter.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSConverter.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsRecordConverter.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSRecordConverter.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointSpringTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointSpringTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointSpringTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointTest.java - copied, changed from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointTest.java Removed: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSComponent.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSDigEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSIPEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSLookupEndpoint.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSConverter.java camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSRecordConverter.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointSpringTest.java camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointTest.java Modified: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/WikipediaEndpoint.java camel/trunk/components/camel-dns/src/main/resources/META-INF/services/org/apache/camel/component/dns Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsComponent.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSComponent.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsComponent.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsComponent.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSComponent.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSComponent.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsComponent.java Tue Feb 22 21:16:41 2011 @@ -1,20 +1,18 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns; @@ -24,74 +22,68 @@ import org.apache.camel.Endpoint; import org.apache.camel.impl.DefaultComponent; /** - * - * The DNS components creates endpoints of the form: <br/> - * dns:///... <br/> - * At this point, the DNS component works with these operations:<br/> - * <p> - * dns:///ip <br/> - * - * This will return the IP address associated with the domain passed in - * the header dns.domain. - * </p> - * <p> - * dns:///lookup This endpoint accepts three parameters. - * <ul> - * <li>dns.name: the lookup name. Usually the domain. Mandatory.</li> - * <li>dns.type: the type of the lookup. Should match the values of - * {@see org.xbill.dns.Type}. Optional.</li> - * <li>dns.class: the DNS class of the lookup. Should match the values - * of {@see org.xbill.dns.DClass}. Optional.</li> - * </ul> - * </p> - * - * <p> - * dns:///dig This endpoint takes a few parameters, most of them - * optional : - * <ul> - * <li>dns.server: the server in particular for the query. If none is - * given, the default one specified by the OS will be used.</li> - * <li>dns.query: the query itself. Mandatory.</li> - * <li>dns.type: the type of the lookup. Should match the values of - * {@see org.xbill.dns.Type}. Optional.</li> - * <li>dns.class: the DNS class of the lookup. Should match the values - * of {@see org.xbill.dns.DClass}. Optional.</li> - * </ul> - * - * </p> - * - * <p> - * dns:///wikipedia This endpoint takes one paramter : - * <ul> - * <li>term: the search term on wikipedia</li> - * </ul> - * - * </p> - * + * The DNS components creates endpoints of the form: <br/> + * dns:///... <br/> + * At this point, the DNS component works with these operations:<br/> + * <p> + * dns:///ip <br/> + * <p/> + * This will return the IP address associated with the domain passed in + * the header dns.domain. + * </p> + * <p> + * dns:///lookup This endpoint accepts three parameters. + * <ul> + * <li>dns.name: the lookup name. Usually the domain. Mandatory.</li> + * <li>dns.type: the type of the lookup. Should match the values of + * {@see org.xbill.dns.Type}. Optional.</li> + * <li>dns.class: the DNS class of the lookup. Should match the values + * of {@see org.xbill.dns.DClass}. Optional.</li> + * </ul> + * </p> + * <p/> + * <p> + * dns:///dig This endpoint takes a few parameters, most of them + * optional : + * <ul> + * <li>dns.server: the server in particular for the query. If none is + * given, the default one specified by the OS will be used.</li> + * <li>dns.query: the query itself. Mandatory.</li> + * <li>dns.type: the type of the lookup. Should match the values of + * {@see org.xbill.dns.Type}. Optional.</li> + * <li>dns.class: the DNS class of the lookup. Should match the values + * of {@see org.xbill.dns.DClass}. Optional.</li> + * </ul> + * <p/> + * </p> + * <p/> + * <p> + * dns:///wikipedia This endpoint takes one paramter : + * <ul> + * <li>term: the search term on wikipedia</li> + * </ul> + * <p/> + * </p> */ -public class DNSComponent extends DefaultComponent { +public class DnsComponent extends DefaultComponent { - private static final String OPERATION_IP = "ip"; - - private static final String OPERATION_LOOKUP = "lookup"; - - private static final String OPERATION_DIG = "dig"; - - private static final String OPERATION_WIKIPEDIA = "wikipedia"; - - protected Endpoint createEndpoint(String uri, String remaining, - Map<String, Object> parameters) throws Exception { - if (OPERATION_IP.equals(remaining)) { - return new DNSIPEndpoint(getCamelContext()); - } else if (OPERATION_LOOKUP.equals(remaining)) { - return new DNSLookupEndpoint(getCamelContext()); - } else if (OPERATION_DIG.equals(remaining)) { - return new DNSDigEndpoint(getCamelContext()); - } else if (OPERATION_WIKIPEDIA.equals(remaining)) { - return new WikipediaEndpoint(getCamelContext()); - }else { - throw new IllegalArgumentException(uri - + "is unsupported by the DNS component"); + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { + if (DnsConstants.OPERATION_IP.equals(remaining)) { + return new DnsIpEndpoint(this); + } else { + if (DnsConstants.OPERATION_LOOKUP.equals(remaining)) { + return new DnsLookupEndpoint(this); + } else { + if (DnsConstants.OPERATION_DIG.equals(remaining)) { + return new DnsDigEndpoint(this); + } else { + if (DnsConstants.OPERATION_WIKIPEDIA.equals(remaining)) { + return new WikipediaEndpoint(this); + } else { + throw new IllegalArgumentException(uri + "is unsupported by the DNS component"); + } + } + } } } Added: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsConstants.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsConstants.java?rev=1073508&view=auto ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsConstants.java (added) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsConstants.java Tue Feb 22 21:16:41 2011 @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.camel.component.dns; + +public class DnsConstants { + + public static final String OPERATION_DIG = "dig"; + + public static final String OPERATION_IP = "ip"; + public static final String OPERATION_LOOKUP = "lookup"; + + public static final String OPERATION_WIKIPEDIA = "wikipedia"; + + public static final String DNS_CLASS = "dns.class"; + + public static final String DNS_NAME = "dns.name"; + + public static final String DNS_SERVER = "dns.server"; + public static final String DNS_TYPE = "dns.type"; + public static final String TERM = "term"; + + protected DnsConstants() { + //Utility class + } +} Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSDigEndpoint.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSDigEndpoint.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSDigEndpoint.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsDigEndpoint.java Tue Feb 22 21:16:41 2011 @@ -1,24 +1,21 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns; -import org.apache.camel.CamelContext; import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -33,20 +30,16 @@ import org.xbill.DNS.SimpleResolver; import org.xbill.DNS.Type; /** - * An endpoint for dig-like operations over DNS adresses. - * - * Inspired from Dig.java coming with the distribution of dnsjava, - * though most if not all options are unsupported. + * An endpoint for dig-like operations over DNS adresses. + * <p/> + * Inspired from Dig.java coming with the distribution of dnsjava, + * though most if not all options are unsupported. */ -public class DNSDigEndpoint extends DefaultEndpoint { +public class DnsDigEndpoint extends DefaultEndpoint { - private static final String DNS_SERVER = "dns.server"; - private static final String DNS_TYPE = "dns.type"; - private static final String DNS_CLASS = "dns.class"; - private static final String DNS_NAME = "dns.name"; + public DnsDigEndpoint(DnsComponent component) { + super("dns://dig", component); - public DNSDigEndpoint(CamelContext ctxt) { - super("dns://dig", ctxt); } public Consumer createConsumer(Processor arg0) throws Exception { @@ -58,26 +51,22 @@ public class DNSDigEndpoint extends Defa public void process(Exchange exchange) throws Exception { String server = null; - if (exchange.getIn().getHeader(DNS_SERVER) != null) { + if (exchange.getIn().getHeader(DnsConstants.DNS_SERVER) != null) { server = String.valueOf(exchange.getIn(). - getHeader(DNS_SERVER)); + getHeader(DnsConstants.DNS_SERVER)); } SimpleResolver resolver = new SimpleResolver(server); - int type = Type.value(String.valueOf(exchange.getIn() - .getHeader(DNS_TYPE))); + int type = Type.value(String.valueOf(exchange.getIn().getHeader(DnsConstants.DNS_TYPE))); if (type == -1) { // default: if unparsable value given, use A. type = Type.A; } - int dclass = DClass.value(String.valueOf(exchange.getIn() - .getHeader(DNS_CLASS))); + int dclass = DClass.value(String.valueOf(exchange.getIn().getHeader(DnsConstants.DNS_CLASS))); if (dclass == -1) { // by default, value is IN. dclass = DClass.IN; } - Name name = Name.fromString( - String.valueOf(exchange.getIn().getHeader(DNS_NAME)), - Name.root); + Name name = Name.fromString(String.valueOf(exchange.getIn().getHeader(DnsConstants.DNS_NAME)), Name.root); Record rec = Record.newRecord(name, type, dclass); Message query = Message.newQuery(rec); Message response = resolver.send(query); Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsIpEndpoint.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSIPEndpoint.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsIpEndpoint.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsIpEndpoint.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSIPEndpoint.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSIPEndpoint.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsIpEndpoint.java Tue Feb 22 21:16:41 2011 @@ -1,26 +1,24 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns; import java.net.InetAddress; -import org.apache.camel.CamelContext; +import org.apache.camel.Component; import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -30,18 +28,12 @@ import org.apache.camel.impl.DefaultProd import org.xbill.DNS.Address; /** - * - * An endpoint to conduct IP address lookup from the host name. - * + * An endpoint to conduct IP address lookup from the host name. */ -public class DNSIPEndpoint extends DefaultEndpoint { +public class DnsIpEndpoint extends DefaultEndpoint { - public DNSIPEndpoint(CamelContext context) { - super("dns://ip", context); - } - - public Consumer createConsumer(Processor arg0) throws Exception { - throw new UnsupportedOperationException(); + public DnsIpEndpoint(Component component) { + super("dns://ip", component); } public Producer createProducer() throws Exception { @@ -49,10 +41,8 @@ public class DNSIPEndpoint extends Defau public void process(Exchange exchange) throws Exception { Object domain = exchange.getIn().getHeader("dns.domain"); - if (!(domain instanceof String) - || ((String) domain).length() == 0) { - throw new IllegalArgumentException( - "Invalid or null domain :" + domain); + if (!(domain instanceof String) || ((String) domain).length() == 0) { + throw new IllegalArgumentException("Invalid or null domain :" + domain); } InetAddress address = Address.getByName((String) domain); exchange.getOut().setBody(address); @@ -64,4 +54,8 @@ public class DNSIPEndpoint extends Defau return false; } + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("Creating a consumer is not supported"); + } + } Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsLookupEndpoint.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSLookupEndpoint.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsLookupEndpoint.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsLookupEndpoint.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSLookupEndpoint.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DNSLookupEndpoint.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/DnsLookupEndpoint.java Tue Feb 22 21:16:41 2011 @@ -1,24 +1,22 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns; -import org.apache.camel.CamelContext; +import org.apache.camel.Component; import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -30,18 +28,12 @@ import org.xbill.DNS.Lookup; import org.xbill.DNS.Type; /** - * - * An endpoint to manage lookup operations, using the API from dnsjava. - * + * An endpoint to manage lookup operations, using the API from dnsjava. */ -public class DNSLookupEndpoint extends DefaultEndpoint { +public class DnsLookupEndpoint extends DefaultEndpoint { - private static final String DNS_NAME = "dns.name"; - private static final String DNS_TYPE = "dns.type"; - private static final String DNS_CLASS = "dns.class"; - - public DNSLookupEndpoint(CamelContext context) { - super("dns://lookup", context); + public DnsLookupEndpoint(Component component) { + super("dns://lookup", component); } public Consumer createConsumer(Processor processor) throws Exception { @@ -52,29 +44,31 @@ public class DNSLookupEndpoint extends D return new DefaultProducer(this) { public void process(Exchange exchange) throws Exception { - Object name = exchange.getIn().getHeader(DNS_NAME); + Object name = exchange.getIn().getHeader(DnsConstants.DNS_NAME); if (name == null || "".equals(name)) { throw new IllegalArgumentException("name is null or empty"); } - String dns_name = String.valueOf(name); - Object type = exchange.getIn().getHeader(DNS_TYPE); - Integer dns_type = null; + String dnsName = String.valueOf(name); + Object type = exchange.getIn().getHeader(DnsConstants.DNS_TYPE); + Integer dnsType = null; if (type != null) { - dns_type = Type.value(String.valueOf(type)); + dnsType = Type.value(String.valueOf(type)); } - Object dclass = exchange.getIn().getHeader(DNS_CLASS); - Integer dns_class = null; + Object dclass = exchange.getIn().getHeader(DnsConstants.DNS_CLASS); + Integer dnsClass = null; if (dclass != null) { - dns_class = DClass.value(String.valueOf(dclass)); + dnsClass = DClass.value(String.valueOf(dclass)); } Lookup lookup = null; - if (dns_type != null && dns_class != null) { - lookup = new Lookup(dns_name, dns_type, dns_class); - } else if (dns_type != null) { - lookup = new Lookup(dns_name, dns_type); + if (dnsType != null && dnsClass != null) { + lookup = new Lookup(dnsName, dnsType, dnsClass); } else { - lookup = new Lookup(dns_name); + if (dnsType != null) { + lookup = new Lookup(dnsName, dnsType); + } else { + lookup = new Lookup(dnsName); + } } lookup.run(); Modified: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/WikipediaEndpoint.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/WikipediaEndpoint.java?rev=1073508&r1=1073507&r2=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/WikipediaEndpoint.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/WikipediaEndpoint.java Tue Feb 22 21:16:41 2011 @@ -1,24 +1,22 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns; -import org.apache.camel.CamelContext; +import org.apache.camel.Component; import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -34,23 +32,19 @@ import org.xbill.DNS.SimpleResolver; import org.xbill.DNS.Type; /** - * * an endpoint to make queries against wikipedia using * the short TXT query. - * + * <p/> * See here for a reference: * http://www.commandlinefu.com/commands/view/2829/query-wikipedia-via-console-over-dns - * + * <p/> * This endpoint accepts the following header: * term: a simple term to use to query wikipedia. - * */ public class WikipediaEndpoint extends DefaultEndpoint { - - private static final String TERM = "term"; - - public WikipediaEndpoint(CamelContext context) { - super("dns:///wikipedia", context); + + public WikipediaEndpoint(Component component) { + super("dns:///wikipedia", component); } public Consumer createConsumer(Processor processor) throws Exception { @@ -63,10 +57,7 @@ public class WikipediaEndpoint extends D public void process(Exchange exchange) throws Exception { SimpleResolver resolver = new SimpleResolver(); int type = Type.TXT; - Name name = Name.fromString( - String.valueOf( - exchange.getIn().getHeader(TERM)) + ".wp.dg.cx", - Name.root); + Name name = Name.fromString(String.valueOf(exchange.getIn().getHeader(DnsConstants.TERM)) + ".wp.dg.cx", Name.root); Record rec = Record.newRecord(name, type, DClass.IN); Message query = Message.newQuery(rec); Message response = resolver.send(query); Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsConverter.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSConverter.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsConverter.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsConverter.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSConverter.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSConverter.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsConverter.java Tue Feb 22 21:16:41 2011 @@ -1,20 +1,18 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns.types; @@ -25,23 +23,14 @@ import java.util.List; import org.apache.camel.Converter; import org.xbill.DNS.Address; -import org.xbill.DNS.DClass; -import org.xbill.DNS.ExtendedResolver; import org.xbill.DNS.Message; -import org.xbill.DNS.Name; import org.xbill.DNS.Record; -import org.xbill.DNS.Resolver; -import org.xbill.DNS.ReverseMap; -import org.xbill.DNS.Section; -import org.xbill.DNS.Type; /** - * * A converter for all the DNS objects used by the DNS component. - * */ @Converter -public class DNSConverter { +public class DnsConverter { /** * @param record @@ -51,7 +40,7 @@ public class DNSConverter { public String convert(Record record) { return record.toString(); } - + /** * @param records * @return the String representation of a record. @@ -64,7 +53,7 @@ public class DNSConverter { } return list; } - + /** * @param message * @return the String representation of a message. @@ -73,9 +62,8 @@ public class DNSConverter { public String convert(Message message) { return message.toString(); } - + /** - * * @param address a DNS address * @return its String representation. */ @@ -83,9 +71,8 @@ public class DNSConverter { public String convert(Address address) { return address.toString(); } - + /** - * * @param address * @return the host name of the address. */ @@ -93,7 +80,7 @@ public class DNSConverter { public String convert(InetAddress address) { return address.getHostAddress(); } - + /** * @param domain * @return the InetAddress object for a given domain. Copied: camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsRecordConverter.java (from r1073498, camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSRecordConverter.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsRecordConverter.java?p2=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsRecordConverter.java&p1=camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSRecordConverter.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DNSRecordConverter.java (original) +++ camel/trunk/components/camel-dns/src/main/java/org/apache/camel/component/dns/types/DnsRecordConverter.java Tue Feb 22 21:16:41 2011 @@ -1,27 +1,23 @@ /** - * - */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.camel.component.dns.types; import java.io.IOException; + import org.xbill.DNS.DClass; import org.xbill.DNS.ExtendedResolver; import org.xbill.DNS.Message; @@ -33,11 +29,9 @@ import org.xbill.DNS.Section; import org.xbill.DNS.Type; /** - * * More converters for all the DNS objects used by the DNS component. - * */ -public class DNSRecordConverter { +public class DnsRecordConverter { /** * @param ip, like "192.168.1.1" @@ -55,10 +49,11 @@ public class DNSRecordConverter { Message response = res.send(query); Record[] answers = response.getSectionArray(Section.ANSWER); - if (answers.length == 0) - return null; - else - return answers[0]; + if (answers.length == 0) { + return null; + } else { + return answers[0]; + } } - + } Modified: camel/trunk/components/camel-dns/src/main/resources/META-INF/services/org/apache/camel/component/dns URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/main/resources/META-INF/services/org/apache/camel/component/dns?rev=1073508&r1=1073507&r2=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/main/resources/META-INF/services/org/apache/camel/component/dns (original) +++ camel/trunk/components/camel-dns/src/main/resources/META-INF/services/org/apache/camel/component/dns Tue Feb 22 21:16:41 2011 @@ -16,4 +16,4 @@ # specific language governing permissions and limitations # under the License. # -class=org.apache.camel.component.dns.DNSComponent \ No newline at end of file +class=org.apache.camel.component.dns.DnsComponent \ No newline at end of file Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointSpringTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointSpringTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointSpringTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointSpringTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointSpringTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointSpringTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointSpringTest.java Tue Feb 22 21:16:41 2011 @@ -36,7 +36,7 @@ import org.xbill.DNS.Section; /** * Tests for the dig endpoint. */ -public class DNSDigEndpointSpringTest extends CamelSpringTestSupport { +public class DnsDigEndpointSpringTest extends CamelSpringTestSupport { private static final String RESPONSE_MONKEY = "\"A monkey is a nonhuman " + "primate mammal with the exception usually of the lemurs and tarsiers. More specifically, the term monkey refers to a subset " Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSDigEndpointTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsDigEndpointTest.java Tue Feb 22 21:16:41 2011 @@ -35,7 +35,7 @@ import org.xbill.DNS.Section; /** * Tests for the dig endpoint. */ -public class DNSDigEndpointTest extends CamelTestSupport { +public class DnsDigEndpointTest extends CamelTestSupport { private static final String RESPONSE_MONKEY = "\"A monkey is a nonhuman " + "primate mammal with the exception usually of the lemurs and " + "tarsiers. More specifically, the term monkey refers to a subset " + "of monkeys: any of the smaller longer-tailed catarrhine or " Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointSpringTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointSpringTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointSpringTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointSpringTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointSpringTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointSpringTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointSpringTest.java Tue Feb 22 21:16:41 2011 @@ -28,7 +28,7 @@ import org.springframework.context.suppo /** * A series of tests to check the IP lookup operation. */ -public class DNSIPEndpointSpringTest extends CamelSpringTestSupport { +public class DnsIpEndpointSpringTest extends CamelSpringTestSupport { @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSIPEndpointTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsIpEndpointTest.java Tue Feb 22 21:16:41 2011 @@ -27,7 +27,7 @@ import org.junit.Test; /** * A series of tests to check the IP lookup operation. */ -public class DNSIPEndpointTest extends CamelTestSupport { +public class DnsIpEndpointTest extends CamelTestSupport { @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointSpringTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointSpringTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointSpringTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointSpringTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointSpringTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointSpringTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointSpringTest.java Tue Feb 22 21:16:41 2011 @@ -34,7 +34,7 @@ import org.xbill.DNS.Record; /** * A set of test cases to make DNS lookups. */ -public class DNSLookupEndpointSpringTest extends CamelSpringTestSupport { +public class DnsLookupEndpointSpringTest extends CamelSpringTestSupport { @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; Copied: camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointTest.java (from r1073498, camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointTest.java) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointTest.java?p2=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointTest.java&p1=camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointTest.java&r1=1073498&r2=1073508&rev=1073508&view=diff ============================================================================== --- camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DNSLookupEndpointTest.java (original) +++ camel/trunk/components/camel-dns/src/test/java/org/apache/camel/component/dns/DnsLookupEndpointTest.java Tue Feb 22 21:16:41 2011 @@ -33,7 +33,7 @@ import org.xbill.DNS.Record; /** * A set of test cases to make DNS lookups. */ -public class DNSLookupEndpointTest extends CamelTestSupport { +public class DnsLookupEndpointTest extends CamelTestSupport { @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint;