Seam SVN: r13367 - in modules/security/trunk/examples/idmconsole: src/main/webapp/WEB-INF and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-13 07:27:20 -0400 (Tue, 13 Jul 2010)
New Revision: 13367
Added:
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
Modified:
modules/security/trunk/examples/idmconsole/pom.xml
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
Log:
security rule configuration
Modified: modules/security/trunk/examples/idmconsole/pom.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/pom.xml 2010-07-13 11:26:49 UTC (rev 13366)
+++ modules/security/trunk/examples/idmconsole/pom.xml 2010-07-13 11:27:20 UTC (rev 13367)
@@ -79,6 +79,13 @@
<dependency>
<groupId>org.jboss.seam.xml</groupId>
<artifactId>seam-xml-config</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- CDI (JSR-299) -->
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-13 11:26:49 UTC (rev 13366)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-07-13 11:27:20 UTC (rev 13367)
@@ -1,19 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- The contents of this file is permitted to be empty.
- The schema definition is provided for your convenience.
--->
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:s="urn:java:seam:core"
- xmlns:perm="org.jboss.seam.security.permission"
+ xmlns:s="urn:java:ee"
+ xmlns:drools="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:security="urn:java:org.jboss.seam.security.permission"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
- <perm:JpaPermissionStore>
- <s:specializes/>
-
- <perm:identityPermissionClass>org.jboss.seam.security.examples.idmconsole.model.IdentityPermission</perm:identityPermissionClass>
- </perm:JpaPermissionStore>
+ <security:JpaPermissionStore>
+ <s:overrides/>
+ <security:identityPermissionClass>org.jboss.seam.security.examples.idmconsole.model.IdentityPermission</security:identityPermissionClass>
+ </security:JpaPermissionStore>
+
+ <drools:RuleResources>
+ <s:modifies/>
+ <security:SecurityRulesConfig/>
+ <drools:resources>
+ <s:value>security-rules.drl</s:value>
+ </drools:resources>
+ </drools:RuleResources>
+
+ <drools:DroolsConfig>
+ <s:modifies/>
+ <security:SecurityRulesConfig/>
+ <drools:ruleResources>
+ <s:Inject/>
+ <security:SecurityRulesConfig/>
+ </drools:ruleResources>
+ </drools:DroolsConfig>
+
+ <security:RuleBasedPermissionResolver>
+ <s:overrides/>
+ <security:securityRules>
+ <security:SecurityRulesConfig/>
+ <s:Inject/>
+ <s:Default/>
+ </security:securityRules>
+ </security:RuleBasedPermissionResolver>
+
</beans>
Added: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl (rev 0)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/security-rules.drl 2010-07-13 11:27:20 UTC (rev 13367)
@@ -0,0 +1,247 @@
+package SeamSpacePermissions;
+
+dialect 'mvel'
+
+import java.security.Principal;
+
+import org.jboss.seam.security.permission.PermissionCheck;
+import org.jboss.seam.security.permission.RoleCheck;
+import org.jboss.seam.security.Role;
+
+import org.jboss.seam.security.examples.seamspace.model.BlogComment;
+import org.jboss.seam.security.examples.seamspace.model.Member;
+import org.jboss.seam.security.examples.seamspace.model.MemberAccount;
+import org.jboss.seam.security.examples.seamspace.model.MemberBlog;
+import org.jboss.seam.security.examples.seamspace.model.MemberFriend;
+import org.jboss.seam.security.examples.seamspace.model.MemberImage;
+
+# These rules allow members to manage permissions on their own images
+
+rule ManageImagePermissions
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "seam.read-permissions", granted == false)
+then
+ check.grant();
+end
+
+rule GrantImagePermissions
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "seam.grant-permission", granted == false)
+then
+ check.grant();
+end
+
+# Allow all users to read the available roles
+
+rule ReadRoles
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "seam.role", action == "read", granted == false)
+ Role(name == "user")
+then
+ check.grant();
+end
+
+# This rule allows a member to delete their own images
+
+rule DeleteImage
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "delete", granted == false)
+then
+ check.grant();
+end
+
+# This rule allows members to revoke permissions on their images to other users/roles
+
+rule RevokeImagePermissions
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "seam.revoke-permission", granted == false)
+then
+ check.grant();
+end
+
+rule ViewProfileImage
+ no-loop
+ activation-group "permissions"
+when
+ image: MemberImage()
+ check: PermissionCheck(target == image, action == "view", granted == false)
+ eval( image.getMember().getPicture() == image )
+then
+ check.grant();
+end
+
+rule FriendViewImage
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.isFriend(acct.member)))
+ PermissionCheck(target == image, action == "view")
+ role: RoleCheck(name == "friends")
+then
+ role.grant();
+end
+
+rule GuestViewImage
+ no-loop
+ activation-group "permissions"
+when
+ image: MemberImage()
+ PermissionCheck(target == image, action == "view")
+ role: RoleCheck(name == "guest")
+then
+ role.grant();
+end
+
+rule ViewMyImages
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ image: MemberImage(mbr : member -> (mbr.memberId.equals(acct.member.memberId)))
+ check: PermissionCheck(target == image, action == "view")
+then
+ check.grant();
+end
+
+rule RestrictCommentPage
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "/comment.xhtml", granted == false)
+ Role(name == "user")
+then
+ check.grant();
+end
+
+rule CanCreateBlogComment
+ no-loop
+ activation-group "permissions"
+when
+ blog: MemberBlog()
+ check: PermissionCheck(target == blog, action == "create", granted == false)
+ Role(name == "user")
+then
+ check.grant();
+end
+
+rule CreateBlogComment
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "blogComment", action == "insert", granted == false)
+ Role(name == "user")
+then
+ check.grant();
+end
+
+# This rule grants permission for users to create their own blog entries
+rule CreateBlog
+ no-loop
+ activation-group "permissions"
+when
+ mbr: Member()
+ acct: MemberAccount(member.memberId == mbr.memberId)
+ check: PermissionCheck(target.memberId == mbr.memberId, action == "createBlog", granted == false)
+then
+ check.grant();
+end
+
+# This rule grants permission for users to upload pictures to their profile
+rule UploadImage
+ no-loop
+ activation-group "permissions"
+when
+ mbr: Member()
+ acct: MemberAccount(member.memberId == mbr.memberId)
+ check: PermissionCheck(target.memberId == mbr.memberId, action == "uploadImage", granted == false)
+then
+ check.grant();
+end
+
+rule InsertMemberBlog
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ blog: MemberBlog(member == acct.member)
+ check: PermissionCheck(target == blog, action == "insert", granted == false)
+then
+ check.grant();
+end
+
+rule CreateFriendComment
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ member: Member() //friends contains acct.member)
+ check: PermissionCheck(target == member, action == "createFriendComment", granted == false)
+then
+ check.grant();
+end
+
+rule CreateFriendRequest
+ no-loop
+ activation-group "permissions"
+when
+ acct: MemberAccount()
+ member: Member() //friends not contains acct.member)
+ check: PermissionCheck(target == member, action == "createFriendRequest", granted == false)
+then
+ check.grant();
+end
+
+rule CreateAccount
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "seam.account", action == "create", granted == false)
+ Role(name == "admin")
+then
+ check.grant();
+end
+
+/*****************************************************************************************
+
+ The Following Rules are for Identity Management
+
+******************************************************************************************/
+
+rule ManageUsers
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "seam.user", granted == false)
+ Role(name == "admin")
+then
+ check.grant();
+end
+
+rule ManageRoles
+ no-loop
+ activation-group "permissions"
+when
+ check: PermissionCheck(target == "seam.role", granted == false)
+ Role(name == "admin")
+then
+ check.grant();
+end
14 years, 5 months
Seam SVN: r13366 - in modules/security/trunk/impl: src/main/java/org/jboss/seam/security/permission and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-13 07:26:49 -0400 (Tue, 13 Jul 2010)
New Revision: 13366
Modified:
modules/security/trunk/impl/pom.xml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionResolver.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
configuration for rule based permissions
Modified: modules/security/trunk/impl/pom.xml
===================================================================
--- modules/security/trunk/impl/pom.xml 2010-07-13 11:24:17 UTC (rev 13365)
+++ modules/security/trunk/impl/pom.xml 2010-07-13 11:26:49 UTC (rev 13366)
@@ -71,10 +71,60 @@
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-workitems</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-transformer-xstream</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
+ <groupId>org.jboss.seam.drools</groupId>
+ <artifactId>seam-drools-impl</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+
+ <exclusions>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-workitems</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.seam.security</groupId>
<artifactId>seam-security-api</artifactId>
<version>${project.version}</version>
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java 2010-07-13 11:24:17 UTC (rev 13365)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionCheck.java 2010-07-13 11:26:49 UTC (rev 13366)
@@ -12,27 +12,27 @@
*/
public class PermissionCheck
{
- private Object target;
+ private Object resource;
- private String action;
+ private String permission;
private boolean granted;
private Set<String> requirements;
- public PermissionCheck(Object target, String action)
+ public PermissionCheck(Object resource, String permission)
{
- this.target = target;
- this.action = action;
+ this.resource = resource;
+ this.permission = permission;
granted = false;
}
- public Object getTarget()
+ public Object getResource()
{
- return target;
+ return resource;
}
- public String getAction()
+ public String getPermission()
{
- return action;
+ return permission;
}
public void require(String requirement)
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionResolver.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionResolver.java 2010-07-13 11:24:17 UTC (rev 13365)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/PermissionResolver.java 2010-07-13 11:26:49 UTC (rev 13366)
@@ -9,6 +9,6 @@
*/
public interface PermissionResolver
{
- boolean hasPermission(Object target, String action);
- void filterSetByAction(Set<Object> targets, String action);
+ boolean hasPermission(Object resource, String permission);
+ void filterSetByAction(Set<Object> resources, String permission);
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2010-07-13 11:24:17 UTC (rev 13365)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2010-07-13 11:26:49 UTC (rev 13366)
@@ -48,12 +48,6 @@
@Inject Identity identity;
@Inject
- public boolean create()
- {
- initSecurityContext();
- return getSecurityContext() != null;
- }
-
protected void initSecurityContext()
{
if (getSecurityRules() != null)
@@ -70,7 +64,7 @@
* @param action String The action to be performed on the target
* @return boolean True if the user has the specified permission
*/
- public boolean hasPermission(Object target, String action)
+ public boolean hasPermission(Object resource, String permission)
{
StatefulKnowledgeSession securityContext = getSecurityContext();
@@ -82,18 +76,18 @@
synchronized( securityContext )
{
- if (!(target instanceof String) && !(target instanceof Class))
+ if (!(resource instanceof String) && !(resource instanceof Class<?>))
{
- handles.add( securityContext.insert(target) );
+ handles.add( securityContext.insert(resource) );
}
- else if (target instanceof Class)
+ else if (resource instanceof Class<?>)
{
// TODO fix
String componentName = null; // manager. Seam.getComponentName((Class) target);
- target = componentName != null ? componentName : ((Class) target).getName();
+ resource = componentName != null ? componentName : ((Class) resource).getName();
}
- check = new PermissionCheck(target, action);
+ check = new PermissionCheck(resource, permission);
try
{
@@ -267,7 +261,6 @@
this.securityContext = securityContext;
}
-
public KnowledgeBase getSecurityRules()
{
return securityRules;
14 years, 5 months
Seam SVN: r13365 - modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-13 07:24:17 -0400 (Tue, 13 Jul 2010)
New Revision: 13365
Added:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/SecurityRulesConfig.java
Log:
added security rule config qualifier
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/SecurityRulesConfig.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/SecurityRulesConfig.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/permission/SecurityRulesConfig.java 2010-07-13 11:24:17 UTC (rev 13365)
@@ -0,0 +1,27 @@
+package org.jboss.seam.security.permission;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * This qualifier is used solely for the configuration of a DroolsConfig using
+ * the Seam XML config module
+ *
+ * @author Shane Bryzak
+ */
+@Qualifier
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+public @interface SecurityRulesConfig {
+
+}
14 years, 5 months
Seam SVN: r13364 - in modules/drools/trunk: api/src/main/java/org/jboss/seam/drools/qualifiers/config and 3 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-13 07:14:54 -0400 (Tue, 13 Jul 2010)
New Revision: 13364
Added:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealtimeClockConfig.java
Removed:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java
Modified:
modules/drools/trunk/api/pom.xml
modules/drools/trunk/impl/pom.xml
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java
modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
Log:
update to latest xml config, fix naming typo
Modified: modules/drools/trunk/api/pom.xml
===================================================================
--- modules/drools/trunk/api/pom.xml 2010-07-13 10:35:08 UTC (rev 13363)
+++ modules/drools/trunk/api/pom.xml 2010-07-13 11:14:54 UTC (rev 13364)
@@ -31,6 +31,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>org.drools</groupId>
Deleted: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java 2010-07-13 10:35:08 UTC (rev 13363)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java 2010-07-13 11:14:54 UTC (rev 13364)
@@ -1,48 +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.seam.drools.qualifiers.config;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
-@Qualifier
-@Target( { TYPE, METHOD, FIELD, PARAMETER })
-@Documented
-@Retention(RUNTIME)
-@Inherited
-public @interface CEPRealitimeClockConfig {
-
-}
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealtimeClockConfig.java (from rev 13361, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealtimeClockConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealtimeClockConfig.java 2010-07-13 11:14:54 UTC (rev 13364)
@@ -0,0 +1,48 @@
+/*
+ * 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.drools.qualifiers.config;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface CEPRealtimeClockConfig {
+
+}
Modified: modules/drools/trunk/impl/pom.xml
===================================================================
--- modules/drools/trunk/impl/pom.xml 2010-07-13 10:35:08 UTC (rev 13363)
+++ modules/drools/trunk/impl/pom.xml 2010-07-13 11:14:54 UTC (rev 13364)
@@ -35,6 +35,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>org.drools</groupId>
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java 2010-07-13 10:35:08 UTC (rev 13363)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java 2010-07-13 11:14:54 UTC (rev 13364)
@@ -21,13 +21,13 @@
*/
package org.jboss.seam.drools.config;
-import org.jboss.seam.drools.qualifiers.config.CEPRealitimeClockConfig;
+import org.jboss.seam.drools.qualifiers.config.CEPRealtimeClockConfig;
/**
*
* @author Tihomir Surdilovic
*/
-@CEPRealitimeClockConfig
+@CEPRealtimeClockConfig
public class CEPRealtimeClockRuleResources extends RuleResources
{
Modified: modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-07-13 10:35:08 UTC (rev 13363)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-07-13 11:14:54 UTC (rev 13364)
@@ -16,13 +16,13 @@
Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:s="urn:java:seam:core"
+ xmlns:s="urn:java:ee"
xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config:org.jboss.seam.drools.qualifiers.config"
xmlns:drools="urn:java:org.drools:org.drools.runtime">
<s:genericBean class="org.jboss.seam.drools.config.DroolsConfig">
<d:KnowledgeBaseProducer>
- <s:specializes />
+ <s:modifies />
<d:produceKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
@@ -35,7 +35,7 @@
</d:KnowledgeBaseProducer>
<d:KnowledgeSessionProducer>
- <s:specializes />
+ <s:modifies />
<d:produceStatefulSession>
<s:ApplyQualifiers />
<s:parameters>
@@ -107,7 +107,7 @@
</d:KnowledgeSessionProducer>
<d:KnowledgeAgentProducer>
- <s:specializes />
+ <s:modifies />
<d:produceScannedKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
@@ -137,7 +137,7 @@
</d:KnowledgeAgentProducer>
<d:EntryPointProducer>
- <s:specializes />
+ <s:modifies />
<d:produceEntryPoint>
<s:ApplyQualifiers />
<s:parameters>
@@ -159,7 +159,7 @@
</d:EntryPointProducer>
<d:KnowledgeLoggerProducer>
- <s:specializes />
+ <s:modifies />
<d:produceStatefulKnowledgeLogger>
<s:ApplyQualifiers />
<s:parameters>
@@ -215,7 +215,7 @@
</d:KnowledgeLoggerProducer>
<d:ExecutionResultsProducer>
- <s:specializes />
+ <s:modifies />
<d:produceStatelessExecutionResults>
<s:ApplyQualifiers />
<s:parameters>
@@ -255,7 +255,7 @@
</d:ExecutionResultsProducer>
<d:QueryResultsProducer>
- <s:specializes />
+ <s:modifies />
<d:produceQueryResults>
<s:ApplyQualifiers />
<s:parameters>
@@ -278,20 +278,18 @@
</s:genericBean>
<d:DroolsConfig>
- <s:specializes />
+ <s:modifies />
<d:DefaultConfig />
<s:parameters>
<d:RuleResources>
<d:DefaultConfig />
- <s:type>
- <d:DefaultRuleResources />
- </s:type>
+ <s:Exact>org.jboss.seam.drools.config.DefaultRuleResources</s:Exact>
</d:RuleResources>
</s:parameters>
</d:DroolsConfig>
<d:DroolsConfig>
- <s:specializes />
+ <s:modifies />
<d:MVELDialectConfig />
<d:kbuilderPropertiesMap>
<s:entry>
@@ -302,16 +300,14 @@
<s:parameters>
<d:RuleResources>
<d:MVELDialectConfig />
- <s:type>
- <d:MVELDialectRuleResources />
- </s:type>
+ <s:Exact>org.jboss.seam.drools.config.MVELDialectRuleResources</s:Exact>
</d:RuleResources>
</s:parameters>
</d:DroolsConfig>
<d:DroolsConfig>
- <s:specializes />
- <d:CEPRealitimeClockConfig />
+ <s:modifies />
+ <d:CEPRealtimeClockConfig />
<d:kbasePropertiesMap>
<s:entry>
<s:key>drools.eventProcessingMode</s:key>
@@ -326,16 +322,14 @@
</d:ksessionPropertiesMap>
<s:parameters>
<d:RuleResources>
- <d:CEPRealitimeClockConfig />
- <s:type>
- <d:CEPRealtimeClockRuleResources />
- </s:type>
+ <d:CEPRealtimeClockConfig />
+ <s:Exact>org.jboss.seam.drools.config.CEPRealtimeClockRuleResources</s:Exact>
</d:RuleResources>
</s:parameters>
</d:DroolsConfig>
<d:DroolsConfig>
- <s:specializes />
+ <s:modifies />
<d:CEPPseudoClockConfig />
<d:kbasePropertiesMap>
<s:entry>
@@ -352,15 +346,13 @@
<s:parameters>
<d:RuleResources>
<d:CEPPseudoClockConfig />
- <s:type>
- <d:CEPPseudoClockRuleResources />
- </s:type>
+ <s:Exact>org.jboss.seam.drools.config.CEPPseudoClockRuleResources</s:Exact>
</d:RuleResources>
</s:parameters>
</d:DroolsConfig>
<d:DroolsConfig>
- <s:specializes />
+ <s:modifies />
<d:AgentConfig />
<d:kagentPropertiestMap>
<s:entry>
@@ -389,9 +381,7 @@
<s:parameters>
<d:RuleResources>
<d:AgentConfig />
- <s:type>
- <d:AgentRuleResources />
- </s:type>
+ <s:Exact>org.jboss.seam.drools.config.AgentRuleResources</s:Exact>
</d:RuleResources>
</s:parameters>
</d:DroolsConfig>
14 years, 5 months
Seam SVN: r13362 - modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-12 23:59:05 -0400 (Mon, 12 Jul 2010)
New Revision: 13362
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
Log:
typo
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-12 22:29:39 UTC (rev 13361)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-13 03:59:05 UTC (rev 13362)
@@ -191,7 +191,7 @@
{
});
AnnotatedType<?> tp = bb.getBuilder().create();
- log.info("Adding XML definied bean: " + tp.getJavaClass().getName());
+ log.info("Adding XML Defined Bean: " + tp.getJavaClass().getName());
event.addAnnotatedType(tp);
}
14 years, 5 months
Seam SVN: r13361 - in sandbox/encore/shell/src/main/java/org/jboss/encore/shell: cli and 3 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-12 18:29:39 -0400 (Mon, 12 Jul 2010)
New Revision: 13361
Added:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Execution.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CommandParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CompositeCommandParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedBooleanOptionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueOptionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueVarargsOptionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueOptionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueVarargsOptionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/ParseErrorParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/BuiltIn.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Command.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java
Removed:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/BuiltIn.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Command.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Option.java
Modified:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandMetadata.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/OptionMetadata.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Plugin.java
Log:
More consistent parsing algorithm & plugin execution
Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -1,101 +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.shell;
-
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-
-import org.jboss.encore.shell.cli.CommandMetadata;
-import org.jboss.encore.shell.plugins.Plugin;
-
-/**
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-public class Execution
-{
- @Inject
- private BeanManager manager;
-
- private CommandMetadata command;
- private Object[] parameterArray;
-
- @SuppressWarnings("unchecked")
- public void perform()
- {
- if (command != null)
- {
- try
- {
- Class<? extends Plugin> pluginType = command.getParent().getType();
- Set<Bean<?>> beans = manager.getBeans(pluginType);
- Bean<? extends Object> bean = manager.resolve(beans);
-
- Plugin plugin = null;
- if (bean != null)
- {
- CreationalContext<? extends Plugin> context = (CreationalContext<? extends Plugin>) manager
- .createCreationalContext(bean);
- if (context != null)
- {
- plugin = (Plugin) manager.getReference(bean, pluginType, context);
- command.getMethod().invoke(plugin, parameterArray);
- }
- }
-
- }
- catch (Exception e)
- {
- System.err.println("I don't understand what you meant.");
- }
- }
- else
- {
- System.err.println("I don't understand what you meant.");
- }
- }
-
- public CommandMetadata getCommand()
- {
- return command;
- }
-
- public void setCommand(final CommandMetadata command)
- {
- this.command = command;
- }
-
- public Object[] getParameterArray()
- {
- return parameterArray;
- }
-
- public void setParameterArray(final Object... parameters)
- {
- this.parameterArray = parameters;
- }
-
-}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -31,6 +31,7 @@
import jline.console.ConsoleReader;
import jline.console.completer.Completer;
+import org.jboss.encore.shell.cli.Execution;
import org.jboss.encore.shell.cli.ExecutionParser;
import org.jboss.encore.shell.events.AcceptUserInput;
import org.jboss.encore.shell.events.Shutdown;
@@ -62,7 +63,7 @@
private ConsoleReader reader;
private boolean exitRequested = false;
- public void init(@Observes final Startup event) throws Exception
+ void init(@Observes final Startup event) throws Exception
{
System.out.println("Startup");
log.info("Encore Shell - Starting up.");
@@ -71,9 +72,14 @@
reader.setHistoryEnabled(true);
reader.setPrompt(prompt);
reader.addCompleter(completer);
+
+ if (parameters.contains("--verbose"))
+ {
+ // TODO set verbose mode
+ }
}
- public void doShell(@Observes final AcceptUserInput event)
+ void doShell(@Observes final AcceptUserInput event)
{
String line;
try
@@ -90,18 +96,61 @@
}
catch (IOException e)
{
- throw new IllegalStateException("Shell line reading failure", e);
+ throw new IllegalStateException("Shell input stream failure", e);
}
}
private void execute(final String line)
{
- Execution execution = parser.parse(line);
- execution.perform();
+ Execution execution = null;
+ try
+ {
+ execution = parser.parse(line);
+ try
+ {
+ execution.perform();
+ }
+ catch (Exception e)
+ {
+ System.err.println("Error executing command: " + execution.getOriginalStatement() + " : " + e.getMessage());
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println("Error parsing input: " + e.getMessage());
+ }
}
- public void teardown(@Observes final Shutdown event)
+ void teardown(@Observes final Shutdown event)
{
exitRequested = true;
}
+
+ /**
+ * Prompt the user for input, using {@link message} as the prompt text.
+ */
+ public String prompt(final String message)
+ {
+ System.out.print(message);
+ try
+ {
+ String currentPrompt = reader.getPrompt();
+ reader.setPrompt(" ");
+ String line = reader.readLine();
+ reader.setPrompt(currentPrompt);
+ return line;
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException("Shell input stream failure", e);
+ }
+ }
+
+ /**
+ * Write the given {@link line} to the console output.
+ */
+ public void write(final String line)
+ {
+ System.out.println(line);
+ }
}
\ No newline at end of file
Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/BuiltIn.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/BuiltIn.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/BuiltIn.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -1,48 +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.shell.cli;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import org.jboss.encore.shell.plugins.Plugin;
-
-/**
- * Defines a #{@link Plugin} as built in, thus, commands will be accessible without providing a plugin name;
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-@Target({ TYPE, METHOD, PARAMETER, FIELD })
-@Retention(RUNTIME)
-@Documented
-public @interface BuiltIn
-{
-
-}
Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Command.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Command.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Command.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -1,57 +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.shell.cli;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Represents a single command to be run on a Shell.
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-@Qualifier
-@Target({ METHOD, PARAMETER, TYPE, FIELD })
-@Retention(RUNTIME)
-@Documented
-public @interface Command
-{
- /**
- * One or more names for this command.
- */
- String[] value() default {};
-
- /**
- * Help text for this command.
- */
- String help() default "";
-}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -34,6 +34,9 @@
import javax.enterprise.inject.spi.ProcessBean;
import javax.inject.Named;
+import org.jboss.encore.shell.plugins.BuiltIn;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Option;
import org.jboss.encore.shell.plugins.Plugin;
import org.jboss.encore.shell.util.Annotations;
@@ -115,7 +118,7 @@
option.setParent(commandMeta);
option.setName(opt.value());
option.setHelp(opt.help());
- option.setRequired(opt.requred());
+ option.setRequired(opt.required());
}
}
commandMeta.addOption(option);
@@ -140,6 +143,6 @@
{
name = plugin.getSimpleName();
}
- return name;
+ return name.toLowerCase();
}
}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandMetadata.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandMetadata.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandMetadata.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -38,6 +38,35 @@
private String help;
private List<OptionMetadata> options = new ArrayList<OptionMetadata>();
+ public OptionMetadata getNamedOption(final String name) throws IllegalArgumentException
+ {
+ for (OptionMetadata option : options)
+ {
+ if (option.isNamed() && option.getName().equals(name))
+ {
+ return option;
+ }
+ }
+ throw new IllegalArgumentException("No such option [" + name + "] for command: " + this);
+ }
+
+ public OptionMetadata getOrderedOptionByIndex(final int index) throws IllegalArgumentException
+ {
+ int currentIndex = 0;
+ for (OptionMetadata option : options)
+ {
+ if (!option.isNamed() && (index == currentIndex))
+ {
+ return option;
+ }
+ else if (!option.isNamed())
+ {
+ currentIndex++;
+ }
+ }
+ throw new IllegalArgumentException("No option with index [" + index + "] exists for command: " + this);
+ }
+
public Method getMethod()
{
return method;
@@ -99,16 +128,4 @@
{
this.parent = parent;
}
-
- public OptionMetadata getNamedOption(final String token)
- {
- for (OptionMetadata option : options)
- {
- if (option.isNamed() && option.getName().equals(token))
- {
- return option;
- }
- }
- return null;
- }
}
\ No newline at end of file
Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Execution.java (from rev 13360, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Execution.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Execution.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,112 @@
+/*
+ * 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.shell.cli;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class Execution
+{
+ @Inject
+ private BeanManager manager;
+
+ private CommandMetadata command;
+ private Object[] parameterArray;
+ private String originalStatement;
+
+ @SuppressWarnings("unchecked")
+ public void perform()
+ {
+ if (command != null)
+ {
+ try
+ {
+ Class<? extends Plugin> pluginType = command.getParent().getType();
+ Set<Bean<?>> beans = manager.getBeans(pluginType);
+ Bean<? extends Object> bean = manager.resolve(beans);
+
+ Plugin plugin = null;
+ if (bean != null)
+ {
+ CreationalContext<? extends Plugin> context = (CreationalContext<? extends Plugin>) manager
+ .createCreationalContext(bean);
+ if (context != null)
+ {
+ plugin = (Plugin) manager.getReference(bean, pluginType, context);
+
+ command.getMethod().invoke(plugin, parameterArray);
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ System.err.println("I don't understand what you meant.");
+ }
+ }
+ else
+ {
+ System.err.println("I don't understand what you meant.");
+ }
+ }
+
+ public CommandMetadata getCommand()
+ {
+ return command;
+ }
+
+ public void setCommand(final CommandMetadata command)
+ {
+ this.command = command;
+ }
+
+ public Object[] getParameterArray()
+ {
+ return parameterArray;
+ }
+
+ public void setParameterArray(final Object... parameters)
+ {
+ this.parameterArray = parameters;
+ }
+
+ public String getOriginalStatement()
+ {
+ return originalStatement;
+ }
+
+ public void setOriginalStatement(final String originalStatement)
+ {
+ this.originalStatement = originalStatement;
+ }
+
+}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/ExecutionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -21,10 +21,8 @@
*/
package org.jboss.encore.shell.cli;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
@@ -32,7 +30,14 @@
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
-import org.jboss.encore.shell.Execution;
+import org.jboss.encore.shell.cli.parser.CommandParser;
+import org.jboss.encore.shell.cli.parser.CompositeCommandParser;
+import org.jboss.encore.shell.cli.parser.NamedBooleanOptionParser;
+import org.jboss.encore.shell.cli.parser.NamedValueOptionParser;
+import org.jboss.encore.shell.cli.parser.NamedValueVarargsOptionParser;
+import org.jboss.encore.shell.cli.parser.OrderedValueOptionParser;
+import org.jboss.encore.shell.cli.parser.OrderedValueVarargsOptionParser;
+import org.jboss.encore.shell.cli.parser.ParseErrorParser;
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
@@ -48,18 +53,15 @@
public Execution parse(final String line)
{
- Queue<String> tokens = new LinkedList<String>();
- for (String token : line.split("\\s+"))
- {
- tokens.add(token);
- }
+ Queue<String> tokens = tokenize(line);
Map<String, PluginMetadata> plugins = registry.getPlugins();
Map<String, PluginMetadata> builtInPlugins = registry.getBuiltInPlugins();
Execution execution = executionInstance.get();
+
+ execution.setOriginalStatement(line);
CommandMetadata command = null;
- List<Object> parameters = new ArrayList<Object>();
if (tokens.size() > 0)
{
@@ -82,7 +84,7 @@
{
command = plugin.getCommands().get(0);
}
- else if (tokens.size() > 1)
+ else if (tokens.size() > 0)
{
String second = tokens.peek();
if ((plugin != null) && (command == null))
@@ -98,11 +100,55 @@
if (command != null)
{
execution.setCommand(command);
- parameters.addAll(Arrays.asList(tokens.toArray()));
- execution.setParameterArray(parameters.toArray());
+
+ // parse parameters and set order / nulls for command invocation
+
+ Object[] parameters = parseParameters(command, tokens);
+ execution.setParameterArray(parameters);
}
+ else
+ {
+ throw new IllegalStateException("Missing command for plugin: " + plugin.getName());
+ }
}
return execution;
}
+
+ private Queue<String> tokenize(final String line)
+ {
+ Queue<String> tokens = new LinkedList<String>();
+
+ for (String token : line.split("\\s+"))
+ {
+ tokens.add(token);
+ }
+ return tokens;
+ }
+
+ private Object[] parseParameters(final CommandMetadata command, final Queue<String> tokens)
+ {
+ Map<OptionMetadata, Object> valueMap = new HashMap<OptionMetadata, Object>();
+
+ CommandParser commandParser = new CompositeCommandParser(new NamedBooleanOptionParser(),
+ new NamedValueOptionParser(),
+ new NamedValueVarargsOptionParser(), new OrderedValueOptionParser(),
+ new OrderedValueVarargsOptionParser(), new ParseErrorParser());
+
+ commandParser.parse(command, valueMap, tokens);
+
+ Object[] parameters = new Object[command.getOptions().size()];
+ for (OptionMetadata option : command.getOptions())
+ {
+ Object value = valueMap.get(option);
+ if (option.isRequired() && (value == null))
+ {
+ throw new IllegalStateException("Command is missing required option: " + option);
+ }
+
+ parameters[option.getIndex()] = value;
+ }
+
+ return parameters;
+ }
}
Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Option.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Option.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Option.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -1,60 +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.shell.cli;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * A command option.
- *
- * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
- */
-@Qualifier
-@Target({ METHOD, PARAMETER })
-@Retention(RUNTIME)
-@Documented
-public @interface Option
-{
- /**
- * The name of this option;
- */
- String value() default "";
-
- /**
- * Specify whether or not this option is required.
- */
- boolean requred() default false;
-
- /**
- * Help text for this option.
- */
- String help() default "";
-}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/OptionMetadata.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/OptionMetadata.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/OptionMetadata.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -109,4 +109,14 @@
this.parent = parent;
}
+ public boolean isBoolean()
+ {
+ return (Boolean.TYPE.equals(getType()) || Boolean.class.equals(getType()));
+ }
+
+ public boolean isVarargs()
+ {
+ return getType().isArray();
+ }
+
}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.inject.Inject;
@@ -45,27 +46,36 @@
String[] tokens = buffer.split("\\s+");
if (tokens.length == 1)
{
- String plugin = tokens[0];
- for (String pluginName : plugins.keySet())
+ String token = tokens[0];
+ for (Entry<String, PluginMetadata> p : plugins.entrySet())
{
- if (pluginName.startsWith(plugin))
+ String pluginName = p.getValue().getName();
+ if (isPotentialMatch(pluginName, token))
{
PluginMetadata pluginMetadata = plugins.get(pluginName);
- if (pluginMetadata.isImplicitCommand())
+ if (pluginMetadata.isBuiltIn() && pluginMetadata.isImplicitCommand())
{
List<String> names = pluginMetadata.getCommands().get(0).getNames();
for (String name : names)
{
- candidates.add(name);
+ if (isPotentialMatch(name, token))
+ {
+ candidates.add(name.toLowerCase() + " ");
+ }
}
}
else
{
- candidates.add(pluginName);
+ candidates.add(pluginName.toLowerCase() + " ");
}
}
}
}
return 0;
}
+
+ private boolean isPotentialMatch(final String name, final String token)
+ {
+ return name.matches("(?i)" + token + ".*");
+ }
}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -61,7 +61,7 @@
*/
public boolean isImplicitCommand()
{
- return commands.size() == 1;
+ return (commands.size() == 1) && isBuiltIn();
}
public String getName()
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,47 @@
+/*
+ * 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.shell.cli.builtin;
+
+import javax.inject.Inject;
+
+import org.jboss.encore.shell.Shell;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Option;
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * Implements a demonstration {@link Plugin}
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class Echo implements Plugin
+{
+ @Inject
+ Shell shell;
+
+ @Command(help = "This is a demo command")
+ public void run(@Option(help = "The text to be echoed") final String text)
+ {
+ shell.write("Echo plugin says: \"" + text + "\"");
+ }
+}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -24,9 +24,9 @@
import javax.enterprise.event.Event;
import javax.inject.Inject;
-import org.jboss.encore.shell.cli.BuiltIn;
-import org.jboss.encore.shell.cli.Command;
import org.jboss.encore.shell.events.Shutdown;
+import org.jboss.encore.shell.plugins.BuiltIn;
+import org.jboss.encore.shell.plugins.Command;
import org.jboss.encore.shell.plugins.Plugin;
/**
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -21,14 +21,12 @@
*/
package org.jboss.encore.shell.cli.builtin;
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-import javax.inject.Named;
+import java.util.Arrays;
-import org.jboss.encore.shell.cli.BuiltIn;
-import org.jboss.encore.shell.cli.Command;
-import org.jboss.encore.shell.cli.Option;
import org.jboss.encore.shell.events.Shutdown;
+import org.jboss.encore.shell.plugins.BuiltIn;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Option;
import org.jboss.encore.shell.plugins.Plugin;
/**
@@ -38,15 +36,18 @@
*
*/
@BuiltIn
-@Named("help")
public class Help implements Plugin
{
- @Inject
- private Event<Shutdown> shutdown;
-
@Command(help = "Get help about specific commands")
- public void help(@Option(requred = true) final String command, @Option final String subcommand)
+ public void help(@Option("test") final String test, @Option final String... commands)
{
- System.out.println("You requested help for: " + command);
+ if (commands == null)
+ {
+ System.out.println("Welcome to Encore!");
+ }
+ else
+ {
+ System.out.println("You requested help for: " + Arrays.deepToString(commands));
+ }
}
}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CommandParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CommandParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CommandParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -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.shell.cli.parser;
+
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public interface CommandParser
+{
+ public void parse(CommandMetadata command, Map<OptionMetadata, Object> valueMap, Queue<String> tokens);
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CompositeCommandParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CompositeCommandParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/CompositeCommandParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,79 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class CompositeCommandParser implements CommandParser
+{
+ List<CommandParser> parsers = new ArrayList<CommandParser>();
+
+ public CompositeCommandParser(final CommandParser... parsers)
+ {
+ this.parsers = Arrays.asList(parsers);
+ }
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ boolean complete = false;
+ while (!complete)
+ {
+ boolean altered = false;
+ for (CommandParser parser : parsers)
+ {
+ if (tokens.size() == 0)
+ {
+ complete = true;
+ break;
+ }
+
+ int size = tokens.size();
+ parser.parse(command, valueMap, tokens);
+
+ if (size > tokens.size())
+ {
+ altered = true;
+ break;
+ }
+ }
+
+ if (!altered)
+ {
+ break;
+ }
+ }
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedBooleanOptionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedBooleanOptionParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedBooleanOptionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,65 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class NamedBooleanOptionParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String currentToken = tokens.peek();
+ if (currentToken.startsWith("--"))
+ {
+ currentToken = currentToken.substring(2);
+ OptionMetadata option = command.getNamedOption(currentToken);
+
+ if (option.isBoolean())
+ {
+ tokens.remove();
+ String value = "true";
+ if (!tokens.isEmpty())
+ {
+ String nextToken = tokens.peek();
+ if (nextToken.matches("true|false"))
+ {
+ value = nextToken;
+ tokens.remove(); // increment the chain of tokens
+ }
+ }
+ valueMap.put(option, value); // add the value, should we return this as a tuple instead?
+ }
+ }
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueOptionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueOptionParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueOptionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,65 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class NamedValueOptionParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String currentToken = tokens.peek();
+ if (currentToken.startsWith("--"))
+ {
+ currentToken = currentToken.substring(2);
+ OptionMetadata option = command.getNamedOption(currentToken);
+ tokens.remove();
+
+ if (!option.isBoolean())
+ {
+ String value = null;
+ if (!tokens.isEmpty())
+ {
+ String nextToken = tokens.peek();
+ if (!nextToken.startsWith("--"))
+ {
+ value = nextToken;
+ tokens.remove(); // increment the chain of tokens
+ }
+ }
+ valueMap.put(option, value); // add the value, should we return this as a tuple instead?
+ }
+ }
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueVarargsOptionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueVarargsOptionParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/NamedValueVarargsOptionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,77 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class NamedValueVarargsOptionParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String currentToken = tokens.peek();
+ if (currentToken.startsWith("--"))
+ {
+ currentToken = currentToken.substring(2);
+ OptionMetadata option = command.getNamedOption(currentToken);
+ if (option.isVarargs())
+ {
+ tokens.remove();
+ List<String> args = new ArrayList<String>();
+ while (!tokens.peek().startsWith("--"))
+ {
+ args.add(tokens.remove());
+ }
+ valueMap.put(option, args.toArray()); // add the value, should we return this as a tuple instead?
+ }
+ }
+ }
+
+ /**
+ * Return a count of how many ordered params have already been parsed.
+ */
+ private int getNumberOrderedParamsIn(final Map<OptionMetadata, Object> valueMap)
+ {
+ int result = 0;
+ for (OptionMetadata option : valueMap.keySet())
+ {
+ if (!option.isNamed())
+ {
+ result++;
+ }
+ }
+ return result;
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueOptionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueOptionParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueOptionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,69 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class OrderedValueOptionParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String currentToken = tokens.peek();
+ if (!currentToken.startsWith("--"))
+ {
+ OptionMetadata option = command.getOrderedOptionByIndex(getNumberOrderedParamsIn(valueMap));
+ if (!option.isVarargs())
+ {
+ valueMap.put(option, currentToken); // add the value, should we return this as a tuple instead?
+ tokens.remove();
+ }
+ }
+ }
+
+ /**
+ * Return a count of how many ordered params have already been parsed.
+ */
+ private int getNumberOrderedParamsIn(final Map<OptionMetadata, Object> valueMap)
+ {
+ int result = 0;
+ for (OptionMetadata option : valueMap.keySet())
+ {
+ if (!option.isNamed())
+ {
+ result++;
+ }
+ }
+ return result;
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueVarargsOptionParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueVarargsOptionParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/OrderedValueVarargsOptionParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,76 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class OrderedValueVarargsOptionParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String currentToken = tokens.peek();
+ if (!currentToken.startsWith("--"))
+ {
+ OptionMetadata option = command.getOrderedOptionByIndex(getNumberOrderedParamsIn(valueMap));
+ if (option.isVarargs())
+ {
+ List<String> args = new ArrayList<String>();
+ while (!tokens.isEmpty() && !tokens.peek().startsWith("--"))
+ {
+ args.add(tokens.remove());
+ }
+ valueMap.put(option, args.toArray(new String[0])); // add the value, should we return this as a tuple
+ // instead?
+ }
+ }
+ }
+
+ /**
+ * Return a count of how many ordered params have already been parsed.
+ */
+ private int getNumberOrderedParamsIn(final Map<OptionMetadata, Object> valueMap)
+ {
+ int result = 0;
+ for (OptionMetadata option : valueMap.keySet())
+ {
+ if (!option.isNamed())
+ {
+ result++;
+ }
+ }
+ return result;
+ }
+
+}
Added: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/ParseErrorParser.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/ParseErrorParser.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/parser/ParseErrorParser.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,47 @@
+/*
+ * 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.shell.cli.parser;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Queue;
+
+import org.jboss.encore.shell.cli.CommandMetadata;
+import org.jboss.encore.shell.cli.OptionMetadata;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+public class ParseErrorParser implements CommandParser
+{
+
+ @Override
+ public void parse(final CommandMetadata command, final Map<OptionMetadata, Object> valueMap,
+ final Queue<String> tokens)
+ {
+ String token = tokens.peek();
+ String commandNames = Arrays.deepToString(command.getNames().toArray());
+ throw new IllegalStateException("Error parsing token [" + token + "] for command: " + commandNames);
+ }
+
+}
Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/BuiltIn.java (from rev 13360, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/BuiltIn.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/BuiltIn.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/BuiltIn.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,47 @@
+/*
+ * 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.shell.plugins;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+
+/**
+ * Defines a #{@link Plugin} as built in, thus, commands will be accessible without providing a plugin name;
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface BuiltIn
+{
+
+}
Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Command.java (from rev 13360, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Command.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Command.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Command.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,57 @@
+/*
+ * 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.shell.plugins;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Represents a single command to be run on a Shell.
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+@Qualifier
+@Target({ METHOD, PARAMETER, TYPE, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface Command
+{
+ /**
+ * One or more names for this command.
+ */
+ String[] value() default {};
+
+ /**
+ * Help text for this command.
+ */
+ String help() default "";
+}
Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java (from rev 13360, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/Option.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -0,0 +1,65 @@
+/*
+ * 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.shell.plugins;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A command option.
+ *
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ *
+ */
+@Qualifier
+@Target({ METHOD, PARAMETER })
+@Retention(RUNTIME)
+@Documented
+public @interface Option
+{
+ /**
+ * The name of this option;
+ */
+ String value() default "";
+
+ /**
+ * Specify whether or not this option is required.
+ */
+ boolean required() default false;
+
+ /**
+ * The default value for this option, if not provided in user input.
+ */
+ String defaultValue() default "";
+
+ /**
+ * Help text for this option.
+ */
+ String help() default "";
+}
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Plugin.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Plugin.java 2010-07-11 01:16:28 UTC (rev 13360)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Plugin.java 2010-07-12 22:29:39 UTC (rev 13361)
@@ -21,9 +21,15 @@
*/
package org.jboss.encore.shell.plugins;
+
/**
+ * A custom {@link Plugin} must implement this interface in order to be detected and installed at framework boot-time.
+ * In order to create plugin shell-commands, one must create a method annotated with @{@link Command}. Any command
+ * method parameters to be provided as input through the shell must be individually annotated with the @{@link Option}
+ * annotation; other (non-annotated) command parameters are ignored.
+ *
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
- *
+ *
*/
public interface Plugin
{
14 years, 5 months
Seam SVN: r13360 - in modules/xml/trunk: impl/src/main/java/org/jboss/seam/xml/bootstrap and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-10 21:16:28 -0400 (Sat, 10 Jul 2010)
New Revision: 13360
Removed:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java
Modified:
modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml
Log:
change <type> to <Exact> as per SEAMXML-8
Modified: modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
===================================================================
--- modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml 2010-07-11 01:16:28 UTC (rev 13360)
@@ -141,7 +141,7 @@
<itemizedlist>
<listitem><para><literal>Beans</literal></para></listitem>
- <listitem><para><literal>extends</literal></para></listitem>
+ <listitem><para><literal>modifies</literal></para></listitem>
<listitem><para><literal>overrides</literal></para></listitem>
<listitem><para><literal>parameters</literal></para></listitem>
<listitem><para><literal>value</literal></para></listitem>
@@ -173,6 +173,7 @@
<listitem><para><literal>javax.enterprise.event</literal></para></listitem>
<listitem><para><literal>javax.decorator</literal></para></listitem>
<listitem><para><literal>javax.interceptor</literal></para></listitem>
+ <listitem><para><literal>org.jboss.weld.extensions.core</literal></para></listitem>
</itemizedlist>
<para>Other namspaces are specified using the following syntax:</para>
@@ -193,16 +194,16 @@
<para>By configuring a bean via XML creates a new bean, however there
may be cases where you want to modify an existing bean rather than
adding a new one. The <literal><s:overrides></literal> and
- <literal><s:extends></literal> tags allow you to do this.</para>
+ <literal><s:modifies></literal> tags allow you to do this.</para>
<para>The <literal><s:overrides></literal> tag prevents the existing bean from being
installed, and registers a new one with the given configuration. The
- <literal><s:extends></literal> tag does the same, except that it merges
+ <literal><s:modifies></literal> tag does the same, except that it merges
the annotations on the bean with the annotations defined in XML. This has the
same effect as modifiying an existing bean.</para>
<programlisting role="XML"><![CDATA[
<test:Report>
- <s:extends>
+ <s:modifies>
<test:NewQualifier/>
</test:Report>
@@ -406,9 +407,7 @@
<test:SomeBean>
<test:someField>
<s:Inject/>
- <s:type>
- <test:InjectedBean/>
- </s:type>
+ <s:Exact>com.mydomain.InjectedBean</s:Exact>
</test:someField>
</test:SomeBean>
]]>
@@ -491,7 +490,7 @@
<s:genericBean class="org.jboss.seam.xml.test.generic.GenericMain" >
<test:GenericDependant>
<s:ApplyQualifiers/>
- <s:extends/>
+ <s:modifies/>
<test:instance>
<s:ApplyQualifiers/>
</test:instance>
Modified: modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml
===================================================================
--- modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml 2010-07-11 01:16:28 UTC (rev 13360)
@@ -100,9 +100,7 @@
<s:overrides/>
<r:datasource>
<s:Inject/>
- <s:type>
- <r:BillingDatasource/>
- </s:type>
+ <s:Exact>org.example.reports.BillingDatasource</s:Exact>
</r:datasource>
</r:Report>
</beans>
@@ -142,8 +140,8 @@
from the class definition.</para>
</callout>
<callout arearefs="datasource-type">
- <para>The <literal><s:type></literal> restricts the type of bean that is availible for injection without using qualifiers. In this case
- <literal>BillingDatasource</literal> will be injected.</para>
+ <para>The <literal><s:Eact></literal> annotation restricts the type of bean that is availible for injection without using qualifiers. In this case
+ <literal>BillingDatasource</literal> will be injected. This is provided as part of weld-extensions.</para>
</callout>
</calloutlist>
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -64,6 +64,7 @@
import org.jboss.seam.xml.parser.SaxNode;
import org.jboss.seam.xml.util.FileDataReader;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.core.Exact;
import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -429,6 +430,53 @@
return false;
}
+ /**
+ * temprary hack to support @Exact in seam-xml, remove once WELD-485 is
+ * resolved
+ */
+ <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager beanManager)
+ {
+
+ AnnotatedTypeBuilder<X> builder = AnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).mergeAnnotations(pat.getAnnotatedType(), true);
+
+ // support for @Exact
+ // fields
+ for (AnnotatedField<? super X> f : pat.getAnnotatedType().getFields())
+ {
+ if (f.isAnnotationPresent(Exact.class))
+ {
+ Class<?> type = f.getAnnotation(Exact.class).value();
+ builder.overrideFieldType(f.getJavaMember(), type);
+ }
+ }
+ // method parameters
+ for (AnnotatedMethod<? super X> m : pat.getAnnotatedType().getMethods())
+ {
+ for (AnnotatedParameter<? super X> p : m.getParameters())
+ {
+ if (p.isAnnotationPresent(Exact.class))
+ {
+ Class<?> type = p.getAnnotation(Exact.class).value();
+ builder.overrideMethodParameterType(m.getJavaMember(), type, p.getPosition());
+ }
+ }
+ }
+ // constructor parameters
+ for (AnnotatedConstructor<X> c : pat.getAnnotatedType().getConstructors())
+ {
+ for (AnnotatedParameter<? super X> p : c.getParameters())
+ {
+ if (p.isAnnotationPresent(Exact.class))
+ {
+ Class<?> type = p.getAnnotation(Exact.class).value();
+ builder.overrideConstructorParameterType(c.getJavaMember(), type, p.getPosition());
+ }
+ }
+ }
+ pat.setAnnotatedType(builder.create());
+
+ }
+
public static class DefaultLiteral extends AnnotationLiteral<Default> implements Default
{
};
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -43,7 +43,6 @@
allowed.add(XmlItemType.FIELD);
allowed.add(XmlItemType.METHOD);
allowed.add(XmlItemType.PARAMETERS);
- allowed.add(XmlItemType.TYPE);
}
public Set<XmlItemType> getAllowedItem()
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -59,7 +59,6 @@
}
allowed.add(XmlItemType.ANNOTATION);
allowed.add(XmlItemType.VALUE);
- allowed.add(XmlItemType.TYPE);
}
public Field getField()
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -341,22 +341,6 @@
Annotation a = createAnnotation(fi);
type.addToField(item.getField(), a);
}
- List<TypeXmlItem> types = item.getChildrenOfType(TypeXmlItem.class);
- if (types.size() > 1)
- {
- throw new XmlConfigurationException("Only one <type> element may be present on a field", rb.getDocument(), rb.getLineno());
- }
- if (!types.isEmpty())
- {
- List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
- if (overridenTypes.size() != 1)
- {
- throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
- }
-
- type.overrideFieldType(item.getField(), overridenTypes.get(0).getJavaClass());
- }
-
}
for (MethodXmlItem item : rb.getChildrenOfType(MethodXmlItem.class))
{
@@ -382,20 +366,6 @@
Annotation a = createAnnotation(pan);
type.addToMethodParameter(item.getMethod(), param, a);
}
- List<TypeXmlItem> types = fi.getChildrenOfType(TypeXmlItem.class);
- if (types.size() > 1)
- {
- throw new XmlConfigurationException("Only one <type> element may be present on a parameter", rb.getDocument(), rb.getLineno());
- }
- if (!types.isEmpty())
- {
- List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
- if (overridenTypes.size() != 1)
- {
- throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
- }
- type.overrideMethodParameterType(item.getMethod(), overridenTypes.get(0).getJavaClass(), param);
- }
}
}
@@ -417,21 +387,6 @@
Annotation a = createAnnotation(pan);
type.addToConstructorParameter((Constructor) c, param, a);
}
- List<TypeXmlItem> types = fi.getChildrenOfType(TypeXmlItem.class);
- if (types.size() > 1)
- {
- throw new XmlConfigurationException("Only one <type> element may be present on a parameter", rb.getDocument(), rb.getLineno());
- }
- if (!types.isEmpty())
- {
- List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
- if (overridenTypes.size() != 1)
- {
- throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
- }
-
- type.overrideConstructorParameterType(c, overridenTypes.get(0).getJavaClass(), param);
- }
}
}
return result;
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -1,47 +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.seam.xml.model;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class TypeXmlItem extends AbstractXmlItem
-{
-
- static final Set<XmlItemType> allowed = new HashSet<XmlItemType>();
-
- static
- {
- allowed.add(XmlItemType.CLASS);
- allowed.add(XmlItemType.ANNOTATION);
- }
-
- public TypeXmlItem(XmlItem parent, String document, int lineno)
- {
- super(XmlItemType.TYPE, parent, null, null, null, document, lineno);
- }
-
- public Set<XmlItemType> getAllowedItem()
- {
- return allowed;
- }
-}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -23,5 +23,5 @@
public enum XmlItemType
{
- CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, MODIFIES, TYPE, GENERIC_BEAN;
+ CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, MODIFIES, GENERIC_BEAN;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-07-11 01:16:28 UTC (rev 13360)
@@ -30,7 +30,6 @@
import org.jboss.seam.xml.model.OverrideXmlItem;
import org.jboss.seam.xml.model.ParameterXmlItem;
import org.jboss.seam.xml.model.ParametersXmlItem;
-import org.jboss.seam.xml.model.TypeXmlItem;
import org.jboss.seam.xml.model.ValueXmlItem;
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.model.XmlItemType;
@@ -40,7 +39,7 @@
{
private final CompositeNamespaceElementResolver delegate;
- static final String[] namspaces = { "java.lang", "java.util", "javax.annotation", "javax.inject", "javax.enterprise.inject", "javax.enterprise.context", "javax.enterprise.event", "javax.decorator", "javax.interceptor", "org.jboss.seam.xml.annotations.internal" };
+ static final String[] namspaces = { "java.lang", "java.util", "javax.annotation", "javax.inject", "javax.enterprise.inject", "javax.enterprise.context", "javax.enterprise.event", "javax.decorator", "javax.interceptor", "org.jboss.seam.xml.annotations.internal", "org.jboss.weld.extensions.core" };
public RootNamespaceElementResolver()
{
@@ -87,10 +86,6 @@
{
return new ParametersXmlItem(parent, node.getDocument(), node.getLineNo());
}
- else if (item.equals("type"))
- {
- return new TypeXmlItem(parent, node.getDocument(), node.getLineNo());
- }
else if (item.equals("genericBean"))
{
return new GenericBeanXmlItem(parent, node.getAttributes(), node.getDocument(), node.getLineNo());
Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml 2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml 2010-07-11 01:16:28 UTC (rev 13360)
@@ -7,17 +7,13 @@
<overrides/>
<test:value>
<Inject/>
- <type>
- <test:AllowedType/>
- </type>
+ <Exact>org.jboss.seam.xml.test.types.AllowedType</Exact>
</test:value>
<test:create>
<Inject/>
<parameters>
<test:SomeInterface>
- <type>
- <test:RestrictedType/>
- </type>
+ <Exact>org.jboss.seam.xml.test.types.RestrictedType</Exact>
</test:SomeInterface>
</parameters>
</test:create>
14 years, 5 months
Seam SVN: r13359 - in modules/xml/trunk/impl/src: main/java/org/jboss/seam/xml/core and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-10 20:54:59 -0400 (Sat, 10 Jul 2010)
New Revision: 13359
Removed:
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/iface/
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/iface/
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
Log:
removed interface config as per SEAMXML-8
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-11 00:40:19 UTC (rev 13358)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-11 00:54:59 UTC (rev 13359)
@@ -90,7 +90,7 @@
List<Exception> errors = new ArrayList<Exception>();
- Map<Class, GenericBeanResult> genericBeans = new HashMap<Class, GenericBeanResult>();
+ Map<Class<?>, GenericBeanResult> genericBeans = new HashMap<Class<?>, GenericBeanResult>();
/**
* This is the entry point for the extension
@@ -213,26 +213,6 @@
event.veto();
return;
}
- boolean found = false;
- AnnotatedTypeBuilder builder = AnnotatedTypeBuilder.newInstance(event.getAnnotatedType());
- builder.mergeAnnotations(event.getAnnotatedType(), true);
- for (XmlResult r : results)
- {
- for (BeanResult<?> i : r.getInterfaces())
- {
- if (i.getType().isAssignableFrom(event.getAnnotatedType().getJavaClass()))
- {
- found = true;
- builder.mergeAnnotations(i.getBuilder().create(), true);
- log.info("Overriding " + event.getAnnotatedType().getJavaClass() +" annotations based on interface " + i.getType().getName());
- }
- }
- }
- if (found)
- {
- event.setAnnotatedType(builder.create());
- }
-
}
public <T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> event)
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java 2010-07-11 00:40:19 UTC (rev 13358)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java 2010-07-11 00:54:59 UTC (rev 13359)
@@ -50,8 +50,6 @@
private final List<BeanResult<?>> beans = new ArrayList<BeanResult<?>>();
- private final List<BeanResult<?>> interfaces = new ArrayList<BeanResult<?>>();
-
private final List<GenericBeanResult> genericBeans = new ArrayList<GenericBeanResult>();
private final Map<BeanResult<?>, List<FieldValueObject>> fieldValues = new HashMap<BeanResult<?>, List<FieldValueObject>>();
@@ -128,16 +126,6 @@
return veto;
}
- public void addInterface(BeanResult<?> bean)
- {
- interfaces.add(bean);
- }
-
- public List<BeanResult<?>> getInterfaces()
- {
- return interfaces;
- }
-
public void addInterfaceFieldValues(Class<?> clazz, List<FieldValueObject> values)
{
interfaceFieldValues.put(clazz, values);
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-11 00:40:19 UTC (rev 13358)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-11 00:54:59 UTC (rev 13359)
@@ -130,14 +130,7 @@
ClassXmlItem cxml = (ClassXmlItem) rb;
// get the AnnotatedType information
BeanResult<?> tp = buildAnnotatedType(cxml);
- if (cxml.getJavaClass().isInterface())
- {
- ret.addInterface(tp);
- }
- else
- {
- ret.addBean(tp);
- }
+ ret.addBean(tp);
// <override> or <speciailizes> need to veto the bean
if (tp.getBeanType() != BeanResultType.ADD)
{
14 years, 5 months
Seam SVN: r13358 - in modules/xml/trunk/impl/src: main/java/org/jboss/seam/xml/model and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-10 20:40:19 -0400 (Sat, 10 Jul 2010)
New Revision: 13358
Added:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java
Removed:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ExtendsXmlItem.java
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/ResourceLoaderXmlDocumentProvider.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/simple/simple-beans.xml
Log:
rename extends to modifies
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/ResourceLoaderXmlDocumentProvider.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/ResourceLoaderXmlDocumentProvider.java 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/ResourceLoaderXmlDocumentProvider.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -97,8 +97,8 @@
{
Set<URL> e = getResources(i);
docs.addAll(e);
- iterator = docs.listIterator();
}
+ iterator = docs.listIterator();
}
protected Set<URL> getResources(String resource)
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ExtendsXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ExtendsXmlItem.java 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ExtendsXmlItem.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -1,41 +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.seam.xml.model;
-
-import java.util.Collections;
-import java.util.Set;
-
-public class ExtendsXmlItem extends AbstractXmlItem
-{
-
- public ExtendsXmlItem(XmlItem parent, String document, int lineno)
- {
- super(XmlItemType.EXTENDS, parent, null, null, null, document, lineno);
-
- }
-
- public Set<XmlItemType> getAllowedItem()
- {
- return Collections.emptySet();
- }
-
-}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -302,7 +302,7 @@
BeanResult<?> buildAnnotatedType(ClassXmlItem rb)
{
boolean override = !rb.getChildrenOfType(OverrideXmlItem.class).isEmpty();
- boolean extend = !rb.getChildrenOfType(ExtendsXmlItem.class).isEmpty();
+ boolean extend = !rb.getChildrenOfType(ModifiesXmlItem.class).isEmpty();
BeanResultType beanType = BeanResultType.ADD;
if (override && extend)
{
Copied: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java (from rev 13307, modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ExtendsXmlItem.java)
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -0,0 +1,41 @@
+/*
+ * 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.xml.model;
+
+import java.util.Collections;
+import java.util.Set;
+
+public class ModifiesXmlItem extends AbstractXmlItem
+{
+
+ public ModifiesXmlItem(XmlItem parent, String document, int lineno)
+ {
+ super(XmlItemType.MODIFIES, parent, null, null, null, document, lineno);
+
+ }
+
+ public Set<XmlItemType> getAllowedItem()
+ {
+ return Collections.emptySet();
+ }
+
+}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -23,5 +23,5 @@
public enum XmlItemType
{
- CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, EXTENDS, TYPE, GENERIC_BEAN;
+ CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, MODIFIES, TYPE, GENERIC_BEAN;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-07-11 00:40:19 UTC (rev 13358)
@@ -26,10 +26,10 @@
import org.jboss.seam.xml.model.EntryXmlItem;
import org.jboss.seam.xml.model.GenericBeanXmlItem;
import org.jboss.seam.xml.model.KeyXmlItem;
+import org.jboss.seam.xml.model.ModifiesXmlItem;
import org.jboss.seam.xml.model.OverrideXmlItem;
import org.jboss.seam.xml.model.ParameterXmlItem;
import org.jboss.seam.xml.model.ParametersXmlItem;
-import org.jboss.seam.xml.model.ExtendsXmlItem;
import org.jboss.seam.xml.model.TypeXmlItem;
import org.jboss.seam.xml.model.ValueXmlItem;
import org.jboss.seam.xml.model.XmlItem;
@@ -79,9 +79,9 @@
{
return new OverrideXmlItem(parent, node.getDocument(), node.getLineNo());
}
- else if (item.equals("extends"))
+ else if (item.equals("modifies"))
{
- return new ExtendsXmlItem(parent, node.getDocument(), node.getLineNo());
+ return new ModifiesXmlItem(parent, node.getDocument(), node.getLineNo());
}
else if (item.equals("parameters"))
{
Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml 2010-07-11 00:40:19 UTC (rev 13358)
@@ -5,19 +5,21 @@
<genericBean class="org.jboss.seam.xml.test.generic.GenericMain" >
<test:GenericDependant>
<ApplyQualifiers/>
- <extends/>
+ <modifies/>
<test:instance>
<ApplyQualifiers/>
</test:instance>
</test:GenericDependant>
</genericBean>
- <test:GenericMain><extends/>
+ <test:GenericMain>
+ <modifies/>
<test:HighGenericQualifier/>
<test:configuredValue><value>100</value></test:configuredValue>
</test:GenericMain>
- <test:GenericMain><extends/>
+ <test:GenericMain>
+ <modifies/>
<test:LowGenericQualifier/>
<test:configuredValue><value>10</value></test:configuredValue>
</test:GenericMain>
Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/simple/simple-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/simple/simple-beans.xml 2010-07-09 23:56:38 UTC (rev 13357)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/simple/simple-beans.xml 2010-07-11 00:40:19 UTC (rev 13358)
@@ -29,7 +29,7 @@
</test:OverriddenBean>
<test:ExtendedBean>
- <extends/>
+ <modifies/>
<test:ExtendedQualifier2/>
</test:ExtendedBean>
14 years, 5 months
Seam SVN: r13357 - sandbox/encore/shell/src/main/java/org/jboss/encore/shell.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-09 19:56:38 -0400 (Fri, 09 Jul 2010)
New Revision: 13357
Modified:
sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java
Log:
Minor messaging fix.
Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java 2010-07-09 23:49:57 UTC (rev 13356)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Execution.java 2010-07-09 23:56:38 UTC (rev 13357)
@@ -74,7 +74,7 @@
}
else
{
-
+ System.err.println("I don't understand what you meant.");
}
}
14 years, 5 months