how to replace the code which has deprecated classes - spring-batch

Currently I am using the below code in spring batch job. how to replace the code in the latest version of spring since the class is deprecated in latest versions.
<beans:bean id="vms.batch.vrsToAnalysis.vendorSetter"
class="org.springframework.batch.core.resource.ListPreparedStatementSetter" >
<beans:property name="parameters">
<beans:list>
<beans:value>1</beans:value>
<beans:value>1</beans:value>
</beans:list>
</beans:property>
</beans:bean>

Please have a look at the official java doc: https://docs.spring.io/spring-batch/docs/4.3.7/api/index.html?org/springframework/batch/item/database/support/ListPreparedStatementSetter.html
It suggests to use ArgumentPreparedStatementSetter instead. Your xml snippet should then look somewhat like this:
<beans:bean id="vms.batch.vrsToAnalysis.vendorSetter" class="org.springframework.jdbc.core.ArgumentPreparedStatementSetter">
<beans:constructor-arg>
<beans:array>
<beans:value>1</beans:value>
<beans:value>1</beans:value>
</beans:array>
</beans:constructor-arg>
</beans:bean>

Replacing org.springframework.batch.core.resource.ListPreparedStatementSette with org.springframework.jdbc.core.ArgumentPreparedStatementSetter did the trick.

Related

sun_checks.xml location in checkstyle-idea.xml

My checkstyle-idea.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA">
<option name="configuration">
<map>
<entry key="active-configuration" value="CLASSPATH:/sun_checks.xml:The default CheckStyle rules" />
<entry key="check-nonjava-files" value="false" />
<entry key="check-test-classes" value="false" />
<entry key="location-0" value="CLASSPATH:/sun_checks.xml:The default CheckStyle rules" />
<entry key="suppress-errors" value="false" />
<entry key="thirdparty-classpath" value="" />
</map>
</option>
</component>
</project>
And i can't seem to find this file in my Ubuntu 14.04. Searched everywhere. The only solution i see is to download it and replace that location.
But is there a way to understand where it is located now?
My /etc/environment doesn't contain it also. So where is it? Because CheckStyle works and checks the code in Idea.
The Checkstyle-IDEA plugin contains a copy of the Sun Checks (sun_checks.xml). It is contained in the root of the plugin's JAR file. The plugin JAR is usually located at:
Linux: ~/.<PRODUCT><VERSION>/config/plugins/CheckStyle-IDEA/lib/checkstyle-idea-4.5.2.jar
Windows: C:\Users\<YourUserName>\.<PRODUCT><VERSION>\config\plugins\CheckStyle-IDEA\lib\checkstyle-idea-4.5.2.jar
Version numbers may differ in your case. The part .<PRODUCT><VERSION> should appear as something like .IdeaIC13 (for IntelliJ IDEA version 13).
Note that you should not need to find this file. You should never change it or touch it in any way. If you need to change the rules configuration, create your own rule set and use that. You may of course create your own rule set based on a copy of sun_checks.xml.
For mac I located it by typing:
sudo find / -iname Checkstyle-IDEA
Which lead me to
~/Library/Application Support/IntelliJIdea15/CheckStyle-IDEA/lib
I was then able to open the jar with an archive program and make a copy of the sun_checks.xml for my own customization.

Modify workflowModel.xml in Alfresco

