What is the equivalent of class Class in gosu?

295 views
Skip to first unread message

extenditus

unread,
Feb 13, 2012, 8:22:59 PM2/13/12
to gosu-lang
Could someone please tell me what is the equivalent of class Class in
gosu?
http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html

The reason I am asking is that I am trying to read resource files from
the class path in PolicyCenter. Okay, I know this is not a
PolicyCenter forum but I have not been able to get a decent answer to
my question from the GW support group.

In Java I could do this

MyJavaClass.class.getClassLoader().getResourceAsStream(fileName)


I could also do

ClassLoader.getSystemResourceAsStream(fileName)


fileName is a resource in the class path. In JEE applications, it
would be in WEB-INF/classes or it could be in a jar file in WEB-INF/
lib.
What are the best practices here? How do I read resource files from a
class path and access it in Gosu?

I would really appreciate any pointers here.



Brian Chang

unread,
Feb 13, 2012, 8:39:17 PM2/13/12
to gosu...@googlegroups.com
As a Gosu guy, I'd tell you you can get a classpath resource with gw.config.CommonServices.getTypeSystem().getResource( resourceName ) which will get you the URL of your resource.

As a Guidewire Platform guy, I'd ask what's the GW support forum you asked?  Your need is covered by features in the Guidewire platform, not entirely specific to Gosu, and need not involve a class loader or the type system.






--
You received this message because you are subscribed to the Google Groups "gosu-lang" group.
To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.




--
Brian
bcha...@gmail.com

extenditus

unread,
Feb 13, 2012, 9:01:17 PM2/13/12
to gosu-lang
Hello Brian,
Thanks for your reply. The GW support forum I was referring too
were the GW consultants I have I my project. When I ask a question
that is not included in the Gosu reference/integration/configuration/
or application guide , they alway say it is a platform question and
they would get back to me. This take too long. Could you advise since
you are a GW platform guy ? :)

I will try your suggestion
("gw.config.CommonServices.getTypeSystem().getResource( resourceName )
"). My question would be, where in the PolicyCenter directory
structure would you place resourceName ?

All I want to do is read a property file from the class path. an
example would be

WEB-INF/classes/myprop.properties

Or read an excel or xml file from the class path. Where would the
resource file be placed?

Must it be under gsrc ? Or could it be under modules/configuration/
config ? How is modules/configuration/config/config.xml read when the
pc.war is exploded under tomcat? ( I don't really have access to a
servlet context from a gosu file under gsrc directory. Or do I? )

Okay, okay, I know I have really gone PolicyCenter specific... Your
response would be greatly appreciated.
> bchan...@gmail.com

Brian Chang

unread,
Feb 13, 2012, 9:59:40 PM2/13/12
to gosu...@googlegroups.com
I've given you a tip that you can try out with Gosu in general, but I'm sorry, this list is not a channel for for providing support for Guidewire products.

The target audience here is those who have an interest in Gosu as a general-purpose language, and as that audience hopefully grows, many will likely have no view into the world of Guidewire products, and won't care. On this list we're unlikely to know your employer, the GW product you're working with, and even your name.  This problem magnifies the already-high risk of divulging proprietary information.  For that reason, as much as I wish I could cut the red tape and help out, I won't be able to.


extenditus

unread,
Feb 13, 2012, 10:20:46 PM2/13/12
to gosu-lang
That okay Brian. I do understand. I would ask the GW Consultants on my
project if they have a forum like this! I appreciate your
responses....
> bchan...@gmail.com

osagie uwaifo

unread,
Feb 14, 2012, 12:26:29 PM2/14/12
to gosu-lang
Brian - Your suggestion worked out.  I just wanted to let you know. Thank for your help.
Thanks,
Osagie Uwaifo
http://www.extendit.us
Reply all
Reply to author
Forward
0 new messages