Try this:
<core:new var="inetSocketAddress" className="java.net.InetSocketAddress" >
<core:arg type="java.lang.String" value="${proxyServer}" />
<core:arg type="int" value="${proxyPort}" />
</core:new>
<core:invokeStatic var="proxyType" className="java.lang.Class" method="forName">
<core:arg type="java.lang.String" value="java.net.Proxy$Type"/>
</core:invokeStatic>
<core:set value="${proxyType.getField('HTTP')}" var="proxyTypeHTTP" />
<core:set value="${proxyTypeHTTP.HTTP}" var="proxyTypeHTTP" />
<core:new var="proxy" className="java.net.Proxy" >
<core:arg value="${proxyTypeHTTP}" />
<core:arg type="java.net.InetSocketAddress" value="${inetSocketAddress}" />
</core:new>
<core:invoke var="restConnection" on="${restUrl}" method="openConnection">
<core:arg type="java.net.Proxy" value="${proxy}" />
</core:invoke>
Original Message:
Sent: Aug 20, 2020 06:38 PM
From: robert walker
Subject: how to access Enum/Value in gel script thats defined in java.net.Proxy.Type.HTTP?
hi all, sorry if this is the not right place to ask a gel question
can someone tell me if they know how to access a java core lib like java.net.Proxy.Type in gel?
i want to do this in gel
InetSocketAddress addr = new InetSocketAddress("http://proxy.com", 80);Proxy httpProxy = new Proxy(Proxy.Type.HTTP, addr);URL url = new URL("http://restfulurl.com");HttpURLConnection con = url.openConnection( httpProxy );
so i tried this, but can't get access to the enum java.net.Proxy.Type or one of it's values java.net.Proxy.Type.HTTP
<j:new className="java.net.InetSocketAddress" var="addr"> <j:arg type="java.lang.String" value="http://proxy.com"/> <j:arg type="java.lang.Integer" value="80"/></j:new> <j:new className="java.net.Proxy" var="httpProxy"> <j:arg type="java.net.Proxy.Type" value="java.net.Proxy.Type.HTTP"/> <j:arg type="java.net.InetSocketAddress" value="${addr}"/></j:new>
it complains about ClassNotFoundException: java.net.Proxy.Type which is understandable. its almost like i need a gel tag thats like
core:invokeStatic but of course java.net.Proxy.Type.HTTP is not a static var but a java.lang.Enum
thanks all for any help you may be!
------------------------------
robert
------------------------------