Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C9965200C7E for ; Tue, 23 May 2017 15:30:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C684E160BC3; Tue, 23 May 2017 13:30:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BEB6F160BB6 for ; Tue, 23 May 2017 15:30:45 +0200 (CEST) Received: (qmail 75854 invoked by uid 500); 23 May 2017 13:30:44 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 75844 invoked by uid 99); 23 May 2017 13:30:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2017 13:30:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6576BC039D for ; Tue, 23 May 2017 13:30:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.205 X-Spam-Level: X-Spam-Status: No, score=0.205 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.796, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id UzR2KDawFnAe for ; Tue, 23 May 2017 13:30:41 +0000 (UTC) Received: from homiemail-a81.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id DE78D5F613 for ; Tue, 23 May 2017 13:30:40 +0000 (UTC) Received: from homiemail-a81.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a81.g.dreamhost.com (Postfix) with ESMTP id 003143D13 for ; Tue, 23 May 2017 06:30:39 -0700 (PDT) Received: from [10.251.154.4] (guest-pool2-19-018.guest.nat.upenn.edu [128.91.19.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: keith@suderman.com) by homiemail-a81.g.dreamhost.com (Postfix) with ESMTPSA id 409913D09 for ; Tue, 23 May 2017 06:30:39 -0700 (PDT) From: Keith Suderman Content-Type: multipart/alternative; boundary="Apple-Mail=_C70F583C-0BEE-4454-B052-6D4DF4E611F8" Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: Simple question.. how to call a java class method in Groovy Script Date: Tue, 23 May 2017 09:30:39 -0400 References: <592327E8.3090305@gmx.org> <86A4CFEB-065C-448D-8182-B7DFE164794D@anc.org> To: users@groovy.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3259) archived-at: Tue, 23 May 2017 13:30:47 -0000 --Apple-Mail=_C70F583C-0BEE-4454-B052-6D4DF4E611F8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I recommend JetBrains IntelliJ to everyone. If you are a student you = can get the Ultimate edition for free, the free "community" version is = typically sufficient for most use cases, and purchasing an Ultimate = Edition license will pay for itself in a few weeks in a corporate = environment. Cheers, Keith > On May 22, 2017, at 4:31 PM, RJ wrote: >=20 > I'm working on the server directly.. any suggestions on IDE for groovy = script ? Thanks >=20 >=20 > On Mon, May 22, 2017 at 3:43 PM, Keith Suderman > wrote: >=20 >> On May 22, 2017, at 2:13 PM, RJ > wrote: >>=20 >> Thanks for the response, Jochen. Tried your suggestion, it doesn't = like it: >>=20 >> 2017-05-22 14:06:15,871 ERROR - > Possible solutions: getAt(java.lang.String), wait(), find(), grep(), = wait(long), grep(java.lang.Object)> >> org.codehaus.groovy.runtime.InvokerInvocationException: = groovy.lang.MissingMethodException: No signature of method: static = com.example.auth.principal.getId() is applicable for argument types: () = values: [] >> Possible solutions: getAt(java.lang.String), wait(), find(), grep(), = wait(long), grep(java.lang.Object) >=20 > Is the class name Principal or principal? Also, what IDE are you = using? Any decent IDE should be able to show you the available method = signatures and do auto-completion for you. >=20 >>=20 >> We try something like this in Java.. Whats the equivalent in Groovy = Script ? >=20 > Whenever in doubt just use the Java syntax. Apart from some Java 8 = stuff (coming soon), Groovy is perfectly happy with Java syntax. Once = the code is working then you can worry about making it more "Groovy" >=20 > Cheers, > Keith >=20 >>=20 >> import com.example.auth.principal; >> public String1 abcd(final principal Principal){ >> return Principal.getId(); >> } >>=20 >> On Mon, May 22, 2017 at 2:03 PM, Jochen Theodorou > wrote: >> On 22.05.2017 19 :40, RJ wrote: >> Here is my script. Highlighted the method call.. tried some google >> searches for the syntax. Thanks for the help! >>=20 >> import java.util.* >> import com.example.auth.user; >>=20 >> class EBSAttrRelease { >> def Map> run(final UserObject... = args) { >> def userid=3Dcom.example.auth.user.getId() >> return [MYLOGINID:userid] >> } >> } >>=20 >> try "import com.example.auth.user as User" instead of "import = com.example.auth.user" and then "def userid=3DUser.getId()"... assuming = of course that getId is a static method in the class = com.example.auth.user >>=20 >> bye Jochen >>=20 >=20 > ---------------------- > Keith Suderman > Research Associate > Department of Computer Science > Vassar College, Poughkeepsie NY > suderman@cs.vassar.edu >=20 >=20 >=20 >=20 >=20 ---------------------- Keith Suderman Research Associate Department of Computer Science Vassar College, Poughkeepsie NY suderman@cs.vassar.edu --Apple-Mail=_C70F583C-0BEE-4454-B052-6D4DF4E611F8 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii I recommend JetBrains IntelliJ to everyone.  If you are = a student you can get the Ultimate edition for free, the free = "community" version is typically sufficient for most use cases, and = purchasing an Ultimate Edition license will pay for itself in a few = weeks in a corporate environment.

