Symfony service strict parameter - dependency-injection

Does anyone know what the "strict" parameter does when injecting a service in Symfony ?
For example:
<service ...>
<argument type="service" id="whatever" strict=false />
</service>
Thank you!

I did some research and it's a leftover from Symfony 2.8 as this comment suggests:
Note: The $strict parameter is deprecated since version 2.8 and will be removed in 3.0.
Since 3.0 the parameter doesn't exist as well as the deprecation warning but classes YamlFileLoader and XmlFileLoader still read it even though the Reference class takes only two arguments.
So, this parameter does nothing :).

Related

magento unable to reroute to controller in config.xml

(FYI this is version 1.4, and yes I'm flushing my var/cache folder. I've started reading through Alan Storm's tutorials and that helped, but nothing specific on this problem)
I am new to Magento, we are using the OnePage checkout method, and we have the following:
app/code/local/Ourcompany/Checkout/etc/config.xml
Which has the following definition:
<frontend>
<routers>
<checkout>
<args>
<modules>
<Ourcompany_Checkout before="Mage_Checkout">Ourcompany_Checkout</Ourcompany_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
I have a corresponding file in:
/app/code/local/Ourcompany/Checkout/controllers/OnepageController.php
In there I have a class:
class Ourcompany_Checkout_OnepageController extends Mage_Checkout_OnepageController
So far I have not been able to get Magento to acknowledge it's there. The native methods in core are being called only. If I remove or rename this page, there is no error statement - I think my syntax in config.xml is not correct. Can anyone identify the improper syntax present?
This is the first time I have answered my own question but I think the answer here is noteworthy. The CommerceBug debugger was very useful as I was able to look at classes that were loaded. As it turns out, there was another module that had been created, called Admaster which got precedence as the router for the OnepageController.
I'm sure dealing with this type of conflict is common for Magento, so I have a mental checklist item now if this happens again.

Parameter substitution in log4j2

I need to allow deployers to specify the path for our Tomcat webapp log4j2 RollingFileLogger. I'd like to use JNDI but can use a plain -D param if I had to. This apache page seems to explain things pretty well.
Only problem is it doesn't work. I will admit to not being particularly experienced in JNDI, but I can't even get a simple JVM param to work. Reading about Property Substitution I got the impression I cannot just put the $${jndi:xxxx} in the filename attribute and that I should use a ${xxx} Property substitution instead. Unfortunately while that property substituion works fine no lookup jndi or env ever resolves.
log4j2.xml:
<Properties>
<Property name="filename">$${jndi:logPath/directory}/ief.log</Property>
</Properties>
....
<RollingFile name="RollingFileLogger" fileName="${filename}" immediateFlush="false" append="true"
Result:
2014-09-16 14:44:46,284 ERROR Unable to create file ${jndi:logPath/directory}/ief.log java.io.IOException: The filename, directory name, or volume label syntax is incorrect
As you can see the property is substituted but the lookup is not done. I am unsure what the context.xml entry should look like. But my best guess is:
<Resource name="logPath"
auth="Container"
directory="/tmp" />
I am using log4j version 2.0 but am fairly certain this is my misunderstanding not a bug. Any help clearing up what I'm doing wrong would be greatly appreciated.
I never found a JNDI browser that would work in Tomcat 7. But it did turn out to be a stupid problem. I defined this as a RESOURCE instead of an ENVIRONMENT. Just for the record the context.xml should look like:
<Environment name="logPath"
auth="Container"
type="java.lang.String"
value="/tmp" />
And log4j2 lookup is then:
<Property name="logName">$${jndi:logPath}/iefrest.log</Property>
<Property name="patternName">$${jndi:logPath}/iefrest</Property>
...
<RollingFile name="RollingFileLogger" fileName="${logName}" immediateFlush="false" append="true"
filePattern="${patternName}-%d{yyyyMMdd-HH}.log.gz">
It is worth noting that the "java:comp/env" (which is clearly documented but misleading to people that don't have a deep knowledge of JNDI - like me) actually maps to the Environment XML element and does not imply a prefix to the name attribute.
From a Log4J2 prespective it is also interesting that the filename attribute is taken EXACTLY as provided. Specifically you cannot say filename="${logName}.log". This will not parse into the desired results. However expected concatenation DOES take place on the filepattern attribute. Inconsistent but not unmanageable.
If you specify $${jndi:logPath/directory}, the lookup will add the prefix java:comp/env/, so the full value that it will look up is java:comp/env/logPath/directory. (This prefix is not added if your jndi lookup key already contains a ':' character.) Perhaps you can use a JNDI browser to see if this gives you the expected value.
Any errors that occur during this lookup will be logged to the status logger at WARN level. Status logs appear in the console. You can enable status logs by specifying <Configuration status="trace" ... in your log4j2.xml configuration file.

Apache Camel URL Escaping with space

I have a simple Camel Route which processes the incoming Http request and then routes to other Http consumers based on the Resource path. Everything works fine but I hit the java.net.URISyntaxException: Illegal character in path when used a space in the path.
Other special characters seem to work fine.
I am building a RESTful APIs and currently using the browser to test my APIs.
Here is the Spring DSL of my route:
<route id="API">
<from uri="jetty:http://0.0.0.0/api?matchOnUriPrefix=true"/>
<bean ref="basicAuthBean"/>
<choice>
<when>
<simple>${in.header.CamelHttpPath} contains 'blah1'</simple>
<to uri="http://localhost:10001/api?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</when>
<when>
<simple>${in.header.CamelHttpPath} contains 'blah2'</simple>
<to uri="http://localhost:10002/api?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</when>
</choice>
</route>
I enabled trace on the Camel Context and found that the CamelHttpPath had already replaced the escape character "%20" with a space. I also saw that there was CamelHttpUri which had not escaped the special character.
As a hack in my Spring DSL I added the following before the choice element:
<setHeader headerName="CamelHttpPath">
<simple>${in.header.CamelHttpUri}</simple>
</setHeader>
This solved my problem but I am pretty sure there is a better way to do this. Did I miss setting some properties or is my route DSL not accurate?
Also, what is the difference between the CamelHttpPath and CamelHttpUri?
I should also mention that I am using the Camel Context in Apache ServiceMix 4.4.2 and the Camel Version used is 2.8.5.
Thanks in advance for the help!
I think we have fixed this in later Camel releases due to be released like Camel 2.10.4 etc. I remember working on that space fix.
https://issues.apache.org/jira/browse/CAMEL-5504
As Camel 2.8.x is no longer supported you would need to patch the issue yourself.
Or upgrade to ServiceMix 4.5.0 which includes Camel 2.10.3.

Grails g:javascript tag with query string generates error

When I create a tag <g:javascript src="highcharts/highcharts.js?v=255" /> i get the error:
I can't work out the type of /tools/js/highcharts/highcharts.js?v=205 with type [text/javascript]. Please check the URL, resource definition or specify [type] attribute
The docs say that g:javascript doesn't have a type attribute and after looking through the grails source I found that it's using FileNameUtils.getExtension() to determine the type of resource. Since that just does a lastIndexOf('.') and returns the right side of that, it obviously won't be found. In this case we don't really need to add the v=255 so I can remove it for now however I'd still like to be able to do so in the future. What are my options here?
Grails version is 2.1.2
What about using the HTML tag?
<script src="highcharts/highcharts.js?v=255 type="text/javascript"/>
If all you want is deal with versioning javascript includes so you can set the cache high and change the number as needed you should look at the grails cached resources plugin.
Personally I think you would want to make highcharts.js part of a module for the resources plugin to deal with for you. It will take care of versioning and minification etc as you let it. The quick start should give you enough to get going.

Question related to find/replace using propertyregex

In my ant build file, I have a property 'Version' that contains the version. Ex. 2.5.17.230
Now, I am using propertyregex of ant-contrib to replace all '.' (dot) characters with an underscore. I have written the statement as follows:
<propertyregex property="Version" input="${Version}" regexp="." replace="_" global="true" />
However, it does not work. I have even tried these in vain:
regexp="\." and regexp="[.]"
Can someone please help?
Thanks
The PropertyRegex documentation states that unless the override attribute is set to true, the task will not overwrite the property value if it's already set. And since you're trying to overwrite the Version property, your example will do nothing.
Got it! I was passing the same variable as input. I used another variable 'Version2' to get the result from propertyregex. Here is what it should have been:
<propertyregex property="Version2" input="${Version}" regexp="\." replace="_" global="true" />
Cheers!

Resources