1 / 34

SCE - 3a מרכיבים: קשרים דר’ יעקב אקסמן תשס"ו

SCE - 3a מרכיבים: קשרים דר’ יעקב אקסמן תשס"ו. הנדסת מרכיבי תוכנה. דרישות תוכנה. דגם הייררכי. דגם פיזיקלי. מרכיבים. קוד להרצה = exe. מדידות. מרכיבים סיווג. Produces output?. YES. NO. Transceives Data?. Specific function?. YES. NO. YES. NO. ?. Remote?. YES. YES. NO.

roxy
Download Presentation

SCE - 3a מרכיבים: קשרים דר’ יעקב אקסמן תשס"ו

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SCE-3a מרכיבים: קשרים דר’ יעקב אקסמן תשס"ו

  2. הנדסת מרכיבי תוכנה דרישות תוכנה דגםהייררכי דגםפיזיקלי מרכיבים קוד להרצה = exe מדידות

  3. מרכיבים סיווג Produces output? YES NO Transceives Data? Specific function? YES NO YES NO ? Remote? YES YES NO Object Aspect Connector Gluon

  4. מרכיבים קשרים קשרים (Connectors) מרכיבים שמעבירים נתונים למרחקים. לא יוצרים פלט משל עצמם.

  5. מרכיבים קשרים • למה קשרים? • גישת מרכיבים - לשקעים (sockets) • ייחודיות לתקשורת – טיפול שקוף לבעיות • כגון "מסדור" (marshalling, serialization) • תבניות ברמת שפה – עיין תבניות תיכון • כגון Proxy, Adapter

  6. קשרים ספרות [ASCN-2003] J. Aldrich, V. Sazawal, C. Chambers & D. Notkin “Language Support for Connector Abstractions” ecoop – 2003. [CAN-2002] J. Aldrich, C. Chambers & D. Notkin “ArchJava: Connecting Software Architecture to Implementation” Proc. Int. Conf. SE, Orland, FL – 2002.

  7. קשרים סוגי סמנטיקה ניתן להחליף קשרים בלי להשפיע על מרכיבים אחרים • קריאות (calls) • אירועים (events) • זיכרון משותף (shared memory) • זרמים (streams) • "רמזורים" (semaphores)

  8. קשרים תכונות תקשורת • רוחב סרט (bandwidth) • תזמון (synchronicity) • אמינות (reliability) • פרוטוקול תעבורה (wire protocol)

  9. קשרים ArchJava אתר: www.archjava.org מהדר: archj Eclipse plugin: ArchJava.Eclipse-1.3.1.zip

  10. קשרים ArchJava • ?ArchJava למה • מוחשי – להבנת מושגים • סייג – לאו דווקא התחביר הרצוי • ריבוי שפות – בעייתי

  11. קשרים ArchJava הייררכיית מושגים מרכיב= Component [הקשר עצמו] שער = Port שיטה = Method

  12. קשרים שערים ב- ArchJava • Port methods • provides • - מסופק (ממומש) במרכיב • - ניתן לקריאה ע"י מרכיבים אחרים • requires • - נדרש להיות מסופק • ע"י מרכיב אחר שמתקשר אותו שער יכול להכיל בו-זמנית גם שיטות מסופקות וגם נדרשות

  13. קשרים דוגמה: PoemSwap יישום בין עמיתים (peer-to-peer) לשיתוף שירה ה"קשר" PoemPeer הוא ממשק לרשת של היישום PoemSwap

  14. קשרים דוגמת Component Class שערי יישום public component class PoemPeer { public portsearch {//port = אפשר להתייחס כמו עצם ממש providesPoemDesc[ ] search(PoemDesc partialDesc) throws IOException; provides void downloadPoem(PoemDesc desc) throws IOException; } public portpoems { requiresPoemDesc[ ] getPoemDescs( ); requires Poem getPoem(PoemDesc desc); requires void addPoem(Poem poem);}

  15. קשרים דוגמת Component Class שערים בממשקי תקשורת public component class PoemPeer { public port interfaceclient{ //port interface = כמו מחלקה requires client(InetAddress address) throws IOException; //constructor requires PoemDesc[ ] search(PoemDesc partialDesc, int hops, Nonce n); requires Poem download(PoemDesc desc); } //התאמה public port interfaceserver{ provides PoemDesc[ ] search(PoemDesc partialDesc, int hops, Nonce n); provides Poem download(PoemDesc desc); } עמית (peer) הוא גם שרת וגם לקוח

  16. קשרים דוגמת Component Class מימוש קוד המחלקה public component class PoemPeer { … void downloadPoem(PoemDesc desc) throws IOException { client peer = new client(desc.getAddress( )); Poem newPoem = peer.download(desc); if (newPoem != null) { poems.addPoem(newPoem); //port =!עצם ממש } } // other method definitions... }

  17. קשרים דוגמה: PoemSwap public component class PoemSwap { private final SwapUI ui = new SwapUI( ); private final PoemStore store = new PoemStore( ); private final PoemPeer peer = new PoemPeer( ); connect patternSwapUI.poems, PoemStore.poems; connect pattern PoemPeer.poems, PoemStore.poems; connect pattern SwapUI.search, PoemPeer.search; הייררכיה! ליישום PoemSwap שלושה תת-מרכיבים: ה"קשר" PoemPeer,והעצמים SwapUI, PoemStore

  18. קשרים מושגי ArchJava • Connect Pattern • תבנית קישור: • קישור שמותר ליצור • בין 2 או יותר שערים • Connect expression • קישור בפועל • בשיטות של המרכיב

  19. קשרים דוגמה קישורים בפועל public component class PoemSwap { … public PoemSwap( ) { //constructor TCPConnector.registerObject(peer, POEM_PORT, “server”); connect(ui.poems, store.poems); connect(peer.poems, store.poems); connect(ui.search, peer.search); } לא חובה לממש בפועל Connection Patterns כאן שלושתם ממומשים ע"י connect

  20. קשרים דוגמה: קישור בין מכונות שונות • connect pattern PoemPeer.client, PoemPeer.server withTCPConnector { • client(PoemPeer sender, InetAddress address) throws IOException { • connect(sender.client, PoemPeer.server) • with new TCPConnector(address, POEM_PORT, “server”); • } • };

  21. קשרים דוגמה שניה הרחבת קשר בסיסי: עם מטמון public class CachingConnectorextendsConnector { protected Map cache = new Hashtable( ); public Object invoke(Call call) throws Throwable { List arguments = Arrays.asList(call.getArguments( )); Object result = cache.get(arguments); if (result != null) return result; result = super.invoke(call); if (result != null) cache.put(arguments, result); return result; }}

  22. קשרים דוגמה שלישית משימות גינון

  23. קשרים ב-JAVA protected void handleMessageIn(Message m) { … } else if (msg instanceof PlantInfoReply) { PlantInfoReply p = (PlantInfoReply) msg; // case for plant info message careMap.put(p.name,p); state = AWAITING_TASKS; sendTasksRequest(); return; } else if (msg instanceof TaskListReply) { // case for task reply message below... } protected void sendTasksRequest( ) { try { TaskListQuery q = new TaskListQuery(); q.list = "Water Plants"; sendMessage(taskServer,q,newClosure()); } catch (Exception ex) { // an error occurred, restart the cycle ex.printStackTrace(); resetState(); }} קוד ללא הפשטה: כל מסר מפורש

  24. קשרים הפשטת תקשורת: ArchJava void infoReply(PlantInfoReply data) { careMap.put(data.name, data); state = AWAITING_TASKS; try { TaskPort.taskQuery("Water Plants"); } catch (Exception ex) { // an error occurred, restart the cycle ex.printStackTrace(); resetState(); }}

  25. קשרים סיכום ביניים מרוויחיםמה מבחינת ארכיטקטורת המערכת?

  26. קשרים בדיקתיות התאמה אוטומטית של מרכיבים • בדיקת סיפוק הדרישות ברמת השפה: • התאמה בין Requiresלבין Provides • בדיקת serializability של נתונים

  27. קשרים UML2 נסיון לבטא קשרים ב-UML2

  28. קשרים ספרות: UML2 [ICGNSO-2004] J. Ivers, P. Clements, D. Garlan et al. “Documenting Architectural Connectors with UML2” CMU-2004

  29. קשרים UML2 יש ב-UML2 מושגים חדשים כמו Connectorו- Port אך הסמנטיקה מוגבלת.

  30. קשרים ב-UML2 בתור Association Classes תוספת קשרים לשערים

  31. קשרים ב-UML2 בתור Classesעם stereotype <<Connector>> stereotype

  32. קשרים ב-UML2 UML2 לא פותר את בעיית הייצוג של קשרים

  33. מרכיבים סיווג Produces output? YES NO Transceives Data? Specific function? YES NO YES NO ? Remote? YES YES NO Object Aspect Connector Gluon

  34. מרכיבים דביקונים דביקונים (Gluons) מרכיבים שמתאמים בין מרכיבים קרובים. לא יוצרים פלט משל עצמם.

More Related