GWT client global configuration values - java

I need to store a few configuration parameters on the client side of my GWT app--I'm only using the client side of the framework. I just want to store things like an API access URL base.
Ideally, it would be nice if this were dynamically read, but I can live with having the values statically baked in on every compilation.
When scouring the web for answers, I kept running into all the deferred binding and locale management stuff. I don't care about any of that. I just want to set some property like api.url and read it from the Java code. Failing that, I'd like to set it in an external JavaScript file and read it in from the main generated JS code somehow. However, keeping it simple is an important goal; I don't want to go down the path of some Rube Goldberg-esque JSNI monstrosity.
Is there any means of accomplishing that with some sort of properties files, or a simple JSNI import mechanism? Or am I pretty much stuck with using a Constants-based configuration class (which still requires a recompile to bake in)?

This is what you're looking for: http://www.gwtproject.org/articles/dynamic_host_page.html

In order to escape from the compilations each time when configuration changed i would like to suggest the RPC call of configuration parameters in onmodule load.
In onsuccess you can assign those parameters to your Gwt static variables,those available throughout the Gwt code.
This may reduce the pain,you can change the parameters on serverside and deploy again,No Need To Compile each time for a single line change.

You can define a property on the module xml. Like this:
<define-property values="desenv, production" name="environment"/>
<set-property name="environment" value="production"/>

Related

What's the recommended way in Java to make a piece of code available only when needed?

The question regards an endpoint that I want to make available only for demoing and should not be part of the project in production. Therefore I need to find a way of making the piece of code that reveals this endpoint available only when it should be.
I thought of using a different .properties file when it is needed, but this requires creating another one and changing the configuration and if there is a more simple way I would like to know.
Maybe building with a different Maven profile? Can I use the Maven profile name inside the code?

Define Jodd Madvoc mappings from external file

I am using Jodd Madvoc web framework and define actions (classes and methods) using annotations. Everything works fine, but now I need to have these action definitions in an external file, so Madvoc don't need to scan my class path for the action classes (and for some other reasons).
I could probably code this by myself, since Madvoc is quite open for extension, but just wonder if there is already a way to do this?
Thank you!
What you are asking for is the so-called routing file. And the answer is: yes, Madvoc has support for routing files, since v3.6 (that was one of the new features, so thats maybe why you didn't know about it:). Anyway, all you have to do is to have a route file and use different configurator: RouteMadvocConfigurator instead of default one. This configurator reads routing file from the class path and defines the actions from it. You should be able to specify all action flags using routing file, including async flag, interceptors and so on. Nice thing about the routing file is that it's syntax is not so strict, so you can make your own format easily.
Here is an example of routing file:
`/hello.html` "jodd.madvoc.action.HelloAction#view"
GET /helloWorld.html jodd.madvoc.action.HelloAction#world
/zigzag/${id} jodd.madvoc.action.ArgsAction#zigzag /zigzag
As said, the format is loose, so you can e.g. define http method name everywhere you like in the line and so on.
You can see more details in official documentation.

GWT/SmartGWT adding new language at Runtime

I am using SmartGWT 3.0 and GWT 2.5. I know most of everything is pretty much compiled into corresponding javascripts by GWT. And this applies to i18n property files as well.
However i was looking for a way in which i can dynamically add a new language support by simply adding a new property file in the appropriate package.
I have tried that but it doesn't seem to work. Looking for any work around for this.
Thanks,
Vicky
I also need something like this, because i dont want to recompile my application for message changes all the time, also i dont want to increase compile permutation.
I am thinking following solution will be close enought to replace Message interface
Implement a servlet which will return Map of values from server according to locale langauge
Implement the message interface which will return values by calling the servlet with the locale language, and return values from the internal map.
Use ETag caching for the servlet response in order to cache the message texts on the client side.
I am not sure if this will solve the issue but it seems easy and good solution to me.
I am looking for any comments for the given solution or possible solutions for how not to increase compile permutations and need for compile each time a resource changes.

Centralized Application properties for multiple system

I am looking for a open-source solutions which allow hosting different properties for different applications and allow changes. On any change of properties it should notify or push the change to the application appropriately.
So, instead every application managing the properties in physical file and deploying physically; these properties can be pushed to a single system. User will have GUI to load and change the properties as per right. Should allow push as mentioned.
If you have already similar open source solutions in mind please advice.
Is this something that Puppet can manage for you?
I don't think what you've described (as nice as it would be) will be likely to exist in an app server. If a program is looking for a file, it's either going to load it with a FileReader (or similar), or it will use ClassLoader.getResourceAsStream(). It might be looking for data that is returned in properties, format, XML properties format, or even something completely different like RDF with which to configure itself. Also many programs read their config on start-up and then hold the values in memory, so you would still need to reboot them to get them to change.
To get something like this to work there would need to be a standard for configuration provisioning and live updates. Once that existed the webapp authors and server vendors would each need to add support for the standard.
If you are the one writing the programs to be managed however, then you can write your programs to request configuration from a service, and have a configuration push feature.... there may be packages out there that can speed up adding that to your code, but I get the impression you are looking to manage programs written by others.
Have you considered to use JMX? I think he could be a good starting point to implement your requirements.
MBeans's attributes can store your application's properties, the MBeanServer will allow you to make them available from remotting, JConsole offers you an GUI to update properties values.
You also can write within the MBean some code that notify the corrrespondig application when a user change any properties using the GUI.

How can I pass a system properties file to GWT?

Is there a system property or a program argument that I can use to pass the name of a properties file to GWT, to tell GWT to load these into the system properties?
I'm trying to change something like this:
com.google.gwt.dev.GWTShell -Dsysprop1=value1 -Dsysprop2=value2 ...
to something like this:
com.google.gwt.dev.GWTShell -Dgwt.system.properties=/my/properties/file ...
The motivation is to be able to change easily between sets of properties according the runtime environment, for example so that I can have dev.properties and prod.properties property without having to set the properties individually on the startup command.
Aside: there are two other options that will work, but which I'd like to avoid for now:
adding a layer of indirection through which to pick up all of the system properties (because this will be a pain to retrofit)
adding a bootstrapper to load the property set before delegating everything GWT (because I'm lazy, though this might be a reasonable longer term option if GWT doesn't support this out of the box).
There's a great example of how to do this using GWT Generators here.

Categories

Resources