🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #141860

Re: Ciekawy problem projektowy

#141860
From: Rafal
Date: Tue, 21 Oct 2008 21:45
54 lines
2768 bytes
Dnia Tue, 21 Oct 2008 22:04:01 +0200, Mateusz Ludwin napisał(a):

> Rafal rzecze:
> 
>> Inaczej: obiekt dao ma zarejestrowanych dwóch słuchaczy i równolegle
>> wykonuje 2 operacje raportowe. Skąd biedne DAO ma wiedzieć, któremu
>> słuchaczowi jaką informację o postępie wysłać? :)
> 
> No właśnie, skąd? Czemu zrobiłeś DAO singletonem?

Bo tak już było. :)
Poza tym wyczytałem gdzieś, że beany usług i dao (i większość springowych) 
powinny być singletonami.
Poza tym domyślnie spring tworzy singletony zamiast prototype.

O już mam:
"The following diagram illustrates the Spring prototype scope. Please note 
that a DAO would not typically be configured as a prototype, since a 
typical DAO would not hold any conversational state; it was just easier for 
this author to reuse the core of the singleton diagram."
Żródło: 
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-prototype



Ps. Ale załóżmy, że DAO jednak nie jest singletonem, SERVICE wtedy również 
nie może być singletonem, nie? Hmm. Muszę doczytać o prototype w Springu bo 
faktycznie nie pamietam kiedy to używałem.
Do MB jest wstrzykiwany service a do niego dao.

Wydaje mi się, że przy użyciu prototype może bardzo ucierpieć na tym 
wydajność - przy każdym dostępie do warstwy usług jest tworzony nowy obiekt 
service (opakowanie w transakcje itd, itp) i dao (tu pewnie też jakieś 
dodatkowe operacje)... :(
Choć wtedy mógłby zapamietywać w tych dao stan postępu.

Z wewnatrz MB bym zrobiłbym cos takiego:
service.getDao().addListener(this);
service.getDao().reportMethod();
service.getDao().removeListener(this);


Ps2. Chociaż cos takiego też jest nie ładne bo service to interfejs i nie 
powinien mieć metody getDao() ...

Hmm. Ciężkie jest życie programisty purysty. :)





-- 
Pozdrawiam
Rafal
Technical Details
Message-ID: <7fv22mbe84pj.1kzjyp0zes8n4$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!lublin.pl!news.lublin.pl!not-for-mail
References: <1gftxd4rvd75r.40k8q597vzs8.dlg@40tude.net> <gdljki.f0.1@teren.hamstera.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!lublin.pl!news.lublin.pl!not-for-mail
From: Rafal <rl@NOSPAM.adrem.pl>
Newsgroups: pl.comp.lang.java
Subject: Re: Ciekawy problem projektowy
Date: Tue, 21 Oct 2008 23:45:58 +0200
Organization: lubman
Lines: 54
Message-ID: <7fv22mbe84pj.1kzjyp0zes8n4$.dlg@40tude.net>
References: <1gftxd4rvd75r.40k8q597vzs8.dlg@40tude.net> <gdljki.f0.1@teren.hamstera.pl>
NNTP-Posting-Host: host-89-167-54-129.pronet.lublin.pl
Mime-Version: 1.0
X-Trace: news.lublin.pl 1224625559 17898 89.167.54.129 (21 Oct 2008 21:45:59 GMT)
X-Complaints-To: abuse@news.lublin.pl
NNTP-Posting-Date: Tue, 21 Oct 2008 21:45:59 +0000 (UTC)
User-Agent: 40tude_Dialog/2.0.15.1pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit