Author: lukaszlenart Date: Tue Dec 18 20:37:23 2012 New Revision: 1423630 URL: http://svn.apache.org/viewvc?rev=1423630&view=rev Log: WW-3947 improves Portlet Archetype
Removed: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/test/java/JettyPlutoLauncher.java Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/README.txt struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/META-INF/maven/archetype-metadata.xml struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/HelloAction.java struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/UpdateNameAction.java struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/resources/struts.xml struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/portlet.xml struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/README.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/README.txt?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/README.txt (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/README.txt Tue Dec 18 20:37:23 2012 @@ -1,42 +1,38 @@ INFORMATION =========== - This is Struts 2's "Portlet" Maven Archetype -- To be used to create a simple portlet that can be deployed as a webapp or JSR168 portlet. +- To be used to create a simple portlet that can be deployed as JSR286 portlet. +- There is a maven profile in order to test this portlet on Pluto Portal. USAGE ===== -- change directory to where the portlet template is to be created, - for example, a 'projects' directory (which you may need to create): - - cd /home/tmjee/projects - -- run the following command to generate the sample portlet template, assuming :- - - root java package -> com.myCompany.myPortlet - - - the portlet war name -> myWebApp - - - mvn archetype:create -DgroupId=com.myCompany.myPortlet \ - -DartifactId=myWebApp \ - -DarchetypeGroupId=org.apache.struts \ - -DarchetypeArtifactId=struts2-archetype-portlet \ - -DarchetypeVersion=2.0.9-SNAPSHOT \ - -DremoteRepositories=http://people.apache.org/maven-snapshot-repository - -- to compile, execute - mvn compile - -- to run test cases execute - mvn test +1- Generate your archetype +- mvn archetype:generate -DartifactId=struts2-portlet-helloworld -DgroupId=com.mycompany.struts2.portlet -Dversion=1.0.0-SNAPSHOT -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-portlet -DarchetypeVersion=2.3.8 + +2- Build your portlet project for Pluto Portal +- cd struts2-portlet-helloworld +- mvn clean package -Ppluto-embedded + +3- Download and install Pluto Portal +- cd .. +- curl -v -H "Accept-Encoding: gzip" "http://apache.opensourcemirror.com/portals/pluto/pluto-2.0.3-bundle.zip" > pluto-2.0.3.zip +- unzip pluto-2.0.3.zip -d . + +4- Deploy your portlet app +- cp struts2-portlet-helloworld/target/struts2-portlet-helloworld-1.0.0-SNAPSHOT.war pluto-2.0.3/webapps + +5- Start Pluto Portal and create a page for your portlet +- ./pluto-2.0.3/bin/startup.sh +- Go to http://localhost:8080/pluto/portal (login: pluto / pwd: pluto) +- Click on "Pluto Admin" (http://localhost:8080/pluto/portal/Pluto%20Admin) +- On "Portal Pages" section : Add page "Struts2" +- On "Portlet Applications" section : select "/struts2-portlet-helloworld" and "HelloPortlet" then click "Add Portlet" + +6- Test your portlet app +- Go to your Struts2 page http://localhost:8080/pluto/portal/Struts2 and play with your portlet !! -- to clean execute - mvn clean -- to package execute - mvn package -- to start it with jetty execute as a servlet - mvn jetty:run Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/META-INF/maven/archetype-metadata.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/META-INF/maven/archetype-metadata.xml (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/META-INF/maven/archetype-metadata.xml Tue Dec 18 20:37:23 2012 @@ -16,7 +16,7 @@ </includes> </fileSet> - <fileSet filtered="false" packaged="false"> + <fileSet filtered="true" packaged="false"> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml Tue Dec 18 20:37:23 2012 @@ -10,7 +10,13 @@ <name>\${artifactId}</name> <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <struts2.version>${project.version}</struts2.version> + <portlet.api.version>2.0</portlet.api.version> + <!-- plugins --> + <plugin.compiler.version>3.0</plugin.compiler.version> + <plugin.war.version>2.3</plugin.war.version> + <plugin.pluto.version>2.0.3</plugin.pluto.version> </properties> <dependencies> @@ -29,104 +35,57 @@ </dependency> <dependency> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-config-browser-plugin</artifactId> - <version>\${struts2.version}</version> - </dependency> - - <dependency> <groupId>javax.portlet</groupId> <artifactId>portlet-api</artifactId> - <version>2.0</version> + <version>${portlet.api.version}</version> <scope>provided</scope> </dependency> - - <dependency> - <groupId>com.bekk.boss</groupId> - <artifactId>maven-jetty-pluto-embedded</artifactId> - <version>1.0.1</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty</artifactId> - <version>6.1.21</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jsp-2.1</artifactId> - <version>6.1.14</version> - <scope>provided</scope> - </dependency> - + </dependencies> <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> + <version>${plugin.compiler.version}</version> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> </plugins> </build> - <profiles> - <profile> - <id>pluto-embedded</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.pluto</groupId> - <artifactId>maven-pluto-plugin</artifactId> - <version>1.1.6</version> - <executions> - <execution> - <phase>generate-resources</phase> - <goals> - <goal>assemble</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.mortbay.jetty</groupId> - <artifactId>maven-jetty-plugin</artifactId> - <version>6.1.21</version> - <configuration> - <webXml>${project.build.directory}/pluto-resources/web.xml</webXml> - <webAppConfig> - <contextPath>/${project.artifactId}</contextPath> - <defaultsDescriptor>/WEB-INF/jetty-pluto-web-default.xml</defaultsDescriptor> - </webAppConfig> - <systemProperties> - <systemProperty> - <name>org.apache.pluto.embedded.portletIds</name> - <value>HelloPortlet</value> - </systemProperty> - </systemProperties> - <scanIntervalSeconds>10</scanIntervalSeconds> - <scanTargets> - <scanTarget>src/main/webapp/WEB-INF</scanTarget> - <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget> - <scanTarget>src/main/resources/struts.xml</scanTarget> - </scanTargets> - </configuration> - <dependencies> - <dependency> - <groupId>com.bekk.boss</groupId> - <artifactId>maven-jetty-pluto-embedded</artifactId> - <version>1.0.1</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - </profile> - </profiles> + <profiles> + <profile> + <id>pluto-embedded</id> + <build> + <plugins> + <!-- configure maven-war-plugin to use updated web.xml --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>${plugin.war.version}</version> + <configuration> + <webXml>\${project.build.directory}/pluto-resources/web.xml</webXml> + </configuration> + </plugin> + <!-- bind 'pluto2:assemble' goal to 'generate-resources' lifecycle --> + <plugin> + <groupId>org.apache.portals.pluto</groupId> + <artifactId>maven-pluto-plugin</artifactId> + <version>${plugin.pluto.version}</version> + <executions> + <execution> + <goals> + <goal>assemble</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/HelloAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/HelloAction.java?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/HelloAction.java (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/HelloAction.java Tue Dec 18 20:37:23 2012 @@ -1,12 +1,10 @@ -package ${packageName}; +package ${package}; import javax.portlet.PortletPreferences; import org.apache.struts2.dispatcher.DefaultActionSupport; import org.apache.struts2.portlet.interceptor.PortletPreferencesAware; -import com.opensymphony.xwork2.Preparable; - public class HelloAction extends DefaultActionSupport implements PortletPreferencesAware { private static final long serialVersionUID = 1L; Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/UpdateNameAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/UpdateNameAction.java?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/UpdateNameAction.java (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/java/UpdateNameAction.java Tue Dec 18 20:37:23 2012 @@ -1,4 +1,4 @@ -package ${packageName}; +package ${package}; import javax.portlet.PortletPreferences; Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/resources/struts.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/resources/struts.xml?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/resources/struts.xml (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/resources/struts.xml Tue Dec 18 20:37:23 2012 @@ -5,14 +5,14 @@ <struts> <package name="default" extends="struts-portlet-default" namespace="/view"> - <action name="index" class="${packageName}.HelloAction"> + <action name="index" class="${package}.HelloAction"> <result>/WEB-INF/jsp/view/index.jsp</result> </action> </package> <package name="edit" extends="struts-portlet-default" namespace="/edit"> - <action name="index" class="${packageName}.UpdateNameAction"> + <action name="index" class="${package}.UpdateNameAction"> <result type="redirectAction"> <param name="actionName">index</param> <param name="portletMode">view</param> Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/portlet.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/portlet.xml?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/portlet.xml (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/portlet.xml Tue Dec 18 20:37:23 2012 @@ -1,19 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> -<portlet-app - version="1.0" - xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" - id="${artifactId}"> +<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd + http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" + id="\${artifactId}"> <portlet id="HelloPortlet"> <description xml:lang="EN">Simple hello world portlet</description> <portlet-name>HelloPortlet</portlet-name> - <display-name xml:lang="EN">${artifactId}</display-name> + <display-name xml:lang="EN">\${artifactId}</display-name> <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class> + <init-param> + <name>actionPackages</name> + <value>${package}</value> + </init-param> + <!-- The namespace for the actions configured for view mode --> <init-param> <name>viewNamespace</name> Modified: struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml?rev=1423630&r1=1423629&r2=1423630&view=diff ============================================================================== --- struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml (original) +++ struts/struts2/trunk/archetypes/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml Tue Dec 18 20:37:23 2012 @@ -1,5 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app id="${artifactId}"> - <!-- Empty --> +<web-app id="\${artifactId}"> + <display-name>Struts2 Hello World Portlet</display-name> + + <filter> + <filter-name>struts2</filter-name> + <filter-class> + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + </filter-class> + </filter> + + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> </web-app>