Wednesday, 15 May 2013

java - Design pattern for page logging -



java - Design pattern for page logging -

i creating website using spring. thinking of implementing design pattern logging info each page hit. these logs crucial identifying user pattern etc. there set of mutual parameters need log each page nail apart mutual parameters, each page have different parameter logged.

i thinking of design pattern should implement achieving this?

i thought of using stratergy pattern didn't much.

for eg. parameter a,b,c mutual , in add-on these search page logs f,g,h browse page logs i,j,k

public interface commonparameters { void logcommonparameters(string a, string b, string c); } public interface searpageparameters inherits commonparameters { void logsearchparameters(string f, string g, string h); } public interface browsepageparameters inherits commonparameters { void logbrowsepageparameters(string i, string j, string k); } public class loghelper { commonparameters commonparameters; }

but requires classes implement browsepageparameters can instantiate in loghelper. don't want create class each page. suggestions on design pattern should follow this?

try read interceptor :) , set configuration of web.xml. http://viralpatel.net/blogs/spring-mvc-interceptor-example/

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-handlermapping-interceptor

your code much more cleaner , solution more elegant.

java design-patterns

No comments:

Post a Comment