prmr / Creco

Recommendation System for Consumer Products
Apache License 2.0
6 stars 2 forks source link

Create singleton spring beans #24

Closed forgues closed 10 years ago

forgues commented 10 years ago

CRData, CategorySearch and ProductSearch classes should all become singleton beans.

Each of the three classes will implement its own interface, so that we can also create mock objects to test.

forgues commented 10 years ago

I wasn't sure what to call the CRData interface. The interface exposes getters for products and categories. I think ICRData is a confusing name and IData is quite vague. I named it IDataStore for now, but if anyone dislikes the name or has a better idea, let me know.

prmr commented 10 years ago

There's a couple of touch-ups in master you might want to pull in your branch.

forgues commented 10 years ago

I pulled the latest changes from master, and my branch is also almost ready to be merged back into master. CRData is now a bean (with interface IDataStore), and it can be autowired into any other class, so I'll go ahead and remove the CRData.getData() method.

If anyone needs to get a copy of the data object in some new class, you simply need to add the following class variable declaration: @Autowired private IDataStore aDataStore;

The autowired tag should automatically inject the data object into the class whenever the class is instantiated. Afterwards you can do aDataStore.getCategories(), etc, as usual.

I'll add more detailed info in the wiki once this is merged into master.

forgues commented 10 years ago

Merge into master is complete and the wiki has been updated.