Seam SVN: r7731 - branches/Seam_2_0/src/main/org/jboss/seam/pageflow and 2 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 08:07:24 -0400 (Fri, 28 Mar 2008)
New Revision: 7731
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Events.xml
branches/Seam_2_0/src/main/org/jboss/seam/pageflow/Pageflow.java
trunk/doc/reference/en/modules/events.xml
trunk/src/main/org/jboss/seam/pageflow/Pageflow.java
Log:
JBSEAM-2787
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Events.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Events.xml 2008-03-28 11:56:30 UTC (rev 7730)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Events.xml 2008-03-28 12:07:24 UTC (rev 7731)
@@ -667,7 +667,9 @@
<listitem><para><literal>org.jboss.seam.beginConversation </literal>— called whenever a long-running conversation begins</para></listitem>
<listitem><para><literal>org.jboss.seam.endConversation </literal>— called whenever a long-running conversation ends</para></listitem>
<listitem><para><literal>org.jboss.seam.conversationTimeout</literal>— called when a conversation timeout occurs. The conversation id is passed as a parameter.</para></listitem>
+ <listitem><para><literal>org.jboss.seam.beginPageflow </literal>— called when a pageflow begins</para></listitem>
<listitem><para><literal>org.jboss.seam.beginPageflow.<name> </literal>— called when the pageflow <name> begins</para></listitem>
+ <listitem><para><literal>org.jboss.seam.endPageflow </literal>— called when a pageflow ends</para></listitem>
<listitem><para><literal>org.jboss.seam.endPageflow.<name> </literal>— called when the pageflow <name> ends</para></listitem>
<listitem><para><literal>org.jboss.seam.createProcess.<name> </literal>— called when the process <name> is created</para></listitem>
<listitem><para><literal>org.jboss.seam.endProcess.<name> </literal>— called when the process <name> ends</para></listitem>
Modified: branches/Seam_2_0/src/main/org/jboss/seam/pageflow/Pageflow.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/pageflow/Pageflow.java 2008-03-28 11:56:30 UTC (rev 7730)
+++ branches/Seam_2_0/src/main/org/jboss/seam/pageflow/Pageflow.java 2008-03-28 12:07:24 UTC (rev 7731)
@@ -348,6 +348,8 @@
"org.jboss.seam.endPageflow." +
processInstance.getProcessDefinition().getName()
);
+ Events.instance().raiseEvent(
+ "org.jboss.seam.endPageflow");
}
}
@@ -411,6 +413,7 @@
protected void raiseBeginEvent(String pageflowDefinitionName)
{
Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
+ Events.instance().raiseEvent("org.jboss.seam.beginPageflow");
}
private void storePageflowToViewRootIfNecessary()
Modified: trunk/doc/reference/en/modules/events.xml
===================================================================
--- trunk/doc/reference/en/modules/events.xml 2008-03-28 11:56:30 UTC (rev 7730)
+++ trunk/doc/reference/en/modules/events.xml 2008-03-28 12:07:24 UTC (rev 7731)
@@ -655,7 +655,9 @@
<listitem><para><literal>org.jboss.seam.beginConversation </literal>— called whenever a long-running conversation begins</para></listitem>
<listitem><para><literal>org.jboss.seam.endConversation </literal>— called whenever a long-running conversation ends</para></listitem>
<listitem><para><literal>org.jboss.seam.conversationTimeout</literal>— called when a conversation timeout occurs. The conversation id is passed as a parameter.</para></listitem>
+ <listitem><para><literal>org.jboss.seam.beginPageflow</literal>— called when a pageflow begins</para></listitem>
<listitem><para><literal>org.jboss.seam.beginPageflow.<name> </literal>— called when the pageflow <name> begins</para></listitem>
+ <listitem><para><literal>org.jboss.seam.endPageflow</literal>— called when a pageflow ends</para></listitem>
<listitem><para><literal>org.jboss.seam.endPageflow.<name> </literal>— called when the pageflow <name> ends</para></listitem>
<listitem><para><literal>org.jboss.seam.createProcess.<name> </literal>— called when the process <name> is created</para></listitem>
<listitem><para><literal>org.jboss.seam.endProcess.<name> </literal>— called when the process <name> ends</para></listitem>
Modified: trunk/src/main/org/jboss/seam/pageflow/Pageflow.java
===================================================================
--- trunk/src/main/org/jboss/seam/pageflow/Pageflow.java 2008-03-28 11:56:30 UTC (rev 7730)
+++ trunk/src/main/org/jboss/seam/pageflow/Pageflow.java 2008-03-28 12:07:24 UTC (rev 7731)
@@ -348,6 +348,8 @@
"org.jboss.seam.endPageflow." +
processInstance.getProcessDefinition().getName()
);
+ Events.instance().raiseEvent(
+ "org.jboss.seam.endPageflow");
}
}
@@ -411,6 +413,7 @@
protected void raiseBeginEvent(String pageflowDefinitionName)
{
Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
+ Events.instance().raiseEvent("org.jboss.seam.beginPageflow");
}
private void storePageflowToViewRootIfNecessary()
16 years, 1 month
Seam SVN: r7730 - branches/Seam_2_0/doc/Seam_Reference_Guide.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 07:56:30 -0400 (Fri, 28 Mar 2008)
New Revision: 7730
Removed:
branches/Seam_2_0/doc/Seam_Reference_Guide/Makefile
Log:
Remove unused file
Deleted: branches/Seam_2_0/doc/Seam_Reference_Guide/Makefile
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/Makefile 2008-03-28 11:11:49 UTC (rev 7729)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/Makefile 2008-03-28 11:56:30 UTC (rev 7730)
@@ -1,14 +0,0 @@
-#Makefile for Red Hat Documentation
-#Created by Jeff Fearn <jfearn(a)redhat.com>
-#Copyright Red Hat Inc. 2006
-
-XML_LANG = en-US
-DOCNAME = Seam_Reference_Guide
-SYSTEM = Seam
-
-TRANSLATIONS = $(XML_LANG)
-#OTHER_LANGS = as-IN bn-IN de-DE es-ES fr-FR gu-IN hi-IN it-IT ja-JP kn-IN ko-KR ml-IN mr-IN or-IN pa-IN pt-BR ru-RU si-LK ta-IN te-IN zh-CN zh-TW
-#TRANSLATIONS = $(XML_LANG) $(OTHER_LANGS)
-
-COMMON_CONFIG = /usr/share/documentation-devel
-include $(COMMON_CONFIG)/make/Makefile.common
16 years, 1 month
Seam SVN: r7729 - branches/Seam_2_0/src/main/org/jboss/seam/framework.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 07:11:49 -0400 (Fri, 28 Mar 2008)
New Revision: 7729
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityController.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityHome.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityQuery.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityController.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityHome.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityQuery.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/MutableEntityController.java
branches/Seam_2_0/src/main/org/jboss/seam/framework/PersistenceController.java
Log:
backport r7719, JBSEAM-2780
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityController.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityController.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityController.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -82,4 +82,10 @@
getEntityManager().remove(entity);
}
+ @Override
+ protected boolean isPersistenceContextOpen(EntityManager persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityHome.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityHome.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityHome.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -216,4 +216,10 @@
}
}
+ @Override
+ protected boolean isPersistenceContextOpen(EntityManager persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityQuery.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityQuery.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/EntityQuery.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -235,4 +235,10 @@
}
}
+ @Override
+ protected boolean isPersistenceContextOpen(EntityManager persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityController.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityController.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityController.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -118,4 +118,10 @@
getSession().refresh(entity);
}
+ @Override
+ protected boolean isPersistenceContextOpen(Session persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityHome.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityHome.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityHome.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -119,4 +119,10 @@
}
}
+ @Override
+ protected boolean isPersistenceContextOpen(Session persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityQuery.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityQuery.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/HibernateEntityQuery.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -201,5 +201,11 @@
{
this.fetchSize = fetchSize;
}
+
+ @Override
+ protected boolean isPersistenceContextOpen(Session persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/MutableEntityController.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/MutableEntityController.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/MutableEntityController.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -82,4 +82,10 @@
getEntityManager().remove(entity);
}
+ @Override
+ protected boolean isPersistenceContextOpen(EntityManager persistenceContext)
+ {
+ return persistenceContext.isOpen();
+ }
+
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/framework/PersistenceController.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/framework/PersistenceController.java 2008-03-28 10:32:17 UTC (rev 7728)
+++ branches/Seam_2_0/src/main/org/jboss/seam/framework/PersistenceController.java 2008-03-28 11:11:49 UTC (rev 7729)
@@ -15,7 +15,7 @@
public T getPersistenceContext()
{
- if (persistenceContext==null)
+ if (persistenceContext==null || !isPersistenceContextOpen(persistenceContext))
{
persistenceContext = (T) getComponentInstance( getPersistenceContextName() );
}
@@ -28,5 +28,10 @@
}
protected abstract String getPersistenceContextName();
+
+ protected boolean isPersistenceContextOpen(T persistenceContext)
+ {
+ return false;
+ }
}
16 years, 1 month
Seam SVN: r7728 - trunk/doc/reference/en/modules and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 06:32:17 -0400 (Fri, 28 Mar 2008)
New Revision: 7728
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Tutorial.xml
trunk/doc/reference/en/modules/tutorial.xml
Log:
JBSEAM-2786
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Tutorial.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Tutorial.xml 2008-03-28 01:52:14 UTC (rev 7727)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Tutorial.xml 2008-03-28 10:32:17 UTC (rev 7728)
@@ -264,7 +264,7 @@
</example>
<para> The most important things to notice in this example are the <literal>@Name</literal> and
<literal>@Scope</literal> annotations. These annotations establish that this class is a Seam component. </para>
- <para> We'll see below that the properties of our <literal>User</literal> class are bound to
+ <para> We'll see below that the properties of our <literal>User</literal> class are bound
directly to JSF components and are populated by JSF during the update model values phase. We
don't need any tedious glue code to copy data back and forth between the JSP pages and the
entity bean domain model. </para>
@@ -337,7 +337,7 @@
<calloutlist>
<callout arearefs="registration-stateless-annotation">
<para> The EJB standard <literal>@Stateless</literal> annotation marks this class as
- stateless session bean. </para>
+ a stateless session bean. </para>
</callout>
<callout arearefs="registration-in-annotation">
<para> The <link linkend="in-annotation">
@@ -357,7 +357,7 @@
<callout arearefs="registration-action-listener">
<para> The action listener method uses the standard EJB3
<literal>EntityManager</literal> API to interact with the database, and returns the
- JSF outcome. Note that, since this is a sesson bean, a transaction is automatically
+ JSF outcome. Note that, since this is a session bean, a transaction is automatically
begun when the <literal>register()</literal> method is called, and committed when it
completes. </para>
</callout>
Modified: trunk/doc/reference/en/modules/tutorial.xml
===================================================================
--- trunk/doc/reference/en/modules/tutorial.xml 2008-03-28 01:52:14 UTC (rev 7727)
+++ trunk/doc/reference/en/modules/tutorial.xml 2008-03-28 10:32:17 UTC (rev 7728)
@@ -261,7 +261,7 @@
<para> The most important things to notice in this example are the <literal>@Name</literal> and
<literal>@Scope</literal> annotations. These annotations establish that this class is a Seam
component. </para>
- <para> We'll see below that the properties of our <literal>User</literal> class are bound to
+ <para> We'll see below that the properties of our <literal>User</literal> class are bound
directly to JSF components and are populated by JSF during the update model values phase. We
don't need any tedious glue code to copy data back and forth between the JSP pages and the
entity bean domain model. </para>
@@ -333,7 +333,7 @@
<calloutlist>
<callout arearefs="registration-stateless-annotation">
<para> The EJB standard <literal>@Stateless</literal> annotation marks this class as
- stateless session bean. </para>
+ a stateless session bean. </para>
</callout>
<callout arearefs="registration-in-annotation">
<para> The <link linkend="in-annotation">
@@ -353,7 +353,7 @@
<callout arearefs="registration-action-listener">
<para> The action listener method uses the standard EJB3
<literal>EntityManager</literal> API to interact with the database, and returns the
- JSF outcome. Note that, since this is a sesson bean, a transaction is automatically
+ JSF outcome. Note that, since this is a session bean, a transaction is automatically
begun when the <literal>register()</literal> method is called, and committed when it
completes. </para>
</callout>
16 years, 1 month
Seam SVN: r7727 - trunk/doc/reference/en/modules.
by seam-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2008-03-27 21:52:14 -0400 (Thu, 27 Mar 2008)
New Revision: 7727
Modified:
trunk/doc/reference/en/modules/websphere.xml
Log:
JBSEAM-2758 - Thanks Eric Jung - I did not add the cross link because of some formatting issues.
Modified: trunk/doc/reference/en/modules/websphere.xml
===================================================================
--- trunk/doc/reference/en/modules/websphere.xml 2008-03-28 01:42:24 UTC (rev 7726)
+++ trunk/doc/reference/en/modules/websphere.xml 2008-03-28 01:52:14 UTC (rev 7727)
@@ -233,6 +233,20 @@
the web module and the EJB3 beans. The
<literal>ejb-link</literal> element is simply not used.
</para>
+ <para>Note also that <literal>EjbSynchronizations</literal> is
+ a built-in Seam EJB and not part of the Hotel Booking example. This
+ means that if your application's <literal>components.xml</literal>
+ specifies <literal>transaction:ejb-transaction</literal>
+ , then you must include:</para>
+ <programlisting role="XML"><![CDATA[
+ <ejb-local-ref>
+ <ejb-ref-name>myapp/EjbSynchronizations</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local-home></local-home>
+ <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local>
+ </ejb-local-ref>]]></programlisting>
+ <para>in your web.xml. If you don't include it, you'll get the following error:</para>
+ <programlisting>Name comp/env/myapp/EjbSynchronizations not found in context java:</programlisting>
</listitem>
</varlistentry>
<varlistentry>
16 years, 1 month
Seam SVN: r7726 - branches/Seam_2_0/doc/Seam_Reference_Guide/en.
by seam-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2008-03-27 21:42:24 -0400 (Thu, 27 Mar 2008)
New Revision: 7726
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Websphere.xml
Log:
JBSEAM-2758 - Thanks Eric Jung - I did not add the cross link because of some formatting issues.
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Websphere.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Websphere.xml 2008-03-28 00:44:23 UTC (rev 7725)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Websphere.xml 2008-03-28 01:42:24 UTC (rev 7726)
@@ -232,6 +232,20 @@
the web module and the EJB3 beans. The
<literal>ejb-link</literal> element is simply not used.
</para>
+ <para>Note also that <literal>EjbSynchronizations</literal> is
+ a built-in Seam EJB and not part of the Hotel Booking example. This
+ means that if your application's <literal>components.xml</literal>
+ specifies <literal>transaction:ejb-transaction</literal>
+ , then you must include:</para>
+ <programlisting role="XML"><![CDATA[
+ <ejb-local-ref>
+ <ejb-ref-name>myapp/EjbSynchronizations</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local-home></local-home>
+ <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local>
+ </ejb-local-ref>]]></programlisting>
+ <para>in your web.xml. If you don't include it, you'll get the following error:</para>
+ <programlisting>Name comp/env/myapp/EjbSynchronizations not found in context java:</programlisting>
</listitem>
</varlistentry>
<varlistentry>
16 years, 1 month
Seam SVN: r7725 - branches/Seam_2_0/doc/Seam_Reference_Guide/en.
by seam-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2008-03-27 20:44:23 -0400 (Thu, 27 Mar 2008)
New Revision: 7725
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Persistence.xml
Log:
JBSEAM-1946 - re-added the documentation for using different JPA providers. This is workaround until the redesign is finished.
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml 2008-03-27 18:09:46 UTC (rev 7724)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml 2008-03-28 00:44:23 UTC (rev 7725)
@@ -421,6 +421,50 @@
</sect2>
</sect1>
+
+ <sect1 id="alt-jpa-providers">
+ <title>Using Alternate JPA Providers</title>
+
+ <para> Seam comes packaged and configured with Hibernate as the default JPA provider.
+ If you require using a different JPA provider you must tell <literal>seam</literal>
+ about it.
+ </para>
+
+ <note>
+ <title>This is a workaround</title>
+ <para>
+ Configuration of the JPA provider will be easier in the future and will
+ not require configuration changes, unless you are adding a custom persistence provider
+ implementation.
+ </para>
+ </note>
+
+ <para>Telling seam about a different JPA provider can be be done in one of two ways:</para>
+ <para>Update your application's <literal>components.xml</literal>
+ so that the generic <literal>PersistenceProvider</literal> takes
+ precedence over the hibernate version. Simply add the following
+ to the file:
+ </para>
+ <programlisting role="XML"><![CDATA[<component name="org.jboss.seam.persistence.persistenceProvider"
+ class="org.jboss.seam.persistence.PersistenceProvider"
+ scope="stateless">
+</component>]]></programlisting>
+ <para>If you want to take advantage of your JPA provider's
+ non-standard features you will need to write you own implementation of
+ the <literal>PersistenceProvider</literal>. Use
+ <literal>HibernatePersistenceProvider</literal> as a starting
+ point (don't forget to give back to the community :). Then you
+ will need to tell <literal>seam</literal> to use it as before.
+ </para>
+ <programlisting role="XML"><![CDATA[<component name="org.jboss.seam.persistence.persistenceProvider"
+ class="org.your.package.YourPersistenceProvider">
+</component>]]></programlisting>
+ <para>All that is left is updating the <literal>persistence.xml</literal>
+ file with the correct provider class, and what ever properties your
+ provider needs. Don't forget to package your new provider's jar files in the
+ application if they are needed.
+ </para>
+ </sect1>
<sect1>
<title>Configuring Seam in Java EE 5</title>
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Persistence.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Persistence.xml 2008-03-27 18:09:46 UTC (rev 7724)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Persistence.xml 2008-03-28 00:44:23 UTC (rev 7725)
@@ -484,7 +484,8 @@
API via the <literal>getDelegate()</literal> method. Naturally, the most interesting
vendor is Hibernate, and the most powerful delegate interface is
<literal>org.hibernate.Session</literal>. You'd be nuts to use anything else. Trust
- me, I'm not biased at all.
+ me, I'm not biased at all. If you must use a different JPA provider see
+ <link linkend="alt-jpa-providers">Using Alternate JPA Providers</link>.
</para>
<para>
16 years, 1 month
Seam SVN: r7724 - in trunk/src/main/org/jboss/seam: servlet and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-27 14:09:46 -0400 (Thu, 27 Mar 2008)
New Revision: 7724
Modified:
trunk/src/main/org/jboss/seam/Component.java
trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
trunk/src/main/org/jboss/seam/util/SortItem.java
trunk/src/main/org/jboss/seam/util/Sorter.java
Log:
Revert r7722 and r7723
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-03-27 17:33:32 UTC (rev 7723)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-03-27 18:09:46 UTC (rev 7724)
@@ -957,46 +957,44 @@
private List<Interceptor> newSort(List<Interceptor> list)
{
-
- List<SortItem<Interceptor>> sortable = new ArrayList<SortItem<Interceptor>>();
-
- for (final Interceptor i : list)
+ List<SortItem<Interceptor>> siList = new ArrayList<SortItem<Interceptor>>();
+ Map<Class<?>,SortItem<Interceptor>> ht = new HashMap<Class<?>,SortItem<Interceptor>>();
+
+ for (Interceptor i : list)
{
-
-
- sortable.add(new SortItem<Interceptor>()
- {
-
- Class<?> clazz = i.getUserInterceptorClass();
- org.jboss.seam.annotations.intercept.Interceptor interceptor = clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
+ SortItem<Interceptor> si = new SortItem<Interceptor>(i);
+ siList.add(si);
+ ht.put( i.getUserInterceptorClass(), si );
+ }
- @Override
- public List<Class> getAround()
+ for (SortItem<Interceptor> si : siList)
+ {
+ Class<?> clazz = si.getObj().getUserInterceptorClass();
+ if ( clazz.isAnnotationPresent(org.jboss.seam.annotations.intercept.Interceptor.class) )
+ {
+ org.jboss.seam.annotations.intercept.Interceptor interceptorAnn = clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
+ for (Class<?> cl : Arrays.asList( interceptorAnn.around() ) )
{
- return Arrays.asList(interceptor.around());
+ SortItem<Interceptor> sortItem = ht.get(cl);
+ if (sortItem!=null) si.getAround().add( sortItem );
}
-
- @Override
- protected Interceptor getObject()
+ for (Class<?> cl : Arrays.asList( interceptorAnn.within() ) )
{
- return i;
+ SortItem<Interceptor> sortItem = ht.get(cl);
+ if (sortItem!=null) si.getWithin().add( sortItem );
}
+ }
+ }
- @Override
- public List<Class> getWithin()
- {
- return Arrays.asList(interceptor.within());
- }
-
- @Override
- public Class getKey()
- {
- return clazz;
- }
-
- });
+ Sorter<Interceptor> sList = new Sorter<Interceptor>();
+ siList = sList.sort(siList);
+
+ list.clear();
+ for (SortItem<Interceptor> si : siList)
+ {
+ list.add( si.getObj() );
}
- return new Sorter<Interceptor>().sort(sortable);
+ return list ;
}
private void initDefaultInterceptors()
Modified: trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-03-27 17:33:32 UTC (rev 7723)
+++ trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-03-27 18:09:46 UTC (rev 7724)
@@ -3,7 +3,9 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -103,60 +105,51 @@
private List<Filter> getSortedFilters()
{
- List<SortItem<Filter>> sortable = new ArrayList<SortItem<Filter>>();
//retrieve the Filter instances from the application context
+ Map<String, SortItem<Filter>> sortItemsMap = new HashMap<String, SortItem<Filter>>();
+ List<SortItem<Filter>> sortItems = new ArrayList<SortItem<Filter>>();
-
- for (final String filterName : Init.instance().getInstalledFilters())
+ for (String filterName : Init.instance().getInstalledFilters())
{
-
- sortable.add(new SortItem<Filter>()
+ Filter filter = (Filter) Component.getInstance(filterName, ScopeType.APPLICATION);
+ boolean disabled = false;
+ if (filter instanceof AbstractFilter)
{
+ disabled = ((AbstractFilter) filter).isDisabled();
+ }
+ if (!disabled)
+ {
+ SortItem<Filter> si = new SortItem<Filter>(filter);
+ sortItemsMap.put(filterName, si);
+ sortItems.add(si);
+ }
+ }
- private Filter filter = (Filter) Component.getInstance(filterName, ScopeType.APPLICATION);
-
- @Override
- public List<String> getAround()
+ //create sort items
+ for (SortItem<Filter> sortItem : sortItems)
+ {
+ org.jboss.seam.annotations.web.Filter filterAnn = getFilterAnnotation(sortItem.getObj().getClass());
+ if ( filterAnn != null )
+ {
+ for (String s : Arrays.asList( filterAnn.around() ) )
{
- return Arrays.asList( getFilterAnnotation( filter.getClass() ).around() );
+ SortItem<Filter> aroundSortItem = sortItemsMap.get(s);
+ if (sortItem!=null && aroundSortItem != null) sortItem.getAround().add( aroundSortItem );
}
-
- @Override
- protected Filter getObject()
+ for (String s : Arrays.asList( filterAnn.within() ) )
{
- return filter;
+ SortItem<Filter> withinSortItem = sortItemsMap.get(s);
+ if (sortItem!=null && withinSortItem != null) sortItem.getWithin().add( withinSortItem );
}
-
- @Override
- public List<String> getWithin()
- {
- return Arrays.asList( getFilterAnnotation( filter.getClass() ).within() );
- }
-
- @Override
- public boolean isAddable()
- {
- if (filter instanceof AbstractFilter)
- {
- return !((AbstractFilter) filter).isDisabled();
- }
- else
- {
- return true;
- }
- }
-
- @Override
- public String getKey()
- {
- return filter.getClass().getName();
- }
-
-
- });
+ }
}
- return new Sorter<Filter>().sort(sortable);
-
+
+ // Do the sort
+ Sorter<Filter> sList = new Sorter<Filter>();
+ sortItems = sList.sort(sortItems);
+ List<Filter> sorted = new ArrayList<Filter>();
+ for (SortItem<Filter> si: sortItems) sorted.add( si.getObj() );
+ return sorted;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
Modified: trunk/src/main/org/jboss/seam/util/SortItem.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/SortItem.java 2008-03-27 17:33:32 UTC (rev 7723)
+++ trunk/src/main/org/jboss/seam/util/SortItem.java 2008-03-27 18:09:46 UTC (rev 7724)
@@ -3,42 +3,31 @@
import java.util.ArrayList;
import java.util.List;
-
-public abstract class SortItem<T>
+public class SortItem<T>
{
- private List<SortItem> around = new ArrayList<SortItem>();
- private List<SortItem> within = new ArrayList<SortItem>();
-
- final List<SortItem> getAroundSortItems()
+ private T obj;
+ private List<SortItem> around = new ArrayList<SortItem>();
+ private List<SortItem> within = new ArrayList<SortItem>();
+
+ public SortItem(T obj)
{
- return around;
- }
+ this.obj = obj;
+ }
- final List<SortItem> getWithinSortItems()
+ public T getObj()
{
- return within;
- }
+ return obj;
+ }
- public Object getKey()
+ public List<SortItem> getAround()
{
- return getObject().hashCode();
- }
+ return around;
+ }
- protected abstract T getObject();
-
- public boolean isAddable()
+ public List<SortItem> getWithin()
{
- return true;
- }
+ return within;
+ }
- public abstract List<? extends Object> getAround();
- public abstract List<? extends Object> getWithin();
-
- @Override
- public String toString()
- {
- return getObject().toString() + " within [" + getWithin() + "] around [" + getAround() + "]";
- }
-
}
Modified: trunk/src/main/org/jboss/seam/util/Sorter.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Sorter.java 2008-03-27 17:33:32 UTC (rev 7723)
+++ trunk/src/main/org/jboss/seam/util/Sorter.java 2008-03-27 18:09:46 UTC (rev 7724)
@@ -1,28 +1,54 @@
package org.jboss.seam.util;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class Sorter<T>
{
- private void remove(SortItem<T> item, List<SortItem<T>> list)
+ private List<SortItem<T>> list = null; //new ArrayList();
+
+ public List<SortItem<T>> sort(List<SortItem<T>> lst)
{
+
+ this.list = lst;
+ List<SortItem<T>> res = new ArrayList<SortItem<T>>();
+ SortItem<T> inmost = null;
+
+ do
+ {
+ inmost = getInmost();
+ if (inmost!=null)
+ {
+ res.add(inmost);
+ remove(inmost);
+ }
+ }
+ while ( !list.isEmpty() && inmost!=null );
+
+ if ( !list.isEmpty() )
+ {
+ throw new IllegalArgumentException("Can not sort list:"+list);
+ }
+
+ return res;
+ }
+
+ private void remove(SortItem<T> item)
+ {
list.remove(item);
for (SortItem<T> o: list)
{
- o.getWithinSortItems().remove(item);
+ o.getWithin().remove(item);
}
}
- private SortItem<T> getInmost(List<SortItem<T>> list)
+ private SortItem<T> getInmost()
{
SortItem<T> res=null;
for (SortItem<T> o: list)
{
- if ( o.getWithinSortItems().isEmpty() && nobodyWantsAround(o, list) )
+ if ( o.getWithin().isEmpty() && nobodyWantsAround(o) )
{
res = o;
break;
@@ -31,12 +57,12 @@
return res;
}
- private boolean nobodyWantsAround(SortItem<T> item, List<SortItem<T>> list)
+ private boolean nobodyWantsAround(SortItem<T> item)
{
boolean res = true;
for (SortItem<T> o: list)
{
- if ( o.getAroundSortItems().contains(item) )
+ if ( o.getAround().contains(item) )
{
res = false;
break;
@@ -45,69 +71,4 @@
return res;
}
- public List<T> sort(List<SortItem<T>> sortable)
- {
-
- // Build a map of items
- Map<Object, SortItem<T>> sortItemsMap = new HashMap<Object, SortItem<T>>();
- for (SortItem<T> item : sortable)
- {
- if (item.isAddable())
- {
- sortItemsMap.put(item.getKey(), item);
- }
- }
-
- List<SortItem<T>> sortItemsList = new ArrayList<SortItem<T>>();
-
- for ( Object key : sortItemsMap.keySet() )
- {
- SortItem<T> sortItem = sortItemsMap.get(key);
- for ( Object aroundKey : sortItem.getAround() )
- {
- if ( sortItemsMap.get( aroundKey ) != null )
- {
- sortItem.getAroundSortItems().add( sortItemsMap.get(aroundKey) );
- }
- }
- for ( Object withinKey : sortItem.getWithin() )
- {
- if ( sortItemsMap.get( withinKey ) != null )
- {
- sortItem.getWithinSortItems().add( sortItemsMap.get( withinKey ) );
- }
- }
- sortItemsList.add(sortItem);
- }
-
- List<SortItem<T>> result = new ArrayList<SortItem<T>>();
- SortItem<T> inmost = null;
-
- do
- {
- inmost = getInmost(sortItemsList);
- if (inmost!=null)
- {
- result.add(inmost);
- remove(inmost, sortItemsList);
- }
- }
- while ( !sortItemsList.isEmpty() && inmost!=null );
-
- if ( !sortItemsList.isEmpty() )
- {
- throw new IllegalArgumentException("Can not sort list:" + sortItemsList);
- }
-
-
- List<T> sorted = new ArrayList<T>();
- for (SortItem<T> sortItem : result)
- {
- sorted.add( sortItem.getObject() );
- }
- return sorted;
- }
-
-
-
}
16 years, 1 month
Seam SVN: r7723 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-27 13:33:32 -0400 (Thu, 27 Mar 2008)
New Revision: 7723
Modified:
trunk/src/main/org/jboss/seam/Component.java
Log:
minor
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-03-27 15:55:22 UTC (rev 7722)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-03-27 17:33:32 UTC (rev 7723)
@@ -996,10 +996,7 @@
});
}
- log.info(getName() + " unsorted interceptors: " + sortable);
- List<Interceptor> temp = new Sorter<Interceptor>().sort(sortable);
- log.info(getName() + " sorted interceptors: " + temp);
- return temp;
+ return new Sorter<Interceptor>().sort(sortable);
}
private void initDefaultInterceptors()
16 years, 1 month
Seam SVN: r7722 - in trunk/src/main/org/jboss/seam: servlet and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-27 11:55:22 -0400 (Thu, 27 Mar 2008)
New Revision: 7722
Added:
trunk/src/main/org/jboss/seam/util/SortItem.java
Removed:
trunk/src/main/org/jboss/seam/util/SortItem.java
Modified:
trunk/src/main/org/jboss/seam/Component.java
trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
trunk/src/main/org/jboss/seam/util/Sorter.java
Log:
Better sorter (risky)
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-03-27 14:50:42 UTC (rev 7721)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-03-27 15:55:22 UTC (rev 7722)
@@ -957,44 +957,49 @@
private List<Interceptor> newSort(List<Interceptor> list)
{
- List<SortItem<Interceptor>> siList = new ArrayList<SortItem<Interceptor>>();
- Map<Class<?>,SortItem<Interceptor>> ht = new HashMap<Class<?>,SortItem<Interceptor>>();
-
- for (Interceptor i : list)
+
+ List<SortItem<Interceptor>> sortable = new ArrayList<SortItem<Interceptor>>();
+
+ for (final Interceptor i : list)
{
- SortItem<Interceptor> si = new SortItem<Interceptor>(i);
- siList.add(si);
- ht.put( i.getUserInterceptorClass(), si );
- }
+
+
+ sortable.add(new SortItem<Interceptor>()
+ {
+
+ Class<?> clazz = i.getUserInterceptorClass();
+ org.jboss.seam.annotations.intercept.Interceptor interceptor = clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
- for (SortItem<Interceptor> si : siList)
- {
- Class<?> clazz = si.getObj().getUserInterceptorClass();
- if ( clazz.isAnnotationPresent(org.jboss.seam.annotations.intercept.Interceptor.class) )
- {
- org.jboss.seam.annotations.intercept.Interceptor interceptorAnn = clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
- for (Class<?> cl : Arrays.asList( interceptorAnn.around() ) )
+ @Override
+ public List<Class> getAround()
{
- SortItem<Interceptor> sortItem = ht.get(cl);
- if (sortItem!=null) si.getAround().add( sortItem );
+ return Arrays.asList(interceptor.around());
}
- for (Class<?> cl : Arrays.asList( interceptorAnn.within() ) )
+
+ @Override
+ protected Interceptor getObject()
{
- SortItem<Interceptor> sortItem = ht.get(cl);
- if (sortItem!=null) si.getWithin().add( sortItem );
+ return i;
}
- }
- }
- Sorter<Interceptor> sList = new Sorter<Interceptor>();
- siList = sList.sort(siList);
-
- list.clear();
- for (SortItem<Interceptor> si : siList)
- {
- list.add( si.getObj() );
+ @Override
+ public List<Class> getWithin()
+ {
+ return Arrays.asList(interceptor.within());
+ }
+
+ @Override
+ public Class getKey()
+ {
+ return clazz;
+ }
+
+ });
}
- return list ;
+ log.info(getName() + " unsorted interceptors: " + sortable);
+ List<Interceptor> temp = new Sorter<Interceptor>().sort(sortable);
+ log.info(getName() + " sorted interceptors: " + temp);
+ return temp;
}
private void initDefaultInterceptors()
Modified: trunk/src/main/org/jboss/seam/servlet/SeamFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-03-27 14:50:42 UTC (rev 7721)
+++ trunk/src/main/org/jboss/seam/servlet/SeamFilter.java 2008-03-27 15:55:22 UTC (rev 7722)
@@ -3,9 +3,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -105,51 +103,60 @@
private List<Filter> getSortedFilters()
{
+ List<SortItem<Filter>> sortable = new ArrayList<SortItem<Filter>>();
//retrieve the Filter instances from the application context
- Map<String, SortItem<Filter>> sortItemsMap = new HashMap<String, SortItem<Filter>>();
- List<SortItem<Filter>> sortItems = new ArrayList<SortItem<Filter>>();
- for (String filterName : Init.instance().getInstalledFilters())
+
+ for (final String filterName : Init.instance().getInstalledFilters())
{
- Filter filter = (Filter) Component.getInstance(filterName, ScopeType.APPLICATION);
- boolean disabled = false;
- if (filter instanceof AbstractFilter)
+
+ sortable.add(new SortItem<Filter>()
{
- disabled = ((AbstractFilter) filter).isDisabled();
- }
- if (!disabled)
- {
- SortItem<Filter> si = new SortItem<Filter>(filter);
- sortItemsMap.put(filterName, si);
- sortItems.add(si);
- }
- }
- //create sort items
- for (SortItem<Filter> sortItem : sortItems)
- {
- org.jboss.seam.annotations.web.Filter filterAnn = getFilterAnnotation(sortItem.getObj().getClass());
- if ( filterAnn != null )
- {
- for (String s : Arrays.asList( filterAnn.around() ) )
+ private Filter filter = (Filter) Component.getInstance(filterName, ScopeType.APPLICATION);
+
+ @Override
+ public List<String> getAround()
{
- SortItem<Filter> aroundSortItem = sortItemsMap.get(s);
- if (sortItem!=null && aroundSortItem != null) sortItem.getAround().add( aroundSortItem );
+ return Arrays.asList( getFilterAnnotation( filter.getClass() ).around() );
}
- for (String s : Arrays.asList( filterAnn.within() ) )
+
+ @Override
+ protected Filter getObject()
{
- SortItem<Filter> withinSortItem = sortItemsMap.get(s);
- if (sortItem!=null && withinSortItem != null) sortItem.getWithin().add( withinSortItem );
+ return filter;
}
- }
+
+ @Override
+ public List<String> getWithin()
+ {
+ return Arrays.asList( getFilterAnnotation( filter.getClass() ).within() );
+ }
+
+ @Override
+ public boolean isAddable()
+ {
+ if (filter instanceof AbstractFilter)
+ {
+ return !((AbstractFilter) filter).isDisabled();
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ @Override
+ public String getKey()
+ {
+ return filter.getClass().getName();
+ }
+
+
+ });
}
-
- // Do the sort
- Sorter<Filter> sList = new Sorter<Filter>();
- sortItems = sList.sort(sortItems);
- List<Filter> sorted = new ArrayList<Filter>();
- for (SortItem<Filter> si: sortItems) sorted.add( si.getObj() );
- return sorted;
+ return new Sorter<Filter>().sort(sortable);
+
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
Deleted: trunk/src/main/org/jboss/seam/util/SortItem.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/SortItem.java 2008-03-27 14:50:42 UTC (rev 7721)
+++ trunk/src/main/org/jboss/seam/util/SortItem.java 2008-03-27 15:55:22 UTC (rev 7722)
@@ -1,33 +0,0 @@
-package org.jboss.seam.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SortItem<T>
-{
-
- private T obj;
- private List<SortItem> around = new ArrayList<SortItem>();
- private List<SortItem> within = new ArrayList<SortItem>();
-
- public SortItem(T obj)
- {
- this.obj = obj;
- }
-
- public T getObj()
- {
- return obj;
- }
-
- public List<SortItem> getAround()
- {
- return around;
- }
-
- public List<SortItem> getWithin()
- {
- return within;
- }
-
-}
Added: trunk/src/main/org/jboss/seam/util/SortItem.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/SortItem.java (rev 0)
+++ trunk/src/main/org/jboss/seam/util/SortItem.java 2008-03-27 15:55:22 UTC (rev 7722)
@@ -0,0 +1,44 @@
+package org.jboss.seam.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public abstract class SortItem<T>
+{
+
+ private List<SortItem> around = new ArrayList<SortItem>();
+ private List<SortItem> within = new ArrayList<SortItem>();
+
+ final List<SortItem> getAroundSortItems()
+ {
+ return around;
+ }
+
+ final List<SortItem> getWithinSortItems()
+ {
+ return within;
+ }
+
+ public Object getKey()
+ {
+ return getObject().hashCode();
+ }
+
+ protected abstract T getObject();
+
+ public boolean isAddable()
+ {
+ return true;
+ }
+
+ public abstract List<? extends Object> getAround();
+ public abstract List<? extends Object> getWithin();
+
+ @Override
+ public String toString()
+ {
+ return getObject().toString() + " within [" + getWithin() + "] around [" + getAround() + "]";
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/util/SortItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/src/main/org/jboss/seam/util/Sorter.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Sorter.java 2008-03-27 14:50:42 UTC (rev 7721)
+++ trunk/src/main/org/jboss/seam/util/Sorter.java 2008-03-27 15:55:22 UTC (rev 7722)
@@ -1,54 +1,28 @@
package org.jboss.seam.util;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class Sorter<T>
{
- private List<SortItem<T>> list = null; //new ArrayList();
-
- public List<SortItem<T>> sort(List<SortItem<T>> lst)
+ private void remove(SortItem<T> item, List<SortItem<T>> list)
{
-
- this.list = lst;
- List<SortItem<T>> res = new ArrayList<SortItem<T>>();
- SortItem<T> inmost = null;
-
- do
- {
- inmost = getInmost();
- if (inmost!=null)
- {
- res.add(inmost);
- remove(inmost);
- }
- }
- while ( !list.isEmpty() && inmost!=null );
-
- if ( !list.isEmpty() )
- {
- throw new IllegalArgumentException("Can not sort list:"+list);
- }
-
- return res;
- }
-
- private void remove(SortItem<T> item)
- {
list.remove(item);
for (SortItem<T> o: list)
{
- o.getWithin().remove(item);
+ o.getWithinSortItems().remove(item);
}
}
- private SortItem<T> getInmost()
+ private SortItem<T> getInmost(List<SortItem<T>> list)
{
SortItem<T> res=null;
for (SortItem<T> o: list)
{
- if ( o.getWithin().isEmpty() && nobodyWantsAround(o) )
+ if ( o.getWithinSortItems().isEmpty() && nobodyWantsAround(o, list) )
{
res = o;
break;
@@ -57,12 +31,12 @@
return res;
}
- private boolean nobodyWantsAround(SortItem<T> item)
+ private boolean nobodyWantsAround(SortItem<T> item, List<SortItem<T>> list)
{
boolean res = true;
for (SortItem<T> o: list)
{
- if ( o.getAround().contains(item) )
+ if ( o.getAroundSortItems().contains(item) )
{
res = false;
break;
@@ -71,4 +45,69 @@
return res;
}
+ public List<T> sort(List<SortItem<T>> sortable)
+ {
+
+ // Build a map of items
+ Map<Object, SortItem<T>> sortItemsMap = new HashMap<Object, SortItem<T>>();
+ for (SortItem<T> item : sortable)
+ {
+ if (item.isAddable())
+ {
+ sortItemsMap.put(item.getKey(), item);
+ }
+ }
+
+ List<SortItem<T>> sortItemsList = new ArrayList<SortItem<T>>();
+
+ for ( Object key : sortItemsMap.keySet() )
+ {
+ SortItem<T> sortItem = sortItemsMap.get(key);
+ for ( Object aroundKey : sortItem.getAround() )
+ {
+ if ( sortItemsMap.get( aroundKey ) != null )
+ {
+ sortItem.getAroundSortItems().add( sortItemsMap.get(aroundKey) );
+ }
+ }
+ for ( Object withinKey : sortItem.getWithin() )
+ {
+ if ( sortItemsMap.get( withinKey ) != null )
+ {
+ sortItem.getWithinSortItems().add( sortItemsMap.get( withinKey ) );
+ }
+ }
+ sortItemsList.add(sortItem);
+ }
+
+ List<SortItem<T>> result = new ArrayList<SortItem<T>>();
+ SortItem<T> inmost = null;
+
+ do
+ {
+ inmost = getInmost(sortItemsList);
+ if (inmost!=null)
+ {
+ result.add(inmost);
+ remove(inmost, sortItemsList);
+ }
+ }
+ while ( !sortItemsList.isEmpty() && inmost!=null );
+
+ if ( !sortItemsList.isEmpty() )
+ {
+ throw new IllegalArgumentException("Can not sort list:" + sortItemsList);
+ }
+
+
+ List<T> sorted = new ArrayList<T>();
+ for (SortItem<T> sortItem : result)
+ {
+ sorted.add( sortItem.getObject() );
+ }
+ return sorted;
+ }
+
+
+
}
16 years, 1 month