This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TemperatureServiceImple .java | |
package uk.co.mo.training.ws; | |
import javax.jws.WebService; | |
import org.springframework.stereotype.Service; | |
@SuppressWarnings("restriction") | |
@WebService(endpointInterface = "uk.co.mo.training.ws.TemperatureService",serviceName="temperatureService") | |
@Service | |
public class TemperatureServiceImple implements TemperatureService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(JMock.class) | |
public class HomeControllerTest { | |
Mockery context = new JUnit4Mockery(); | |
//mock object : ContactDAO (using JMock) | |
ContactDAOInterface contactDAO = context.mock(ContactDAOInterface.class); | |
// Spring MVC controller | |
HomeController cc = new HomeController(); | |
// mock objects (using spring mock) | |
private MockHttpServletRequest request; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--(1) In web.xml (\WEB-INF\web.xml) add the following --> | |
<resource-ref> | |
<description> | |
Resource reference to a factory for java.sql.Connection | |
instances that may be used for talking to the database | |
that is configured in server.xml in TOMCAT. | |
For JBOSS- jboss-web.xml and *-ds.xml | |
</description> | |
<res-ref-name>jdbc/SampleDB</res-ref-name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Spring provides several options for making a DataSource available to your application. | |
(1) Getting a DataSource from JNDI --> | |
<bean id=”dataSource” | |
class=”org.springframework.jndi.JndiObjectFactoryBean“> | |
<property name=”jndiName”> | |
<value>java:comp/env/jdbc/myDatasource</value> | |
</property> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getStackTrace(Throwable aThrowable) { | |
final Writer result = new StringWriter(); | |
final PrintWriter printWriter = new PrintWriter(result); | |
aThrowable.printStackTrace(printWriter); | |
return result.toString(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void processData(int param1, int param2) | |
{ | |
CallableStatement cs=null; | |
Connection conn=null; | |
try{ | |
// get JNDI JDBC connection | |
InitialContext ctxt = new InitialContext(); | |
DataSource ds = (DataSource) ctxt.lookup("java:/myAppDS"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean dealerExists(String agentNumber) { | |
return getSessionFactory().getCurrentSession() | |
.getNamedQuery("myapp.namedquery").setParameter(0, agentNumber) | |
.list().get(0) != null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
import org.springframework.jdbc.core.JdbcTemplate; | |
import org.springframework.jdbc.object.StoredProcedure; | |
public class MyStoredProcedure extends StoredProcedure{ | |
public MyStoredProcedure(String procedureName,DataSource dataSource) { | |
super(new JdbcTemplate(dataSource), procedureName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; | |
import org.quartz.JobExecutionContext; | |
import org.springframework.batch.core.JobExecutionException; | |
import org.springframework.batch.core.JobParameters; | |
import org.springframework.batch.core.JobParametersBuilder; | |
import org.springframework.batch.core.configuration.JobLocator; | |
import org.springframework.batch.core.launch.JobLauncher; | |
import org.springframework.scheduling.quartz.QuartzJobBean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; | |
import org.springframework.batch.core.Job; | |
import org.springframework.batch.core.JobExecution; | |
import org.springframework.batch.core.JobExecutionException; |
OlderNewer