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

Deprecate XFactory.getDefault() methods and move to AtmosphereConfig #1451

Closed
uklance opened this issue Jan 22, 2014 · 2 comments
Closed

Deprecate XFactory.getDefault() methods and move to AtmosphereConfig #1451

uklance opened this issue Jan 22, 2014 · 2 comments

Comments

@uklance
Copy link
Contributor

uklance commented Jan 22, 2014

@jfarcand and I believe that XFactory.getDefault() methods are a bit dirty. A static method having access to non static values is an anti-pattern and requires mutable static data which I consider to be a bad idea. @jfarcand mentioned that this was legacy code that was acceptable in the bad old days of EJB < 3.

I suggest that all of the static XFactory.getDefault() methods are deprecated in favour of non static methods eg. AtmosphereConfig.getXFactory(). The preferred method is to inject the AtmosphereConfig into any services using atmosphere.

To remain backwards compatible, I guess we could store AtmosphereConfig in a static variable and the deprecated getDefault() methods could delegate through to it until they are eventually removed in a future version of atmosphere.

This means that the following will be deprecated:

AtmosphereResourceFactory.getDefault()
AtmosphereResourceSessionFactory.getDefault()
BroadcasterFactory.getDefault()
DefaultBroadcasterFactory.getDefault()
MetaBroadcaster.getDefault()
ServletContextFactory.getDefault()
ServletProxyFactory.getDefault()
WebSocketProcessorFactory.getDefault()

In favour of:

AtmosphereConfig.getAtmosphereResourceFactory()
AtmosphereConfig.getAtmosphereResourceSessionFactory()
AtmosphereConfig.getBroadcasterFactory()
AtmosphereConfig.getMetaBroadcaster()
AtmosphereConfig.getServletContextFactory()
AtmosphereConfig.getServletProxyFactory()
AtmosphereConfig.getWebSocketProcessorFactory()
@jfarcand
Copy link
Member

Pull request welcomed. But we still need a mechanism for retrieving broadcaster from external components.

@uklance
Copy link
Contributor Author

uklance commented Jan 25, 2014

Yes, as I said if we have a static reference to AtmosphereConfig the deprecated static methods can pass through to it (until removed in a future major release of atmosphere).

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

2 participants