[Javalist] Spring kerdesek

aszomor at szomor.hu aszomor at szomor.hu
2012. Jún. 5., K, 09:22:37 CEST


Hali,

Ha nem megy a DI, vedd elő Service Locator-al (elég csúnya hack, de  
valószínűleg a GWT bekavar).

Attila.


Idézet (zamek <zamek at vili.pmmf.hu>):

> hello,
>
> 06/04/2012 04:02 PM keltezéssel, cx.chico írta:
>> @Autowired vagy @Resource :)
>>
>> A példa:
>>
>> @Component
>> public class PollingService {
>> }
>>
>> @Service("getDeviceData")
>> public class DeviceServiceImpl extends RemoteServiceServlet implements
>>         DeviceService {
>>
>>     @Autowired
>>     private PollingService pollingService;
>>
>> (...)
> Ezt probaltam, nem mukodott:
>
> Could not autowire field:  
> com.zamek.monitor.gwt.server.PollingService  
> com.zamek.monitor.gwt.server.device.communication.DeviceServiceImpl.pollingService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.zamek.monitor.gwt.server.PollingService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:  
> {@org.springframework.beans.factory.annotation.Autowired(required=true)}
>
> A PollingService-ben meg kellene valami?
>> Az @Autowired annotáció típus alapján működik, ha jól emlékszem, akkor
>> az AOP proxy miatt lehet, hogy interface-t kell megadni.
>> A @Scope("prototype") azt jelenti, hogy minden új session-ben
>> automatikusan létrejön egy ilyen példány. Ha nem kezelsz session-t
>> (userek)  nincs rá szükséged, csak bajt csinál.
>>
>> Mivel az alkalmazásban már van egy @Service, szerintem megoldható a
>> feladat helper-ként is:
>>
>> @Service("getDeviceData")
>> public class DeviceServiceImpl extends RemoteServiceServlet implements
>>         DeviceService {
>>
>>     private PollingService pollingService = new PollingService();
>>
>> (...)
>>
> Az nem jo, az kellene, hogy a PollingService allandoan letezzen  
> pontosan egy peldanyban, ez a hatterben egy szalban lekerdezi a  
> plc-ket. Ezt kerdezgeti a DeviceServiceImpl, amikor egy kliens akarja.
>
> EJB-ben ez igy nez ki:
>
> A PollingSevice egy @Singleton annotacioval keszult Bean.
> A @PostConstruct  metodusaban indit egy timert, aminek a lejartakor  
> vegigkerdezi a plc-ket, majd ujrahuzza magat.
>
> -- 
>  thx,
> ----------------------------------
> Zoltan Zidarics programmer
> PTE-PMMFK H-7621 Pecs, Boszorkany u. 2. Hungary
> E-Mail: zamek at vili.pmmf.hu
> ----------------------------------
>       _______________________________________________
> Javalist mailing list
> Javalist at lists.javaforum.hu
> http://lists.javaforum.hu/mailman/listinfo/javalist
>




További információk a(z) Javalist levelezőlistáról