Maven profile activation based on classpath property - maven-profiles

Is it possible to activate a Maven profile based on a classpath property that you in turn set based on reading a properties file? I have verified that the classpath exists at the phase where my profile is supposed to take effect, and also separately gave the property through command line which worked, but when I attempt to read it from properties file, and attempt to run the profile based on classpath property, it does not work. I even tried setting the interested property as system property hoping that profile will be activated, but same result. This link refers as if classpath properties can be read, but this link mentions as if only system properties can be read for profile activation. However, for me both don't work. Any pointers will be helpful.
Thanks,
Paddy

Related

How to switch between different properties files based on request at runtime?

Currently I read properties file by defining a global element like;
> <configuration-properties doc:name="Local Configuration Properties"
> doc:id="899a4f41-f036-4262-8cf2-3b0062dbd740"
> file="config\local_app.properties" />
But this is not enough for me
when try to deal different clients dynamically.
Usecase
I need to pick right configuration file when request comes in. That is, for different clients I have different properties file.( their credentials and all different). When request is received from listener, i'll check with clientid header and based on that value, i'll pick right configuration file. My properties files are added to different location.(Doing deployment through openshift.) Not within mule app. So, we don't need to redeploy the application each time, when our application supports new client.
So, in this case, how to define ? and how to pick right properties file?
eg:
clientid =google, i have properties file defined for google-app.properties.
clientid=yahoo, i have properties file defined for yahoo-app.properties.
clientid=? I'll add properties file ?-app.properties later
Properties files are read deployment time. That means that if you change the values, you to redeploy the application to read the new ones. System properties need a restart of the Mule Runtime instance to be set. And Runtime Manager properties need a restart of the application. In any case the application will restart. Properties can not be used as you want.
There is no way to use configuration properties dynamically like that. What you could do is to create a module using Mule SDK that read properties files and returns the resulting set of properties, so you can assign the result to a variable, and use the values as variables. You will need to find a way to update the values. Maybe set a flow with a scheduler to read the values with a fixed frequency.

Syntax of Local.Properties In Hybris

