001/* 002 * (c) 2010 ThoughtWorks Ltd 003 * All rights reserved. 004 * 005 * The software in this package is published under the terms of the BSD 006 * style license a copy of which has been included with this distribution in 007 * the LICENSE.txt file. 008 * 009 * Created on 10-Apr-2009 010 */ 011package proxytoys.examples.overview; 012 013import com.thoughtworks.proxy.factory.CglibProxyFactory; 014import com.thoughtworks.proxy.toys.privilege.AccessControllerExecutor; 015import com.thoughtworks.proxy.toys.privilege.Privileging; 016 017import java.io.File; 018import java.io.FileReader; 019import java.io.IOException; 020import java.io.LineNumberReader; 021 022 023/** 024 * @author Joerg Schaible 025 */ 026public class PrivilegingToyExample { 027 028 public static void packageOverviewExample1() throws IOException { 029 File file = Privileging.proxy(new File("src/main/java/" + PoolToyExample.class.getName().replace('.', '/') + ".java")) 030 .executedBy(new AccessControllerExecutor()) 031 .build(new CglibProxyFactory()); 032 LineNumberReader reader = new LineNumberReader(new FileReader(file), 16 * 1024); 033 while (reader.readLine() != null) ; 034 System.out.println("Lines of code: " + reader.getLineNumber()); 035 reader.close(); 036 } 037 038 039 public static void main(String[] args) throws IOException { 040 System.out.println(); 041 System.out.println(); 042 System.out.println("Running Privileging Toy Example"); 043 System.out.println(); 044 System.out.println("Example 1 of Package Overview:"); 045 packageOverviewExample1(); 046 } 047}