Funkční EJB.
1.1 --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dao/KnihaDAO.java Wed Feb 10 20:55:08 2010 +0100
1.2 +++ b/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dao/KnihaDAO.java Wed Feb 10 21:05:17 2010 +0100
1.3 @@ -1,27 +1,24 @@
1.4 package cz.frantovo.springDemo1.dao;
1.5
1.6 +import cz.frantovo.springDemo1.KnihaDAORemote;
1.7 import cz.frantovo.springDemo1.dto.Kniha;
1.8 import java.util.ArrayList;
1.9 import java.util.Collection;
1.10 import javax.annotation.Resource;
1.11 +import javax.ejb.Stateless;
1.12 import javax.sql.DataSource;
1.13 import org.springframework.jdbc.core.JdbcTemplate;
1.14 -import org.springframework.stereotype.Repository;
1.15
1.16 /**
1.17 *
1.18 * @author fiki
1.19 */
1.20 -@Repository("knihaDAO")
1.21 -public class KnihaDAO {
1.22 +@Stateless
1.23 +public class KnihaDAO implements KnihaDAORemote {
1.24
1.25 + @Resource(mappedName="jdbc/sqlVyuka/piskoviste")
1.26 private DataSource dataSource;
1.27
1.28 - @Resource
1.29 - public void setDataSource(DataSource dataSource) {
1.30 - this.dataSource = dataSource;
1.31 - }
1.32 -
1.33 public Collection<Kniha> getKnihy() {
1.34 Collection<Kniha> vysledek = new ArrayList<Kniha>();
1.35
2.1 --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/dto/Kniha.java Wed Feb 10 20:55:08 2010 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,74 +0,0 @@
2.4 -package cz.frantovo.springDemo1.dto;
2.5 -
2.6 -import java.util.Date;
2.7 -
2.8 -/**
2.9 - *
2.10 - * @author fiki
2.11 - */
2.12 -public class Kniha {
2.13 - private int id;
2.14 - private String nazev;
2.15 - private String isbn;
2.16 - private int pocetStran;
2.17 - private Date datumAktualizace;
2.18 - private int rokVydani;
2.19 - private int autor;
2.20 -
2.21 - public int getId() {
2.22 - return id;
2.23 - }
2.24 -
2.25 - public void setId(int id) {
2.26 - this.id = id;
2.27 - }
2.28 -
2.29 - public String getNazev() {
2.30 - return nazev;
2.31 - }
2.32 -
2.33 - public void setNazev(String nazev) {
2.34 - this.nazev = nazev;
2.35 - }
2.36 -
2.37 - public String getIsbn() {
2.38 - return isbn;
2.39 - }
2.40 -
2.41 - public void setIsbn(String isbn) {
2.42 - this.isbn = isbn;
2.43 - }
2.44 -
2.45 - public int getPocetStran() {
2.46 - return pocetStran;
2.47 - }
2.48 -
2.49 - public void setPocetStran(int pocetStran) {
2.50 - this.pocetStran = pocetStran;
2.51 - }
2.52 -
2.53 - public Date getDatumAktualizace() {
2.54 - return datumAktualizace;
2.55 - }
2.56 -
2.57 - public void setDatumAktualizace(Date datumAktualizace) {
2.58 - this.datumAktualizace = datumAktualizace;
2.59 - }
2.60 -
2.61 - public int getRokVydani() {
2.62 - return rokVydani;
2.63 - }
2.64 -
2.65 - public void setRokVydani(int rokVydani) {
2.66 - this.rokVydani = rokVydani;
2.67 - }
2.68 -
2.69 - public int getAutor() {
2.70 - return autor;
2.71 - }
2.72 -
2.73 - public void setAutor(int autor) {
2.74 - this.autor = autor;
2.75 - }
2.76 -
2.77 -}
3.1 --- a/java/SpringDemo1/SpringDemo1-ejb/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java Wed Feb 10 20:55:08 2010 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,18 +0,0 @@
3.4 -package cz.frantovo.springDemo1.web;
3.5 -
3.6 -import cz.frantovo.springDemo1.dao.KnihaDAO;
3.7 -import cz.frantovo.springDemo1.dto.Kniha;
3.8 -import java.util.Collection;
3.9 -
3.10 -/**
3.11 - *
3.12 - * @author fiki
3.13 - */
3.14 -public class SpringDemo1Bean {
3.15 -
3.16 - public Collection<Kniha> getKnihy() {
3.17 - KnihaDAO dao = new KnihaDAO();
3.18 - return dao.getKnihy();
3.19 - }
3.20 -
3.21 -}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/KnihaDAORemote.java Wed Feb 10 21:05:17 2010 +0100
4.3 @@ -0,0 +1,16 @@
4.4 +package cz.frantovo.springDemo1;
4.5 +
4.6 +import cz.frantovo.springDemo1.dto.Kniha;
4.7 +import java.util.Collection;
4.8 +import javax.ejb.Remote;
4.9 +
4.10 +/**
4.11 + *
4.12 + * @author fiki
4.13 + */
4.14 +@Remote
4.15 +public interface KnihaDAORemote {
4.16 +
4.17 + public Collection<Kniha> getKnihy();
4.18 +
4.19 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/java/SpringDemo1/SpringDemo1-lib/src/cz/frantovo/springDemo1/dto/Kniha.java Wed Feb 10 21:05:17 2010 +0100
5.3 @@ -0,0 +1,74 @@
5.4 +package cz.frantovo.springDemo1.dto;
5.5 +
5.6 +import java.util.Date;
5.7 +
5.8 +/**
5.9 + *
5.10 + * @author fiki
5.11 + */
5.12 +public class Kniha {
5.13 + private int id;
5.14 + private String nazev;
5.15 + private String isbn;
5.16 + private int pocetStran;
5.17 + private Date datumAktualizace;
5.18 + private int rokVydani;
5.19 + private int autor;
5.20 +
5.21 + public int getId() {
5.22 + return id;
5.23 + }
5.24 +
5.25 + public void setId(int id) {
5.26 + this.id = id;
5.27 + }
5.28 +
5.29 + public String getNazev() {
5.30 + return nazev;
5.31 + }
5.32 +
5.33 + public void setNazev(String nazev) {
5.34 + this.nazev = nazev;
5.35 + }
5.36 +
5.37 + public String getIsbn() {
5.38 + return isbn;
5.39 + }
5.40 +
5.41 + public void setIsbn(String isbn) {
5.42 + this.isbn = isbn;
5.43 + }
5.44 +
5.45 + public int getPocetStran() {
5.46 + return pocetStran;
5.47 + }
5.48 +
5.49 + public void setPocetStran(int pocetStran) {
5.50 + this.pocetStran = pocetStran;
5.51 + }
5.52 +
5.53 + public Date getDatumAktualizace() {
5.54 + return datumAktualizace;
5.55 + }
5.56 +
5.57 + public void setDatumAktualizace(Date datumAktualizace) {
5.58 + this.datumAktualizace = datumAktualizace;
5.59 + }
5.60 +
5.61 + public int getRokVydani() {
5.62 + return rokVydani;
5.63 + }
5.64 +
5.65 + public void setRokVydani(int rokVydani) {
5.66 + this.rokVydani = rokVydani;
5.67 + }
5.68 +
5.69 + public int getAutor() {
5.70 + return autor;
5.71 + }
5.72 +
5.73 + public void setAutor(int autor) {
5.74 + this.autor = autor;
5.75 + }
5.76 +
5.77 +}
6.1 --- a/java/SpringDemo1/SpringDemo1-war/nbproject/genfiles.properties Wed Feb 10 20:55:08 2010 +0100
6.2 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/genfiles.properties Wed Feb 10 21:05:17 2010 +0100
6.3 @@ -1,8 +1,8 @@
6.4 -build.xml.data.CRC32=dc678faa
6.5 +build.xml.data.CRC32=aaa9ef7f
6.6 build.xml.script.CRC32=8b02e3a0
6.7 build.xml.stylesheet.CRC32=c0ebde35@1.21.2.1
6.8 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
6.9 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6.10 -nbproject/build-impl.xml.data.CRC32=dc678faa
6.11 +nbproject/build-impl.xml.data.CRC32=aaa9ef7f
6.12 nbproject/build-impl.xml.script.CRC32=10b6ccbc
6.13 nbproject/build-impl.xml.stylesheet.CRC32=b139b33b@1.21.2.1
7.1 --- a/java/SpringDemo1/SpringDemo1-war/nbproject/project.properties Wed Feb 10 20:55:08 2010 +0100
7.2 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/project.properties Wed Feb 10 21:05:17 2010 +0100
7.3 @@ -13,7 +13,7 @@
7.4 debug.classpath=${build.classes.dir}:${javac.classpath}
7.5 debug.test.classpath=\
7.6 ${run.test.classpath}
7.7 -display.browser=true
7.8 +display.browser=false
7.9 dist.dir=dist
7.10 dist.ear.war=${dist.dir}/${war.ear.name}
7.11 dist.javadoc.dir=${dist.dir}/javadoc
7.12 @@ -54,7 +54,6 @@
7.13 javadoc.windowtitle=
7.14 jspcompilation.classpath=${jspc.classpath}:${javac.classpath}
7.15 lib.dir=${web.docbase.dir}/WEB-INF/lib
7.16 -no.dependencies=false
7.17 persistence.xml.dir=${conf.dir}
7.18 platform.active=default_platform
7.19 project.SpringDemo1-ejb=../SpringDemo1-ejb
8.1 --- a/java/SpringDemo1/SpringDemo1-war/nbproject/project.xml Wed Feb 10 20:55:08 2010 +0100
8.2 +++ b/java/SpringDemo1/SpringDemo1-war/nbproject/project.xml Wed Feb 10 21:05:17 2010 +0100
8.3 @@ -17,10 +17,10 @@
8.4 </web-module-libraries>
8.5 <web-module-additional-libraries/>
8.6 <source-roots>
8.7 - <root id="src.dir" name="Source Packages"/>
8.8 + <root id="src.dir"/>
8.9 </source-roots>
8.10 <test-roots>
8.11 - <root id="test.src.dir" name="Test Packages"/>
8.12 + <root id="test.src.dir"/>
8.13 </test-roots>
8.14 </data>
8.15 <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/java/SpringDemo1/SpringDemo1-war/src/java/cz/frantovo/springDemo1/web/SpringDemo1Bean.java Wed Feb 10 21:05:17 2010 +0100
9.3 @@ -0,0 +1,39 @@
9.4 +package cz.frantovo.springDemo1.web;
9.5 +
9.6 +import cz.frantovo.springDemo1.KnihaDAORemote;
9.7 +import cz.frantovo.springDemo1.dao.KnihaDAO;
9.8 +import cz.frantovo.springDemo1.dto.Kniha;
9.9 +import java.util.Collection;
9.10 +import java.util.logging.Level;
9.11 +import java.util.logging.Logger;
9.12 +import javax.naming.Context;
9.13 +import javax.naming.InitialContext;
9.14 +import javax.naming.NamingException;
9.15 +
9.16 +/**
9.17 + *
9.18 + * @author fiki
9.19 + */
9.20 +public class SpringDemo1Bean {
9.21 +
9.22 + private static final Logger log = Logger.getLogger(SpringDemo1Bean.class.getSimpleName());
9.23 + private KnihaDAORemote knihaDAO;
9.24 +
9.25 + public Collection<Kniha> getKnihy() {
9.26 + return lookupCilDAO().getKnihy();
9.27 + }
9.28 +
9.29 + private KnihaDAORemote lookupCilDAO() {
9.30 + if (knihaDAO == null) {
9.31 + try {
9.32 + Context c = new InitialContext();
9.33 + knihaDAO = (KnihaDAORemote) c.lookup("cz.frantovo.springDemo1.KnihaDAORemote");
9.34 + } catch (NamingException e) {
9.35 + log.log(Level.SEVERE, "Chyba při hledání CilDAO", e);
9.36 + throw new RuntimeException(e);
9.37 + }
9.38 + }
9.39 + return knihaDAO;
9.40 + }
9.41 +
9.42 +}
10.1 --- a/java/SpringDemo1/nbproject/project.properties Wed Feb 10 20:55:08 2010 +0100
10.2 +++ b/java/SpringDemo1/nbproject/project.properties Wed Feb 10 21:05:17 2010 +0100
10.3 @@ -4,7 +4,7 @@
10.4 client.module.uri=SpringDemo1-war
10.5 client.urlPart=
10.6 debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath}
10.7 -display.browser=true
10.8 +display.browser=false
10.9 dist.dir=dist
10.10 dist.jar=${dist.dir}/${jar.name}
10.11 endorsed.classpath=\
10.12 @@ -30,4 +30,5 @@
10.13 reference.SpringDemo1-ejb.dist-ear=${project.SpringDemo1-ejb}/dist/SpringDemo1-ejb.jar
10.14 reference.SpringDemo1-war.dist-ear=${project.SpringDemo1-war}/dist/SpringDemo1-war.war
10.15 resource.dir=setup
10.16 +run.classpath=
10.17 source.root=.