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