Archives for categorie "Spring"

Integration example of Spring and BlazeDS with Maven2.

Multiproject EAR:
- Flex 4
- Spring 3
- BlazeDS 3




  • Share/Bookmark
LCDS-Spring-Helloworld Project
Configuration example of a J2EE web application with LiveCycle, issues:

  • Start the database hsqldb with the init scripts startdb.bat (Windows) o startdb.sh (Unix) adapted to our enviroment pointed to hsqldb.jar (you can configure another database connection modifying jdbc.properties file)
  • Load the database with SQL scripts in db directory using build.xml Ant file (on project top directory).
  • Adjust hidden files .actionScriptProperties, .flexProperties of flex enviroment to our local configuration.
  • Adapt local web servers paths of the project in build.properties.
  • Configurate deploy properties of the project (url, port…)

LCDS-Spring-HelloWorld

  • Share/Bookmark

Vote at your favorite country.
¡Choose with your vote the most favorite country in the world!
- Click in the mark of the country.
- Add points to your favorite country to improve it in the ranking.
- Remove points to the other countries.

Technology:
- Flex-Cairngorm
- J2EE-Blazeds-Spring-Hibernate
- MySQL

Go to he game

  • Share/Bookmark
Aug
5
Arcadio 1 comment

Spring can provide DAO’s beans through three strategies:

  1. Inject DAO’s as properties in service bean of applicationContext.xml
    <bean id="myDao" class="app.dao.MyDaoImpl">
    	<property name="sessionFactory">
    		<ref local="sessionFactory" />
    	</property>
    </bean>
    <bean id="myService" class="app.service.myService">
    	<property name="dao" ref="myDao"/>
    </bean>

    Define servies properties

    private IMyDao dao;
    public IMyDao getDao() {
    	return dao;
    }
    public void setDao(IMyDao dao) {
    	this.dao = dao;
    }
  2. Create a factory (as a Singleton) that provide DAO instances whereever it was needed:

    Factory implementation:

    package app.dao;
    
    public class MyDaoFactory {
    	private static MyDaoFactory instance;
    	private IMyDao instanceDAO;
    
       public static MyDaoFactory getInstance() {
           if (instance == null) {
            	instance = new MyDaoFactory();
           }
           return instance;
       }
    
       public IMyDao getInstanceDAO() {
    		return getInstance().instanceDAO;
    	}
    
    	public void setInstanceDAO(IMyDao instanceDAO) {
    		this.instanceDAO = instanceDAO;
    	}
    }

    ApplicationContext declaration (inject DAO on the factory):

    <bean id="myDao" class="app.dao.MyDaoImpl">
    	<property name="sessionFactory">
    		<ref local="sessionFactory" />
    	</property>
    </bean>
    <bean id="myDaoFactory" class="app.dao.MyDaoFactory">
    	<property name="instanceDAO">
    		<ref local="myDao"/>
    	</property>
    </bean>

    Use it in the service:

    IMyDao myDao=MyDaoFactory.getInstance().getInstanceDAO();
  3. Use the BeanFactory of Spring:
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
    	new String[] { "applicationContext.xml" });
    	IMyDao myDao = (IMyDao) ctx.getBean("myDao");
  • Share/Bookmark

BlaseDSspring

Application example with Flex, BlazeDS and Spring. On this configuration you must notice on SpringFactory which provide beans of Spring to BlazeDS.

Flex Cient
Must be changed with the project url path on following files:

  • Main-config.xml
  • .actionScriptProperties
  • .flexProperties
  • .project

Servidor
build.properties must be configured with local parameters.
Project don’t include following necessary libraries(provided with spring and blazeds):

aspectjrt.jar, aspectjweaver.jar, backport-util-concurrent.jar, cfgatewayadapter.jar, commons-codec-1.3.jar, commons-dbcp.jar, commons-httpclient-3.0.1.jar, commons-logging.jar, commons-pool.jar, concurrent.jar, flex-messaging-common.jar, flex-messaging-core.jar, flex-messaging-opt.jar, flex-messaging-proxy.jar, flex-messaging-remoting.jar, hsqldb.jar, servlet-api.jar, spring.jar, standard.jar y xalan.jar.

To deploy the project:

  1. Launch server HSQLDB through file server.bat (windows) or server.sh (unix)
  2. Create and load database with build.xml
  3. Start server and try flex application
  • Share/Bookmark
Creative Commons License
This blog is under Creative Commons licence, unless indicated otherwise.
Special thanks to Mark James for the icon set used in this blog.