Feb 16 2009

Spring annotations based config

Published by Gilles at 9:41 pm under J2EE, Java, Spring

Example

DAO class in persistence package

JAVA:
  1. package com.mycompany.persistence;
  2. import org.springframework.stereotype.Repository;
  3. [...]
  4.  
  5. public class DaoImpl
  6. implements Dao {
  7. [...]
  8. }

Service class in service package

JAVA:
  1. package com.mycompany.service;
  2. import org.springframework.stereotype.Service;
  3. [...]
  4.  
  5. @Service
  6. public class ServiceImpl
  7. implements Service {
  8.         @Autowired
  9.     private Dao dao;
  10. [...]
  11. }

Usage of service in a jax-ws webservice implementation

JAVA:
  1. package com.mycompany.ws.impl;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.web.context.support.SpringBeanAutowiringSupport;
  4.  
  5. [...]
  6.  
  7. @javax.jws.WebService (endpointInterface="com.mycompany.ws.MyWs", targetNamespace="http://schema.mycompany.com/service", serviceName="myservice", portName="portname", wsdlLocation="WEB-INF/wsdl/mywsdl.wsdl")
  8. public class WsImpl
  9. extends SpringBeanAutowiringSupport{
  10.  
  11.     @Autowired
  12.     private Service service;
  13. [...]

Pages: 1 2 3 4 5

Trackback URI | Comments RSS

Leave a Reply