Seam SVN: r13527 - tags.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-28 16:31:40 -0400 (Wed, 28 Jul 2010)
New Revision: 13527
Added:
tags/JBoss_Seam_2_2_1_CR2/
Log:
created tag for JBoss Seam 2.2.1.CR2
Copied: tags/JBoss_Seam_2_2_1_CR2 (from rev 13526, branches/community/Seam_2_2)
14 years, 5 months
Seam SVN: r13526 - in branches/community/Seam_2_2: build and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-28 16:27:44 -0400 (Wed, 28 Jul 2010)
New Revision: 13526
Modified:
branches/community/Seam_2_2/build/default.build.properties
branches/community/Seam_2_2/changelog.txt
branches/community/Seam_2_2/readme.txt
Log:
updating release information - 2.2.1.CR2
Modified: branches/community/Seam_2_2/build/default.build.properties
===================================================================
--- branches/community/Seam_2_2/build/default.build.properties 2010-07-28 13:42:07 UTC (rev 13525)
+++ branches/community/Seam_2_2/build/default.build.properties 2010-07-28 20:27:44 UTC (rev 13526)
@@ -8,7 +8,7 @@
major.version 2
minor.version .2
patchlevel .1
-qualifier -SNAPSHOT
+qualifier .CR2
#
# Other program locations
# -----------------------
Modified: branches/community/Seam_2_2/changelog.txt
===================================================================
--- branches/community/Seam_2_2/changelog.txt 2010-07-28 13:42:07 UTC (rev 13525)
+++ branches/community/Seam_2_2/changelog.txt 2010-07-28 20:27:44 UTC (rev 13526)
@@ -1,6 +1,52 @@
JBoss Seam Changelog
====================
+Release Notes - Seam - Version 2.2.1.CR2
+
+** Bug
+ * [JBSEAM-2419] - IAE: factory method with defined scope outjected a value: guestRole
+ * [JBSEAM-2974] - <s:fileUpload> doesnt work inside <h:dataTable>
+ * [JBSEAM-3769] - org.jboss.seam.ui.facelet.RendererRequest replaces HttpServletXXX with MockHttpServletXXX
+ * [JBSEAM-3996] - Seam should ignore duplicate classes on classpath
+ * [JBSEAM-4039] - Seam component cannot serve as a JAX-RS subresource
+ * [JBSEAM-4540] - OpenId example doesn't work with JBossAS 6.0.0.M1
+ * [JBSEAM-4542] - NoSuchEJBException when both Authenticator and web service use EJB transaction
+ * [JBSEAM-4562] - Drools example throws RuntimeDroolsException on JBoss AS 6
+ * [JBSEAM-4567] - Metawidget examples fail to deploy to JBoss AS 6 M2
+ * [JBSEAM-4570] - Seam Excel example doesn't work correctly on JBossAS 6.0.0.M2
+ * [JBSEAM-4587] - seam-mail does not render facets correctly on JBoss AS 6
+ * [JBSEAM-4590] - Multiple war in ear - resources not isolated between wars
+ * [JBSEAM-4591] - jboss-seam-resteasy.jar deployed without dependencies in seam-gen project
+ * [JBSEAM-4592] - jboss-seam-resteasy.jar not copied to a new seam-gen project
+ * [JBSEAM-4593] - AbstractSeamTest.Request.run() should call "afterRequest()" before facesContext.release()
+ * [JBSEAM-4600] - Deploying of icefaces project generated by seam-gen fails with exception
+ * [JBSEAM-4601] - Seambay example - web services page doesn't work with JBossAS 6.0.0.M2
+ * [JBSEAM-4606] - interpolation of parameters in logged messages are not substituted
+ * [JBSEAM-4623] - ServletContext is application scoped even though several can exist in one .ear
+ * [JBSEAM-4624] - Tasks example doesn't work correctly on Windows
+ * [JBSEAM-4629] - Disable default behaviour of auto-save for process instances
+ * [JBSEAM-4632] - Seam Reference Guide - 18.1.5. Lists - two properties called "alignment" in p:list
+ * [JBSEAM-4636] - tasks_jboss5.editTurtleTask fails
+ * [JBSEAM-4642] - Contextual instance are not available via ResteasyProviderFactory.getContextData()
+ * [JBSEAM-4666] - QueueConnection.stop() can not be called from an EJB containrer as stated in JEE5 spec section EE 6.6
+ * [JBSEAM-4669] - Major java deadlock between BijectionInterceptor and Component since the getInstanceFromFactory method is synchronized
+ * [JBSEAM-4671] - XML texts in the chapter for WebSphere do not render correctly in HTML + light refresh of the chapter
+ * [JBSEAM-4676] - Seam param - disabling EL expression evaluation
+ * [JBSEAM-4677] - Transaction Interceptor leaks transactions
+
+** Patch
+ * [JBSEAM-4444] - rich:comboBox have no dropdown arrow image when the project is generate by seam-gen
+ * [JBSEAM-4461] - small typo/mistake in reference manual
+ * [JBSEAM-4626] - Make install of own DocumentStore implementation possible
+ * [JBSEAM-4630] - File Attachment not Visible in certain versions of AppleMail
+
+** Task
+ * [JBSEAM-3035] - upgrade to Spring JAR to version 2.5
+ * [JBSEAM-4583] - Update Portlet Bridge and GateIn release instructions
+ * [JBSEAM-4627] - Upgrade to RESTEasy 2.0-beta-2
+ * [JBSEAM-4638] - In Seam mail do not recommend replacing the mail-ra.rar in JBoss 5.x
+ * [JBSEAM-4645] - Implement functional tests for nestedbooking example
+
Release Notes - Seam - Version 2.2.1.CR1
** Bug
Modified: branches/community/Seam_2_2/readme.txt
===================================================================
--- branches/community/Seam_2_2/readme.txt 2010-07-28 13:42:07 UTC (rev 13525)
+++ branches/community/Seam_2_2/readme.txt 2010-07-28 20:27:44 UTC (rev 13526)
@@ -1,7 +1,7 @@
JBoss Seam - Contextual Component framework for Java EE 5
=========================================================
-version 2.2.1.CR1, February 2010
+version 2.2.1.CR2, July 2010
This software is distributed under the terms of the FSF Lesser Gnu
Public License (see lgpl.txt).
14 years, 5 months
Seam SVN: r13525 - modules/resteasy/trunk.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-07-28 09:42:07 -0400 (Wed, 28 Jul 2010)
New Revision: 13525
Modified:
modules/resteasy/trunk/pom.xml
Log:
Bump parent version
Modified: modules/resteasy/trunk/pom.xml
===================================================================
--- modules/resteasy/trunk/pom.xml 2010-07-28 11:39:52 UTC (rev 13524)
+++ modules/resteasy/trunk/pom.xml 2010-07-28 13:42:07 UTC (rev 13525)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.jboss.seam</groupId>
<artifactId>seam-parent</artifactId>
- <version>1</version>
+ <version>2</version>
</parent>
<groupId>org.jboss.seam.resteasy</groupId>
14 years, 5 months
Seam SVN: r13524 - in modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence: transaction and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-28 07:39:52 -0400 (Wed, 28 Jul 2010)
New Revision: 13524
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
Log:
update to work with latest weld extensions
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java 2010-07-28 09:59:16 UTC (rev 13523)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java 2010-07-28 11:39:52 UTC (rev 13524)
@@ -27,6 +27,11 @@
import org.jboss.weld.extensions.el.Expressions;
+/**
+ *
+ * Parses hql queries and replaces el with named parameters
+ *
+ */
public class QueryParser
{
private final List<Object> parameterValues = new ArrayList<Object>();
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-28 09:59:16 UTC (rev 13523)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-28 11:39:52 UTC (rev 13524)
@@ -59,7 +59,7 @@
private static final Logger log = LoggerFactory.getLogger(TransactionExtension.class);
- public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager)
+ public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager, DefaultBeanExtension defaultBeanExtension)
{
AnnotatedTypeBuilder<SeamTransaction> utbuilder = new AnnotatedTypeBuilder().setJavaClass(SeamTransaction.class);
BeanBuilder<SeamTransaction> builder = new BeanBuilder<SeamTransaction>(manager);
@@ -67,7 +67,7 @@
builder.setBeanLifecycle(new TransactionBeanLifecycle(manager));
builder.getQualifiers().clear();
builder.getQualifiers().add(DefaultTransactionLiteral.INSTANCE);
- DefaultBeanExtension.addDefaultBean(SeamTransaction.class, builder.create());
+ defaultBeanExtension.addDefaultBean(SeamTransaction.class, builder.create());
}
/**
14 years, 5 months
Seam SVN: r13523 - in branches/community/Seam_2_2/examples/wiki: src/main/org/jboss/seam/wiki/core/action and 2 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-28 05:59:16 -0400 (Wed, 28 Jul 2010)
New Revision: 13523
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
Log:
implemented nuke feature, excluding blacklist
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-28 09:59:16 UTC (rev 13523)
@@ -390,7 +390,6 @@
lacewiki.label.adminHome.spamReport.Reporter=Reporter
lacewiki.label.adminHome.spamReport.Comment=Comment
lacewiki.label.adminHome.spamReport.Poster=Comment Poster
-lacewiki.label.adminHome.spamReport.ViewOriginal=View the original post
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this skin.
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-28 09:59:16 UTC (rev 13523)
@@ -6,30 +6,37 @@
*/
package org.jboss.seam.wiki.core.action;
+import static org.jboss.seam.international.StatusMessage.Severity.INFO;
+
+import java.util.Date;
+
+import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.Component;
-import org.jboss.seam.security.AuthorizationException;
-import org.jboss.seam.security.Identity;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.FlushModeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Events;
-import org.jboss.seam.core.Conversation;
import org.jboss.seam.international.Messages;
import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.annotations.*;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.wiki.core.feeds.FeedDAO;
-import org.jboss.seam.wiki.core.feeds.FeedEntryManager;
-import org.jboss.seam.wiki.core.model.*;
+import org.jboss.seam.security.AuthorizationException;
+import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.action.prefs.CommentsPreferences;
import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
+import org.jboss.seam.wiki.core.feeds.FeedDAO;
+import org.jboss.seam.wiki.core.feeds.FeedEntryManager;
+import org.jboss.seam.wiki.core.model.FeedEntry;
+import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiNode;
+import org.jboss.seam.wiki.core.model.WikiSpamReport;
import org.jboss.seam.wiki.core.ui.WikiRedirect;
import org.jboss.seam.wiki.core.wikitext.editor.WikiTextEditor;
import org.jboss.seam.wiki.util.WikiUtil;
-import static org.jboss.seam.international.StatusMessage.Severity.INFO;
-
-import java.util.Date;
-
@Name("commentHome")
@Scope(ScopeType.CONVERSATION)
public class CommentHome extends NodeHome<WikiComment, WikiNode>{
@@ -38,7 +45,7 @@
/* -------------------------- Context Wiring ------------------------------ */
- @In
+ @In(required = false)
protected DocumentHome documentHome;
@In
@@ -77,7 +84,10 @@
@Override
public void create() {
super.create();
- setParentNodeId(documentHome.getInstance().getId());
+ if (documentHome != null)
+ {
+ setParentNodeId(documentHome.getInstance().getId());
+ }
}
@Override
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2010-07-28 09:59:16 UTC (rev 13523)
@@ -6,31 +6,41 @@
*/
package org.jboss.seam.wiki.core.action;
+import static org.jboss.seam.international.StatusMessage.Severity.INFO;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Events;
import org.jboss.seam.international.Messages;
import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.annotations.*;
-import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.wiki.core.action.prefs.CommentsPreferences;
import org.jboss.seam.wiki.core.action.prefs.DocumentEditorPreferences;
import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
+import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import org.jboss.seam.wiki.core.feeds.FeedDAO;
import org.jboss.seam.wiki.core.feeds.FeedEntryManager;
-import org.jboss.seam.wiki.core.wikitext.renderer.MacroWikiTextRenderer;
-import org.jboss.seam.wiki.core.model.*;
-import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
+import org.jboss.seam.wiki.core.model.FeedEntry;
+import org.jboss.seam.wiki.core.model.WikiDirectory;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.model.WikiDocumentDefaults;
+import org.jboss.seam.wiki.core.model.WikiFile;
+import org.jboss.seam.wiki.core.model.WikiTextMacro;
import org.jboss.seam.wiki.core.template.TemplateRegistry;
+import org.jboss.seam.wiki.core.template.WikiDocumentEditorDefaults;
import org.jboss.seam.wiki.core.template.WikiDocumentTemplate;
-import org.jboss.seam.wiki.core.template.WikiDocumentEditorDefaults;
import org.jboss.seam.wiki.core.wikitext.editor.WikiTextEditor;
+import org.jboss.seam.wiki.core.wikitext.renderer.MacroWikiTextRenderer;
import org.jboss.seam.wiki.preferences.Preferences;
import org.jboss.seam.wiki.util.WikiUtil;
-import static org.jboss.seam.international.StatusMessage.Severity.INFO;
-
-import java.util.*;
-
@Name("documentHome")
@Scope(ScopeType.CONVERSATION)
public class DocumentHome extends NodeHome<WikiDocument, WikiDirectory> {
@@ -262,7 +272,20 @@
public String remove() {
return trash();
}
+
+ public String reallyRemove()
+ {
+ checkRemovePermissions();
+
+ getLog().debug("removing node : " + getInstance());
+ getNodeRemover().removeDependencies(getInstance());
+ getEntityManager().remove(getInstance());
+ getEntityManager().flush();
+ Events.instance().raiseEvent("Node.removed", getInstance());
+ return "removed";
+ }
+
@Override
protected NodeRemover getNodeRemover() {
return (DocumentNodeRemover)Component.getInstance(DocumentNodeRemover.class);
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-28 09:59:16 UTC (rev 13523)
@@ -10,6 +10,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
@@ -18,13 +19,18 @@
import org.jboss.seam.faces.Renderer;
import org.jboss.seam.framework.EntityHome;
import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.log.Log;
import org.jboss.seam.security.AuthorizationException;
import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.action.prefs.UserManagementPreferences;
import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
import org.jboss.seam.wiki.core.dao.UserDAO;
+import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.model.Role;
import org.jboss.seam.wiki.core.model.User;
+import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.model.WikiNode;
import org.jboss.seam.wiki.core.model.WikiUploadImage;
import org.jboss.seam.wiki.core.upload.Uploader;
import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
@@ -40,7 +46,9 @@
import static org.jboss.seam.international.StatusMessage.Severity.INFO;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -48,6 +56,9 @@
@Scope(ScopeType.CONVERSATION)
public class UserHome extends EntityHome<User> {
+ @Logger
+ static Log log;
+
// TODO: This is a performance optimization, our EM is always already joined (SMPC)
//protected void joinTransaction() {}
@@ -56,7 +67,7 @@
@In
private UserDAO userDAO;
-
+
@In
private Hash hashUtil;
@@ -356,11 +367,73 @@
@Restrict("#{s:hasPermission('User', 'delete', userHome.instance)}")
public String nuke() {
+
+ // First delete their comments
+
+ DocumentHome documentHome = (DocumentHome) Component.getInstance("documentHome");
+ WikiNodeDAO wikiNodeDAO = (WikiNodeDAO) Component.getInstance("wikiNodeDAO");
+
+ // Find all the content that this user has created
+ List<WikiNode> userNodes = wikiNodeDAO.findWikiNodes(getInstance());
+
+ Set<WikiNode> nodesToDelete = new HashSet<WikiNode>();
+
+ // Build a list of all the child nodes of the user's nodes
+ for (WikiNode node : userNodes)
+ {
+ recursiveAddChildren(wikiNodeDAO, node, nodesToDelete);
+ }
+
+ while (!nodesToDelete.isEmpty())
+ {
+ WikiNode nodeToDelete = null;
+
+ main: for (WikiNode node : nodesToDelete)
+ {
+ // We need to find a node without children contained in the same set (which should contain any children if they exist)
+ for (WikiNode n : nodesToDelete)
+ {
+ if (n.getParent().equals(node)) continue main;
+ }
+
+ nodeToDelete = node;
+ break;
+ }
+
+ if (nodeToDelete == null)
+ {
+ throw new IllegalStateException("Error while deleting child nodes - no childless node found in set.");
+ }
+ else
+ {
+ if (nodeToDelete instanceof WikiComment)
+ {
+ WikiComment comment = (WikiComment) nodeToDelete;
+
+ documentHome.setId(getCommentDocument(comment).getId());
+ CommentHome commentHome = (CommentHome) Component.getInstance("commentHome");
+
+ commentHome.setId(comment.getId());
+ commentHome.remove(comment.getId());
+ }
+ else if (nodeToDelete instanceof WikiDocument)
+ {
+ documentHome.setId(nodeToDelete.getId());
+ documentHome.reallyRemove();
+ }
+ else
+ {
+ log.info("Unhandled node found, could not delete: " + nodeToDelete);
+ }
- // TODO need to do almost the same as remove(), however we want to delete
- // all the user's nodes instead of re-parenting them, plus add their
- // e-mail and ip address to the blacklist
+ }
+
+ nodesToDelete.remove(nodeToDelete);
+ }
+ // TODO blacklist the user
+
+
// Remove preferences for this user
PreferenceProvider prefProvider = (PreferenceProvider)Component.getInstance("preferenceProvider");
prefProvider.deleteUserPreferenceValues(getInstance());
@@ -372,6 +445,29 @@
}
return outcome;
}
+
+ private void recursiveAddChildren(WikiNodeDAO wikiNodeDAO, WikiNode parent, Set<WikiNode> nodeSet)
+ {
+ if (nodeSet.contains(parent)) return;
+
+ List<WikiNode> children = wikiNodeDAO.findChildren(parent, WikiNode.SortableProperty.createdOn, true, 0, 0);
+ for (WikiNode child : children)
+ {
+ recursiveAddChildren(wikiNodeDAO, child, nodeSet);
+ }
+
+ nodeSet.add(parent);
+ }
+
+ private WikiDocument getCommentDocument(WikiComment comment)
+ {
+ WikiNode parent = comment.getParent();
+ while (!(parent instanceof WikiDocument))
+ {
+ parent = parent.getParent();
+ }
+ return (WikiDocument) parent;
+ }
@Restrict("#{s:hasPermission('User', 'edit', userHome.instance)}")
public void removePortrait() {
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-07-28 09:59:16 UTC (rev 13523)
@@ -10,7 +10,6 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.log.Log;
import org.jboss.seam.wiki.core.model.WikiComment;
-import org.jboss.seam.wiki.core.model.WikiFeed;
import org.jboss.seam.wiki.core.model.WikiSpamReport;
@Name("spamReportDAO")
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java 2010-07-28 09:59:16 UTC (rev 13523)
@@ -1,20 +1,30 @@
package org.jboss.seam.wiki.core.dao;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+
import org.hibernate.Session;
-import org.hibernate.transform.ResultTransformer;
import org.jboss.seam.Component;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.log.Log;
-import org.jboss.seam.wiki.core.model.*;
+import org.jboss.seam.wiki.core.model.User;
+import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiDirectory;
+import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.model.WikiFile;
+import org.jboss.seam.wiki.core.model.WikiMenuItem;
+import org.jboss.seam.wiki.core.model.WikiNode;
+import org.jboss.seam.wiki.core.model.WikiTreeNode;
+import org.jboss.seam.wiki.core.model.WikiUpload;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.NoResultException;
-import java.util.*;
-
/**
* DAO for nodes, transparently respects security access levels.
* <p>
@@ -22,6 +32,7 @@
* about access levels because it relies on a restricted (filtered) Entitymanager.
*
* @author Christian Bauer
+ * @author Shane Bryzak
*
*/
@Name("wikiNodeDAO")
@@ -58,6 +69,7 @@
}
+ @SuppressWarnings("unchecked")
public List<WikiNode> findWikiNodes(List<Long> ids) {
return restrictedEntityManager
.createQuery("select n from WikiNode n where n.id in (:idList)")
@@ -100,23 +112,38 @@
return null;
}
- public List<WikiNode> findChildren(WikiNode node, WikiNode.SortableProperty orderBy, boolean orderAscending, int firstResult, int maxResults) {
+ @SuppressWarnings("unchecked")
+ public List<WikiNode> findChildren(WikiNode node, WikiNode.SortableProperty orderBy,
+ boolean orderAscending, int firstResult, int maxResults) {
StringBuilder queryString = new StringBuilder();
queryString.append("select n from WikiNode n where n.parent = :parent").append(" ");
queryString.append("order by n.").append(orderBy.name()).append(" ").append(orderAscending ? "asc" : "desc");
- return restrictedEntityManager
- .createQuery(queryString.toString())
- .setHint("org.hibernate.comment", "Find wikinode children order by "+orderBy.name())
- .setParameter("parent", node)
- .setHint("org.hibernate.cacheable", false)
- .setFirstResult(firstResult)
- .setMaxResults(maxResults)
- .getResultList();
+ Query query = restrictedEntityManager
+ .createQuery(queryString.toString())
+ .setHint("org.hibernate.comment", "Find wikinode children order by "+orderBy.name())
+ .setParameter("parent", node)
+ .setHint("org.hibernate.cacheable", false)
+ .setFirstResult(firstResult);
+
+ if (maxResults > 0)
+ {
+ query.setMaxResults(maxResults);
+ }
+
+ return query.getResultList();
}
+
+ public List<WikiNode> findWikiNodes(User user)
+ {
+ return restrictedEntityManager.createQuery("select n from WikiNode n where n.createdBy = :createdBy")
+ .setParameter("createdBy", user)
+ .getResultList();
+ }
- public List<WikiDirectory> findChildWikiDirectories(WikiDirectory dir) {
+ @SuppressWarnings("unchecked")
+ public List<WikiDirectory> findChildWikiDirectories(WikiDirectory dir) {
return restrictedEntityManager
.createQuery("select d from WikiDirectory d left join fetch d.feed where d.parent = :parent")
.setHint("org.hibernate.comment", "Find wikinode children directories")
@@ -139,7 +166,8 @@
return null;
}
- public List<WikiComment> findWikiComments(WikiDocument document, boolean orderbyDateAscending) {
+ @SuppressWarnings("unchecked")
+ public List<WikiComment> findWikiComments(WikiDocument document, boolean orderbyDateAscending) {
String query =
"select c from WikiComment c where c.parent = :parentDoc order by c.createdOn " +
(orderbyDateAscending ? "asc" : "desc");
@@ -149,7 +177,65 @@
.setHint("org.hibernate.comment", "Finding all comments of document")
.getResultList();
}
-
+
+ /**
+ * Returns a list of all the WikiComments created by a particular user
+ * @param createdBy
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public List<WikiComment> findWikiComments(User createdBy)
+ {
+ return (List<WikiComment>) restrictedEntityManager.createQuery(
+ "select c from WikiComment c where c.createdBy = :createdBy")
+ .setParameter("createdBy", createdBy)
+ .getResultList();
+ }
+
+ /**
+ * Returns a list of all the WikiComments matching the specified parameters
+ *
+ * @param fromUserName
+ * @param fromUserEmail
+ * @param fromUserHomepage
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public List<WikiComment> findWikiComments(String fromUserName, String fromUserEmail,
+ String fromUserHomepage)
+ {
+ if (fromUserName == null && fromUserEmail == null && fromUserHomepage == null)
+ {
+ throw new IllegalArgumentException("At least one parameter must be not null.");
+ }
+
+ StringBuilder criteria = new StringBuilder();
+ if (fromUserName != null)
+ {
+ criteria.append("where c.fromUserName = :fromUserName");
+ }
+
+ if (fromUserEmail != null)
+ {
+ if (criteria.length() > 0) criteria.append(" and ");
+ criteria.append("c.fromUserEmail = :fromUserEmail");
+ }
+
+ if (fromUserHomepage != null)
+ {
+ if (criteria.length() > 0) criteria.append(" and ");
+ criteria.append("c.fromUserHomepage = :fromUserHomepage");
+ }
+
+ Query query = restrictedEntityManager.createQuery("select c from WikiComment c " + criteria.toString());
+
+ if (fromUserName != null) query.setParameter("fromUserName", fromUserName);
+ if (fromUserEmail != null) query.setParameter("fromUserEmail", fromUserEmail);
+ if (fromUserHomepage != null) query.setParameter("fromUserHomepage", fromUserHomepage);
+
+ return (List<WikiComment>) query.getResultList();
+ }
+
public WikiFile findWikiFile(Long fileId) {
try {
return (WikiFile) restrictedEntityManager
@@ -228,6 +314,7 @@
return null;
}
+ @SuppressWarnings("unchecked")
public List<WikiDocument> findWikiDocuments(WikiDirectory directory, WikiNode.SortableProperty orderBy, boolean orderAscending) {
StringBuilder query = new StringBuilder();
@@ -259,6 +346,7 @@
return null;
}
+ @SuppressWarnings("unchecked")
public List<WikiDocument> findWikiDocuments(int maxResults, WikiNode.SortableProperty orderBy, boolean orderAscending) {
StringBuilder query = new StringBuilder();
@@ -305,6 +393,7 @@
return null;
}
+ @SuppressWarnings("unchecked")
public List<WikiUpload> findWikiUploads(WikiDirectory directory, WikiNode.SortableProperty orderBy, boolean orderAscending) {
StringBuilder query = new StringBuilder();
query.append("select u from WikiUpload u where u.parent = :dir");
@@ -405,6 +494,7 @@
}
// Recursive! Don't use for large trees...
+ @SuppressWarnings("unchecked")
private void appendWikiNodeChildren(String query, List tree, long parentNodeId, long currentLevel, Long maxDepth, Long flattenToLevel) {
List<WikiNode> nodes = restrictedEntityManager.createQuery(query)
.setHint("org.hibernate.comment", "Querying children of wiki node: " + parentNodeId)
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-28 09:21:42 UTC (rev 13522)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-28 09:59:16 UTC (rev 13523)
@@ -275,29 +275,53 @@
<h:column>
<f:facet name="header">
#{messages['lacewiki.label.adminHome.spamReport.Comment']}
- </f:facet>
+ </f:facet>
- <s:div styleClass="commentText" rendered="#{report.comment.useWikiText and not empty report.comment.parent.areaNumber}">
- <s:formattedText value="#{report.comment.content}"
- linkStyleClass="regularLink"
- brokenLinkStyleClass="brokenLink"
- attachmentLinkStyleClass="regularLink"
- thumbnailLinkStyleClass="regularLink"
- enableMacroRendering="false"/>
- </s:div>
- <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name != report.comment.subject}" style="margin-top:15px;">
- <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
- </s:div>
- <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name == report.comment.subject}">
- <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
- </s:div>
+ <div style="padding: 4px">
+ <h:outputLink value="#{wikiURLRenderer.renderURL(report.comment)}">
+ <h:outputText value="#{report.comment.subject}"/>
+ </h:outputLink>
+
+ <s:div styleClass="commentText" rendered="#{report.comment.useWikiText and not empty report.comment.parent.areaNumber}">
+ <s:formattedText value="#{report.comment.content}"
+ linkStyleClass="regularLink"
+ brokenLinkStyleClass="brokenLink"
+ attachmentLinkStyleClass="regularLink"
+ thumbnailLinkStyleClass="regularLink"
+ enableMacroRendering="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name != report.comment.subject}" style="margin-top:15px;">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+ <s:div styleClass="commentText plaintext" rendered="#{not report.comment.useWikiText and report.comment.parent.name == report.comment.subject}">
+ <h:outputText value="#{wiki:escapeHTML(report.comment.content, true, true)}" escape="false"/>
+ </s:div>
+
+ <div>
+
+ <s:fragment rendered="#{s:hasPermission('Comment', 'delete', report.comment)}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
+ <ui:param name="jsFunctionName" value="deleteCommentId#{report.comment.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(' ')
+ .concat(messages['lacewiki.label.commentsDisplay.CommentThread'])
+ .concat(': \'')
+ .concat(report.comment.subject)
+ .concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="commentDisplayForm, messageBoxContainer"
+ action="#{commentHome.remove(report.comment.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
+ </div>
+ </div>
- <div>
- <h:outputLink value="#{wikiURLRenderer.renderURL(report.comment)}">
- <h:outputText value="#{messages['lacewiki.label.adminHome.spamReport.ViewOriginal']}"/>
- </h:outputLink>
- </div>
-
</h:column>
<h:column>
<f:facet name="header">
14 years, 5 months
Seam SVN: r13522 - in modules/persistence/trunk/impl: src/main/java/org/jboss/seam/persistence and 1 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-28 05:21:42 -0400 (Wed, 28 Jul 2010)
New Revision: 13522
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HotelNameProducer.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
Modified:
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
Log:
add the ability to use el in jpa queries
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-07-28 09:05:52 UTC (rev 13521)
+++ modules/persistence/trunk/impl/pom.xml 2010-07-28 09:21:42 UTC (rev 13522)
@@ -54,6 +54,11 @@
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </dependency>
<dependency>
<groupId>javax.transaction</groupId>
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-28 09:05:52 UTC (rev 13521)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -110,13 +110,6 @@
}
}
- /**
- */
- public void processProducer()
- {
-
- }
-
public void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, BeanManager manager)
{
// create the new bean to be registerd later
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-07-28 09:05:52 UTC (rev 13521)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -29,12 +29,15 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
+import javax.persistence.Query;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
+import org.jboss.weld.extensions.el.Expressions;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,10 +64,13 @@
static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
+ private final Bean<Expressions> expressionsBean;
+
public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
{
this.delegate = delegate;
this.beanManager = beanManager;
+ this.expressionsBean = (Bean) beanManager.resolve(beanManager.getBeans(Expressions.class, DefaultLiteral.INSTANCE));
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
@@ -73,6 +79,10 @@
{
joinTransaction();
}
+ if ("createQuery".equals(method.getName()) && method.getParameterTypes().length > 0 && method.getParameterTypes()[0].equals(String.class))
+ {
+ return handleCreateQueryWithString(method, args);
+ }
return method.invoke(delegate, args);
}
@@ -122,4 +132,30 @@
}
+ protected Object handleCreateQueryWithString(Method method, Object[] args) throws Throwable
+ {
+ if (args[0] == null)
+ {
+ return method.invoke(delegate, args);
+ }
+ String ejbql = (String) args[0];
+ if (ejbql.indexOf('#') > 0)
+ {
+ CreationalContext<Expressions> ctx = beanManager.createCreationalContext(expressionsBean);
+ Expressions expressions = (Expressions) beanManager.getReference(expressionsBean, Expressions.class, ctx);
+ QueryParser qp = new QueryParser(expressions, ejbql);
+ Object[] newArgs = args.clone();
+ newArgs[0] = qp.getEjbql();
+ Query query = (Query) method.invoke(delegate, newArgs);
+ for (int i = 0; i < qp.getParameterValues().size(); i++)
+ {
+ query.setParameter(QueryParser.getParameterName(i), qp.getParameterValues().get(i));
+ }
+ return query;
+ }
+ else
+ {
+ return method.invoke(delegate, args);
+ }
+ }
}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/QueryParser.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.jboss.weld.extensions.el.Expressions;
+
+public class QueryParser
+{
+ private final List<Object> parameterValues = new ArrayList<Object>();
+ private final StringBuilder ejbqlBuilder;
+
+ public static String getParameterName(int loc)
+ {
+ return "el" + (loc + 1);
+ }
+
+ public String getEjbql()
+ {
+ return ejbqlBuilder.toString();
+ }
+
+ public List<Object> getParameterValues()
+ {
+ return parameterValues;
+ }
+
+ public QueryParser(Expressions expressions, String ejbql)
+ {
+ this(expressions, ejbql, 0);
+ }
+
+ public QueryParser(Expressions expressions, String ejbql, int startingParameterNumber)
+ {
+ StringTokenizer tokens = new StringTokenizer(ejbql, "#}", true);
+ ejbqlBuilder = new StringBuilder(ejbql.length());
+ while (tokens.hasMoreTokens())
+ {
+ String token = tokens.nextToken();
+ if ("#".equals(token) && tokens.hasMoreTokens())
+ {
+ String expressionToken = tokens.nextToken();
+
+ if (!expressionToken.startsWith("{") || !tokens.hasMoreTokens())
+ {
+ ejbqlBuilder.append(token).append(expressionToken);
+ }
+ else
+ {
+ String expression = token + expressionToken + tokens.nextToken();
+ ejbqlBuilder.append(':').append(getParameterName(startingParameterNumber + parameterValues.size()));
+ parameterValues.add(expressions.evaluateValueExpression(expression));
+ }
+ }
+ else
+ {
+ ejbqlBuilder.append(token);
+ }
+ }
+ }
+
+}
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HotelNameProducer.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HotelNameProducer.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HotelNameProducer.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -0,0 +1,14 @@
+package org.jboss.seam.persistence.test;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+public class HotelNameProducer
+{
+ @Produces
+ @Named("hotelName")
+ public String getHotelName()
+ {
+ return "Hilton";
+ }
+}
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.PersistenceContextExtension;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextELTest
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addPackage(TransactionExtension.class.getPackage());
+ war.addPackage(PersistenceContextExtension.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
+ war.addClasses(ManagedPersistenceContextELTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class);
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManager em;
+
+ @Test
+ public void testELInInquery() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ Hotel h = new Hotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ h = new Hotel("Other Hotel", "Real St ", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ Hotel hilton = (Hotel) em.createQuery("select h from Hotel h where h.name=#{hotelName}").getSingleResult();
+ Assert.assertTrue(hilton.getName().equals("Hilton"));
+ Assert.assertTrue(hilton.getAddress().equals("Fake St"));
+ transaction.commit();
+
+ }
+
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-28 09:05:52 UTC (rev 13521)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-28 09:21:42 UTC (rev 13522)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.persistence.test;
import java.util.List;
14 years, 5 months
Seam SVN: r13521 - in modules/resteasy/trunk: impl/src/test/java/org/jboss/seam/resteasy/test and 1 other directories.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-07-28 05:05:52 -0400 (Wed, 28 Jul 2010)
New Revision: 13521
Modified:
modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/SeamResteasyClientTest.java
modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/validation/ValidationTest.java
modules/resteasy/trunk/pom.xml
Log:
Upgrade to Arquillian Alpha 3 + get tests running on JBoss 6 M4
Modified: modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/SeamResteasyClientTest.java
===================================================================
--- modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/SeamResteasyClientTest.java 2010-07-27 20:04:10 UTC (rev 13520)
+++ modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/SeamResteasyClientTest.java 2010-07-28 09:05:52 UTC (rev 13521)
@@ -36,18 +36,17 @@
public static JavaArchive createSeamResteasyLibrary()
{
- JavaArchive jar = ShrinkWrap.create("seam-resteasy.jar", JavaArchive.class);
+ JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "seam-resteasy.jar");
jar.addManifestResource("META-INF/web-fragment.xml", "web-fragment.xml");
jar.addManifestResource("META-INF/beans.xml", ArchivePaths.create("beans.xml"));
jar.addPackage(SeamResteasyConfiguration.class.getPackage());
jar.addPackage(ValidateRequest.class.getPackage());
- jar.addPackage(SeamResteasyClientTest.class.getPackage());
return jar;
}
public static WebArchive createTestApplication()
{
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class);
+ WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
war.addClass(CustomSeamResteasyConfiguration.class);
war.addClass(EntityNotFoundException.class);
war.addClass(TestProvider.class);
Modified: modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/validation/ValidationTest.java
===================================================================
--- modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/validation/ValidationTest.java 2010-07-27 20:04:10 UTC (rev 13520)
+++ modules/resteasy/trunk/impl/src/test/java/org/jboss/seam/resteasy/test/validation/ValidationTest.java 2010-07-28 09:05:52 UTC (rev 13521)
@@ -23,7 +23,7 @@
@Deployment
public static JavaArchive createDeployment()
{
- JavaArchive jar = ShrinkWrap.create("test.jar", JavaArchive.class);
+ JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar");
jar.addManifestResource("org/jboss/seam/resteasy/test/validation/beans.xml", ArchivePaths.create("beans.xml"));
jar.addPackage(ValidateRequest.class.getPackage());
jar.addPackage(ValidationTest.class.getPackage());
Modified: modules/resteasy/trunk/pom.xml
===================================================================
--- modules/resteasy/trunk/pom.xml 2010-07-27 20:04:10 UTC (rev 13520)
+++ modules/resteasy/trunk/pom.xml 2010-07-28 09:05:52 UTC (rev 13521)
@@ -17,6 +17,7 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
+ <arquillian.version>1.0.0.Alpha3</arquillian.version>
</properties>
<url>http://www.seamframework.org</url>
@@ -37,6 +38,7 @@
<module>impl</module>
</modules>
+
<dependencyManagement>
<dependencies>
<dependency>
@@ -50,25 +52,29 @@
</dependencyManagement>
<dependencies>
- <!-- CDI (JSR-299) -->
+ <!--
+ We will need this once we implement ValidationInterceptor check.
+ Will be implemented once packing maven dependencies with ShrinkWrap gets easier
<dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ </dependency> -->
+ <!-- Provided dependencies -->
+ <dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
- <!-- Bean validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>provided</scope>
</dependency>
- <!-- Interceptors -->
<dependency>
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
- <!-- RESTEasy -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
@@ -95,15 +101,16 @@
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-jbossas-remote-60</artifactId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
- <version>6.0.0-SNAPSHOT</version>
+<!-- <version>6.0.0-SNAPSHOT</version>-->
<!-- <version>6.0.0.20100429-M3</version>-->
+ <version>6.0.0.20100721-M4</version>
<type>pom</type>
<scope>test</scope>
</dependency>
@@ -116,8 +123,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <classifier>jdk15</classifier>
- <version>5.10</version>
+ <version>5.12.1</version>
<scope>test</scope>
</dependency>
</dependencies>
14 years, 5 months
Seam SVN: r13520 - in sandbox/encore: core/src/main/java/org/jboss/encore/grammar and 15 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-27 16:04:10 -0400 (Tue, 27 Jul 2010)
New Revision: 13520
Added:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/Mutable.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java
Removed:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java
sandbox/encore/core/src/main/java/org/jboss/encore/model/Mutable.java
sandbox/encore/core/src/main/java/org/jboss/encore/model/Project.java
sandbox/encore/core/src/main/java/org/jboss/encore/model/Stateful.java
sandbox/encore/core/src/main/java/org/jboss/encore/model/java/
sandbox/encore/core/src/main/java/org/jboss/seam/
sandbox/encore/core/src/test/java/org/jboss/seam/
sandbox/encore/src/main/java/org/jboss/encore/grammar/java/
sandbox/encore/src/main/java/org/jboss/encore/model/java/
sandbox/encore/src/main/java/org/jboss/encore/mojo/
sandbox/encore/src/main/java/org/jboss/seam/encore/
sandbox/encore/src/test/java/org/jboss/encore/grammar/java/
sandbox/encore/src/test/java/org/jboss/seam/encore/
sandbox/encore/src/test/resources/org/
Modified:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Import.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
sandbox/encore/model/pom.xml
sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java
Log:
Java parser enhancements (can change class and method modifiers, set class and method names and visibility, and remove imports)
Copied: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/Mutable.java (from rev 13512, sandbox/encore/core/src/main/java/org/jboss/encore/model/Mutable.java)
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/Mutable.java (rev 0)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/Mutable.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.grammar;
+
+/**
+ * Represents an object that queues changes before making final modifications to a resource.
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public interface Mutable
+{
+ /**
+ * Apply all changes made to this or other objects to which this may belong. (Apply all pending changes in the object
+ * graph.)
+ */
+ void applyChanges();
+}
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Import.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Import.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Import.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -25,7 +25,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ImportDeclaration;
import org.jboss.encore.grammar.Internal;
-import org.jboss.encore.model.Mutable;
+import org.jboss.encore.grammar.Mutable;
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -31,6 +31,8 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ImportDeclaration;
import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.jface.text.BadLocationException;
@@ -39,9 +41,10 @@
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.UndoEdit;
import org.jboss.encore.grammar.Internal;
+import org.jboss.encore.grammar.Mutable;
import org.jboss.encore.grammar.java.ast.MethodFinderVisitor;
+import org.jboss.encore.grammar.java.ast.ModifierAccessor;
import org.jboss.encore.grammar.java.ast.TypeDeclarationFinderVisitor;
-import org.jboss.encore.model.Mutable;
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
@@ -52,13 +55,17 @@
private Document document;
private CompilationUnit unit;
+ private final ModifierAccessor ma = new ModifierAccessor();
/**
- * Parses and process the java source code as a compilation unit and the result it abstract syntax tree (AST)
- * representation and this action uses the third edition of java Language Specification.
+ * Parses and process the java source code as a compilation unit and the
+ * result it abstract syntax tree (AST) representation and this action uses
+ * the third edition of java Language Specification.
*
- * @param source - the java source to be parsed (i.e. the char[] contains Java source).
- * @return CompilationUnit Abstract syntax tree representation of a java source file.
+ * @param source - the java source to be parsed (i.e. the char[] contains
+ * Java source).
+ * @return CompilationUnit Abstract syntax tree representation of a java
+ * source file.
*/
public JavaClass(final InputStream inputStream)
{
@@ -94,56 +101,74 @@
unit.recordModifications();
}
+ /*
+ * Import modifiers
+ */
+
@SuppressWarnings("unchecked")
- public Method addMethod()
+ public Import addImport(final String className)
{
- Method m = new Method(this);
- getTypeDeclaration().bodyDeclarations().add(m.getInternal());
- return m;
+ Import imprt = new Import(this).setName(className);
+ unit.imports().add(imprt.getInternal());
+ return imprt;
}
- @SuppressWarnings("unchecked")
- public Method addMethod(final String method)
+ public Import addImport(final Class<?> type)
{
- Method m = new Method(this, method);
- getTypeDeclaration().bodyDeclarations().add(m.getInternal());
- return m;
+ return addImport(type.getName());
}
- @SuppressWarnings("unchecked")
- public Import addImport(final String className)
+ public JavaClass addImports(final Class<?>... types)
{
- Import imprt = new Import(this).setName(className);
- unit.imports().add(imprt.getInternal());
- return imprt;
+ for (Class<?> type : types)
+ {
+ addImport(type.getName());
+ }
+ return this;
}
- public void addImports(final String... types)
+ public JavaClass addImports(final String... types)
{
for (String type : types)
{
addImport(type);
}
+ return this;
}
- public void addImport(final Class<?> type)
+ public JavaClass removeImport(String name)
{
- addImport(type.getName());
+ for (Import i : getImports())
+ {
+ if (i.getName().equals(name))
+ {
+ removeImport(i);
+ break;
+ }
+ }
+ return this;
}
- public void addImports(final Class<?>... types)
+ public JavaClass removeImport(Class<?> clazz)
{
- for (Class<?> type : types)
- {
- addImport(type.getName());
- }
+ return removeImport(clazz.getName());
}
- public Stack<UndoEdit> getUndoStack()
+ public JavaClass removeImport(Import imprt)
{
- return undoStack;
+ Object internal = imprt.getInternal();
+ if (unit.imports().contains(internal))
+ {
+ unit.imports().remove(internal);
+ }
+ return this;
}
+ /**
+ * Get a list of the {@link Import}s contained within this {@link JavaClass}.
+ * Note that modification of this list does not affect internal state, but
+ * modification of individual {@link Import} objects will.
+ */
@SuppressWarnings("unchecked")
public List<Import> getImports()
{
@@ -157,6 +182,31 @@
return results;
}
+ /*
+ * Method modifiers
+ */
+
+ @SuppressWarnings("unchecked")
+ public Method addMethod()
+ {
+ Method m = new Method(this);
+ getTypeDeclaration().bodyDeclarations().add(m.getInternal());
+ return m;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Method addMethod(final String method)
+ {
+ Method m = new Method(this, method);
+ getTypeDeclaration().bodyDeclarations().add(m.getInternal());
+ return m;
+ }
+
+ /**
+ * Get a list of the {@link Method}s contained within this {@link JavaClass}.
+ * Note that modification of this list does not affect internal state, but
+ * modification of individual {@link Method} objects will.
+ */
public List<Method> getMethods()
{
List<Method> result = new ArrayList<Method>();
@@ -181,18 +231,138 @@
return this;
}
- public TypeDeclaration getTypeDeclaration()
+ private TypeDeclaration getTypeDeclaration()
{
TypeDeclarationFinderVisitor typeDeclarationFinder = new TypeDeclarationFinderVisitor();
unit.accept(typeDeclarationFinder);
return typeDeclarationFinder.getTypeDeclarations().get(0);
}
+ /*
+ * Name modifiers
+ */
+
public String getName()
{
return getTypeDeclaration().getName().getIdentifier();
}
+ public JavaClass setName(String name)
+ {
+ getTypeDeclaration().setName(unit.getAST().newSimpleName(name));
+ return this;
+ }
+
+ /*
+ * Package modifiers
+ */
+
+ public String getPackage()
+ {
+ PackageDeclaration pkg = unit.getPackage();
+ if (pkg != null)
+ {
+ return pkg.getName().getFullyQualifiedName();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public JavaClass setPackage(String name)
+ {
+ unit.getPackage().setName(unit.getAST().newName(name));
+ return this;
+ }
+
+ public JavaClass setDefaultPackage()
+ {
+ unit.setPackage(null);
+ return this;
+ }
+
+ public boolean isDefaultPackage()
+ {
+ return unit.getPackage() == null;
+ }
+
+ /*
+ * Visibility modifiers
+ */
+ public boolean isPackagePrivate()
+ {
+ return (!isPublic() && !isPrivate() && !isProtected());
+ }
+
+ public JavaClass setPackagePrivate()
+ {
+ ma.clearVisibility(getTypeDeclaration());
+ return this;
+ }
+
+ public boolean isPublic()
+ {
+ return ma.hasModifier(getTypeDeclaration(), ModifierKeyword.PUBLIC_KEYWORD);
+ }
+
+ public JavaClass setPublic()
+ {
+ ma.clearVisibility(getTypeDeclaration());
+ ma.addModifier(getTypeDeclaration(), ModifierKeyword.PUBLIC_KEYWORD);
+ return this;
+ }
+
+ public boolean isPrivate()
+ {
+ return ma.hasModifier(getTypeDeclaration(), ModifierKeyword.PRIVATE_KEYWORD);
+ }
+
+ public JavaClass setPrivate()
+ {
+ ma.clearVisibility(getTypeDeclaration());
+ ma.addModifier(getTypeDeclaration(), ModifierKeyword.PRIVATE_KEYWORD);
+ return this;
+ }
+
+ public boolean isProtected()
+ {
+ return ma.hasModifier(getTypeDeclaration(), ModifierKeyword.PROTECTED_KEYWORD);
+ }
+
+ public JavaClass setProtected()
+ {
+ ma.clearVisibility(getTypeDeclaration());
+ ma.addModifier(getTypeDeclaration(), ModifierKeyword.PROTECTED_KEYWORD);
+ return this;
+ }
+
+ /*
+ * Type modifiers
+ */
+
+ public boolean isAbstract()
+ {
+ return ma.hasModifier(getTypeDeclaration(), ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+
+ public JavaClass setAbstract(boolean abstrct)
+ {
+ if (abstrct)
+ {
+ ma.addModifier(getTypeDeclaration(), ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+ else
+ {
+ ma.removeModifier(getTypeDeclaration(), ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+ return this;
+ }
+
+ /*
+ * Non-manipulation methods.
+ */
+
@Override
public String toString()
{
Deleted: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -1,327 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.grammar.java;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
-import org.eclipse.jdt.core.dom.Statement;
-import org.jboss.encore.grammar.Internal;
-import org.jboss.encore.model.Mutable;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public class Method implements Internal, Mutable
-{
- private JavaClass parent = null;
- private AST ast = null;
- private CompilationUnit cu = null;
- private final MethodDeclaration method;
-
- private void init(final JavaClass parent)
- {
- this.parent = parent;
- cu = (CompilationUnit) parent.getInternal();
- ast = cu.getAST();
- }
-
- public Method(final JavaClass parent)
- {
- init(parent);
- method = ast.newMethodDeclaration();
- method.setConstructor(false);
- }
-
- public Method(final JavaClass parent, final Object internal)
- {
- init(parent);
- method = (MethodDeclaration) internal;
- }
-
- public Method(final JavaClass parent, final String method)
- {
- init(parent);
-
- String stub = "public class Stub { " + method + " }";
- JavaClass temp = new JavaClass(stub);
- List<Method> methods = temp.getMethods();
- MethodDeclaration newMethod = methods.get(0).getMethodDeclaration();
- MethodDeclaration subtree = (MethodDeclaration) ASTNode.copySubtree(cu.getAST(), newMethod);
- this.method = subtree;
- }
-
- @SuppressWarnings("unchecked")
- public String getBody()
- {
- String result = "";
-
- List<Statement> statements = (List<Statement>) method.getBody().getStructuralProperty(Block.STATEMENTS_PROPERTY);
- for (Statement statement : statements)
- {
- result += statement + " ";
- }
-
- return result;
- }
-
- public Method setBody(final String body)
- {
- String stub = "public class Stub { public void method() {" + body + "} }";
- JavaClass temp = new JavaClass(stub);
- List<Method> methods = temp.getMethods();
- Block block = methods.get(0).getMethodDeclaration().getBody();
-
- block = (Block) ASTNode.copySubtree(method.getAST(), block);
- method.setBody(block);
-
- return this;
- }
-
- public Method setConstructor(final boolean isConstructor)
- {
- method.setConstructor(isConstructor);
- if (isConstructor())
- {
- method.setName(ast.newSimpleName(parent.getName()));
- }
- return this;
- }
-
- public boolean isConstructor()
- {
- return method.isConstructor();
- }
-
- @SuppressWarnings("unchecked")
- public Method setAbstract()
- {
- method.modifiers().add(ast.newModifier(ModifierKeyword.ABSTRACT_KEYWORD));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Method setFinal()
- {
- method.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));
- return this;
- }
-
- public String getName()
- {
- return method.getName().toString();
- }
-
- public Method setName(final String name)
- {
- if (method.isConstructor())
- {
- throw new IllegalStateException("Cannot set the name of a constructor.");
- }
- method.setName(ast.newSimpleName(name));
- return this;
- }
-
- public boolean isPackagePrivate()
- {
- return (!isPublic() && !isPrivate() && !isProtected());
- }
-
- @SuppressWarnings("unchecked")
- public Method setPackagePrivate()
- {
- List<Modifier> modifiers = method.modifiers();
-
- List<Modifier> toBeRemoved = new ArrayList<Modifier>();
- for (Modifier modifier : modifiers)
- {
- if (modifier.isPrivate() || modifier.isProtected() || modifier.isPublic())
- {
- toBeRemoved.add(modifier);
- }
- }
-
- modifiers.removeAll(toBeRemoved);
-
- modifiers.add(ast.newModifier(ModifierKeyword.PRIVATE_KEYWORD));
- return this;
- }
-
- public boolean isPublic()
- {
- return hasModifier(ModifierKeyword.PUBLIC_KEYWORD);
- }
-
- @SuppressWarnings("unchecked")
- public Method setPublic()
- {
- method.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
- return this;
- }
-
- public boolean isPrivate()
- {
- return hasModifier(ModifierKeyword.PRIVATE_KEYWORD);
- }
-
- @SuppressWarnings("unchecked")
- public Method setPrivate()
- {
- method.modifiers().add(ast.newModifier(ModifierKeyword.PRIVATE_KEYWORD));
- return this;
- }
-
- public boolean isProtected()
- {
- return hasModifier(ModifierKeyword.PROTECTED_KEYWORD);
- }
-
- @SuppressWarnings("unchecked")
- public Method setProtected()
- {
- method.modifiers().add(ast.newModifier(ModifierKeyword.PROTECTED_KEYWORD));
- return this;
- }
-
- public String getReturnType()
- {
- String result = null;
- if (!isConstructor() && (method.getReturnType2() != null))
- {
- result = method.getReturnType2().toString();
- }
- return result;
- }
-
- public Method setReturnType(final Class<?> type)
- {
- return setReturnType(type.getSimpleName());
- }
-
- public Method setReturnType(final String type)
- {
- method.setReturnType2(ast.newSimpleType(ast.newSimpleName(type)));
- return this;
- }
-
- public Method setReturnTypeVoid()
- {
- method.setReturnType2(null);
- return this;
- }
-
- private MethodDeclaration getMethodDeclaration()
- {
- return method;
- }
-
- @Override
- public String toString()
- {
- return method.toString();
- }
-
- @SuppressWarnings("unchecked")
- private boolean hasModifier(final ModifierKeyword modifier)
- {
- boolean result = false;
- List<Modifier> modifiers = method.modifiers();
- for (Modifier m : modifiers)
- {
- if (m.getKeyword() == modifier)
- {
- result = true;
- }
- }
- return result;
- }
-
- @Override
- public Object getInternal()
- {
- return method;
- }
-
- public void applyChanges()
- {
- parent.applyChanges();
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((method == null) ? 0 : method.hashCode());
- result = prime * result + ((parent == null) ? 0 : parent.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj)
- {
- if (this == obj)
- {
- return true;
- }
- if (obj == null)
- {
- return false;
- }
- if (getClass() != obj.getClass())
- {
- return false;
- }
- Method other = (Method) obj;
- if (method == null)
- {
- if (other.method != null)
- {
- return false;
- }
- }
- else if (!method.equals(other.method))
- {
- return false;
- }
- if (parent == null)
- {
- if (other.parent != null)
- {
- return false;
- }
- }
- else if (!parent.equals(other.parent))
- {
- return false;
- }
- return true;
- }
-}
Copied: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java (from rev 13512, sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java)
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java (rev 0)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -0,0 +1,314 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.grammar.java;
+
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.Block;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+import org.eclipse.jdt.core.dom.Statement;
+import org.jboss.encore.grammar.Internal;
+import org.jboss.encore.grammar.Mutable;
+import org.jboss.encore.grammar.java.ast.ModifierAccessor;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class Method implements Internal, Mutable
+{
+ private JavaClass parent = null;
+ private AST ast = null;
+ private CompilationUnit cu = null;
+ private final ModifierAccessor ma = new ModifierAccessor();
+ private final MethodDeclaration method;
+
+ private void init(final JavaClass parent)
+ {
+ this.parent = parent;
+ cu = (CompilationUnit) parent.getInternal();
+ ast = cu.getAST();
+ }
+
+ public Method(final JavaClass parent)
+ {
+ init(parent);
+ method = ast.newMethodDeclaration();
+ method.setConstructor(false);
+ }
+
+ public Method(final JavaClass parent, final Object internal)
+ {
+ init(parent);
+ method = (MethodDeclaration) internal;
+ }
+
+ public Method(final JavaClass parent, final String method)
+ {
+ init(parent);
+
+ String stub = "public class Stub { " + method + " }";
+ JavaClass temp = new JavaClass(stub);
+ List<Method> methods = temp.getMethods();
+ MethodDeclaration newMethod = methods.get(0).getMethodDeclaration();
+ MethodDeclaration subtree = (MethodDeclaration) ASTNode.copySubtree(cu.getAST(), newMethod);
+ this.method = subtree;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getBody()
+ {
+ String result = "";
+
+ List<Statement> statements = (List<Statement>) method.getBody().getStructuralProperty(Block.STATEMENTS_PROPERTY);
+ for (Statement statement : statements)
+ {
+ result += statement + " ";
+ }
+
+ return result;
+ }
+
+ public Method setBody(final String body)
+ {
+ String stub = "public class Stub { public void method() {" + body + "} }";
+ JavaClass temp = new JavaClass(stub);
+ List<Method> methods = temp.getMethods();
+ Block block = methods.get(0).getMethodDeclaration().getBody();
+
+ block = (Block) ASTNode.copySubtree(method.getAST(), block);
+ method.setBody(block);
+
+ return this;
+ }
+
+ public Method setConstructor(final boolean isConstructor)
+ {
+ method.setConstructor(isConstructor);
+ if (isConstructor())
+ {
+ method.setName(ast.newSimpleName(parent.getName()));
+ }
+ return this;
+ }
+
+ public boolean isConstructor()
+ {
+ return method.isConstructor();
+ }
+
+ public boolean isAbstract()
+ {
+ return ma.hasModifier(method, ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+
+ public Method setAbstract(boolean abstrct)
+ {
+ if (abstrct)
+ {
+ ma.addModifier(method, ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+ else
+ {
+ ma.removeModifier(method, ModifierKeyword.ABSTRACT_KEYWORD);
+ }
+ return this;
+ }
+
+ public Method setFinal()
+ {
+ ma.addModifier(method, ModifierKeyword.FINAL_KEYWORD);
+ return this;
+ }
+
+ public String getName()
+ {
+ return method.getName().getFullyQualifiedName();
+ }
+
+ public Method setName(final String name)
+ {
+ if (method.isConstructor())
+ {
+ throw new IllegalStateException("Cannot set the name of a constructor.");
+ }
+ method.setName(ast.newSimpleName(name));
+ return this;
+ }
+
+ public boolean isPackagePrivate()
+ {
+ return (!isPublic() && !isPrivate() && !isProtected());
+ }
+
+ public Method setPackagePrivate()
+ {
+ ma.clearVisibility(method);
+ return this;
+ }
+
+ public boolean isPublic()
+ {
+ return ma.hasModifier(method, ModifierKeyword.PUBLIC_KEYWORD);
+ }
+
+ public Method setPublic()
+ {
+ ma.clearVisibility(method);
+ ma.addModifier(method, ModifierKeyword.PUBLIC_KEYWORD);
+ return this;
+ }
+
+ public boolean isPrivate()
+ {
+ return ma.hasModifier(method, ModifierKeyword.PRIVATE_KEYWORD);
+ }
+
+ public Method setPrivate()
+ {
+ ma.clearVisibility(method);
+ ma.addModifier(method, ModifierKeyword.PRIVATE_KEYWORD);
+ return this;
+ }
+
+ public boolean isProtected()
+ {
+ return ma.hasModifier(method, ModifierKeyword.PROTECTED_KEYWORD);
+ }
+
+ public Method setProtected()
+ {
+ ma.clearVisibility(method);
+ ma.addModifier(method, ModifierKeyword.PROTECTED_KEYWORD);
+ return this;
+ }
+
+ public String getReturnType()
+ {
+ String result = null;
+ if (!isConstructor() && (method.getReturnType2() != null))
+ {
+ result = method.getReturnType2().toString();
+ }
+ return result;
+ }
+
+ public Method setReturnType(final Class<?> type)
+ {
+ return setReturnType(type.getSimpleName());
+ }
+
+ public Method setReturnType(final String type)
+ {
+ method.setReturnType2(ast.newSimpleType(ast.newSimpleName(type)));
+ return this;
+ }
+
+ public boolean isReturnTypeVoid()
+ {
+ return getReturnType() == null;
+ }
+
+ public Method setReturnTypeVoid()
+ {
+ method.setReturnType2(null);
+ return this;
+ }
+
+ private MethodDeclaration getMethodDeclaration()
+ {
+ return method;
+ }
+
+ @Override
+ public String toString()
+ {
+ return method.toString();
+ }
+
+ @Override
+ public Object getInternal()
+ {
+ return method;
+ }
+
+ @Override
+ public void applyChanges()
+ {
+ parent.applyChanges();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((method == null) ? 0 : method.hashCode());
+ result = prime * result + ((parent == null) ? 0 : parent.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ Method other = (Method) obj;
+ if (method == null)
+ {
+ if (other.method != null)
+ {
+ return false;
+ }
+ }
+ else if (!method.equals(other.method))
+ {
+ return false;
+ }
+ if (parent == null)
+ {
+ if (other.parent != null)
+ {
+ return false;
+ }
+ }
+ else if (!parent.equals(other.parent))
+ {
+ return false;
+ }
+ return true;
+ }
+}
Added: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java (rev 0)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -0,0 +1,67 @@
+package org.jboss.encore.grammar.java.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.BodyDeclaration;
+import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+
+public class ModifierAccessor
+{
+ @SuppressWarnings("unchecked")
+ public boolean hasModifier(BodyDeclaration body, final ModifierKeyword modifier)
+ {
+ boolean result = false;
+ List<Modifier> modifiers = body.modifiers();
+ for (Modifier m : modifiers)
+ {
+ if (m.getKeyword() == modifier)
+ {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Modifier> clearVisibility(BodyDeclaration body)
+ {
+ List<Modifier> modifiers = body.modifiers();
+
+ List<Modifier> toBeRemoved = new ArrayList<Modifier>();
+ for (Modifier modifier : modifiers)
+ {
+ if (modifier.isPrivate() || modifier.isProtected() || modifier.isPublic())
+ {
+ toBeRemoved.add(modifier);
+ }
+ }
+
+ modifiers.removeAll(toBeRemoved);
+ return modifiers;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addModifier(BodyDeclaration body, ModifierKeyword keyword)
+ {
+ body.modifiers().add(body.getAST().newModifier(keyword));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeModifier(BodyDeclaration body, ModifierKeyword keyword)
+ {
+ List<Modifier> modifiers = body.modifiers();
+
+ List<Modifier> toBeRemoved = new ArrayList<Modifier>();
+ for (Modifier modifier : modifiers)
+ {
+ if (modifier.getKeyword().equals(keyword))
+ {
+ toBeRemoved.add(modifier);
+ }
+ }
+
+ modifiers.removeAll(toBeRemoved);
+ }
+}
Deleted: sandbox/encore/core/src/main/java/org/jboss/encore/model/Mutable.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/model/Mutable.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/model/Mutable.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.model;
-
-/**
- * Represents an object that queues changes before making final modifications to a resource.
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public interface Mutable
-{
- /**
- * Apply all changes made to this or other objects to which this may belong. (Apply all pending changes in the object
- * graph.)
- */
- void applyChanges();
-}
Deleted: sandbox/encore/core/src/main/java/org/jboss/encore/model/Project.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/model/Project.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/model/Project.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.model;
-
-/**
- * The root node of the Project Object Graph (POG)
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public interface Project extends Mutable, Stateful
-{
-
-}
Deleted: sandbox/encore/core/src/main/java/org/jboss/encore/model/Stateful.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/model/Stateful.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/model/Stateful.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.model;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public interface Stateful
-{
-
-}
Modified: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -22,6 +22,7 @@
package org.jboss.encore.grammar.java;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -44,42 +45,153 @@
@Before
public void reset()
{
- stream = JavaClassTest.class
- .getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
+ stream = JavaClassTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
javaClass = new JavaClass(stream);
}
@Test
public void testParse() throws Exception
{
- List<Import> imports = javaClass.getImports();
- assertEquals(URL.class.getName(), imports.get(0).getName());
+ assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+ assertEquals(2, javaClass.getMethods().size());
+ assertEquals("MockClassFile", javaClass.getName());
+ assertTrue(javaClass.isPublic());
+ assertFalse(javaClass.isAbstract());
}
@Test
+ public void testSetName() throws Exception
+ {
+ assertEquals("MockClassFile", javaClass.getName());
+ javaClass.setName("Telephone");
+ assertEquals("Telephone", javaClass.getName());
+ }
+
+ @Test
+ public void testSetPackage() throws Exception
+ {
+ javaClass.setPackage("org.lincoln");
+ assertEquals("org.lincoln", javaClass.getPackage());
+ assertFalse(javaClass.isDefaultPackage());
+ }
+
+ @Test
+ public void testSetAbstract() throws Exception
+ {
+ javaClass.setAbstract(true);
+ assertTrue(javaClass.isAbstract());
+ }
+
+ @Test
+ public void testSetVisibilityPublic() throws Exception
+ {
+ javaClass.setPublic();
+ assertFalse(javaClass.isPrivate());
+ assertFalse(javaClass.isPackagePrivate());
+ assertTrue(javaClass.isPublic());
+ assertFalse(javaClass.isProtected());
+ }
+
+ @Test
+ public void testSetVisibilityPackagePrivate() throws Exception
+ {
+ javaClass.setPackagePrivate();
+ assertTrue(javaClass.isPackagePrivate());
+ assertFalse(javaClass.isPublic());
+ assertFalse(javaClass.isPrivate());
+ assertFalse(javaClass.isProtected());
+ }
+
+ @Test
+ public void testSetVisibilityPrivate() throws Exception
+ {
+ javaClass.setPrivate();
+ assertTrue(javaClass.isPrivate());
+ assertFalse(javaClass.isPackagePrivate());
+ assertFalse(javaClass.isPublic());
+ assertFalse(javaClass.isProtected());
+ }
+
+ @Test
+ public void testSetVisibilityProtected() throws Exception
+ {
+ javaClass.setProtected();
+ assertFalse(javaClass.isPrivate());
+ assertFalse(javaClass.isPackagePrivate());
+ assertFalse(javaClass.isPublic());
+ assertTrue(javaClass.isProtected());
+ }
+
+ @Test
+ public void testSetPackageDefault() throws Exception
+ {
+ javaClass.setDefaultPackage();
+ assertNull(javaClass.getPackage());
+ assertTrue(javaClass.isDefaultPackage());
+ }
+
+ @Test
public void testAddImport() throws Exception
{
javaClass.addImport(List.class.getName());
- List<Import> imports = javaClass.getImports();
- assertEquals(2, imports.size());
- assertEquals(URL.class.getName(), imports.get(0).getName());
- assertEquals(List.class.getName(), imports.get(1).getName());
+ assertEquals(2, javaClass.getImports().size());
+ assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+ assertEquals(List.class.getName(), javaClass.getImports().get(1).getName());
}
@Test
public void testAddImportsClasses() throws Exception
{
+ assertEquals(1, javaClass.getImports().size());
+
+ javaClass.addImports(List.class, Map.class);
+
+ assertEquals(3, javaClass.getImports().size());
+ assertEquals(Map.class.getName(), javaClass.getImports().get(2).getName());
+ }
+
+ @Test
+ public void testAddImportStatic() throws Exception
+ {
+ assertEquals(1, javaClass.getImports().size());
+ javaClass.addImport(List.class).setStatic(true).applyChanges();
+ assertEquals(2, javaClass.getImports().size());
+ assertTrue(javaClass.getImports().get(1).isStatic());
+ }
+
+ @Test
+ public void testRemoveImportByClass() throws Exception
+ {
List<Import> imports = javaClass.getImports();
assertEquals(1, imports.size());
+ assertEquals(URL.class.getName(), imports.get(0).getName());
- javaClass.addImports(List.class, Map.class);
-
+ javaClass.removeImport(URL.class);
imports = javaClass.getImports();
- assertEquals(3, imports.size());
- assertEquals(Map.class.getName(), imports.get(2).getName());
+ assertEquals(0, imports.size());
}
@Test
+ public void testRemoveImportByName() throws Exception
+ {
+ assertEquals(1, javaClass.getImports().size());
+ assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+
+ javaClass.removeImport(URL.class.getName());
+ assertEquals(0, javaClass.getImports().size());
+ }
+
+ @Test
+ public void testRemoveImportByReference() throws Exception
+ {
+ assertEquals(1, javaClass.getImports().size());
+ assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+
+ javaClass.removeImport(javaClass.getImports().get(0));
+ assertEquals(0, javaClass.getImports().size());
+ }
+
+ @Test
public void testAddMethod() throws Exception
{
javaClass.addMethod().setName("testMethod").setReturnTypeVoid().setBody("").applyChanges();
@@ -91,22 +203,19 @@
@Test
public void testAddMethodFromString() throws Exception
{
- javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }")
- .setPackagePrivate().applyChanges();
+ javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }").setPackagePrivate().applyChanges();
List<Method> methods = javaClass.getMethods();
assertEquals(3, methods.size());
assertEquals("URL", methods.get(2).getReturnType());
assertEquals("rewriteURL", methods.get(2).getName());
String body = methods.get(2).getBody();
- assertEquals("return null;".replaceAll("\\s+", ""),
- body.replaceAll("\\s+", ""));
+ assertEquals("return null;".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
}
@Test
public void testRemoveMethod() throws Exception
{
- // TODO Removing methods needs to work
List<Method> methods = javaClass.getMethods();
javaClass.removeMethod(methods.get(0)).applyChanges();
methods = javaClass.getMethods();
@@ -116,31 +225,29 @@
@Test
public void testAddConstructor() throws Exception
{
- javaClass.addMethod().setName("testMethod").setConstructor(true).setProtected().setReturnType(String.class)
- .setBody("System.out.println(\"I am a constructor!\");").applyChanges();
- List<Method> methods = javaClass.getMethods();
- assertEquals(3, methods.size());
- assertTrue(methods.get(2).isProtected());
- assertTrue(methods.get(2).isConstructor());
- assertNull(methods.get(2).getReturnType());
- String body = methods.get(2).getBody();
- assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""),
- body.replaceAll("\\s+", ""));
+ javaClass.addMethod().setName("testMethod").setConstructor(true).setProtected().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
+ Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+ assertEquals(3, javaClass.getMethods().size());
+ assertEquals(javaClass.getName(), method.getName());
+ assertTrue(method.isProtected());
+ assertTrue(method.isConstructor());
+ assertNull(method.getReturnType());
+ String body = method.getBody();
+ assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
}
@Test
public void testAddConstructorIngoresReturnTypeAndName() throws Exception
{
- javaClass.addMethod().setName("testMethod").setConstructor(true).setPrivate().setReturnType(String.class)
- .setBody("System.out.println(\"I am a constructor!\");").applyChanges();
- List<Method> methods = javaClass.getMethods();
- assertTrue(methods.get(2).isPrivate());
- assertTrue(methods.get(2).isConstructor());
- assertNull(methods.get(2).getReturnType());
- assertEquals("MockClassFile", methods.get(2).getName());
- String body = methods.get(2).getBody();
- assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""),
- body.replaceAll("\\s+", ""));
+ javaClass.addMethod().setName("testMethod").setConstructor(true).setPrivate().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
+ Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+ assertEquals(3, javaClass.getMethods().size());
+ assertTrue(method.isPrivate());
+ assertTrue(method.isConstructor());
+ assertNull(method.getReturnType());
+ assertEquals(javaClass.getName(), method.getName());
+ String body = method.getBody();
+ assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
}
}
Added: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.grammar.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+public class MethodTest
+{
+ private InputStream stream;
+ private JavaClass javaClass;
+ private Method method;
+
+ @Before
+ public void reset()
+ {
+ stream = MethodTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
+ javaClass = new JavaClass(stream);
+ javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }");
+ method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+ }
+
+ @Test
+ public void testSetName() throws Exception
+ {
+ assertEquals("rewriteURL", method.getName());
+ method.setName("doSomething");
+ assertEquals("doSomething", method.getName());
+ }
+
+ @Test
+ public void testSetReturnType() throws Exception
+ {
+ assertEquals("URL", method.getReturnType());
+ method.setReturnType(Class.class);
+ assertEquals("Class", method.getReturnType());
+ assertFalse(method.isReturnTypeVoid());
+ }
+
+ @Test
+ public void testSetReturnTypeVoid() throws Exception
+ {
+ assertEquals("URL", method.getReturnType());
+ method.setReturnTypeVoid();
+ assertEquals(null, method.getReturnType());
+ assertTrue(method.isReturnTypeVoid());
+ }
+
+ @Test
+ public void testSetConstructor() throws Exception
+ {
+ assertFalse(method.isConstructor());
+ method.setConstructor(true);
+ assertTrue(method.isConstructor());
+ assertEquals(javaClass.getName(), method.getName());
+ }
+
+ @Test
+ public void testSetAbstract() throws Exception
+ {
+ method.setAbstract(true);
+ assertTrue(method.isAbstract());
+ }
+
+ @Test
+ public void testSetPublic() throws Exception
+ {
+ method.setPublic();
+ assertTrue(method.isPublic());
+ assertFalse(method.isPackagePrivate());
+ assertFalse(method.isPrivate());
+ assertFalse(method.isProtected());
+ }
+
+ @Test
+ public void testSetPrivate() throws Exception
+ {
+ method.setPrivate();
+ assertFalse(method.isPublic());
+ assertFalse(method.isPackagePrivate());
+ assertTrue(method.isPrivate());
+ assertFalse(method.isProtected());
+ }
+
+ @Test
+ public void testSetProtected() throws Exception
+ {
+ method.setProtected();
+ assertFalse(method.isPublic());
+ assertFalse(method.isPackagePrivate());
+ assertFalse(method.isPrivate());
+ assertTrue(method.isProtected());
+ }
+
+ @Test
+ public void testSetPackagePrivate() throws Exception
+ {
+ method.setPackagePrivate();
+ assertFalse(method.isPublic());
+ assertTrue(method.isPackagePrivate());
+ assertFalse(method.isPrivate());
+ assertFalse(method.isProtected());
+ }
+}
Modified: sandbox/encore/model/pom.xml
===================================================================
--- sandbox/encore/model/pom.xml 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/model/pom.xml 2010-07-27 20:04:10 UTC (rev 13520)
@@ -19,6 +19,11 @@
<dependencies>
<!-- Resource manipulation dependencies -->
<dependency>
+ <groupId>org.jboss.encore</groupId>
+ <artifactId>encore-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>1.0.0-alpha-9</version>
Modified: sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -22,15 +22,14 @@
package org.jboss.encore.model;
import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import javax.enterprise.event.Event;
import javax.inject.Inject;
+import org.jboss.encore.grammar.java.JavaClass;
import org.jboss.encore.model.events.JavaFileCreated;
/**
@@ -42,21 +41,23 @@
@Inject
Event<JavaFileCreated> event;
- public boolean createJavaFile(final String path, final byte[] data)
+ public File createJavaFile(final String path, final char[] data)
{
- return createJavaFile(path, new ByteArrayInputStream(data));
+ return createJavaFile(path, new JavaClass(data));
}
- public boolean createJavaFile(final String path, final InputStream data)
+ public File createJavaFile(final String path, JavaClass clazz)
{
BufferedWriter writer = null;
try
{
File file = new File(path);
writer = new BufferedWriter(new FileWriter(file));
+ writer.write(clazz.toString());
+ writer.close();
+
event.fire(new JavaFileCreated(file));
- writer.close();
- return true;
+ return file;
}
catch (IOException e)
{
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java 2010-07-27 19:11:53 UTC (rev 13519)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java 2010-07-27 20:04:10 UTC (rev 13520)
@@ -49,7 +49,7 @@
@Command(help = "Get help about specific commands")
public void help(@Option("test") final String test, @Option final String... commands)
{
- if (commands == null)
+ if ((commands == null) || (commands.length == 0))
{
shell.write("Welcome to Encore!");
}
14 years, 5 months
Seam SVN: r13519 - modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-27 15:11:53 -0400 (Tue, 27 Jul 2010)
New Revision: 13519
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
Log:
Preventing potential NPE
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java 2010-07-27 17:08:55 UTC (rev 13518)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java 2010-07-27 19:11:53 UTC (rev 13519)
@@ -143,7 +143,7 @@
{
if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
{
- getSessionMap().remove(getSessionKey(currentContext.getId()));
+ getSessionMap().remove(getSessionKey(getFlashContext().getId()));
Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalContextMap();
14 years, 5 months
Seam SVN: r13518 - modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-27 13:08:55 -0400 (Tue, 27 Jul 2010)
New Revision: 13518
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
Log:
Applied patch for SEAMFACES-42 (NullPointer wrapping External Context)
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java 2010-07-27 15:26:49 UTC (rev 13517)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java 2010-07-27 17:08:55 UTC (rev 13518)
@@ -68,6 +68,10 @@
@RequestScoped
public FlashContext getFlashContext()
{
+ if (currentContext == null)
+ {
+ initializeCurrentContext();
+ }
return currentContext;
}
@@ -85,27 +89,21 @@
}
}
- /*
- * PhaseListener Methods
- */
- public void beforePhase(final PhaseEvent event)
+ private void initializeCurrentContext()
{
- if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
+ String currentId = getCurrentId();
+ if (savedContextExists(currentId))
{
- String currentId = getCurrentId();
- if (savedContextExists(currentId))
- {
- FlashContext context = (FlashContext) getSessionMap().get(getSessionKey(currentId));
- currentContext = context;
- }
- else
- {
- FlashContextImpl context = new FlashContextImpl();
- context.setId(getNextFlashId());
- getSessionMap().put(getSessionKey(context.getId()), context);
- currentContext = context;
- }
+ FlashContext context = (FlashContext) getSessionMap().get(getSessionKey(currentId));
+ currentContext = context;
}
+ else
+ {
+ FlashContextImpl context = new FlashContextImpl();
+ context.setId(getNextFlashId());
+ getSessionMap().put(getSessionKey(context.getId()), context);
+ currentContext = context;
+ }
}
private String getNextFlashId()
@@ -164,6 +162,11 @@
}
}
+ public void beforePhase(PhaseEvent arg0)
+ {
+ /* intentionally empty */
+ }
+
public PhaseId getPhaseId()
{
return PhaseId.ANY_PHASE;
14 years, 5 months