Skip to content

Bean class is not public #1

@robertvandeneynde

Description

@robertvandeneynde

I'm happy to find this project because it will help for my use case and I'm thankful for that project.

I launch the base code at it prints correctly all the dependencies of my application :

import com.headstartech.beansgraph.BeansGraphProducer;
import com.headstartech.beansgraph.ConsoleReporter;
import com.headstartech.beansgraph.EnableBeansGraph;
import org.springframework.stereotype.Component;

@EnableBeansGraph
@Component
public class ConfigureBeanGraphReporters implements BeansGraphConfigurer {

    @Override
    public void configureReporters(BeansGraphProducer producer) {
        ConsoleReporter.forSource(producer).build();
    }
}

However, i want to have my own Reporter, therefore I create a class that implements BeansGraphListener and I want to implement my logic in onBeanGraphResult:

public class BeanGraphChecker implements BeansGraphListener {
    @Override
    public void onBeanGraphResult(ApplicationContext applicationContext, BeansGraphResult result) {
        checkBeanDependencies(applicationContext, result);
    }

    private void checkBeanDependencies(ApplicationContext applicationContext, BeansGraphResult result) {
        UnmodifiableDirectedGraph<Bean, DefaultEdge> graph =  result.getDependencyGraph();
        // Implement my logic on the graph here
    }
}

However, that code does not compile because the Bean class is package protected and not public.
I tried to hack by moving the class to the com.headstartech.beansgraph; package, but I get a runtime error this time.

How am I suppose to use/extend the library when I cannot accessing the Bean class ?

I could fork the project to change the source code but currently I only need that little change.

The Bean class was public and was changed to package since commit d72147, what was the reason to change the visibility at the time ?

Thanks for reading my problem :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions