Tagged: seamframework Toggle Comment Threads | Keyboard Shortcuts

  • hardikmehta 12:15 pm on April 30, 2010 Permalink | Reply
    Tags: , , , , , seamframework   

    Mavenising seam projects [ part 2 ]. 

    This part will continue the discussion started in part 1 [1].

    We now come to the model and action modules which are of type ejb. Particularly in this example (Open18) they are just seam components i.e. pojos  annotated with @Name, but they could also have been ejbs.

    Bellow is the pom.xml for model module. It contains all the entities (JPA)  and some helper classes. It shows jboss-seam as provided dependency which will be provided by the ear module which packages the artifact which will be deployed. This modules takes all the hibernate dependencies from the parent project.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>com.hardik.seaminaction</groupId>
        <artifactId>Open18</artifactId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>model</artifactId>
      <packaging>ejb</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>model</name>
      <url>http://maven.apache.org</url>
      <dependencies>
          <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>jboss-seam</artifactId>
                <version>2.2.0.GA</version>
                <type>ejb</type>
                <scope>provided</scope>
            </dependency>
      </dependencies>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-ejb-plugin</artifactId>
      			<configuration>
      				<ejbVersion>3.0</ejbVersion>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
    </project>
    

    Here the action module which is also of type ejb. It contains all the action classes which are in turn pojos annotated with @Name. The JSF dependency which we see is for the JSF message classes.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>com.hardik.seaminaction</groupId>
        <artifactId>Open18</artifactId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>action</artifactId>
      <packaging>ejb</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>action</name>
      <url>http://maven.apache.org</url>
      <dependencies>
          <dependency>
              <groupId>com.hardik.seaminaction</groupId>
              <artifactId>model</artifactId>
              <version>1.0-SNAPSHOT</version>
          </dependency>
    
          <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>jboss-seam</artifactId>
                <version>2.2.0.GA</version>
                <type>ejb</type>
                <scope>provided</scope>
            </dependency>
          <dependency>
                <groupId>javax.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>1.2_02</version>
                <scope>provided</scope>
            </dependency>
    
      </dependencies>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-ejb-plugin</artifactId>
      			<configuration>
      				<ejbVersion>3.0</ejbVersion>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
    </project>
    

    Links:

    1. Mavenising seam projects [ part 1 ].
    Advertisements
     
  • hardikmehta 3:51 pm on March 7, 2010 Permalink | Reply
    Tags: cdi, , , , jsr 299, jsr299, , , , seamframework   

    Mavenising seam projects [ part 1 ]. 

    Seam [1] is a  very powerful framework for developing java EE web-based applications. It is the only java framework which glues all the tiers of a typical java EE web application together. It is no surprise that many seam features like using EJB 3.0  (for seam any pojo which is a seam component) directly as JSF backing beans, declarative scoping and conversation scope  has been included in the new Contexts and Dependency Injection for Java EE 6 (CDI) also known as JSR 299 [2].  JSR 299 combines best features of seam, Google Guice [3] and Spring [4]. Seam also has tons of other features which make it a very useful framework to learn for any Java developer. Seam by default uses ant. The seam-gen tool creates an ant project and itself is a wrapper to different ant targets.

    Maven on the other hand is emerging as the de-facto building tool for java. As I have already mentioned before, maven gives you a very good overview of your project and you are not lost in minor details. Those details are automatically taken care of. With seam projects, maven is especially useful because you know which dependencies are needed.

    When I started learning seam, by reading the very popular book Seam in Action by Dan Allan [5], I had already switched to maven for all my projects. I decided to mavenise the examples of the book. There are many such projects. The seam documentation also points to the seam-maven-refimpl project [6] which provides a nice template for any seam project. As I wanted to find out how the maven implementation a seam project differs from that of a standard java EE project first hand, I didn’t use the template provided by this project. I just started with a standard java EE project and started adding seam dependencies to it, until I had a working example.

    The implementation  can be found here. Please feel free to point out any mistakes or suggest improvements to th code.

    I have also tried to convert the first examples of the book Seam 2.x Web Development by David Salter [7]. These examples are very simple i.e. without persistence, richfaces etc, although they use state less session beans.

    Here I will discuss the Open18 example from the Seam In Action book in detail.

    Here is the pom file of the main parent project which is no different from an ordinary Java EE project. The only seam specific thing is the jboss repository entry at the end.

    <?xml version="1.0" encoding="UTF-8"?>
    xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>Open18</artifactId>
      <packaging>pom</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>Open18</name>
      <url>http://maven.apache.org</url>
      <modules>
      	<module>action</module>
      	<module>model</module>
        <module>war</module>
        <module>ear</module>
      </modules>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-compiler-plugin</artifactId>
      			<configuration>
      				<source>1.6</source>
      				<target>1.6</target>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
      <dependencyManagement>
      	<dependencies>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>ear</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>war</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>action</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
            <dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>model</artifactId>
      			<version>1.0-SNAPSHOT</version>
            </dependency>
      	</dependencies>
      </dependencyManagement>
        <dependencies>
            <!-- hibernate dependencies with provided scope -->
        </dependencies>
    
       <repositories>
      	<repository>
      		<id>jboss</id>
      		JBoss Repository
            <url>http://repository.jboss.org/maven2/</url>
      	</repository>
      </repositories>
    </project>
    

    Links:

    1. Seam
    2. Contexts and Dependency Injection in Java EE 6 (JSR 299)
    3. Google Guice
    4. Spring framework
    5. Seam in action
    6. Seam maven reference implementation
    7. Seam 2.x Web Development

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: