Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injection for serializers #237

Closed
tvanderlois opened this issue Nov 5, 2014 · 5 comments
Closed

Dependency Injection for serializers #237

tvanderlois opened this issue Nov 5, 2014 · 5 comments

Comments

@tvanderlois
Copy link

Looking at the code, it doesn't look like Taffy does dependency injection on serializers currently. 3.0.0 C2

@ryanguill
Copy link
Collaborator

Relevent discussion: https://groups.google.com/forum/#!topic/taffy-users/CVBV0ASO6kM

I took some time to look at this yesterday evening and thought I had made some progress but although the dependency injection itself seemed to work, I started getting strange issues with things not being returned from the endpoint correctly - so strange that it must be something about my particular codebase.

What I did find:

In newRepresentation() https://github.com/atuttle/Taffy/blob/develop/core/api.cfc#L929 you are using the loaded beanFactory to create the serializer.

If you are using an external beanFactory, and you have your custom serializer loaded into the bean factory, and you provide just the name of the customSerializer, not the path to framework.serializer - everything should work at that point. Again, in mine I was getting strange issues, but they were so strange I can't believe it is a taffy issue, but I didnt have enough time to research it further.

Now, if you are not using an external bean factory, I don't believe the internal bean factory is loading anything but the resources directory: https://github.com/atuttle/Taffy/blob/develop/core/api.cfc#L320
That may be the issue with the example (https://github.com/atuttle/Taffy/tree/master/examples/api_jsonutil) not working.

@ryanguill
Copy link
Collaborator

So I started researching this again this morning and found the issue I was having, you need to ensure that your beanFactory is treating the serializer as transient, or it will cache withStatus() inputs from previous calls.

@atuttle
Copy link
Owner

atuttle commented Nov 6, 2014

Excellent point: Serializers should definitely be treated as transients. I do that with Taffy's built-in factory but we should document it for anyone using an external bean factory.

I have some changes in progress in the built-in factory to resolve dependencies of serializers as they're requested, but I still have 1 failing unit test that I need to resolve.

atuttle pushed a commit that referenced this issue Nov 13, 2014
Also fixes a bug with property-based DI in beans
@atuttle
Copy link
Owner

atuttle commented Nov 13, 2014

Leaving this open for now as a reminder to update the docs as discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants