Configure Spring JNDI datasource with DBCP and connection parameters - spring-mvc

I am using Spring 3 and attempting to use a JNDI (named) data source with DBCP connection pooling.
I would like to be able to set pool parameters, but my
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
</bean>
doesn't support the necessary params:
<!-- Connection Pool settings -->
<param name="maxActive" value="5" />
<param name="maxIdle" value="2" />
<param name="maxWait" value="10000" />
<param name="removeAbandoned" value="true" />
<param name="removeAbandonedTimeout" value="60" />
<param name="logAbandoned" value="true" />
<!-- Purge invalid connections -->
<param name="validationQuery" value="SELECT 1" />
<param name="testOnBorrow" value="true" />
I've googled this extensively, and it looks like it's expected that the container (tomcat) should set these kinds of params for JNDI connections, not the application.
Unfortunately in my situation (cloudbees) I don't have control over tomcat.
Is what I'm attempting even possible?

ok, I've figured out how to do this. For reference, you need to use the Cloudbees SDK's bindings feature:
bees app:bind -a APP_ID -db DB_ID -as DATASOURCE_NAME maxActive=5 maxIdle=2 \
maxWait=10000 removeAbandoned=true removeAbandonedTimeout=60 logAbandoned=true \
validationQuery="SELECT 1" testOnBorrow=true

Related

Writing different levels to different files in log4cxx

I want to have log messages from each log level go to a different file. From the name, LevelMatchFilter seems like what I want, except it seems to not filter anything from a different level.
I think the following properties should do that using LevelRangeFilter. However, anything sent to the global logger ends up in INFO.log, regardless of the level.
log4j.rootLogger = OFF
# Global level based logs
log4j.logger.global = ALL, Info
log4j.appender.Info=org.apache.log4j.FileAppender
log4j.appender.Info.File=Logs/INFO.log
log4j.appender.Info.layout=org.apache.log4j.PatternLayout
log4j.appender.Info.layout.ConversionPattern=%d [%p] %m%n
log4j.appender.Info.filter.a=org.apache.log4j.filter.LevelRangeFilter
log4j.appender.Info.filter.a.LevelMin=info
log4j.appender.Info.filter.a.LevelMax=info
log4j.appender.Info.filter.a.AcceptOnMatch=true
I also tried using INFO for the values of LevelMin and LevelMax but that had the same results.
What am I doing wrong?
As a side question, is there a way to turn on debugging of the log4cxx configuration when using a property file? I found an option when using an xml file, but none of the obvious translations to properties (debug=true, log4j.debug=true) and any effect.
As of log4cxx 0.10 (and probably earlier), the properties format does not support filters. So the XML configuration (or programmatic configuration) is required.
<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<appender name="Info" class="org.apache.log4j.FileAppender">
<param name="file" value="Logs/INFO.log" />
<param name="append" value="false" />
<!-- If this filter accepts the message, it will be printed. That happens if this is an info message -->
<filter class="org.apache.log4j.filter.LevelMatchFilter">
<param name="levelToMatch" value="INFO" />
<param name="acceptOnMatch" value="true" />
</filter>
<!-- If it is not an info message, this filter will reject it -->
<filter class="org.apache.log4j.filter.DenyAllFilter"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%p] %m%n" />
</layout>
</appender>
<root>
<priority value="off" />
</root>
<logger name="global">
<priority value="all" />
<appender-ref ref="Info" />
</logger>
</log4j:configuration>

Unity Interception MethodSignatureMatchingRule could not be resolved

Im using Unity (3.0) interception to add some crosscutting concerns to my application. Somehow I can't use the MethodSignatureMatchingRule in my configuration getting this error message:
{"The type name or alias MethodSignatureMatchingRule could not be resolved. Please check your configuration file and verify this type name."}
My configuration:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
<alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
<containers>
<container name="MyContainer">
<extension type="Interception"/>
<interception>
<policy name="EhabAspect">
<matchingRule name="MethodSignatureMatchingRule" type="MethodSignatureMatchingRule">
<constructor>
<param name="methodName" value="Receive" type="string"/>
</constructor>
</matchingRule>
<callHandler ... (omitted)
</policy>
</interception>
<register type="IMyClass" mapTo="MyClass">
<lifetime type="singleton" />
<interceptor type="InterfaceInterceptor"/>
<policyInjection/>
</register>
</container>
</containers>
</unity>
The same configuration with the NamespaceMatchingRule works fine.
My assembly contains a reference to
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.Unity
Microsoft.Practices.Unity.Configuration
Any suggestions?
I was facing the same problem here. I solved using the full qualified name of the of the class.
<matchingRule name="AuthorizationMethod" type="Microsoft.Practices.Unity.InterceptionExtension.MethodSignatureMatchingRule, Microsoft.Practices.Unity.Interception">
<constructor>
<param name="methodName" value="Authenticate" type="string"/>
<param name="parameterTypeNames" dependencyName="EmptyArray"/>
</constructor>
</matchingRule>

