Skip to content

Instantly share code, notes, and snippets.

@tobyclemson
Last active June 22, 2017 11:55
Show Gist options
  • Save tobyclemson/6a5a1e9e9bf74e03ccb295d458d31868 to your computer and use it in GitHub Desktop.
Save tobyclemson/6a5a1e9e9bf74e03ccb295d458d31868 to your computer and use it in GitHub Desktop.
First lenses attempt
{:type {:annotations #{{:instance #object[com.sun.proxy.$Proxy1
0x5d7c3c23
"@javax.jws.WebService(name=Service, wsdlLocation=, portName=, endpointInterface=, serviceName=, targetNamespace=http://example.com)"],
:type javax.jws.WebService,
:elements #{{:name targetNamespace,
:value "http://example.com"}
{:name name, :value "Service"}
{:name serviceName, :value ""}
{:name endpointInterface, :value ""}
{:name portName, :value ""}
{:name wsdlLocation, :value ""}}}}},
:methods #{{:name someMethod,
:annotations #{{:instance #object[com.sun.proxy.$Proxy3
0x22482c
"@javax.jws.WebMethod(action=http://example.com/Some_Method, exclude=false, operationName=Some_Method)"],
:type javax.jws.WebMethod,
:elements #{{:name exclude, :value false}
{:name action,
:value "http://example.com/Some_Method"}
{:name operationName,
:value "Some_Method"}}}},
:parameters [#{{:instance #object[com.sun.proxy.$Proxy7
0x3e0c5b4a
"@javax.jws.WebParam(name=parameter1, mode=IN, header=false, targetNamespace=http://example.com, partName=)"],
:type javax.jws.WebParam,
:elements #{{:name header, :value false}
{:name mode,
:value #object[javax.jws.WebParam$Mode 0x600e2a8e "IN"]}
{:name partName, :value ""}
{:name name, :value "parameter1"}
{:name targetNamespace, :value "http://example.com"}}}}
#{{:instance #object[com.sun.proxy.$Proxy7
0x2bbf9d6a
"@javax.jws.WebParam(name=parameter2, mode=IN, header=false, targetNamespace=http://example.com, partName=)"],
:type javax.jws.WebParam,
:elements #{{:name header, :value false}
{:name mode,
:value #object[javax.jws.WebParam$Mode 0x600e2a8e "IN"]}
{:name partName, :value ""}
{:name targetNamespace, :value "http://example.com"}
{:name name, :value "parameter2"}}}}]}
{:name otherMethod,
:annotations #{{:instance #object[com.sun.proxy.$Proxy3
0x9d70948
"@javax.jws.WebMethod(action=http://example.com/Other_Method, exclude=false, operationName=Other_Method)"],
:type javax.jws.WebMethod,
:elements #{{:name exclude, :value false}
{:name operationName, :value "Other_Method"}
{:name action, :value "http://example.com/Other_Method"}}}},
:parameters [#{{:instance #object[com.sun.proxy.$Proxy7
0x5fef405e
"@javax.jws.WebParam(name=parameter1, mode=IN, header=false, targetNamespace=http://example.com, partName=)"],
:type javax.jws.WebParam,
:elements #{{:name header, :value false}
{:name mode,
:value #object[javax.jws.WebParam$Mode 0x600e2a8e "IN"]}
{:name partName, :value ""}
{:name name, :value "parameter1"}
{:name targetNamespace, :value "http://example.com"}}}}]}}}
(defn method-info
[type-annotations & {:keys [identifier-fn] :or {identifier-fn identity}}]
(-> type-annotations
(view-single (in [:methods]))
(update each #(select-keys % [:name :parameters]))
(update (*> each (in [:name])) identifier-fn)
(update (*> each (in [:parameters]))
(fn [annotations]
(-> annotations
(view (*> each
(only #(= (:type %) WebParam))
(in [:elements])
(only #(= (:name %) 'name))
(in [:value])))
(update each identifier-fn))))))
#{{:name :some-method,
:parameters [:parameter1 :parameter2]},
{:name :other-method,
:parameters [:parameter1]}}
@tobyclemson
Copy link
Author

The annotation info is generated by: https://github.com/tobyclemson/exegesis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment