目前我也不是很懂這個框架,但已試驗成功,故記錄之。
畢竟只是改代碼,不是在寫代碼。
1.在composite組件中配置
<sca:component name="ManageFiles">
<sca:implementation.java class="com.xx.xx.xx.ManageFiles"/>
</sca:component>
別忘了佈局.composite_graphic
<componentgraphic name="ManageFiles">
<constraint>
<height>103</height>
<width>178</width>
<x>755</x>
<y>437</y>
<location>
<x>755</x>
<y>437</y>
</location>
<size>
<width>178</width>
<height>103</height>
</size>
</constraint>
</componentgraphic>
當然,要是我會直接拖動組件的話,就不用這麼麻煩了
2.在類前加上註解
@Composite
@EagerInit
protected ScheduledExecutorService executor;
Runnable r = new Runnable ()
測試代碼:
@Composite
@EagerInit
public class ManageFiles {
@Resource
protected ScheduledExecutorService executor;
@Init
public void call () {
Runnable r = new Runnable () {
@Override
public void run() {
try {
System.out.println("啦啦啦啦啦啦啦");
} catch (Throwable e) {
e.printStackTrace();
}
}
};
// 每十秒執行一次
executor.scheduleAtFixedRate(r, 0, 10, TimeUnit.SECONDS);
}
}