I know that local.Properties overrides project.Properties.
I also know that that these files define… database connections, ports, build environment, frontend HTTPS, etc.
I further know that project.Properties contains more properties.
Will appreciate if Hybris experts tell me syntax of local.Properties, illustrating with some example.
Please provide correct info.
If we talk about the syntaxes of entries in the project.properties file, then it is key=value
The property files in the hybris are of two types:
The extension level - The property file project.properties is the configuration file that carries properties in the key-value pair for the configurations involved on the extension level For instance, Consider a property in the project.properties of the yacceleratorstorefront (storefront template) extension storefront.storelocator.pageSize.Desktop=10 which clearly indicates the 'StoreLocator' results page size configuration per store. Since the store locator functionality is specific to the storefront and has no relevance for the other modules (like core, facades etc), the property is kept at the extension level.
Please note, project.properties reside in the extension folder
The global level - This is the property file which is the global configuration file, and deals with the properties are extension agnostic and carry a global impact. For instance the property commerceservices.default.desktop.ui.experience=responsive sets the ui experience to responsive mode that specifies the deployment to be for the responsive format.
The local.property file supersedes all of the properties with the same key that is defined in any of the project.proprties.
Please note, the local.properties file reside in the hybris/config folder
The hybris registry creates a property configuration map which constitutes all of the properties mentioned in the deployment configuration. The same could be managed in the HAC under platform/configuration.
The clear intent of the local.proprties file is to have information which either requires to be overriden on a global level. The override may be of different types, e.g. cart expiry time could be made different on different environments by the use of the local.property files.
For further reading, please refer to the link: https://wiki.hybris.com/display/release5/Configuring+the+Behavior+of+the+hybris+Commerce+Suite
property call hierarchy (from primary to secondary):
java -Dproperty.key=something
hybris/config/local.properties
hybris/*/(extension-name)/project.properties
hybris/bin/platform/project.properties
and within java code:
configService.getString("property.key", "last fallback value, if no propertyfile provide this key");
You could review all current variables using the hac interface for properties: http://localhost:9001/platform/config

Carrot2-bisectingKmeans setting the attribute of resouceLookup causes the error of no resouces named stopwords.ar

Carrot2-I tried to cluster docs through the bisectingKmeans algorithm.
I set the attribute of resouceLookup and tested the language of English/Chinese. It both resulted in the error "no resouces named stopwords.ar in resouce lookup locations...".
The cod I wrote:
//set the resoucelookup
File resDir = new File("resouces");
ResouceLookup res = new ResouceLookup(new DirLocator(resDir));
LexicalDataLoaderDescriptor.attributeBuilder(preprocessAttr).resourceLookup(res);
//set the language
MultilingualClusteringDescriptor.attributeBuilder(processingAttr)
.defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);
What's the problem? Thanks.
Copying all the resources is a better idea and the reason why there is no default fallback -- you will have complete control over what resources are present and for which language. This is important because resources are merged by default http://download.carrot2.org/head/manual/index.html#section.attribute.kmeans.merge-resources
The most explicit way to solve this would be to copy all all lexical resources to your resources directory. You can find the resource files in Carrot2 Java API distribution, for example.
An alternative is to tell Carrot2 to load the missing resources from the classpath (Carrot2 JAR):
File resourcesDir = new File("resources");
ResourceLookup resourceLookup = new ResourceLookup(
new DirLocator(resourcesDir), // your custom location
new ContextClassLoaderLocator() // fallback: classpath (Carrot2 JAR)
);
LexicalDataLoaderDescriptor.attributeBuilder(attrs)
.resourceLookup(resourceLookup);
In this arrangement, your resources directory can only contain the resources you'd like to override. The non-overridden ones (and the ones that you don't care about) will be loaded from Carrot2 JAR.
There are two caveats here:
When you upgrade Carrot2 JAR, the fallback resources may silently change.
In case of a misconfigured custom location (e.g. passing an empty directory), clustering will silently proceed with built-in lexical resources without any specific warning (unless you use the debug logging level).

Where am I going wrong with the persistence of User scoped Settings?

I have a Boolean, user scoped setting. I access it through a referenced class library, called Settings. This class library has a Module with properties:
Module AppSettings
Public Property MyBooleanSetting() As Boolean
Get
Return My.Settings.MyBooleanSetting
End Get
Set(ByVal value As Boolean)
My.Settings.MyBooleanSetting = value
My.Settings.Save()
End Set
End Property
End Module
I defined the setting in the Property pages of the Settings class library.
When other code manipulates the setting it will use code like:
Settings.MyBooleanSetting=True
While the code is running this works. But after a restart of the application the new value is not persisted.
Where am I going wrong?
After looking at the Using My.Settings in Visual Basic 2005 MSDN article and these MSDN Forum Threads , I would say you need to verify which path is being used.
User-scope settings are specific for each user. They can be read and set safely by the application code at run time. These settings are stored in a user.config file. To be technically accurate, there are two user.configs per user per application—one for non-roaming and one for roaming. Although the Visual Basic 2005 documentation states that the user.config file will be named according to the user's name (joe.config), this is not the case. The user.config file is created in the \[Local Settings]Application Data\\\. Where:
• is the user data directory, either non-roaming (Local Settings above) or roaming.
• is the user name.
• is the CompanyNameAttribute value, if available. Otherwise, ignore this element.
• is the AppDomain.CurrentDomain.FriendlyName. This usually defaults to the .exe name.
• is the URL, StrongName, or Path, based on the evidence available to hash.
• is a SHA1 hash of evidence gathered from the CurrentDomain, in the following order of preference:
a.StrongName
b.URL
If neither of these is available, use the .exe path.
• is the AssemblyInfo's AssemblyVersionAttribute setting.
Save your breath guys. The code did work after all. I used an other Property in the Viewmodel of my application that cached the Setting.MyBooleanSetting, but I forgot to read it in at application startup...

How to update the JSF2.0 (Primefaces) tooltips dynamically without server restart

I need to update the JSF2.0 (Primefaces) tooltips dynamically without server restart.
Meaning need to find a way where tooltips (atm from properties file) of the a running application can be changed without requiring a server restart.
We are running websphere and deploying a non exploded EAR (can probably convince to deploy exploded war)
Any Ideas or tips please. Thanks you
The value attribute of the p:toolTip component must be an EL expression or a literal text. Usually, one would reference a resource bundle declared using the var attribute of the f:loadBundle tag, in the EL expression for the tooltip.
The underlying resource bundle declared using the basename attribute could be backed by a property file itself (in which case you need to place the property file in the appropriate directory on the classpath), or for that matter it could be a custom ResourceBundle implementation that could read from a properties file (located outside the container), or a database or any store for that matter.
You could therefore change your existing EL expression from the existing one defined as:
<f:loadBundle var="msg" basename="propfile_location" />
to
<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />
In simpler words, you will need to roll your own ResourceBundle class(es) to support the various locales. Needless to state, but you will need to override the ResourceBundle.getObject(java.lang.String) method, as it is invoked by the ResourceBundleELResolver implementation when evaluating the EL expressions referencing ResourceBundles.
Additionally, you will need to ensure that the ResourceBundle.getObject(java.lang.String) implementation of your ResourceBundle will always re-fetch and return the value corresponding to the provided key. Failure to ensure this would mean that the initial value fetched by the resource bundle may be returned on subsequent invocations, especially if you are caching the initial value. You are likely to encounter this behavior even if you deploy an exploded WAR file where you can modify the property file contents without a redeployment of the application, and that is why it is important to use a custom ResourceBundle implementation that does not cache values.