"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(a)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?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072958#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...