Hi,

I am trying to create a dispatcher to define the access levels for the current user. I have followed the steps from the Wiki pages:
http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher
http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2

This seems to work. But as I try to do asm.exists(UserPermissions.class) it returns false. I checked the classpath for the class my.project.services.UserPermissions. And there it does exist. I also tried to make it an interface but this didn't work out either.

My classes:
----------------------------------------------------------------------------------------------
AccessController.java:

public class AccessController implements Dispatcher {

        private ApplicationStateManager asm;

        public AccessController(ApplicationStateManager asm) {
                this.asm = asm;
        }

public boolean dispatch(Request request, Response response) throws IOException {
                boolean canAccess = true; // to avoid the access violation for 
now

                if (asm.exists(UserPermissions.class)) {
                        UserPermissions perms = asm.get(UserPermissions.class);

                        canAccess = perms.canAccess(request);
                }

                if (!canAccess) {
                        throw new RuntimeException("Access violation!");
                }

                return false;
        }
}

----------------------------------------------------------------------------------------------
UserPermissions.java:

public class UserPermissions {

        public boolean canAccess(Request request) {
                return true;
        }

}
----------------------------------------------------------------------------------------------
AppModule.java:

public class AppModule {

        public static void bind(ServiceBinder binder) {
                binder.bind(AccessController.class).withId("AccessController");
        }

public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher> configuration,
                        @InjectService("AccessController") Dispatcher 
accessController) {
configuration.add("AccessController", accessController, "before:PageRender");
        }
}
----------------------------------------------------------------------------------------------

Does anyone have a clue what I am doing wrong?

Yours,
Kasper

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to