Showing posts with label j2ee. Show all posts
Showing posts with label j2ee. Show all posts

July 3, 2007

Multi-Tier Clusters

Today most of projects are build upon a composite structure that has multiple different APIs. Since many of them is unaware of the others and has its of implementation and dependency , every one of them should be have its own configuration which will make them work as a single application.

This is the hard point in fact "To bundle them in single application"

An Example:

in a sample medium size application like AppFuse would be using Hibernate/JPA, Acegi,SpringFramework,JasperReports, JSF, Tomcat/Jetty and so on. it is all good even perfect when you are run in a single JVM. but if you want to build a cluster for only a load balancing you should configure every one by one.


In other world you be building a multi tier cluster for each APIs , which would be harder rhan implemation for some old fashioned singleton type application (a type of application which has lots of static variable and caches)

your applcation would be looking like this.


what should be your success criteria

performance : cluster should not slow down the application in a critical point
transaction: any rollback should be noticed
failover: in case of any instance fail over any other one can replace it.
seamless: the cluster mode should be seamless. should be hidden behind proper interfaces


today most open and commercial API support clusters. but in most cases you would implement a yous own schema for your own needs . before start you should read some articles about "Distributed Application" , you can use any distributable caching, maps, or JMS bridges between your components

June 13, 2007

Clustering Acegi via JGroups (DistributedHashtable)

moved my blog to altuure.com
please click to continue
http://www.altuure.com/2007/12/23/clustering-acegi-via-jgroups-distributedhashtable/

May 28, 2007

anti-JSF thoughts

blog post moved to altuure.com

anti-JSF thoughts

May 7, 2007

Rapid Java : Part I (Platform)

For rapid and non-painful development and products here's some java libraries (startup dependencies)  I choose from bottom to top:

Module I: Core
  • postgresql / mysql / hsql depends on project's size if you don't large size of startup data try to use hsql
  • log4j : logging (alternative commons-logging)
  • hibernate: Simple and high quality open source ORM (alternative:)
  • springframework:  high quality IoC container and very good integration library (a framework to rule them all)
  • quartz: scheduled task
  • osworkflow: Simple workflow and state engine, to manage actions and states
  • velocity: simple and useful template engine for formatted text/html/csv outputs (alternative freemarker)
  • beanshell for providing business point (alternative groovy)
  • acegi: Authentication and authorization
Module II : Report
  • jfreechart:for impressive charts
  • jasperreport: for pdf reports
  • mondrian: for BI
  • jxls: for excel reports
Module III: Web Layer
  • Struts : here, you have lots of choice from popular jsf to tapestry,spring mvc, I choose struts because of two reason simple life cycle and it is action based current I am STILL using struts  1.2.x  but I will move to Struts2
  • Prototype.js  standard js for web 2.0
  • script.aculo.us very useful js lib for effects and more
  • DWR for extra js calls from client browser to your java codes
  • displaytag: very useful jsp taglib
  • jstl: standard jsp taglib
  • tomcat/jetty: choose one that you are familiar

It looks so complex at first sight and I'm sure it could be so painful to you but where All become one you would have quite clear Framework. 
for how to integrate them look at appfuse.

What is missing?
 your  application specs you can need JMS (eg: activemq)  ,networking (eg:jgroups) libs 

April 12, 2007

Clustering Acegi

Acegi is a well known security framework. Some really good features:
  • method level based security configuration
  • url level auth configuration
  • easy login mechanism
  • so on.
But there only one point that is missing in current version (1.0.3) distributable SessionRegistry, in fact there is one implemantion to this interface but it do not support multiple JVM.This is used for concurrent access with username.

Quick Fix:
replace the Maps in SessionRegistryImpl with your distributable caching mechanism (can be ehcache,oscache,vs) and reimplement it. Or you can use some JMS mechanism to fix this cap but it should be used only in complex architectures.

Acegi Concurrent Setup:

<bean id=" org.acegisecurity.concurrent.SessionRegistry" class="org.acegisecurity.concurrent.SessionRegistryImpl"/> <bean id="org.acegisecurity.concurrent.ConcurrentSessionController" class="org.acegisecurity.concurrent.ConcurrentSessionControllerImpl"> <property name="maximumSessions"> <value>1</value> </property> <property name="sessionRegistry"> <ref local="org.acegisecurity.concurrent.SessionRegistry"/> </property> <property name="sessionRegistry" ref="org.acegisecurity.concurrent.SessionRegistry"/> </bean> <bean id="org.acegisecurity.AuthenticationManager" class="org.acegisecurity.providers.ProviderManager "> <property name="providers"> <list> <ref local="org.acegisecurity.providers.dao.DaoAuthenticationProvider"/> <ref local="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"/> </list> </property> <property name="sessionController" ref="org.acegisecurity.concurrent.ConcurrentSessionController "/> </bean> <bean id="org.acegisecurity.concurrent.ConcurrentSessionFilter" class="org.acegisecurity.concurrent.ConcurrentSessionFilter "> <property name="sessionRegistry" ref="org.acegisecurity.concurrent.SessionRegistry"/> <property name="expiredUrl" value="/myself/"/> </bean>




And add org.acegisecurity.concurrent.ConcurrentSessionFilter to your filter list

PS:
check my new blog Clustering Acegi via JGroups (DistributedHashtable)

December 11, 2006

Core and Render Services

While implementing software systems you have two different major issues.
  • Implementing Core Functions: Can be considered as commit transactions( Insert records, transfer files to legacy systems, batch imports) . These methods are atomic and can change the entire data for the whole system.
  • Rendering data as Human Readable Form. All Forms, lists, Reports can be considered in this case. There is no data change in background system but only export of this system.
When you distinguish these two system you can separate the implementation of these functionality. CoreService,RenderService.

  • CoreService: have transactional service methods. Each method is a atomic unit and as a whole the services capture whole system functions.So they are reusable
  • RenderService: Can be implemented depending on the domain. Either Web Technologies, reporting or desktop applications. Each domain have its own constraints so unlike CoreService these methods are hardly reusable.
Here is sample Dependency Diagram.

Sample Flow would be like:
  1. User request page with a GET method
  2. Render Service render the html and form.
  3. User fills the forms and POST the data
  4. Core method reads the data from request and commit the transaction
  5. Redirect the request to and URL
  6. Another GET and render Case

With this pattern you support and increase the separation of concern and increase the abstraction layer.

For java web applications, it would be best to use a action oriented framework like Struts suits well for the pattern