[seam/rest] 6e9075: SEAMREST-9
by noreply@github.com
Branch: refs/heads/master
Home: https://github.com/seam/rest
Commit: 6e9075d7e8cf36bce3d36f47f29c7477bee84ff4
https://github.com/seam/rest/commit/6e9075d7e8cf36bce3d36f47f29c7477bee84ff4
Author: Jozef Hartinger <jharting(a)redhat.com>
Date: 2011-01-06 (Thu, 06 Jan 2011)
Changed paths:
M api/src/main/java/org/jboss/seam/rest/validation/ValidateRequest.java
M docs/reference/src/main/docbook/en-US/validation.xml
M impl/src/main/java/org/jboss/seam/rest/util/Annotations.java
A impl/src/main/java/org/jboss/seam/rest/validation/MethodMetadata.java
R impl/src/main/java/org/jboss/seam/rest/validation/ValidatedMethodMetadata.java
M impl/src/main/java/org/jboss/seam/rest/validation/ValidationInterceptor.java
M impl/src/main/java/org/jboss/seam/rest/validation/ValidationMetadata.java
M impl/src/test/java/org/jboss/seam/rest/test/validation/PersonResource.java
Log Message:
-----------
SEAMREST-9
Commit: 8ddf3678dffa439f8036113f02204fcc94421f85
https://github.com/seam/rest/commit/8ddf3678dffa439f8036113f02204fcc94421f85
Author: Jozef Hartinger <jharting(a)redhat.com>
Date: 2011-01-11 (Tue, 11 Jan 2011)
Changed paths:
M api/src/main/java/org/jboss/seam/rest/validation/ValidateRequest.java
M docs/reference/src/main/docbook/en-US/validation.xml
M impl/src/main/java/org/jboss/seam/rest/util/Annotations.java
A impl/src/main/java/org/jboss/seam/rest/validation/MethodMetadata.java
R impl/src/main/java/org/jboss/seam/rest/validation/ValidatedMethodMetadata.java
M impl/src/main/java/org/jboss/seam/rest/validation/ValidationInterceptor.java
M impl/src/main/java/org/jboss/seam/rest/validation/ValidationMetadata.java
M impl/src/test/java/org/jboss/seam/rest/test/validation/PersonResource.java
Log Message:
-----------
Merge branch 'master' of git://github.com/jharting/seam-rest
13 years, 11 months
Seam SVN: r13985 - branches/community/Seam_2_2/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2011-01-11 08:12:39 -0500 (Tue, 11 Jan 2011)
New Revision: 13985
Modified:
branches/community/Seam_2_2/doc/Seam_Reference_Guide/en-US/Security.xml
Log:
JBSEAM-3347 plus changed formatting to other nonfitted objects
Modified: branches/community/Seam_2_2/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- branches/community/Seam_2_2/doc/Seam_Reference_Guide/en-US/Security.xml 2011-01-11 12:45:45 UTC (rev 13984)
+++ branches/community/Seam_2_2/doc/Seam_Reference_Guide/en-US/Security.xml 2011-01-11 13:12:39 UTC (rev 13985)
@@ -445,16 +445,17 @@
</para>
<programlisting role="XML"><![CDATA[
- <security:jpa-token-store token-class="org.jboss.seam.example.seamspace.AuthenticationToken"/>
- ]]></programlisting>
+<security:jpa-token-store token-class="org.jboss.seam.example.seamspace.AuthenticationToken" />]]>
+ </programlisting>
<para>
Once this is done, the last thing to do is to configure the <literal>RememberMe</literal> component in
<literal>components.xml</literal> also. Its <literal>mode</literal> should be set to <literal>autoLogin</literal>:
</para>
- <programlisting role="XML"><![CDATA[ <security:remember-me mode="autoLogin"/>
- ]]></programlisting>
+ <programlisting role="XML"><![CDATA[
+<security:remember-me mode="autoLogin"/>]]>
+ </programlisting>
<para>
That is all that is required - automatic authentication will now occur for users revisiting your site (as long as they
@@ -466,7 +467,8 @@
should be placed in components.xml:
</para>
- <programlisting role="XML"><![CDATA[ <event type="org.jboss.seam.security.notLoggedIn">
+ <programlisting role="XML">
+ <![CDATA[<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
<action execute="#{identity.tryLogin()}"/>
</event>
@@ -789,8 +791,8 @@
<table>
<title>User Entity Annotations</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="1*" />
<colspec colnum="2" colwidth="1*" />
<colspec colnum="3" colwidth="3*" />
@@ -841,7 +843,7 @@
<literal>md5</literal>, <literal>sha</literal> and <literal>none</literal>. E.g:
</para>
- <programlisting role="JAVA"><![CDATA[@UserPassword(hash = "md5")
+ <programlisting role="JAVA"><![CDATA[@UserPassword (hash="md5")
public String getPasswordHash() {
return passwordHash;
}]]></programlisting>
@@ -926,7 +928,7 @@
<table>
<title>Role Entity Annotations</title>
- <tgroup cols="2">
+ <tgroup cols="3">
<colspec colnum="1" colwidth="2*" />
<colspec colnum="2" colwidth="1*" />
<colspec colnum="3" colwidth="3*" />
@@ -1020,7 +1022,7 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/security-entities-1.png" align="center" scalefit="1"/>
+ <imagedata fileref="images/security-entities-1.png" align="center"/>
</imageobject>
<imageobject role="html">
<imagedata fileref="images/security-entities-1.png" align="center"/>
@@ -1228,8 +1230,8 @@
<title>LdapIdentityStore Configuration Properties</title>
<tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
- <colspec colnum="2" colwidth="1*" />
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="2*" />
<colspec colnum="3" colwidth="3*" />
<thead>
@@ -1711,8 +1713,9 @@
<table>
<title>Identity Management API</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="2*" />
+ <colspec colnum="2" colwidth="1*" />
<colspec colnum="2" colwidth="3*" />
<thead>
@@ -2127,9 +2130,10 @@
<table>
<title>Identity Management Security Permissions</title>
- <tgroup cols="2">
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="2*" />
<colspec colnum="1" colwidth="1*" />
- <colspec colnum="2" colwidth="3*" />
+ <colspec colnum="2" colwidth="2*" />
<thead>
<row>
@@ -3174,11 +3178,10 @@
<table>
<title>PermissionResolver interface</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="1*" />
<colspec colnum="2" colwidth="3*" />
- <colspec colnum="3" colwidth="3*" />
- <colspec colnum="4" colwidth="4*" />
+ <colspec colnum="3" colwidth="3*" />
<thead>
<row>
@@ -3282,7 +3285,7 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/security-permission-sequence.png" align="center"/>
+ <imagedata scalefit="1" fileref="images/security-permission-sequence.png" align="center"/>
</imageobject>
<imageobject role="html">
<imagedata fileref="images/security-permission-sequence.png" align="center"/>
@@ -3646,8 +3649,8 @@
<title>PermissionStore interface</title>
<tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
- <colspec colnum="2" colwidth="3*" />
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="2*" />
<colspec colnum="3" colwidth="3*" />
<thead>
@@ -3844,12 +3847,12 @@
<para>For example, to configure a single entity class to store both user and role permissions:</para>
- <programlisting role="XML"><![CDATA[<security:jpa-permission-store user-permission-class="com.acme.model.AccountPermission"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<security:jpa-permission-store user-permission-class="com.acme.model.AccountPermission" />]]></programlisting>
<para>To configure separate entity classes for storing user and role permissions:</para>
<programlisting role="XML"><![CDATA[<security:jpa-permission-store user-permission-class="com.acme.model.UserPermission"
- role-permission-class="com.acme.model.RolePermission"/>]]></programlisting>
+ role-permission-class="com.acme.model.RolePermission" />]]></programlisting>
<sect4>
<title>Permission annotations</title>
@@ -3864,8 +3867,8 @@
<title>Entity Permission annotations</title>
<tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
- <colspec colnum="2" colwidth="3*" />
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="1*" />
<colspec colnum="3" colwidth="3*" />
<thead>
@@ -3982,7 +3985,8 @@
and <literal>role</literal>, the annotation would be written like this:
</para>
- <programlisting role="JAVA"><![CDATA[@PermissionDiscriminator(userValue = "u", roleValue = "r")]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[@PermissionDiscriminator
+(userValue="u", roleValue="r")]]></programlisting>
</entry>
</row>
@@ -4080,9 +4084,9 @@
<table>
<title>Class Permission Annotations</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="2*" />
- <colspec colnum="2" colwidth="3*" />
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="1*" />
<colspec colnum="3" colwidth="3*" />
<thead>
@@ -4529,9 +4533,10 @@
<table>
<title>Permission Management Security Permissions</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="2*" />
<colspec colnum="2" colwidth="3*" />
+ <colspec colnum="2" colwidth="2*" />
<thead>
<row>
13 years, 11 months
Seam SVN: r13984 - in branches/community/Seam_2_2/examples: blog and 4 other directories.
by seam-commits@lists.jboss.org
Author: sannegrinovero
Date: 2011-01-11 07:45:45 -0500 (Tue, 11 Jan 2011)
New Revision: 13984
Added:
branches/community/Seam_2_2/examples/blog/jboss6/src/actions/IndexerService.java
Modified:
branches/community/Seam_2_2/examples/blog/
branches/community/Seam_2_2/examples/blog/build-jboss42.xml
branches/community/Seam_2_2/examples/blog/build-jboss6.xml
branches/community/Seam_2_2/examples/blog/build.xml
branches/community/Seam_2_2/examples/blog/jboss6/src/actions/SearchService.java
branches/community/Seam_2_2/examples/blog/readme.txt
branches/community/Seam_2_2/examples/blog/src/actions/SearchService.java
branches/community/Seam_2_2/examples/blog/src/domain/BlogEntry.java
branches/community/Seam_2_2/examples/build.xml
branches/community/Seam_2_2/examples/dvdstore/build-jboss42.xml
branches/community/Seam_2_2/examples/dvdstore/build-jboss6.xml
branches/community/Seam_2_2/examples/dvdstore/build.xml
Log:
JBSEAM-4759 - update DVD-Store example to show new Hibernate Search features - blog example
Property changes on: branches/community/Seam_2_2/examples/blog
___________________________________________________________________
Name: svn:ignore
- build
test-output
exploded-archives
dist
test-build
+ build
test-output
exploded-archives
dist
test-build
dist-jbossas6
exploded-archives-jbossas6
lib
staging-jbossas6
blogindexes
Modified: branches/community/Seam_2_2/examples/blog/build-jboss42.xml
===================================================================
--- branches/community/Seam_2_2/examples/blog/build-jboss42.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/build-jboss42.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -2,8 +2,36 @@
<project name="Blog" default="deploy" basedir=".">
- <property name="han.lib" value="yes"/>
+ <!-- Naming -->
+ <property name="Name" value="Seam Blog Example" />
+ <property name="example.name" value="jboss-seam-blog" />
+
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes" />
+ <property name="seam.debug.lib" value="yes" />
+ <property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
+ <property name="cache.lib" value="yes" />
+ <property name="han.lib" value="yes" />
- <import file="../build.xml"/>
-
+ <!-- Datasource -->
+ <property name="example.ds" value="blog-ds.xml" />
+
+ <target name="init" depends="gethsearch3.1">
+ <fileset id="ear.lib.extras" dir="${example.lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ <antcall target="SeamExample.init"/>
+ <path id="build.classpath.extras">
+ <fileset dir="${lib.search.dir}">
+ <include name="*.jar" />
+ </fileset>
+ <fileset dir="${example.lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+ </target>
+
+ <import file="../build.xml" />
+
</project>
Modified: branches/community/Seam_2_2/examples/blog/build-jboss6.xml
===================================================================
--- branches/community/Seam_2_2/examples/blog/build-jboss6.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/build-jboss6.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -2,41 +2,44 @@
<project name="Blog" default="deploy" basedir=".">
- <!-- Naming -->
- <property name="Name" value="Seam Blog Example"/>
- <property name="example.name" value="jboss-seam-blog"/>
- <property name="jboss6" value="yes"/>
- <!-- Libraries to include -->
- <property name="seam.ui.lib" value="yes"/>
- <property name="seam.debug.lib" value="yes"/>
- <property name="facelets.lib" value="yes"/>
- <property name="search.lib" value="yes"/>
- <property name="cache.lib" value="yes"/>
+ <!-- Naming -->
+ <property name="Name" value="Seam Blog Example" />
+ <property name="example.name" value="jboss-seam-blog" />
+ <property name="jboss6" value="yes" />
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes" />
+ <property name="seam.debug.lib" value="yes" />
+ <property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
+ <property name="cache.lib" value="yes" />
<!-- Datasource -->
- <property name="example.ds" value="blog-ds.xml"/>
+ <property name="example.ds" value="blog-ds.xml" />
- <target name="init" depends="preparesrc">
- <antcall target="SeamExample.init"/>
- <path id="build.classpath.extras">
- <fileset dir="${lib.search.dir}">
- <include name="*.jar"/>
- </fileset>
- </path>
- </target>
-
+ <target name="init" depends="preparesrc">
+ <antcall target="SeamExample.init" />
+ <path id="build.classpath.extras">
+ <fileset dir="${lib.search.dir}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+ </target>
+
<target name="preparesrc">
- <mkdir dir="${src.java.dir}"/>
+ <mkdir dir="${src.java.dir}" />
<copy todir="${src.java.dir}">
<fileset includes="**" dir="jboss6/src" />
</copy>
<copy todir="${src.java.dir}">
- <fileset includes="**" excludes="src/actions/SearchService.java" dir="src"/>
- </copy>
-
+ <fileset dir="src">
+ <include name="**" />
+ <exclude name="src/actions/SearchService.java" />
+ <exclude name="src/actions/IndexerService.java" />
+ </fileset>
+ </copy>
</target>
- <import file="../build.xml"/>
-
+ <import file="../build.xml" />
+
</project>
Modified: branches/community/Seam_2_2/examples/blog/build.xml
===================================================================
--- branches/community/Seam_2_2/examples/blog/build.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/build.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -2,29 +2,48 @@
<project name="Blog" default="deploy" basedir=".">
- <!-- Naming -->
- <property name="Name" value="Seam Blog Example"/>
- <property name="example.name" value="jboss-seam-blog"/>
+ <!-- Naming -->
+ <property name="Name" value="Seam Blog Example" />
+ <property name="example.name" value="jboss-seam-blog" />
- <!-- Libraries to include -->
- <property name="seam.ui.lib" value="yes"/>
- <property name="seam.debug.lib" value="yes"/>
- <property name="facelets.lib" value="yes"/>
- <property name="search.lib" value="yes"/>
- <property name="cache.lib" value="yes"/>
-
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes" />
+ <property name="seam.debug.lib" value="yes" />
+ <property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
+ <property name="example.lib.dir" value="lib" />
+ <property name="cache.lib" value="yes" />
+
<!-- Datasource -->
<property name="example.ds" value="blog-ds.xml"/>
- <property name="clean.extra" value="${basedir}/blogindexes" />
+ <property name="clean.extra" value="${basedir}/blogindexes" />
+ <target name="init" depends="gethsearch3.1">
+ <fileset id="ear.lib.extras" dir="${example.lib.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ <antcall target="SeamExample.init"/>
+ <path id="build.classpath.extras">
+ <fileset dir="${lib.search.dir}">
+ <include name="*.jar"/>
+ <!-- Exclude at least wicket or it has tests fail-->
+ <exclude name="*wicket*.jar" />
+ </fileset>
+ <fileset dir="${example.lib.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+ </target>
+
<target name="jboss42" description="Build the Blog example artifacts, and deploy to JBoss AS 4.2.x.GA">
<ant antfile="build-jboss42.xml"/>
- </target>
+ </target>
- <import file="../build.xml"/>
-
<target name="jboss6" description="Build the Blog example artifacts, and deploy to JBoss AS 6">
<ant antfile="build-jboss6.xml"/>
</target>
+
+ <import file="../build.xml" />
+
</project>
Added: branches/community/Seam_2_2/examples/blog/jboss6/src/actions/IndexerService.java
===================================================================
--- branches/community/Seam_2_2/examples/blog/jboss6/src/actions/IndexerService.java (rev 0)
+++ branches/community/Seam_2_2/examples/blog/jboss6/src/actions/IndexerService.java 2011-01-11 12:45:45 UTC (rev 13984)
@@ -0,0 +1,37 @@
+//$Id$
+package actions;
+
+import javax.ejb.Remove;
+
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+
+/**
+ * Index Blog entry at startup
+ *
+ * @author Emmanuel Bernard
+ * @author Sanne Grinovero
+ */
+@Name("indexerService")
+(a)Scope(ScopeType.APPLICATION)
+@Startup
+public class IndexerService
+{
+ @In
+ private FullTextEntityManager entityManager;
+
+ @Create
+ public void index() {
+ entityManager.createIndexer().start();
+ }
+
+ @Remove
+ @Destroy
+ public void stop() {}
+}
Property changes on: branches/community/Seam_2_2/examples/blog/jboss6/src/actions/IndexerService.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: branches/community/Seam_2_2/examples/blog/jboss6/src/actions/SearchService.java
===================================================================
--- branches/community/Seam_2_2/examples/blog/jboss6/src/actions/SearchService.java 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/jboss6/src/actions/SearchService.java 2011-01-11 12:45:45 UTC (rev 13984)
@@ -1,15 +1,11 @@
+//$Id$
package actions;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.MultiFieldQueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.util.Version;
+import org.apache.lucene.search.Query;
import org.hibernate.search.jpa.FullTextEntityManager;
+import org.hibernate.search.query.dsl.QueryBuilder;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
@@ -20,6 +16,7 @@
* Pulls the search results
*
* @author Gavin King
+ * @author Sanne Grinovero
*/
@Name("searchService")
public class SearchService
@@ -35,32 +32,58 @@
{
if (searchPattern==null || "".equals(searchPattern) ) {
searchPattern = null;
- return entityManager.createQuery("select be from BlogEntry be order by date desc").getResultList();
+ return getLatestBlogEntries(100);
}
else
{
- Map<String,Float> boostPerField = new HashMap<String,Float>();
- boostPerField.put( "title", 4f );
- boostPerField.put( "body", 1f );
- String[] productFields = {"title", "body"};
- QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_30, productFields, new StandardAnalyzer(Version.LUCENE_30), boostPerField);
- parser.setAllowLeadingWildcard(true);
- org.apache.lucene.search.Query luceneQuery;
- try
- {
- luceneQuery = parser.parse(searchPattern);
- }
- catch (ParseException e)
- {
- return null;
- }
-
+ Query luceneQuery = getFullTextQuery();
return entityManager.createFullTextQuery(luceneQuery, BlogEntry.class)
.setMaxResults(100)
.getResultList();
}
}
+ private Query getFullTextQuery()
+ {
+ //Create a QueryBuilder targeting BlogEntry
+ QueryBuilder queryBuilder = entityManager
+ .getSearchFactory()
+ .buildQueryBuilder()
+ .forEntity(BlogEntry.class)
+ .get();
+
+ //A fulltext query using English Analyzer
+ Query queryUsingEnglishStemmer = queryBuilder.keyword()
+ .onFields("title:en").boostedTo(4f)
+ .andField("body:en")
+ .matching(searchPattern)
+ .createQuery();
+
+ //A fulltext query using ngrams
+ Query queryUsingNGrams = queryBuilder.keyword()
+ .onFields("title:ngrams").boostedTo(2f)
+ .andField("body:ngrams").boostedTo(0.4f)
+ .matching(searchPattern)
+ .createQuery();
+
+ //Combine them for best results:
+ Query fullTextQuery = queryBuilder.bool()
+ .should(queryUsingEnglishStemmer)
+ .should(queryUsingNGrams)
+ .createQuery();
+
+ return fullTextQuery;
+ }
+
+ private List<BlogEntry> getLatestBlogEntries(int limit)
+ {
+ return entityManager
+ .createQuery("select be from BlogEntry be order by date desc")
+ .setHint("org.hibernate.cacheable", true)
+ .setMaxResults(limit)
+ .getResultList();
+ }
+
public String getSearchPattern()
{
return searchPattern;
Property changes on: branches/community/Seam_2_2/examples/blog/jboss6/src/actions/SearchService.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Modified: branches/community/Seam_2_2/examples/blog/readme.txt
===================================================================
--- branches/community/Seam_2_2/examples/blog/readme.txt 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/readme.txt 2011-01-11 12:45:45 UTC (rev 13984)
@@ -6,10 +6,11 @@
This example runs on JBoss AS as an EAR or Tomcat with JBoss Embedded as a WAR.
-JBoss AS 4.2 needs additional hibernate libraries, use ant target jboss42 for deploying to it.
+JBoss AS 4.2 needs additional Hibernate libraries, use ant target jboss42 for deploying to it.
-JBoss AS 6 needs new hibernate search and hibernate-commons-annotations, and more source code enhancement due Hibernate Search and Lucene-Core
-API changes. Therefore use ant target jboss6 for deploying to JBoss AS 6 M5 and later. For instance:
+JBoss AS 6 needs new Hibernate Search with dependencies, and more source code enhancement due to
+Hibernate Search and Lucene-Core API changes.
+Therefore use ant target jboss6 for deploying to JBoss AS 6 M5 and later. For instance:
ant -f build-jboss6.xml
Modified: branches/community/Seam_2_2/examples/blog/src/actions/SearchService.java
===================================================================
--- branches/community/Seam_2_2/examples/blog/src/actions/SearchService.java 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/src/actions/SearchService.java 2011-01-11 12:45:45 UTC (rev 13984)
@@ -34,14 +34,18 @@
{
if (searchPattern==null || "".equals(searchPattern) ) {
searchPattern = null;
- return entityManager.createQuery("select be from BlogEntry be order by date desc").getResultList();
+ return entityManager
+ .createQuery("select be from BlogEntry be order by date desc")
+ .setHint("org.hibernate.cacheable", true)
+ .setMaxResults(100)
+ .getResultList();
}
else
{
Map<String,Float> boostPerField = new HashMap<String,Float>();
- boostPerField.put( "title", 4f );
- boostPerField.put( "body", 1f );
- String[] productFields = {"title", "body"};
+ boostPerField.put( "title:en", 4f );
+ boostPerField.put( "body:en", 1f );
+ String[] productFields = {"title:en", "body:en"};
QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer(), boostPerField);
parser.setAllowLeadingWildcard(true);
org.apache.lucene.search.Query luceneQuery;
Modified: branches/community/Seam_2_2/examples/blog/src/domain/BlogEntry.java
===================================================================
--- branches/community/Seam_2_2/examples/blog/src/domain/BlogEntry.java 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/blog/src/domain/BlogEntry.java 2011-01-11 12:45:45 UTC (rev 13984)
@@ -1,3 +1,4 @@
+//$Id$
package domain;
import java.util.Date;
@@ -6,23 +7,50 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
+import org.apache.solr.analysis.LowerCaseFilterFactory;
+import org.apache.solr.analysis.NGramFilterFactory;
+import org.apache.solr.analysis.SnowballPorterFilterFactory;
+import org.apache.solr.analysis.StandardTokenizerFactory;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.AnalyzerDefs;
+import org.hibernate.search.annotations.Fields;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.TokenFilterDef;
+import org.hibernate.search.annotations.TokenizerDef;
/**
* Represents a blog entry.
*
- * @author Simon Brown
+ * @author Simon Brown
+ * @author Sanne Grinovero
*/
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Indexed
+@AnalyzerDefs({
+ @AnalyzerDef(name = "en",
+ tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
+ filters = {
+ @TokenFilterDef(factory = LowerCaseFilterFactory.class),
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
+ })
+ }),
+ @AnalyzerDef(name="ngrams", tokenizer=(a)TokenizerDef(factory=StandardTokenizerFactory.class),
+ filters={
+ @TokenFilterDef(factory = LowerCaseFilterFactory.class),
+ @TokenFilterDef(factory = NGramFilterFactory.class,
+ params = { @Parameter(name = "minGramSize", value = "3"), @Parameter(name = "maxGramSize", value = "3") })
+ })}
+ )
public class BlogEntry {
@Id @Length(min=1, max=20)
@@ -30,14 +58,18 @@
private String id;
@NotNull @Length(max=70)
- @Field(index = Index.TOKENIZED)
+ @Fields({
+ @Field(name="title:en", analyzer=@Analyzer(definition="en")),
+ @Field(name="title:ngrams", analyzer=@Analyzer(definition="ngrams"))})
private String title;
@Length(max=200)
private String excerpt;
@NotNull @Length(max=1400)
- @Field(index = Index.TOKENIZED)
+ @Fields({
+ @Field(name="body:en", analyzer=@Analyzer(definition="en")),
+ @Field(name="body:ngrams", analyzer=@Analyzer(definition="ngrams"))})
private String body;
@NotNull
Modified: branches/community/Seam_2_2/examples/build.xml
===================================================================
--- branches/community/Seam_2_2/examples/build.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/build.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -377,6 +377,7 @@
<!-- Dependencies for using Seam with Hibernate Search -->
<fileset id="search.jar" dir="${lib.search.dir}">
<include name="lucene-core.jar" if="search.lib" />
+ <include name="lucene-snowball.jar" if="search.lib" />
<include name="lucene-analyzers.jar" if="search.lib" />
<include name="hibernate-search.jar" if="search.lib" />
<include name="solr-core.jar" if="search.lib" />
@@ -676,6 +677,7 @@
<exclusion groupId="org.hibernate" artifactId="hibernate-core"/>
</dependency>
<dependency groupId="org.hibernate" artifactId="hibernate-search-analyzers" version="3.3.0.Final" />
+ <dependency groupId="org.apache.lucene" artifactId="lucene-snowball" version="3.0.3" />
</copyInlineDependencies>
</target>
@@ -688,7 +690,6 @@
<exclusion groupId="org.apache.solr" artifactId="solr-lucene-core" />
<exclusion groupId="org.apache.solr" artifactId="solr-lucene-highlighter" />
<exclusion groupId="org.apache.solr" artifactId="solr-lucene-spellchecker" />
- <exclusion groupId="org.apache.solr" artifactId="solr-lucene-snowball" />
<exclusion groupId="org.apache.solr" artifactId="solr-commons-csv" />
<exclusion groupId="woodstox" artifactId="wstx-asl" />
<exclusion groupId="net.java.dev.stax-utils" artifactId="stax-utils" />
Modified: branches/community/Seam_2_2/examples/dvdstore/build-jboss42.xml
===================================================================
--- branches/community/Seam_2_2/examples/dvdstore/build-jboss42.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/dvdstore/build-jboss42.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -3,17 +3,16 @@
<project name="DVDStore" default="deploy" basedir=".">
<!-- Naming -->
- <property name="Name" value="Seam Dvd Store Example"/>
- <property name="example.name" value="jboss-seam-dvdstore"/>
- <!-- Libraries -->
- <property name="seam.ui.lib" value="yes" />
- <property name="seam.debug.lib" value="yes" />
- <property name="facelets.lib" value="yes" />
- <property name="jbpm.lib" value="yes" />
- <property name="search.lib" value="yes" />
- <property name="urlrewrite.lib" value="yes"/>
-
- <property name="han.lib" value="yes"/>
+ <property name="Name" value="Seam Dvd Store Example"/>
+ <property name="example.name" value="jboss-seam-dvdstore"/>
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes" />
+ <property name="seam.debug.lib" value="yes" />
+ <property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
+ <property name="jbpm.lib" value="yes" />
+ <property name="urlrewrite.lib" value="yes" />
+ <property name="han.lib" value="yes" />
<target name="init" depends="gethsearch3.1">
<fileset id="ear.lib.extras" dir="${example.lib.dir}">
@@ -30,6 +29,6 @@
</path>
</target>
- <import file="../build.xml"/>
-
+ <import file="../build.xml"/>
+
</project>
Modified: branches/community/Seam_2_2/examples/dvdstore/build-jboss6.xml
===================================================================
--- branches/community/Seam_2_2/examples/dvdstore/build-jboss6.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/dvdstore/build-jboss6.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -5,25 +5,25 @@
<property name="Name" value="Seam Dvd Store Example"/>
<property name="example.name" value="jboss-seam-dvdstore"/>
<property name="jboss6" value="yes"/>
- <!-- Libraries -->
+ <!-- Libraries to include -->
<property name="seam.ui.lib" value="yes" />
<property name="seam.debug.lib" value="yes" />
<property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
<property name="jbpm.lib" value="yes" />
- <property name="search.lib" value="yes" />
- <property name="urlrewrite.lib" value="yes"/>
+ <property name="urlrewrite.lib" value="yes" />
- <target name="init" depends="preparesrc">
- <antcall target="SeamExample.init"/>
- <path id="build.classpath.extras">
- <fileset dir="${lib.search.dir}">
- <include name="*.jar" />
- </fileset>
- </path>
- </target>
+ <target name="init" depends="preparesrc">
+ <antcall target="SeamExample.init" />
+ <path id="build.classpath.extras">
+ <fileset dir="${lib.search.dir}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+ </target>
<target name="preparesrc">
- <mkdir dir="${src.java.dir}"/>
+ <mkdir dir="${src.java.dir}" />
<copy todir="${src.java.dir}">
<fileset includes="**" dir="jboss6/src" />
@@ -37,6 +37,6 @@
</copy>
</target>
- <import file="../build.xml"/>
+ <import file="../build.xml" />
</project>
Modified: branches/community/Seam_2_2/examples/dvdstore/build.xml
===================================================================
--- branches/community/Seam_2_2/examples/dvdstore/build.xml 2011-01-10 17:58:12 UTC (rev 13983)
+++ branches/community/Seam_2_2/examples/dvdstore/build.xml 2011-01-11 12:45:45 UTC (rev 13984)
@@ -3,17 +3,17 @@
<project name="DVDStore" default="deploy" basedir=".">
<!-- Naming -->
- <property name="Name" value="Seam DVD Store Example" />
- <property name="example.name" value="jboss-seam-dvdstore" />
+ <property name="Name" value="Seam DVD Store Example" />
+ <property name="example.name" value="jboss-seam-dvdstore" />
- <!-- Libraries -->
- <property name="seam.ui.lib" value="yes" />
- <property name="seam.debug.lib" value="yes" />
- <property name="facelets.lib" value="yes" />
- <property name="jbpm.lib" value="yes" />
- <property name="search.lib" value="yes" />
- <property name="urlrewrite.lib" value="yes"/>
- <property name="example.lib.dir" value="lib"/>
+ <!-- Libraries to include -->
+ <property name="seam.ui.lib" value="yes" />
+ <property name="seam.debug.lib" value="yes" />
+ <property name="facelets.lib" value="yes" />
+ <property name="search.lib" value="yes" />
+ <property name="example.lib.dir" value="lib" />
+ <property name="jbpm.lib" value="yes" />
+ <property name="urlrewrite.lib" value="yes" />
<!-- Datasource -->
<property name="example.ds" value="jboss-seam-dvdstore-ds.xml" />
@@ -53,7 +53,7 @@
<exclude name=".gpd.*.jpdl.xml" />
</fileset>
- <target name="jboss42" description="Build the DvdStore example artifacts, and deploy to JBoss 4.2.x.GA">
+ <target name="jboss42" description="Build the DvdStore example artifacts, and deploy to JBoss AS 4.2.x.GA">
<ant antfile="build-jboss42.xml"/>
</target>
13 years, 11 months