[MAGNOLIA-2553] FactoryUtil: should return a proxy object for observed objects Created: 13/Jan/09  Updated: 23/Jan/13  Resolved: 17/Feb/10

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: None
Fix Version/s: 4.3

Type: Improvement Priority: Major
Reporter: Philipp Bärfuss Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File proxy.patch    
Issue Links:
dependency
is depended upon by MAGNOLIA-2569 Components: introduce dependency inje... Closed
is depended upon by MAGNOLIA-3080 Cleanup conundrum between FreemarkerH... Closed
relation
is related to MAGNOLIA-3001 FactoryUtil/ClassUtil refactorings Closed
is related to MAGNOLIA-3059 Unable to replace implementation of t... Closed
is related to MAGNOLIA-2533 FactoryUtil$ObservedObjectFactory sho... Closed
is related to MAGNOLIA-3011 ObservedComponentFactory.newInstance(... Closed
is related to MAGNOLIA-3079 ComponentProvider should lookup super... Closed
is related to MAGNOLIA-3086 Module instances could be proxies too Closed
is related to MAGNOLIA-3444 Observed / proxied / c2b objects coul... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

The problematic point is that code which keeps a reference to an object will never see an reloaded changes. It would be more convenient and saver if the factory would return and cache a proxy instead.

Before this, code using such objects always had to get a fresh instance through the factory; once this is implemented, they can keep a reference (i.e get it in their constructor - potentially injected)



 Comments   
Comment by Philipp Bracher [ 13/Jan/09 ]

I have attached a patch (I quick first attempt). While the change is simple I had to change the hacks we use for ServerConfiguration and IPSecurityManager.

But after a bit of polishing I think we can apply it.

Comment by Magnolia International [ 15/Jan/09 ]

Not too keen on pushing this for 4.0 - how about 4.1 ?

Comment by Philipp Bracher [ 15/Jan/09 ]

No problem: can be part of 4.1

Here some notes about how to polish it:

  • the ObservedObjectFactory should be a standard factory (info.magnolia.cms.util.FactoryUtil.InstanceFactory)
  • the factory.newInstance( ) should return the proxy (drop the getProxy() method)
  • if the implementation is a path it will register the factory and use the standard mechanism to create the object
  • if the implementation class is a factory it should be used to create the object (use that for ServerConfig & IPSecurityManager)
Comment by Philipp Bracher [ 15/Jan/09 ]

I updated the patch. All points in the last comment are implemented. Cleaner and lesser changes needed.

Comment by Magnolia International [ 14/Jan/10 ]

patch <finally> applied on trunk ! Leaving open for now, needs a little more testing

Comment by Magnolia International [ 18/Jan/10 ]

The above comment is due to org.apache.commons.proxy.factory.cglib.CglibProxyFactory.PublicCallbackFilter, which was changed in the trunk of commons-proxy to a filter that only filters equals and hashcode methods. This could thus be different as from commons-proxy-1.1

Comment by Magnolia International [ 17/Feb/10 ]

See linked issues for further improvements

Generated at Mon Feb 12 03:37:50 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.