Git Product home page Git Product logo

Comments (6)

matthewadams avatar matthewadams commented on March 29, 2024

I think this is a FAQ. There was another user with the same problem. Let me dig a little.

from spring-data-cassandra.

matthewadams avatar matthewadams commented on March 29, 2024

Here is the thread where I thought afterPropertiesSet wasn't getting called: https://groups.google.com/d/msg/spring-data-cassandra/k2kkod-ZOkI/9X4NllmLbwMJ

I realize it's not necessarily the same as your problem.

Whether you're using XML or Java configuration, those methods should be getting called as part of the normal bean lifecycle. Can you fork, create a branch & repro in the branch so that I can see?

Also, have a look at the Java config-based tests.

from spring-data-cassandra.

JensRantil avatar JensRantil commented on March 29, 2024

I'm using Java configuration for my project. The project is, unfortunately, proprietary so I can't share it. I'm calling afterPropertiesSet() after setting all my properties and things seem to work.

from spring-data-cassandra.

matthewadams avatar matthewadams commented on March 29, 2024

I can't seem to repro this. Can you create a test project that is configured as much like your proprietary one as possible and make it available on github somewhere please?

from spring-data-cassandra.

JensRantil avatar JensRantil commented on March 29, 2024

So, I am not having an issue with this per se. Things were working with or without calling afterProperties() right now. My question is, should I generally make sure to call it? This is where I call them now: https://gist.github.com/JensRantil/f040e900edc8a2ee6192

from spring-data-cassandra.

matthewadams avatar matthewadams commented on March 29, 2024

In general, you should not call afterPropertiesSet() manually. If you return a FactoryBean from a @Bean-annotated method, Spring will see that and ensure that afterPropertiesSet() is called at the appropriate time during bean initialization. The only method that you sometimes need to call is FactoryBean#getObject(), because the Spring Java Config code would not compile: you can't pass a FactoryBean as an argument to something that takes some other type (the type of the object for which the FactoryBean is a factory). In this case, you would have to call bean.getObject(), where bean is a reference to one of your factory beans.

For examples, see:

https://github.com/spring-projects/spring-data-cassandra/blob/master/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractCassandraConfiguration.java#L68

https://github.com/spring-projects/spring-data-cassandra/blob/master/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/java/AbstractCassandraConfiguration.java#L85

I did notice that CqlTemplate was calling afterPropertiesSet() in its constructor, which has since been fixed (as issue https://jira.spring.io/browse/DATACASS-152).

from spring-data-cassandra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.