public void run()

in showcase/src/main/java/org/apache/peeco/showcase/proxyGeneration/ProxyGenerator.java [61:109]


    public void run()
    {
        //TODO: specify some working directory to output the proxy classes to
        final Path out = Paths.get("");
        if (!Files.exists(out))
        {
            throw new IllegalStateException("You should run compile before this task, missing: " + out);
        }

        BeanManager beanManager = CDI.current().getBeanManager();

        beanManager.getBeans(Object.class).stream()
                .filter(b -> beanManager.isNormalScope(b.getScope()) && !isIgnoredBean(b)) // todo: do it also for interception
                .forEach(it ->
                {
                    try
                    { // triggers the proxy creation
                        beanManager.getReference(it, Object.class, beanManager.createCreationalContext(null));
                    }
                    catch (final Exception ex)
                    {
                        ex.printStackTrace();
                    }
                });

        final String config = ClassLoaderProxyService.Spy.class.cast(WebBeansContext.currentInstance().getService(DefiningClassService.class))
                .getProxies().entrySet().stream()
                .map(e ->
                {
                    final Path target = out.resolve(e.getKey().replace('.', '/') + ".class");
                    try
                    {
                        Files.createDirectories(target.getParent());
                        Files.write(target, e.getValue());
                    }
                    catch (final IOException ex)
                    {
                        throw new IllegalStateException(ex);
                    }
                    System.out.println("Created proxy '{" + e.getKey() + "}'" );
                    return "<reflection>\n" +
                            "<name>" + e.getKey().replace("$$", "$$$$") + "</name>\n" +
                            "<allDeclaredConstructors>true</allDeclaredConstructors>\n" +
                            "<allDeclaredMethods>true</allDeclaredMethods>\n" +
                            "<allDeclaredFields>true</allDeclaredFields>\n" +
                            "</reflection>";
                })
                .collect(joining("\n"));
    }