Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts

50 %
50 %
Information about Managing the Evolution of Aspect-Oriented Software with Model-based...
Technology

Published on February 2, 2009

Author: kim.mens

Source: slideshare.net

Description

Presentation of our ECOOP 2006 paper:

A. KELLENS, K. MENS, J. BRICHAU & K. GYBELS.
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts.
Proceedings of the European Conference on Object-Oriented Programming (ECOOP 2006), D. Thomas (Ed.), LNCS 4067, Springer-Verlag, pp. 501–525, 2006.

Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts Andy Kellens Kim Mens Johan Brichau Kris Gybels 1

Crosscutting Concerns */ public class FileDownload { Synchronisation public static void download(String address, String localFileName) { OutputStream out = null; URLConnection conn = null; InputStream in = null; try { URL url = new URL(address); out = new BufferedOutputStream( new FileOutputStream(localFileName)); import java.io.*; import java.util.zip.*; conn = url.openConnection(); in = conn.getInputStream(); /** * Command line program to copy a file to another directory. byte[] buffer = new byte[1024]; * @author Marco Schmidt int numRead; */ public class CopyFile { long numWritten = 0; // constant values for the override option while ((numRead = in.read(buffer)) != -1) { public static final int OVERWRITE_ALWAYS = 1; public static final int OVERWRITE_NEVER = 2; out.write(buffer, 0, numRead); public static final int OVERWRITE_ASK = 3; numWritten += numRead; // program options initialized to default values } private static int bufferSize = 4 * 1024; System.out.println(localFileName + quot;tquot; + numWritten); private static boolean clock = true; private static boolean copyOriginalTimestamp = true; } catch (Exception exception) { private static boolean verify = true; exception.printStackTrace(); private static int override = OVERWRITE_ASK; } finally { public static Long copyFile(File srcFile, File destFile) try { throws IOException { InputStream in = new FileInputStream(srcFile); if (in != null) { OutputStream out = new FileOutputStream(destFile); in.close(); long millis = System.currentTimeMillis(); UI dependency CRC32 checksum = null; } if (verify) { if (out != null) { checksum = new CRC32(); checksum.reset(); out.close(); } } byte[] buffer = new byte[bufferSize]; int bytesRead; } catch (IOException ioe) { while ((bytesRead = in.read(buffer)) >= 0) { } if (verify) { checksum.update(buffer, 0, bytesRead); } } } out.write(buffer, 0, bytesRead); } out.close(); public static void download(String address) { in.close(); if (clock) { int lastSlashIndex = address.lastIndexOf('/'); millis = System.currentTimeMillis() - millis; if (lastSlashIndex >= 0 && System.out.println(quot;Second(s): quot; + (millis/1000L)); } lastSlashIndex < address.length() - 1) { if (verify) { download(address, address.substring(lastSlashIndex + 1)); return new Long(checksum.getValue()); } else { } else { return null; System.err.println(quot;Could not figure out local file name for quot; + } } address); } public static Long createChecksum(File file) throws IOException { long millis = System.currentTimeMillis(); } InputStream in = new FileInputStream(file); CRC32 checksum = new CRC32(); checksum.reset(); public static void main(String[] args) { byte[] buffer = new byte[bufferSize]; for (int i = 0; i < args.length; i++) { int bytesRead; while ((bytesRead = in.read(buffer)) >= 0) { download(args[i]); checksum.update(buffer, 0, bytesRead); } } in.close(); } if (clock) { } millis = System.currentTimeMillis() - millis; System.out.println(quot;Second(s): quot; + (millis/1000L)); } return new Long(checksum.getValue()); } /** */ * Determine if data is to be copied to given file. public class HappyNewYear implements Runnable * Take into consideration override option and * ask user in case file exists and override option is ask. { * @param file File object for potential destination file private static NumberFormat formatter = NumberFormat.getInstance(); * @return true if data is to be copied to file, false if not */ private JFrame frame; public static boolean doCopy(File file) { private JLabel label; boolean exists = file.exists(); if (override == OVERWRITE_ALWAYS || !exists) { private long newYearMillis; return true; private String message; } else if (override == OVERWRITE_NEVER) { return false; public HappyNewYear(JFrame frame, JLabel label) } else if (override == OVERWRITE_ASK) { { return readYesNoFromStandardInput(quot;File exists. quot; + // store argument GUI elements quot;Overwrite (y/n)?quot;); } else { this.frame = frame; throw new InternalError(quot;Program error. Invalid quot; + this.label = label; quot;value for override: quot; + override); } // compute beginning of next year } Calendar cal = new GregorianCalendar(); public static void main(String[] args) throws IOException { int nextYear = cal.get(Calendar.YEAR) + 1; // make sure there are exactly two arguments cal.set(Calendar.YEAR, nextYear); if (args.length != 2) { System.err.println(quot;Usage: CopyFile SRC-FILE-NAME DEST-DIR-NAMEquot;); cal.set(Calendar.MONTH, Calendar.JANUARY); System.exit(1); cal.set(Calendar.DAY_OF_MONTH, 1); } // make sure the source file is indeed a readable file cal.set(Calendar.HOUR_OF_DAY, 0); File srcFile = new File(args[0]); cal.set(Calendar.MINUTE, 0); if (!srcFile.isFile() || !srcFile.canRead()) { System.err.println(quot;Not a readable file: quot; + srcFile.getName()); cal.set(Calendar.SECOND, 0); System.exit(1); newYearMillis = cal.getTime().getTime(); } // make sure the second argument is a directory Scattering // prepare a message File destDir = new File(args[1]); message = quot;Happy quot; + nextYear + quot;!quot;; if (!destDir.isDirectory()) { System.err.println(quot;Not a directory: quot; + destDir.getName()); } System.exit(1); } // create File object for destination file public static int determineFontSize(JFrame frame, File destFile = new File(destDir, srcFile.getName()); int componentWidth, String fontName, int fontStyle, // check if copying is desired given overwrite option String text) if (!doCopy(destFile)) { { return; } int fontSize = componentWidth * 2 / text.length(); Font font = new Font(fontName, fontStyle, fontSize); // copy file, optionally creating a checksum Long checksumSrc = copyFile(srcFile, destFile); FontMetrics fontMetrics = frame.getGraphics(). & getFontMetrics(font); // copy timestamp of last modification if (copyOriginalTimestamp) { int stringWidth = fontMetrics.stringWidth(text); if (!destFile.setLastModified(srcFile.lastModified())) { return (int)(fontSize * 0.95 * System.err.println(quot;Error: Could not set quot; + quot;timestamp of copied file.quot;); componentWidth / stringWidth); } } } // optionally verify file public static void main(String[] args) if (verify) { System.out.print(quot;Verifying destination file...quot;); { Long checksumDest = createChecksum(destFile); JFrame frame = new JFrame(); if (checksumSrc.equals(checksumDest)) { System.out.println(quot; OK, files are equal.quot;); frame.addKeyListener(new KeyListener() } else { { System.out.println(quot; Error: Checksums differ.quot;); Tangling } public void keyPressed(KeyEvent event) {} } public void keyReleased(KeyEvent event) { } if (event.getKeyChar() == KeyEvent.VK_ESCAPE) /** { * Print a message to standard output and read lines from * standard input until yes or no (y or n) is entered. System.exit(0); * @param message informative text to be answered by user } * @return user answer, true for yes, false for no. */ } public static boolean readYesNoFromStandardInput(String message) { public void keyTyped(KeyEvent event) {} System.out.println(message); String line; } BufferedReader in = new BufferedReader(new InputStreamReader( ); System.in)); Boolean answer = null; frame.setUndecorated(true); try JLabel label = new JLabel(quot;.quot;); { while ((line = in.readLine()) != null) { label.setBackground(Color.BLACK); line = line.toLowerCase(); label.setForeground(Color.WHITE); if (quot;yquot;.equals(line) || quot;yesquot;.equals(line)) { answer = Boolean.TRUE; label.setOpaque(true); break; label.setHorizontalAlignment(SwingConstants.CENTER); } else frame.getContentPane().add(label); if (quot;nquot;.equals(line) || quot;noquot;.equals(line)) { GraphicsEnvironment.getLocalGraphicsEnvironment(). answer = Boolean.FALSE; break; getDefaultScreenDevice().setFullScreenWindow(frame); } final int fontStyle = Font.BOLD; else { final String fontName = quot;SansSerifquot;; System.out.println(quot;Could not understand answer (quot;quot; + int fontSizeNumber = determineFontSize(frame, line + quot;quot;). Please use y for yes or n for no.quot;); } Toolkit.getDefaultToolkit().getScreenSize().width, } fontName, fontStyle, formatter.format(88888888)); if (answer == null) { throw new IOException(quot;Unexpected end of input from stdin.quot;); int fontSizeText = determineFontSize(frame, } Toolkit.getDefaultToolkit().getScreenSize().width, in.close(); return answer.booleanValue(); fontName, fontStyle, quot;Happy 8888!quot;); } label.setFont(new Font(fontName, fontStyle, catch (IOException ioe) { Math.min(fontSizeNumber, fontSizeText))); throw new InternalError( new HappyNewYear(frame, label).run(); quot;Cannot read from stdin or write to stdout.quot;); } } } } public void run() { boolean newYear = false; do { long time = System.currentTimeMillis(); long remaining = (newYearMillis - time) / 1000L; String output; if (remaining < 1) { // new year! newYear = true; output = message; } else { // make a String from the number of seconds output = formatter.format(remaining); } label.setText(output); try { Thread.sleep(1000); } } 2

AOP */ public class FileDownload { public static void download(String address, String localFileName) { OutputStream out = null; URLConnection conn = null; InputStream in = null; try { conn = url.openConnection(); public static Long createChecksum(File file) throws IOException { long millis = System.currentTimeMillis(); in = conn.getInputStream(); InputStream in = new FileInputStream(file); byte[] buffer = new byte[1024]; byte[] buffer = new byte[bufferSize]; int numRead; int bytesRead; long numWritten = 0; while ((bytesRead = in.read(buffer)) >= 0) { checksum.update(buffer, 0, bytesRead); while ((numRead = in.read(buffer)) != -1) { } out.write(buffer, 0, numRead); in.close(); if (clock) { numWritten += numRead; millis = System.currentTimeMillis() - millis; import java.io.*; System.out.println(quot;Second(s): quot; + (millis/1000L)); import java.util.zip.*; } } finally { return new Long(checksum.getValue()); /** try { } * Command line program to copy a file to another directory. * @author Marco Schmidt if (in != null) { */ in.close(); public class CopyFile {

Add a comment

Related presentations

Related pages

Managing the Evolution of Aspect-Oriented Software with ...

Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts Andy Kellens 1!, Kim Mens2, Johan Brichau,3, and Kris Gybels 1 Programming ...
Read more

Managing the Evolution of Aspect-Oriented Software with ...

... aspect-oriented programs still suffer from evolution problems. ... Managing the Evolution of Aspect-Oriented Software with Model-Based Pointcuts.
Read more

Managing the Evolution of Aspect-Oriented Software with ...

Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts (2006)
Read more

Managing the Evolution of Aspect-Oriented Software with ...

Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts Andy Kellens Kim Mens Johan Brichau Kris Gybels 1
Read more

Managing the Evolution of Aspect-Oriented Software with ...

提供Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts文档免费下载,摘要:Abstract ...
Read more

Managing the Evolution of Aspect-Oriented Software with ...

Official Full-Text Publication: Managing the Evolution of Aspect-Oriented Software with Model-Based Pointcuts on ResearchGate, the professional network for ...
Read more

Change Operations and Their Consequences in AOP Evolution

Managing the Evolution of Aspect-Oriented Software with Model-Based Pointcuts
Read more

Model-based Pointcuts - researchgate.net

Model-based Pointcuts ... • Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts Andy Kellens, ...
Read more

Test-based pointcuts

... cases for software evolution. ... based pointcuts, a new aspect-oriented programming ... of aspect-oriented software with model-based ...
Read more