This content has been marked as final.
Show 5 replies
-
1. Re: AbstractController add/removeControllerContext
alesj Aug 10, 2007 6:30 AM (in response to alesj)"alesj" wrote:
e.g. ScopedKernelController extends AbstractKernelController extends ScopedController extends AbstractController
If I do this it works and nothing is public.
ScopingKernelController has package protected methods:void addControllerContext(KernelControllerContext context) { super.addControllerContext(context); } void removeControllerContext(KernelControllerContext context) { super.removeControllerContext(context); } void release() { getParentController().removeController(this); setUnderlyingController(null); setParentController(null); parentKernel = null; }
since it is only accessed in PreInstallAction, which is in the same package.
The only change to AbstractKernelController is that it extends ScopedController instead of AbstractController.
This is how ScopedController looks like:/** * Scoped controller. * * @author <a href="ales.justin@jboss.com">Ales Justin</a> */ public abstract class ScopedController extends AbstractController { private AbstractController underlyingController; public void setUnderlyingController(AbstractController underlyingController) { this.underlyingController = underlyingController; } protected boolean isScoped() { return underlyingController != null; } protected void addControllerContext(ControllerContext context) { if (isScoped()) { underlyingController.removeControllerContext(context); context.setController(this); registerControllerContext(context); } else super.addControllerContext(context); } protected void removeControllerContext(ControllerContext context) { if (isScoped()) { unregisterControllerContext(context); context.setController(underlyingController); underlyingController.addControllerContext(context); } else super.removeControllerContext(context); } }
It has protected methods, so that they can be accessed in ScopedKernelController.
And AbstractController now has package protected methods:void addControllerContext(ControllerContext context) { registerControllerContext(context); } // TODO This api looks broken and unsafe see above void removeControllerContext(ControllerContext context) { unregisterControllerContext(context); }
Is this OK?
Or too ugly hack? -
2. Re: AbstractController add/removeControllerContext
alesj Aug 10, 2007 7:13 AM (in response to alesj)+ added missing write locks.
-
3. Re: AbstractController add/removeControllerContext
adrian.brock Aug 10, 2007 8:51 AM (in response to alesj)"alesj" wrote:
Is this OK?
Or too ugly hack?
That's the way I told you to do it before.
The whole point of protected and "friend" in c++ is to allow restricted access
to implementation details, but you need to make sure the access makes sense.
i.e. Is it possible that the implementation will change down the road making these
methods unsupportable? -
4. Re: AbstractController add/removeControllerContext
alesj Aug 10, 2007 9:04 AM (in response to alesj)"adrian@jboss.org" wrote:
"alesj" wrote:
Is this OK?
Or too ugly hack?
That's the way I told you to do it before.
To do an ugly hack? :-)"adrian@jboss.org" wrote:
The whole point of protected and "friend" in c++ is to allow restricted access
to implementation details, but you need to make sure the access makes sense.
i.e. Is it possible that the implementation will change down the road making these methods unsupportable?
If/when the whole scoping impl changes, it will be really easy to strip out the current impl - simply removing the Scoped(Kernel)Controller and re-connect the AbstractKernelController with AbstractController.
Since those two classes + PreInstallAction are the only one's who know what the scope is. -
5. Re: AbstractController add/removeControllerContext
adrian.brock Aug 10, 2007 9:12 AM (in response to alesj)"alesj" wrote:
Since those two classes + PreInstallAction are the only one's who know what the scope is.
And what if a user uses them?
Of course protected and package private methods is not something
somebody should expect to remain very stable unless the behaviour
has been explicitly documentated.