Closed zalizko closed 11 years ago
Hi.
I've never tested it. Your ProjectsPanel has session scope. What scope have other UI components?
Another one is:
@Component
@Scope("prototype")
public class MyVaadinUI extends UI {
@Autowired
ProjectsPanel projectsPanel;
@Override
protected void init(VaadinRequest request) {
final HorizontalLayout layout = new HorizontalLayout();
layout.setMargin(true);
setContent(layout);
layout.addComponent(projectsPanel);
}
}
UI has a prototype scope. Several UI instances have the same ProjectsPanel? Is this working well?
Actually I don't know :-) For now I have only one UI and I don't need more UI's ..
MyVaadinUI has a prototype scope. For each new page, it'll create new instance. They'll use the same ProjectsPanel instance. I don't think that's working well. I can try to test it, later.
It seems that problem is in spring and not in your addon. I just created the basic Spring Application and tested Scheduled annotation on it. Works only in singleton scoped beans.
schedulingTest/src/main/java/ee/zalizko/study/springscheduling/HelloApp.java:
public class HelloApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
HelloService helloService = context.getBean(HelloService.class);
System.out.println(helloService.sayHello());
}
}
schedulingTest/src/main/java/ee/zalizko/study/springscheduling/HelloService.java:
@Component
@Scope("prototype")
public class HelloService {
public String sayHello() {
return "Hello world!";
}
@Scheduled(fixedDelay = 1000)
public void someJob() {
System.out.println("job");
}
}
schedulingTest/src/main/resources/spring-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tasks="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<context:annotation-config />
<tasks:annotation-driven />
<context:component-scan base-package="ee.zalizko.study.springscheduling"/>
</beans>
As a result in console only:
Hello world!
If scope is not defined obviously (singleton scope) then scheduling works fine.
Was anyone able to schedule in prototype scoped bean?
Hi, did u tested spring scheduling with all scopes?
Maybe problem not in your plugin, but in my application scheduling works only in prototype scoped bean ... if I set (as needed) session scope - scheduling does not working. In Spring documentation I did not found any requirements related to scope in scheduling context.