Meaningless Drivel is fun!*
The moose likes Other Application Frameworks and the fly likes Frontman 2.0 mapping url's to different command packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Frontman 2.0 mapping url Watch "Frontman 2.0 mapping url New topic
Author

Frontman 2.0 mapping url's to different command packages

John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
I have the following CommandBroker defined:




I want to be able to map:



to only the commands within com.novo.ecommerce.site.commands and then be able to map



to only the commands within com.novo.ecommerce.administration.commands

So i should only be able to access (myPage) by http://127.0.0.1:8080/ecommerce/administration/myPage and not be able to access that command by http://127.0.0.1:8080/ecommerce/store/myPage

currently i can access myPage bye either url, i should only be able to access that command by http://127.0.0.1:8080/ecommerce/administration/myPage

Not sure if i am going by this the wrong way or not i have multiple servlet mappings:



So I am not sure if i am mapping everything correctly
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

Though I've never done it, you should be able to map multiple instances of the Command Broker.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Bear Bibeault wrote:Though I've never done it, you should be able to map multiple instances of the Command Broker.


I will give that a try but i have one more question pertaining to this.

I have created the following filter:



The point of this filter is to filter everything that comes through the url http://127.0.0.1:8080/ecommerce/account/*

If the customer is not logged in forward to login page, if they are then pass through.

The filter seems to work fine however i am able to access my checkout page through the following url:
http://127.0.0.1:8080/ecommerce/store/checkout

in essence i only want to be able to get to that verb by http://127.0.0.1:8080/ecommerce/account/checkout
passing through the filter to evaluate. Is this still par of the issue from above? Is there a better way to handle these filters in FrontMan?

Below is my current web.xml

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

The CommandBroker is a servlet like any other, so filters get applied prior to the CommandBroker gaining control. You should be able to do anything in your filters regardless of the use of FrontMan.
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Bear Bibeault wrote:The CommandBroker is a servlet like any other, so filters get applied prior to the CommandBroker gaining control. You should be able to do anything in your filters regardless of the use of FrontMan.


So how would i prevent the command(verb) checkout from being viewed from any other url besides http://127.0.0.1:8080/ecommerce/account/checkout

i.e. if i try to acces this url it should not exist
http://127.0.0.1:8080/ecommerce/store/checkout

Maybe i am just not wrapping my head around the whole url mapping, i have kept the mappings super simple prior to this project.

Thanks

John

EDIT:

would this be a bad way to handle that situation?

If the command is accessed from a different url pattern but it hits the command class anyway do a redirect to the proper url, this will also ensure it passes through the filter properly.
Do you see any issues with handling it this way?


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

John Schretz wrote:So how would i prevent the command(verb) checkout from being viewed from any other url besides http://127.0.0.1:8080/ecommerce/account/checkout


Each CommandBroker instance can look in different packages for the defined commands. The CommandBroker for anything other than /account/* shouldn't have a command for checkout.
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Bear Bibeault wrote:
John Schretz wrote:So how would i prevent the command(verb) checkout from being viewed from any other url besides http://127.0.0.1:8080/ecommerce/account/checkout


Each CommandBroker instance can look in different packages for the defined commands. The CommandBroker for anything other than /account/* shouldn't have a command for checkout.


I assume this is given that i am map multiple instances of the Command Broker?

Given the alternative of using only one Command Broker would the following be a suitable solution?

If the command is accessed from a different url pattern but it hits the command class anyway do a redirect to the proper url, this will also ensure it passes through the filter properly.
Do you see any issues with handling it this way?



Thanks again for all the help, this will be used on a pretty large scale project.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

I wouldn't do it, personally. Handling dispatch issues is not the job of the command. If you want distinct parts of the app that understand command subsets, I'd try the multiple command broker approach.
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Sounds good. You will be happy to know that FrontMan 2.0 is running the admin section of a $1.2M a year revenue ecommerce site. Still cant find a need for another framework, whatever i need extra i have been building on top of this
Implementing it now on the entire site.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65



Cool!
 
 
subject: Frontman 2.0 mapping url's to different command packages
 
Similar Threads
Using a filter with frontman
Frontman 2.0 vs /WEB-INF
servlet mapping clarification
Frontman 2 FileNotFoundException ?
FrontMan Commands ?