View Javadoc

1   /*
2    * $Id: HostIpIBean.java 19026 2010-08-16 07:30:47Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.module.ibeans;
11  
12  import org.mule.transformer.types.MimeTypes;
13  
14  import org.ibeans.annotation.Call;
15  import org.ibeans.annotation.Namespace;
16  import org.ibeans.annotation.Return;
17  import org.ibeans.annotation.State;
18  import org.ibeans.annotation.Template;
19  import org.ibeans.annotation.Usage;
20  import org.ibeans.annotation.filter.ExpressionErrorFilter;
21  import org.ibeans.annotation.param.ReturnType;
22  import org.ibeans.annotation.param.UriParam;
23  import org.ibeans.api.CallException;
24  import org.ibeans.api.channel.HTTP;
25  
26  @Usage("Simply pass in the ip address that you want to resolve and an XML document " +
27          "is returned with the geo locations. The format can be found here: " +
28          "http://api.hostip.info/?ip=12.215.42.19")
29  //using regex error filter because the core cannot depend on the XML module
30  @ExpressionErrorFilter(eval = "regex", expr = "Co-ordinates are unavailable", mimeType = MimeTypes.XML)
31  public interface HostIpIBean
32  {
33      @Namespace("gml")
34      public static final String GML_NS = "http://www.opengis.net/gml";
35  
36  //    @Call(uri = "http://api.hostip.info?ip={ip}", properties = HTTP.GET)
37  //    public String getHostInfo(@UriParam("ip") String ip) throws CallException;
38  
39      @Call(uri = "http://api.hostip.info?ip={ip}", properties = HTTP.GET)
40      @Return("#[xpath2://gml:coordinates]")
41      public String getHostInfoName(@UriParam("ip") String ip) throws CallException;
42  
43      @Call(uri = "http://api.hostip.info?ip={ip}", properties = HTTP.GET)
44      @Return("#[xpath2:[boolean]count(//ip) = 1]")
45      public Boolean hasIp(@UriParam("ip") String ip) throws CallException;
46  
47  
48      @ReturnType
49      public static final Class DEFAULT_RETURN_TYPE = String.class;
50  
51      @State
52      void init(@ReturnType Class returnType);
53  
54      @Call(uri = "http://api.hostip.info?ip={ip}")
55      public <T> T getHostInfo(@UriParam("ip") String ip) throws CallException;
56  
57      @Template("one two {number}")
58      public String dummyTemplateMethod(@UriParam("number") String number);
59  }