/*
 * (c) 2010 ThoughtWorks Ltd
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD
 * style license a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 * 
 * Created on 10-Apr-2009
 */
package proxytoys.examples.overview;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.Reader;

import com.thoughtworks.proxy.factory.CglibProxyFactory;
import com.thoughtworks.proxy.toys.privilege.AccessControllerExecutor;
import com.thoughtworks.proxy.toys.privilege.Privileging;

import org.xml.sax.InputSource;


/**
 * @author Joerg Schaible
 */
public class PrivilegingToyExample {

    public static void packageOverviewExample1() throws IOException {
        File file = Privileging.proxy(new File("src/main/java/" + PoolToyExample.class.getName().replace('.', '/') + ".java"))
            .executedBy(new AccessControllerExecutor())
            .build(new CglibProxyFactory());
        LineNumberReader reader = new LineNumberReader(new FileReader(file), 16 * 1024);
        while (reader.readLine() != null);
        System.out.println("Lines of code: " + reader.getLineNumber());
        reader.close();
    }


    public static void main(String[] args) throws IOException {
        System.out.println();
        System.out.println();
        System.out.println("Running Privileging Toy Example");
        System.out.println();
        System.out.println("Example 1 of Package Overview:");
        packageOverviewExample1();
    }
    
    private static class SlowInputSource extends InputSource {
        public SlowInputSource(Reader characterStream)
        {
            super(characterStream);
        }

        @Override
        public Reader getCharacterStream() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
            return super.getCharacterStream();
        }
        
    }
}
@@ -410,31 +410,8 @@
 der;
-%0Aimport java.io.Reader;
 %0A%0Aim
@@ -599,41 +599,8 @@
 g;%0A%0A
-import org.xml.sax.InputSource;%0A%0A
 %0A/**
@@ -1526,434 +1526,5 @@
   %7D%0A
-    %0A    private static class SlowInputSource extends InputSource %7B%0A        public SlowInputSource(Reader characterStream)%0A        %7B%0A            super(characterStream);%0A        %7D%0A%0A        @Override%0A        public Reader getCharacterStream() %7B%0A            try %7B%0A                Thread.sleep(100);%0A            %7D catch (InterruptedException e) %7B%0A            %7D%0A            return super.getCharacterStream();%0A        %7D%0A        %0A    %7D%0A
 %7D

Drop cruft from c&p.