Cheers,
Keith

On May 22, 2017, at 4:31 PM, RJ <ssoguroo@gmail.com> = wrote:

I'm working on the server directly.. any = suggestions on IDE for groovy script ? Thanks


On Mon, May 22, 2017 at 3:43 PM, Keith Suderman = <suderman@anc.org> wrote:

On May 22, 2017, at 2:13 PM, RJ <ssoguroo@gmail.com> wrote:

Thanks for the = response, Jochen.  Tried your suggestion, it doesn't like it:

2017-05-22 14:06:15,871 ERROR - = <groovy.lang.MissingMethodException: No signature of = method: static com.example.auth.principal.getId() is = applicable for argument types: () values: []
Possible = solutions: getAt(java.lang.String), wait(), find(), grep(), wait(long), = grep(java.lang.Object)>
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static = com.example.auth.principal.getId() is applicable for = argument types: () values: []
Possible solutions: = getAt(java.lang.String), wait(), find(), grep(), wait(long), = grep(java.lang.Object)

Is the class name Principal or = principal? Also, what IDE are you using?  Any decent IDE should be = able to show you the available method signatures and do auto-completion = for you.


We try something like this in Java.. Whats the = equivalent in Groovy Script ?

Whenever in doubt just use the Java = syntax.  Apart from some Java 8 stuff (coming soon), Groovy is = perfectly happy with Java syntax.  Once the code is working then = you can worry about making it more "Groovy"

Cheers,
Keith


import = com.example.auth.principal;
public String1 abcd(final = principal Principal){
return Principal.getId();
}

On Mon, May 22, 2017 at 2:03 PM, = Jochen Theodorou <blackdrag@gmx.org> wrote:
On 22.05.2017 19:40, RJ wrote:
Here is my script. Highlighted the method call.. tried some google
searches for the syntax. Thanks for the help!

import java.util.*
import com.example.auth.user;

class EBSAttrRelease {
     def Map<UserString, List<UserObject>> = run(final UserObject... args) {
     def userid=3Dcom.example.auth.user.getId()
     return [MYLOGINID:userid]
     }
}

try "import com.example.auth.user as User" instead of "import = com.example.auth.user" and then "def userid=3DUser.getId()"... assuming = of course that getId is a static method in the class = com.example.auth.user

bye Jochen


----------------------
Keith Suderman
Research Associate
Department of Computer = Science
Vassar College, Poughkeepsie NY






----------------------
Keith = Suderman
Research Associate
Department of Computer = Science
Vassar = College, Poughkeepsie NY




= --Apple-Mail=_C70F583C-0BEE-4454-B052-6D4DF4E611F8--