I want to change some data in workflowModel.xml (set the default value of requiredApprovePercent to 100).
Of course I'm not supposed to change the file in tomcat, I need to override it in my eclipse project.
Do I need to register the model in a context file, and in which directory am I supposed to put the file in my eclipse project?
I would appreciate any help
if you're going to create a custom workflow model you need Alfresco to pick it up when starting. So yesm you need to deploy it with:
<bean id="myworkflows.workflowBootstrap" parent="workflowDeployer">
<property name="models">
<list>
<-- Task Model associated with above process definition -->
<value>alfresco/workflow/customModel.xml</value>
</list>
</property>
<property name="workflowDefinitions">
<props>
<prop key="engineId">activiti</prop>
<prop key="location">alfresco/extension/customModel.bpmn2.0.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
</property>
</bean>
Or something similar in the context file (tomcat/shared/classes/alfresco/extension is the path where you want your custom files to be.
This is also a great link to start working with workflows in Alfresco.
Hope it helps a little bit.

Is it possible to use run-jetty-run's eclipse plugin to debug this app?

Theres about 20 diff ant files, that make up the build. Im not sure how to configure run-jetty-runs eclipse plugin to use this information. Can anyone point me towards a tutorial or some documentation:
<target name="run-jetty" depends="build" description="Runs application in included Jetty container">
<property file="credentials.properties" />
<property name="jetty.port" value="8080" />
<java jar="${jetty.dir}/start.jar" fork="true" dir="${basedir}" maxmemory="512M">
<arg value="${jetty.conf.dir}/jetty.xml" />
<arg value="${jetty.conf.dir}/jetty-jndi.xml" />
<sysproperty key="jetty.port" value="${jetty.port}" />
<jvmarg value="-XX:MaxPermSize=128m" />
<jvmarg value="-Dfile.encoding=UTF-8" />
<jvmarg value="-Djetty.home=${jetty.dir}" />
<jvmarg value="-Djetty.datasource.lanter.username=${jetty.datasource.lanter.username}" />
<jvmarg value="-Djetty.datasource.lanter.password=${jetty.datasource.lanter.password}" />
<jvmarg value="-Djetty.datasource.vs.username=${jetty.datasource.us.username}" />
<jvmarg value="-Djetty.datasource.vs.password=${jetty.datasource.us.password}" />
<jvmarg value="-DSTOP.PORT=${jetty.stop.port}" />
<jvmarg value="-DSTOP.KEY=${jetty.stop.key}" />
</java>
</target>
You have two options:
Start the app using the run-jetty-run plugin; this will give you an entry in the debug menu which means that Jetty (and the app) will be launched in the debugger if you select it.
Use the information in the code block above to create your own run configuration. The classpath should already be correct; you just need to select the correct main class (open META-INF/MANIFEST.MF in start.jar to find that out). Replace all the properties with their values and put each into a new line into the argument text fields of the run configuration.
On the tab "Common", you can set a file name and save the launch config as a file in your project, so everyone working on it will get it.

NAnt and build version

I use Nant for automating ClickOnce build. So after building the application I need to know what is its version (for purpose of folder creation). Also I need build autoincrementing.
For building I use msbuild.exe /t:publish
For this you can use your source code repository revision number/hash as that is often used when using subversion or git repositories.
You can also make use of a buildserver like cruisecontrol (ccnet) this will do this build version incrementing for you.
As far as I understood, you would like to do version detection/management with minimal effort.
Why don't you use AssemblyInfo auto-increment capabilities. Putting [assembly: AssemblyVersion("1.0.*")] into your AssemblyInfo.cs will increment the build number with every build. Find more information in this answer.
After compilation you can detect the assembly version via NAnt function assemblyname::get-version:
assemblyname::get-version(assemblyname::get-assembly-name('MyAssembly.dll'))
Update:
If you can't use Assembly info auto-increment capabilities, you might let NAnt create AssemblyInfo.cs with every build using NAntContrib's <version>-task.
<loadtasks assembly="C:\PathToNAntContibTasks\NAnt.Contrib.Tasks.dll" />
<target name="assemblyinfo" description="generates AssemblyInfo.cs">
<property
name="working.dir"
value="C:\src\foo" />
<property
name="build.number.path"
value="${path::combine(working.dir, 'build.number')}" />
<echo
file="${build.number.path}"
message="0.0.0.0"
unless="${file::exists(build.number.path)}" />
<version
buildtype="Increment"
path="${build.number.path}"/>
<foreach
item="File"
property="assemblyinfo.path">
<in>
<items>
<include name="${path::combine(working.dir, '**\AssemblyInfo.cs')}" />
</items>
</in>
<do>
<asminfo output="${assemblyinfo.path}" language="CSharp">
<imports>
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyVersionAttribute" value="${buildnumber.version}" />
</attributes>
</asminfo>
</do>
</foreach>
</target>

PropertyPlaceholderConfigurer works from Maven command line, but not from Eclipse?

I have Eclipse configured to use an external maven instance. Nonetheless I have an integration test that runs fine from the command line, but fails from within Eclipse. The error is a class Spring application context bean error:
Cannot convert value of type [java.lang.String] to required type
The culprit it a bean that sets property values using a PropertyPlaceholderConfigurer.
<!-- property settings for non-JNDI database connections -->
<bean id="placeholderConfigUuid" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="location" value="classpath:database.properties" />
<property name="placeholderPrefix" value="$DS{" />
</bean>
I know which bean is failing because it appears in the stack trace and because when I replace the $DS{hibernate.dialect} with a static value it works.
EDIT: Here is where the property values are used:
<bean id="myTestLocalEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myapp-core" />
.......ommitted for brevity.......
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<!-- The following use the PropertyPlaceholderConfigurer but it doesn't work in Eclipse -->
<property name="database" value="$DS{hibernate.database}" />
<property name="databasePlatform" value="$DS{hibernate.dialect}" />
</bean>
</property>
</bean>
I have two questions:
1) Since M2Eclipse is using the same Maven setup as the command line, why does one work and the other fail?
2) How to fix this? I really like the ability to run a single jUnit test from within Eclipse on demand.
Does filtering work for a "regular" unit test under Eclipse?
Is m2eclipse configured to process resources and tests resources on resource changes:
alt text http://www.imagebanana.com/img/rwd919ek/screenshot_008.png
Is there anything particular to mention about your integration tests (from a Maven point of view)?
You are using M2Eclipse (up-to-date release?) you are using Maven 3 inside Eclipse, but i assume you are using Maven 2 (2.2.1?) on command line...On the other side you are saying that your "Integration test" is running on command line (build an environment etc.) but you would like to run "Unit Test" from within Eclipse...A Unit Test is different from an integration test...and i'm not astonished that you integration test does not work from Eclipse...May be we can say more if we see the POM's which are used and the code?