Configure Quartz.NET through a mixture of config file and constructor - quartz-scheduler

Is it possible to configure Quartz through a mixture of properties held in a config file (either quartz.properties or app.config / web.config) and also some via the StdSchedulerFactory constructor?
I would like to pass the AdoJobStore connectionstring via the constructor, as it is dynamic depending on the environment, but the rest of the settings are static so would be better placed in a config file.
I've tried passing in only the quartz.dataSource.myDS.connectionString property via the constructor, whilst having the rest of the properties in a quartz.config in the working directory. However, I get the error:
Provider not specified for DataSource: myDS
So I guess this means that if you use the constructor that accepts the NameValueCollection, then it doesn't bother checking the config file(s).
I know that the quartz.config file is in the right place, because if I put the connectionstring in there and use the default constructor, it all works

In the end, they are all simply named-value pairs.
You can have "most" of them in an .xml file...then "add in" the ones you want via code.
Or have all of them in code.
See the UnitTests for the source code, and you'll see this fairly clearly.
Something like this:
NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
config.Add("MyCodedUpKey", "MyCodedUpValue");
If you have a "collision" (a "key" in the config file that you want to override..apply some simple name-valued-pair "update existing key" logic"
Check if Key Exists in NameValueCollection

Related

Setting Cassandra password in reference.conf using Scala

How can an attribute be set programmatically in a reference.conf file?
For example, I am using something like this in Spring to set the attributes of the keystore:
System.setProperty("server.ssl.keyStore", "keystore.jks")
System.setProperty("server.ssl.keyStorePassword", "password123")
Same way, you can override configuration from the reference conf file using system properties, they have the highest precedence order as described here:
https://github.com/lightbend/config#standard-behavior
Please be aware you need to do it before the config is loaded by the class that uses it (via ConfigFactory.load()) and if any other class has already used ConfigFactory, then a call to ConfigFactory.invalidateCaches() will also be required, otherwise the cached value will be used.

Use ResourceSet within another Plugin

I use a xtext generated DSL in my project. I now want to generate some files with a wizard. I can currently create these files just by adding some strings to the file. But initially i wanted to create a Model Object of the DSL and add the new generated file to the resource set. I can't find a way accessing this without the StandaloneSetup of the DSL.
I'm now unsure if the use of the StandaloneSetup inside the Editor is the correct way, since it seems there should be a better way to access the already build up resource set used by the xtext framework to manage the already known files/sources. If i use the StandaloneSetup shouldn't there be 2 Injectors which could get really bad?
you can use the resource service provider registry to obtain the injector
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html
URI fakeOrRealUri = ...;
IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(fakeOrRealUri).get()

Issue with spring cloud config property file order

I am using spring cloud config for loading properties file for my application. I have multiple environments. I notice that the property files are loaded in wrong order. This is what i see in my logs
Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='https://github.com/xyz/configrepo.git/gatekeeper-dev.properties'], MapPropertySource [name='https://github.com/xyz/configrepo.git/gatekeeper.properties']]]
It seems that the environment specific property file is loaded first and overridden by the default property file. Is there any way i can control the order in which they are loaded and processed ?
That is the expected order (for good reasons so I am surprised you found a use case where it wasn't convenient). You can't control it except by changing the names of the files and listing them in a comma separated form. For the sake of clarity: profile specific properties always override default ones. Possibly the logs have confused you.

GWT: Get constants in server side

I'm trying to get the constants (ConstantsWithLookup) stored in the client side in my server side, but it can't figure out how to do it. I have my constants interface and my constants properties in the same folder.
I've tried tips of other similar threads with no success.
I tried Hermes, gwt-i18n-server, gwt-dmesg, GTWI18N, using a ResourceBundle, trying to get source file properties.
For the first two, it seems that the main reason is the outdated support for the newest GWT version. As for the ResourceBundle, it cannot find the properties file because at deployment, there isn't a properties file, just a Constants.class.
I'm trying to avoid changing my properties file to another location (like /WEB-INF/constants).
I'm using Hermes with GWT 2.5.0.rc1, and it works fine. Usage:
put hermes-1.2.0.jar into war/WEB-INF/lib
Then on the server side write something like
MyConstantsWithLookup my = Hermes.get(MyConstantsWithLookup.class, "de");
String string = my.getString(key);
A properties file MyConstantsWithLookup.properties must exist in the same package as MyConstantsWithLookup.java, even if that properties file is empty (which might be the case if you're using #DefaultStringValue etc.)
Also add MyConstantsWithLookup_de.properties etc.
Make sure, that these properties files are copied next to your classes when compiling. Javac doesn't do that, so it must be done in an additional build step (Eclipse usually does this automatically, but it won't happen by itself when you build e.g. with Ant)
Many build setups will skip the java and properties files from the "client" package when compiling the server side. In that case, put your constants files in the "shared" package (if you have one).

How can I save a property using the Props object in scala Lift?

First of all, should I use Lift Props to store specific configurations of my App? Lift documentation explains that you can use this Props to configure the enviroment (production, testing, etc etc.) but never says if you can use them for other purposes.
If there's nothing wrong in using them, how can I store these properties (save them). All the functions that I can see in Props object are getters. E.g if I have a property myapp.myconf1
I would like to do something like:
Prop.save("myapp.myconf1","value1")
Is this possible using Props or should I use other libs like Typesafe config or java props?
Thanks in advance!
The Lift Props object isn't intended to be a read/write store. It's a repository for deployment specific config info (i.e. the settings that are different between your development/test/release environments). The file is stored within the classpath and if you are deploying as WAR file I don't believe there would be any way to change it even if an API existed.
If all you need is to store name value pairs then java props should work fine.