WEB开发网
开发学院软件开发Java Java 理论与实践: 平衡测试,第 3 部分:用方面检... 阅读

Java 理论与实践: 平衡测试,第 3 部分:用方面检验设计约束

 2010-01-11 00:00:00 来源:WEB开发网   
核心提示: 清单 3. 实施 Swing 的单线程规则的方面publicaspectSwingThreadAspect{pointcutswingMethods():call(*javax.swing..*.*(..))||call(javax.swing..*.new(..));pointcutexten


清单 3. 实施 Swing 的单线程规则的方面
public aspect SwingThreadAspect { 
 
 pointcut swingMethods() : call(* javax.swing..*.*(..)) 
    || call(javax.swing..*.new(..)); 
 
 pointcut extendsSwing() : call(* javax.swing.JComponent+.*(..)) 
    || call(* javax.swing..*Model+.*(..)) 
    || call(* javax.swing.text.Document+.*(..)); 
 
 pointcut safeMethods() : call(void JComponent.revalidate()) 
    || call(void JComponent.invalidate(..)) 
    || call(void JComponent.repaint(..)) 
    || call(void add*Listener(EventListener+)) 
    || call(void remove*Listener(EventListener+)) 
    || call(boolean SwingUtilities.isEventDispatchThread()) 
    || call(void SwingUtilities.invokeLater(Runnable)) 
    || call(void SwingUtilities.invokeAndWait(Runnable)) 
    || call(void JTextPane.replaceSelection(..)) 
    || call(void JTextPane.insertComponent(..)) 
    || call(void JTextPane.insertIcon(..)) 
    || call(void JTextPane.setLogicalStyle(..)) 
    || call(void JTextPane.setCharacterAttributes(..)) 
    || call(void JTextPane.setParagraphAttributes(..)); 
 
 pointcut edtMethods() : (swingMethods() || extendsSwing()) && !safeMethods(); 
 
 before() : edtMethods() { 
 if (!SwingUtilities.isEventDispatchThread()) 
  throw new AssertionError(thisJoinPointStaticPart.getSignature() 
   + " called from " + Thread.currentThread().getName()); 
 } 
} 

上一页  1 2 3 4 5 6 7  下一页

Tags:Java 理论 实践

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接