a new java pattern and architecture (shine enterprise pattern)

Discussions

General J2EE: a new java pattern and architecture (shine enterprise pattern)

  1. The Java Web Model Service architecture is based on MVC.It improves all disadvantages ,and add some adavantages points to it.As Struts comes to help us to implement our project based on MVC , we need maplet to implement JWMS architecture.These maplets are based on those old Servlets ,with some new featurs.
    Purpose of JWMS architecture is that, to have a JSP page for every job of your actors in UML diagrams. And those all actions start from a request JSP page ,and continue with one or more maplets ,and then finish with a response JSP page (for all possibles response ) through a flow just like your UML diagrams.

    Figure 1

    Now there isn't any need to make a JSP page for every possible response (for example a proper response for empty fields and an other proper respose for errors ...) like before.Instead, the all things you need is that to create a response jsp page and tag it.A tag for success message a tag for error and so on.
    As you see , every thing is very simple.Also, you can be a project manager too !!!
    An other ability of maplet is that ,you don't need to carry parameters with yourself by using session or application.Maplet gets all parameters from the first page and cross it to an other maplet or JSP.For reaching these parameters you just need to define a public String variable as the same name of parameter in first JSP page.The content of this variable is the same as user inputted parameter(with out doing any job!).
    We are not magicians , we just know how to work with URL !!!
    If you want to send any parameter to next maplet ,add it to URL as the same !!!
    For more information and knowing how to work with AddURL(),forward(),... read the complete document from below link :

    http://SourceForge.net/projects/shine-enterpris/files/

    Omid haghighatgoo
    J2OS manager
    2010

  2. a maplet sample[ Go to top ]

    fileName : maplet.tld
    =====================
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>maplet</shortname>
      <tag>
        <name>Service</name>
        <tagclass>org.j2os.shine.maplet.tag.Service</tagclass>
        <bodycontent>JSP</bodycontent>
        <attribute>
          <name>name</name>
        </attribute>
      </tag>
      <tag>
        <name>SecureService</name>
        <tagclass>org.j2os.shine.maplet.tag.SecureService</tagclass>
        <bodycontent>JSP</bodycontent>
        <attribute>
          <name>name</name>
        </attribute>
      </tag>
      <tag>
        <name>ErrorService</name>
        <tagclass>org.j2os.shine.maplet.tag.ErrorService</tagclass>
        <bodycontent>JSP</bodycontent>
      </tag>
      <tag>
        <name>Resource</name>
        <tagclass>org.j2os.shine.maplet.tag.Resource</tagclass>
        <bodycontent>JSP</bodycontent>
        <attribute>
          <name>show</name>
        </attribute>
        <attribute>
          <name>from</name>
        </attribute>
      </tag>
      <tag>
        <name>DataTable</name>
        <tagclass>org.j2os.shine.maplet.tag.DataTable</tagclass>
        <bodycontent>JSP</bodycontent>
      </tag>
      <tag>
        <name>DataRow</name>
        <tagclass>org.j2os.shine.maplet.tag.DataRow</tagclass>
        <bodycontent>JSP</bodycontent>
      </tag>
    </taglib>
    =====================

     

    fileName : Resuest.jsp
    =====================
    <%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>
    <html>
      <body>
        <form name="myform" action="Core.exec">
          <maplet:Resource show="msg1"/>
          <input type="text" name="name"/>
          <input type="submit" value="ClassicSendQuery"/>
        </form>
      </body>
    </html>
    =====================

     

    fileName : Response.jsp
    =====================
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>
    <maplet:SecureService name="insert">

    </maplet:SecureService>
    <maplet:ErrorService>
      <maplet:Resource show="msg2"/>
      <maplet:DataTable>
        <database-driver>oracle.jdbc.driver.OracleDriver</database-driver>
        <database-url>jdbc:oracle:thin:@javaserver:1521:xe</database-url>
        <database-username>iranair</database-username>
        <database-password>iran123</database-password>
        <database-query-sql>select * from users</database-query-sql>
        <view-border>style="background-color: red; border: 1px solid"</view-border>
        <view-header>style="background-color: green; border: 5px solid"</view-header>
        <view-first-records>style="background-color: pink"</view-first-records>
        <view-second-records>style="background-color: gray"</view-second-records>
      </maplet:DataTable>
    </maplet:ErrorService>
    =====================

     

    fileName : Core.java
    =====================
    package controller;

    import model.database.dao.T1DAO;

    import org.j2os.shine.maplet.Maplet;


    public class Core extends Maplet {
        private T1DAO t1;
        public String name;

        public void startup() throws Exception {
            try {
                t1 = new T1DAO("model/database/setting/Connection.xml");
                System.out.println("DataBaseLogin");
            } catch (Exception e) {
                out.print(e);
            }
        }

        public void request() throws Exception {
            t1.insert(0, name, "none");
            secureForward("Response.jsp", "insert");
        }
    }
    =====================

     

    fileName : T1DAO.java
    =====================
    package model.database.dao;

    import model.database.dto.*;

    import org.j2os.shine.jconnection.*;

    import java.util.*;


    public class T1DAO extends Hibernate {
        public T1DAO(String address) throws Exception {
            login(address);
        }

        public void insert(long id, String name, String famil)
            throws Exception {
            // if id!=0 => update
            begin();

            T1 object = new T1();
            object.setId(id);
            object.setName(name);
            object.setFamil(famil);
            saveOrUpdate(object);
            commit();
        }

        public void delete() throws Exception {
            begin();

            Iterator i = getSQLQueryContent("select * from t1",
                    "model.database.dto.T1");

            while (i.hasNext()) {
                T1 object = (T1) i.next();
                delete(object);
            }

            commit();
        }

        public void update() throws Exception {
            begin();

            Iterator i = getSQLQueryContent("select * from t1",
                    "model.database.dto.T1");

            while (i.hasNext()) {
                T1 object = (T1) i.next();
                object.setFamil("bahador");
                saveOrUpdate(object);
            }

            commit();
        }

        public void select() throws Exception {
            begin();

            Iterator i = getSQLQueryContent("select * from t1",
                    "model.database.dto.T1");

            while (i.hasNext()) {
                T1 object = (T1) i.next();
                System.out.println(object.getName());
            }

            commit();
        }
    }
    =====================

     

    fileName : T1.java
    =====================
    package model.database.dto;
    import org.j2os.shine.maplet.tag.DataTable;
    public class T1 {
        private long id;
        private String name;
        private String famil;

        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setFamil(String famil) {
            this.famil = famil;
        }

        public String getFamil() {
            return famil;
        }

        public void setId(long id) {
            this.id = id;
        }

        public long getId() {
            return id;
        }
    }
    =====================

     

    fileName : T1.xml
    =====================
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE hibernate-mapping PUBLIC
     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="model.database.dto">
      <class name="T1" table="T1" dynamic-update="true" dynamic-insert="true">
        <id name="id" type="long" column="id">
          <generator class="increment"/>
        </id>
        <property name="name" type="java.lang.String" column="name" insert="true" update="true"/>
        <property name="famil" type="java.lang.String" column="famil" insert="true" update="true"/>
      </class>
    </hibernate-mapping>
    =====================

     

    fileName : Connection.xml
    =====================
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@javaserver:1521:xe</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.pool_size">10</property>
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.GenericDialect</property>
        <mapping resource="model/database/dto/T1.xml"/>
      </session-factory>
    </hibernate-configuration>
    =====================

     

    fileName : EN.java
    =====================
    package resource;

    public class EN {
        public String msg1 = "insert your name";
        public String msg2 = "finish";
    }
    =====================

     

    fileName : FA.java
    =====================
    package resource;

    public class FA {
        public String msg1 = "&#1606;&#1575;&#1605; &#1585;&#1575; &#1608;&#1575;&#1585;&#1583; &#1705;&#1606;&#1740;&#1583;";
        public String msg2 = "&#1575;&#1578;&#1605;&#1575;&#1605;";
    }
    =====================