How to use global properties in flex application descriptor? - actionscript-3

I'd like to refactor my adobe flex application descriptor as follows:
<application xmlns="...">
<id>...</id>
<versionNumber>1.0.0</versionNumber>
<versionLabel>${versionNumber} - My Label</versionLabel>
</application>
Is that possible?
Further, could I also fetch the values from a application.properties file and reference it directly withint the application.xml?

Related

How to override keys in Xamarin Android Manifest

I'm using this guide to working with maps in Xamarin.
It says I should use different values of the key
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AbCdEfGhIjKlMnOpQrStUvWValueGoesHere" />
for debug and release builds; the debug version should use an API key that contains SHA-1 certificates from debug.keystore, which has well-known default passwords.
In live mode, I should use SHA-1 certificates from my custom keystore files, whose passwords only I know. The live API key and SHA-1 certificate work in the live APK, but not in the debug build. This makes sense, I guess. I should have one Google Android API key for debugging, and one for production.
What I don't want to do is have this in my AndroidManifest.xml file:
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="<My Debug API Key>" />
<!--<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="<My Release API Key>" />-->
...changing the commented out section depending on whether I'm doing a debug or release build. Is there a more efficient way to do this (something like config transforms in ASP.NET applications)?
I've done some searching, and there are some automatically applied debug overrides, but it doesn't seem like I have a great deal of control over the process.
You can use assembly level MetaData attributes to define tags within the Manifest's Application element and by using conditional compilation:
#if DEBUG
[assembly: MetaData("com.google.android.maps.v2.API_KEY", Value = "DebugKEYValue")]
#else
[assembly: MetaData("com.google.android.maps.v2.API_KEY", Value = "ReleaseKEYValue")]
#endif
Depending upon build type, this will result in:
<application android:allowBackup="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:name="android.app.Application" android:debuggable="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="DebugValue" />
Or:
<application android:allowBackup="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:name="android.app.Application">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="ReleaseKEYValue" />

PhpStorm unable to resolve symbol 'doctrine.orm.entity_manager'

When I open the services.xml in PhpStorm with Symfony Plugin enabled, it's able to resolve all the services, I can Ctrl+Click and go the Service Definition , except doctrine.orm.entity_manager.
It says unable to resolve symbol 'doctrine.orm.entity_manager'
Here is the services.xml file
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="example_manager" class="Vendor\XysBundle\Manager\ExampleManager">
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
</services>
</container>
PhpStorm Details:
PhpStorm 2016.3.1
Build #PS-163.9735.1, built on December 6, 2016
JRE: 1.8.0_112-release-408-b2 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
appDevDebugProjectContainer.xml file exists in the app/cache directory .
How can I get get this working ?
I have the same issue. If you open up the vendor\doctrine\doctrine-bundle\Resources\config\orm.xml file where doctrine services are defined, you can see, there is no service with the id "doctrine.orm.entity_manager" but only "doctrine.orm.entity_manager.abstract"
The definition looks like:
<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" abstract="true" />
As you can see the abstract attribute is set to true. This means this service can serve as a parent of other services, and when you define child services with this abstract parent you don't have to define the method calls or the parameters injected into the constructor for example, instead these definitions will be inherited from the parent.
If you investigate a bit deeper you will find that %doctrine.orm.entity_manager.class% is defined in the same file as a parameter that actually references to the Doctrine Entity Manager:
<parameter key="doctrine.orm.entity_manager.class">Doctrine\ORM\EntityManager</parameter>
So I guess we should use doctrine.orm.entity_manager.abstract, however doctrine.orm.entity_manager is recognised as well, although I don't know how.
For further explanation of abstract service definitions have a look at this Symfony doc page: https://symfony.com/doc/current/service_container/parent_services.html

How to specify file path Dynamically in logback.xml

