# HG changeset patch # User František Kučera # Date 1265832317 -3600 # Node ID d549a4eb6aa9f84c9adf717fae60b4b398fffb47 # Parent 9a3fced9634da37a21e1ebb57a9fcd7156099939 Funkční EJB. diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dao/KnihaDAO.java --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dao/KnihaDAO.java Wed Feb 10 20:55:08 2010 +0100 +++ b/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dao/KnihaDAO.java Wed Feb 10 21:05:17 2010 +0100 @@ -1,27 +1,24 @@ package cz.frantovo.springDemo1.dao; +import cz.frantovo.springDemo1.KnihaDAORemote; import cz.frantovo.springDemo1.dto.Kniha; import java.util.ArrayList; import java.util.Collection; import javax.annotation.Resource; +import javax.ejb.Stateless; import javax.sql.DataSource; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; /** * * @author fiki */ -@Repository("knihaDAO") -public class KnihaDAO { +@Stateless +public class KnihaDAO implements KnihaDAORemote { + @Resource(mappedName="jdbc/sqlVyuka/piskoviste") private DataSource dataSource; - @Resource - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } - public Collection getKnihy() { Collection vysledek = new ArrayList(); diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dto/Kniha.java --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dto/Kniha.java Wed Feb 10 20:55:08 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -package cz.frantovo.springDemo1.dto; - -import java.util.Date; - -/** - * - * @author fiki - */ -public class Kniha { - private int id; - private String nazev; - private String isbn; - private int pocetStran; - private Date datumAktualizace; - private int rokVydani; - private int autor; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getNazev() { - return nazev; - } - - public void setNazev(String nazev) { - this.nazev = nazev; - } - - public String getIsbn() { - return isbn; - } - - public void setIsbn(String isbn) { - this.isbn = isbn; - } - - public int getPocetStran() { - return pocetStran; - } - - public void setPocetStran(int pocetStran) { - this.pocetStran = pocetStran; - } - - public Date getDatumAktualizace() { - return datumAktualizace; - } - - public void setDatumAktualizace(Date datumAktualizace) { - this.datumAktualizace = datumAktualizace; - } - - public int getRokVydani() { - return rokVydani; - } - - public void setRokVydani(int rokVydani) { - this.rokVydani = rokVydani; - } - - public int getAutor() { - return autor; - } - - public void setAutor(int autor) { - this.autor = autor; - } - -} diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java Wed Feb 10 20:55:08 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -package cz.frantovo.springDemo1.web; - -import cz.frantovo.springDemo1.dao.KnihaDAO; -import cz.frantovo.springDemo1.dto.Kniha; -import java.util.Collection; - -/** - * - * @author fiki - */ -public class SpringDemo1Bean { - - public Collection getKnihy() { - KnihaDAO dao = new KnihaDAO(); - return dao.getKnihy(); - } - -} diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/KnihaDAORemote.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/KnihaDAORemote.java Wed Feb 10 21:05:17 2010 +0100 @@ -0,0 +1,16 @@ +package cz.frantovo.springDemo1; + +import cz.frantovo.springDemo1.dto.Kniha; +import java.util.Collection; +import javax.ejb.Remote; + +/** + * + * @author fiki + */ +@Remote +public interface KnihaDAORemote { + + public Collection getKnihy(); + +} diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/dto/Kniha.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/dto/Kniha.java Wed Feb 10 21:05:17 2010 +0100 @@ -0,0 +1,74 @@ +package cz.frantovo.springDemo1.dto; + +import java.util.Date; + +/** + * + * @author fiki + */ +public class Kniha { + private int id; + private String nazev; + private String isbn; + private int pocetStran; + private Date datumAktualizace; + private int rokVydani; + private int autor; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNazev() { + return nazev; + } + + public void setNazev(String nazev) { + this.nazev = nazev; + } + + public String getIsbn() { + return isbn; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + public int getPocetStran() { + return pocetStran; + } + + public void setPocetStran(int pocetStran) { + this.pocetStran = pocetStran; + } + + public Date getDatumAktualizace() { + return datumAktualizace; + } + + public void setDatumAktualizace(Date datumAktualizace) { + this.datumAktualizace = datumAktualizace; + } + + public int getRokVydani() { + return rokVydani; + } + + public void setRokVydani(int rokVydani) { + this.rokVydani = rokVydani; + } + + public int getAutor() { + return autor; + } + + public void setAutor(int autor) { + this.autor = autor; + } + +} diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-war/nbproject/genfiles.properties --- a/java/SpringDemo1/SpringDemo1-war/nbproject/genfiles.properties Wed Feb 10 20:55:08 2010 +0100 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/genfiles.properties Wed Feb 10 21:05:17 2010 +0100 @@ -1,8 +1,8 @@ -build.xml.data.CRC32=dc678faa +build.xml.data.CRC32=aaa9ef7f build.xml.script.CRC32=8b02e3a0 build.xml.stylesheet.CRC32=c0ebde35@1.21.2.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=dc678faa +nbproject/build-impl.xml.data.CRC32=aaa9ef7f nbproject/build-impl.xml.script.CRC32=10b6ccbc nbproject/build-impl.xml.stylesheet.CRC32=b139b33b@1.21.2.1 diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-war/nbproject/project.properties --- a/java/SpringDemo1/SpringDemo1-war/nbproject/project.properties Wed Feb 10 20:55:08 2010 +0100 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/project.properties Wed Feb 10 21:05:17 2010 +0100 @@ -13,7 +13,7 @@ debug.classpath=${build.classes.dir}:${javac.classpath} debug.test.classpath=\ ${run.test.classpath} -display.browser=true +display.browser=false dist.dir=dist dist.ear.war=${dist.dir}/${war.ear.name} dist.javadoc.dir=${dist.dir}/javadoc @@ -54,7 +54,6 @@ javadoc.windowtitle= jspcompilation.classpath=${jspc.classpath}:${javac.classpath} lib.dir=${web.docbase.dir}/WEB-INF/lib -no.dependencies=false persistence.xml.dir=${conf.dir} platform.active=default_platform project.SpringDemo1-ejb=../SpringDemo1-ejb diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-war/nbproject/project.xml --- a/java/SpringDemo1/SpringDemo1-war/nbproject/project.xml Wed Feb 10 20:55:08 2010 +0100 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/project.xml Wed Feb 10 21:05:17 2010 +0100 @@ -17,10 +17,10 @@ - + - + diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/SpringDemo1-war/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/SpringDemo1/SpringDemo1-war/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java Wed Feb 10 21:05:17 2010 +0100 @@ -0,0 +1,39 @@ +package cz.frantovo.springDemo1.web; + +import cz.frantovo.springDemo1.KnihaDAORemote; +import cz.frantovo.springDemo1.dao.KnihaDAO; +import cz.frantovo.springDemo1.dto.Kniha; +import java.util.Collection; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +/** + * + * @author fiki + */ +public class SpringDemo1Bean { + + private static final Logger log = Logger.getLogger(SpringDemo1Bean.class.getSimpleName()); + private KnihaDAORemote knihaDAO; + + public Collection getKnihy() { + return lookupCilDAO().getKnihy(); + } + + private KnihaDAORemote lookupCilDAO() { + if (knihaDAO == null) { + try { + Context c = new InitialContext(); + knihaDAO = (KnihaDAORemote) c.lookup("cz.frantovo.springDemo1.KnihaDAORemote"); + } catch (NamingException e) { + log.log(Level.SEVERE, "Chyba při hledání CilDAO", e); + throw new RuntimeException(e); + } + } + return knihaDAO; + } + +} diff -r 9a3fced9634d -r d549a4eb6aa9 java/SpringDemo1/nbproject/project.properties --- a/java/SpringDemo1/nbproject/project.properties Wed Feb 10 20:55:08 2010 +0100 +++ b/java/SpringDemo1/nbproject/project.properties Wed Feb 10 21:05:17 2010 +0100 @@ -4,7 +4,7 @@ client.module.uri=SpringDemo1-war client.urlPart= debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath} -display.browser=true +display.browser=false dist.dir=dist dist.jar=${dist.dir}/${jar.name} endorsed.classpath=\ @@ -30,4 +30,5 @@ reference.SpringDemo1-ejb.dist-ear=${project.SpringDemo1-ejb}/dist/SpringDemo1-ejb.jar reference.SpringDemo1-war.dist-ear=${project.SpringDemo1-war}/dist/SpringDemo1-war.war resource.dir=setup +run.classpath= source.root=.