SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
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
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts
Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts

Weitere ähnliche Inhalte

Mehr von kim.mens

Mehr von kim.mens (20)

Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programming
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programming
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modelling
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworks
 
Towards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation FrameworkTowards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation Framework
 
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty ApproachesTowards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
 
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software EngineeringBreaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
 
Context-oriented programming
Context-oriented programmingContext-oriented programming
Context-oriented programming
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflection
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Java
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
 
A gentle introduction to reflection
A gentle introduction to reflectionA gentle introduction to reflection
A gentle introduction to reflection
 
Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...
 

Kürzlich hochgeladen

Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
PirithiRaju
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
PirithiRaju
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
PirithiRaju
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
Lokesh Kothari
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Sérgio Sacani
 

Kürzlich hochgeladen (20)

Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
 
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts ServiceJustdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 

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

  • 1. Managing the Evolution of Aspect-Oriented Software with Model-based Pointcuts Andy Kellens Kim Mens Johan Brichau Kris Gybels 1
  • 2. 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