I am new to Logback, I am trying to add file path dynamically, with a property file, for both windows and Linux.
Here is the code sinppet I have, how can I get the value to ${MY_HOME}
<appender name="SERVER_FILE" class="ch.qos.logback.core.FileAppender">
<file>${MY_HOME}/server.log</file>
<append>true</append>
<encoder>
<pattern>%d [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
Typically this is a system property, there are some answers that touch on this but only provide one part of the answer. These are:
Logback.xml configuration
logback how to set destination folder for log files
But the manual on configuration shows that the mechanism is quite flexible
As in many scripting languages, logback configuration files support definition and substitution of variables. Variables can be defined within the configuration file itself, in an external file, in an external resource or even computed and defined on the fly.
In summary you have a number of options for defining the value of MY_HOME:
In the file
You are able to define the value in the file itself with:
<property name="MY_HOME" value="/home/myhome"/>
In the system properties
You can arrange for it to be set as a system property, most likely when you start the JVM.
java -DMY_HOME="/home/myhome" ...
From a property file on your system
You can arrange for logback to read a property file:
<property file="/opt/example/instance_1/properties/system.properties" />
From the classpath
You can write a properties file into a resources directory or into a jar and read it out as a resource, using the classpath.
<property resource="prod.properties" />
Using the property definer
You can arrange to call into your code, by using a property definer. For example:
<define name="MY_HOME" class="biz.nowhere.HomePropertyDefiner">
<application>app</application>
</define>
Where that class is something like (as an example):
public class HomePropertyDefiner extends PropertyDefinerBase {
private String application;
#Override
public String getPropertyValue() {
return String.format("/opt/%s/%s", application, MyInstanceManager.instancePath());
}
public void setApplication(String application) {
this.application = application;
}
}

CAstle Windsor: How to reference a second xml config file that is an embedded resource?

We have one xml configuration file that we use in production. We also have a little test app that has a couple of additional needs. What I'd like to do is create a second, testing-only xml config file that references the embedded production configuration file. Is there any way to do this?
I'm aware of the "include" element, but am not sure where in the file it is supposed to be placed--in the castle node? The components node?
I feel like the answer is here but I'm too dense to figure it out.
Thanks for any help you can provide.
UPDATE
This is how our production config file is set up:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<installers>
<!-- some installers-->
<installers>
<components>
<!--some components-->
<components>
<castle>
<Framework>
<OurCompany>
My most recent attempt at a non-production config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<include uri="assembly://AssemblyContainingEmbeddedXml/MyEmbeddedConfig.xml" />
<components>
<!--components I only want registered with container when running in non-production environment-->
<components>
<castle>
<Framework>
<OurCompany>
The exception I get reads:
Configuration parser encountered Framework, but it was expecting to find installers, facilities or components. There might be either a typo on or you might have forgotten to nest it properly.
(In the actual message, "Framework," "installers," "facilities," and "components" are enclosed in angle brackets.)
The bottom of the page you reference has an example of loading from an embedded resourced:
IResource resource = new AssemblyResource("assembly://Acme.Crm.Data/Configuration/services.xml");
container = new WindsorContainer(new XmlInterpreter(resource));

App.config and Enterprise library

I'm using enterprise library for logging. So, to hold my configurations, I'm using the client's app.config. The requirement changed to "split EL configuration and UI configuration". I did it using enterpriseLibrary.ConfigurationSource. Split the configurations to app.config(For UI) and EL.config(For EL).
Now I want to hide the reference to this EL.config from app.cpnfig, so that the mere existence of this EL>config is hidden from the User.
App.config Code:
<enterpriseLibrary.ConfigurationSource selectedSource="EntLib Configuration Source">
<sources>
<add name="EntLib Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
filePath="C:\My.CommonServices.Logging\My.CommonServices.Logging\EL.config" />
</sources>
You can use FileConfigurationSource to programmatically load an external configuration file.
During application load or initialization you can load your external configuration file:
FileConfigurationSource fcs =
new FileConfigurationSource(
#"C:\My.CommonServices.Logging\My.CommonServices.Logging\EL.config"
);
var builder = new ConfigurationSourceBuilder();
builder.UpdateConfigurationWithReplace(fcs);
EnterpriseLibraryContainer.Current =
EnterpriseLibraryContainer.CreateDefaultContainer(fcs);
Once that is done you can access your favorite features:
LogWriter logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
logWriter.Write("Test");
The only "trick" is ensuring that the configuration file is always present where you expect (either absolute or relative).