FLVPlayback Flash Skin not showing in wordpress

Im trying to insert a flash video with controls in my website. I can see the video but not the controls with FLVPlayback. I put all my files at the same level of my page, so i shouldnt have a path error...
Heres my files:
Confr.flv
Confr.swf
MinimaFlatCustomColorPlayBackSeekCounterVolMute.swf (playerSkin)
My code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="667" height="410" id="Confr" align="middle">
<param name="movie" value="http://unikmedia.ca/ad/wp-content/themes/adapte/Confr.swf" />
<param name="quality" value="best" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://unikmedia.ca/ad/wp-content/themes/adapte/Confr.swf" width="667" height="410">
<param name="movie" value="http://unikmedia.ca/ad/wp-content/themes/adapte/Confr.swf" />
<param name="quality" value="best" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
If you look at this link, you can see the player :http://unikmedia.ca/ad/wp-content/themes/adapte/Confr.swf
But in the wordpress, no controls at all... : http://unikmedia.ca/ad/a-propos/
Please I need help !!!
I had the same problem, and I found the solution... change the "swf BASE directory" in your embeded swf object. With this parameter pointing to your swf directory, the FLVPlayBack will be able to find the control skin swf.
Here's a sample:
<script type="text/javascript">
var flashvars = {};
var params = {"base": "../project/subfolder/"};
var attributes = {id: "Main", name: "Main"};
swfobject.embedSWF("MainLoader.swf", "myAlternativeContent", "920", "550", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
Your file MinimaFlatCustomColorPlayBackSeekCounterVolMute.swf get an 404 error.
Try to find the script who call this file and change it.
But i suggest you to convert the .swf movie to an .mp4 and use jwplayer if its possible.
You can also try to create an 'a-propos' folder at the root of the site, like 'wp-content' folder, and put your 'MinimaFlatCustomColorPlayBackSeekCounterVolMute.swf' file in it
I was having the same issue, in my local workspace I could see it, but on the WP live site I couldn't. In my case I solved it by changing the permissions of the skin swf, try changing the chmod to 777 (of just skin swf file) to see if that's the issue.

video only play in Internet Explorer not in other browser

![In other broeser][2]
[2]: http://i.stack.imgur.com/hSDJB.png code is <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="480" height="360"
codebase="http://www.microsoft.com/Windows/MediaPlayer/">
<param name="Filename" value="hilo_data_final.wmv" />
<param name="AutoStart" value="true" />
<param name="ShowControls" value="true" />
<param name="BufferingTime" value="2" />
<param name="ShowStatusBar" value="true" />
<param name="AutoSize" value="true" />
<param name="InvokeURLs" value="false" />
<embed src="hilo_data_final.wmv" type="application/x-mplayer2"
autostart="1" enabled="1" showstatusbar="1" showdisplay="1" showcontrols="1"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0"
width="480" height="360"></embed>
So what will be problem?
Here you try to use the Windows Media Player to play the video. This is play only on IE and only on computers with windows and media player installed.
Is better to use some flash-base video player (like YouTube do) and then you have more computers and browser that be able to see it.
One suggestion is the flowplayer that I have test it and is very good.
http://flowplayer.org/

Addressing properties of a Shockwave Flash object (MultiPowUpload) in JavaScript

Please pardon the dumb newbie question; I've only been programming Javascript for about 24 hours... :)
I have managed (with some outside help) to embed a shockwave flash object into my page - specifically MultiPowUpload 2.1. It's appearing nicely on the page and seems to be functioning correctly; we can take that part as read.
Now I'm trying to do some more advanced stuff in JavaScript - I have a button, and in the onClick() code I have the following:
var swf = document.getElementById("FlashFilesUpload1");
var itemsCount = swf.filesCount;
alert("items: "+itemsCount);
But the alert statement tells me "items: undefined". It does the same if I set itemsCount to swf.nonExistentProperty - everything is "undefined". But from what I read in the documentation, there definitely is a filesCount property. I tried accessing all the other properties and methods of this swf object, and none of them work, except for toString(), which returns "HTMLObjectElement".
I am obviously addressing this object incorrectly - but what am I doing wrong?
Clarification
In response to #brianpeiris: I am doing this quite differently from the page at the link you suggested. I didn't do this with any great knowledge, I'm just really acting like a monkey, trying to copy other people's code that works, then tweak it so it does what I want... so don't assume I know anything, however obvious - remember, I've only been doing JavaScript for about a day now!
So here's the code for the control itself:
<object id="FlashFilesUpload1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" viewastext>
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values!
The same parameters values should be set for EMBED object below. -->
<param name="FlashVars" value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx" />
<param name="BGColor" value="#F8F6E6" />
<param name="Movie" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="Src" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="WMode" value="Window" />
<param name="Play" value="-1" />
<param name="Loop" value="-1" />
<param name="Quality" value="High" />
<param name="SAlign" value="" />
<param name="Menu" value="-1" />
<param name="Base" value="" />
<param name="AllowScriptAccess" value="always" />
<param name="Scale" value="ShowAll" />
<param name="DeviceFont" value="0" />
<param name="EmbedMovie" value="0" />
<param name="SWRemote" value="" />
<param name="MovieData" value="" />
<param name="SeamlessTabbing" value="1" />
<param name="Profile" value="0" />
<param name="ProfileAddress" value="" />
<param name="ProfilePort" value="0" />
<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
<!-- Replace symbols " with the " at all parameters values and symbols "&" with the "%26" at URL values or & at other values! -->
<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ClientSideControls/ElementITMultiPowUpload2.1.swf"
quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="450" height="350" flashvars="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx">
</embed>
</object>
As you see it's embedded in the HTML as an object, unlike the reference you gave, where they do some other trick using script to get it onto the page.
BTW, when I tried it their way (not very hard, I grant you), I didn't manage to get the control even to appear on my page!
Thanks for your help... much appreciated
Edit: I think I finally figured it out! You simply have set the useExternalInterfaces to Yes.
So in your code you would change
<param
name="FlashVars"
value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx" />
to
<param
name="FlashVars"
value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes" />
and do the same for the <embed> tag.
If you visit the demo site and run the following code in Firebug it returns 0 before you select files and the correct count after you select files. Also, if you check the source, you'll see that the useExternalInterface option is set to Yes
alert(document.getElementById('MultiPowUpload').filesCount());
P.S. You should consider using the SWFObject script included with MultiPowUpload. It lets you set and change variables easily without having to worry about cross-browser issues and it also degrades gracefully for users without flash.
Further edit
To answer your comment: Yes, I've got filesCount working on my machine.
One thing I forgot to mention is that you might be trying to retrieve filesCount before the flash control is fully loaded.
The following is the code I'm using. I copied your code exactly and added the useExternalInterface setting as well as my own javascript.
Note that my javascript code repeatedly checks the filesCount every 500 milliseconds using the setInterval function.
<object id="FlashFilesUpload1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" viewastext>
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values!
The same parameters values should be set for EMBED object below. -->
<param name="FlashVars" value="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes" />
<param name="BGColor" value="#F8F6E6" />
<param name="Movie" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="Src" value="ClientSideControls/ElementITMultiPowUpload2.1.swf" />
<param name="WMode" value="Window" />
<param name="Play" value="-1" />
<param name="Loop" value="-1" />
<param name="Quality" value="High" />
<param name="SAlign" value="" />
<param name="Menu" value="-1" />
<param name="Base" value="" />
<param name="AllowScriptAccess" value="always" />
<param name="Scale" value="ShowAll" />
<param name="DeviceFont" value="0" />
<param name="EmbedMovie" value="0" />
<param name="SWRemote" value="" />
<param name="MovieData" value="" />
<param name="SeamlessTabbing" value="1" />
<param name="Profile" value="0" />
<param name="ProfileAddress" value="" />
<param name="ProfilePort" value="0" />
<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
<!-- Replace symbols " with the " at all parameters values and symbols "&" with the "%26" at URL values or & at other values! -->
<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ClientSideControls/ElementITMultiPowUpload2.1.swf"
quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="450" height="350" flashvars="uploadButtonVisible=false&uploadUrl=../ReceiveBulkCases.aspx&useExternalInterface=Yes">
</embed>
</object>
<script>
function updateMessage() {
var message = (new Date()).toLocaleTimeString() + ': ';
try {
var objectElement = document.getElementsByTagName('object')[0];
var embedElement = document.getElementsByTagName('embed')[0];
if (objectElement.filesCount) {
message += 'We are in IE ' + objectElement.filesCount();
}
else if (embedElement.filesCount) {
message += 'We are in Firefox ' + embedElement.filesCount();
}
else {
message += "The flash object is not loaded or useExternalInterface is not set to 'Yes'";
}
}
catch (exp) {
message += 'An error occurred';
}
document.getElementById('message').innerHTML = message;
}
// Update the message every 500 milliseconds
setInterval(updateMessage, 500);
</script>

Resources