Seam SVN: r12630 - in modules/faces/trunk/impl/src: main/java/org/jboss/seam/faces/beanManager and 3 other directories.
by seam-commits@lists.jboss.org
Author: nickarls
Date: 2010-04-24 17:53:25 -0400 (Sat, 24 Apr 2010)
New Revision: 12630
Added:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java
modules/faces/trunk/impl/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider
Removed:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/cdi/
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingPhaseListener.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingSystemEventListener.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java
modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/PhaseEventBridgeTest.java
modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/SystemEventBridgeTest.java
Log:
BeanManagerAware for faces module
Fixed precedence
Lazy loading of providers
Weld-specific provider (Pete, can we have this in weld-extensions?)
Added: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java (rev 0)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -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.seam.faces.beanManager;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+
+import org.jboss.weld.extensions.beanManager.BeanManagerProvider;
+
+/**
+ * A BeanManager provider for the Servlet Context attribute
+ * "javax.enterprise.inject.spi.BeanManager"
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class FacesServletContextBeanManagerProvider implements BeanManagerProvider
+{
+ public static final FacesServletContextBeanManagerProvider DEFAULT = new FacesServletContextBeanManagerProvider();
+
+ public BeanManager getBeanManager()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext == null)
+ {
+ return null;
+ }
+ ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
+ return (BeanManager) servletContext.getAttribute(BeanManager.class.getName());
+ }
+
+ public int getPrecedence()
+ {
+ return 20;
+ }
+
+}
\ No newline at end of file
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingPhaseListener.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingPhaseListener.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingPhaseListener.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -31,7 +31,7 @@
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
/**
* Provide CDI injection to PhaseListener artifacts by delegating through this
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingSystemEventListener.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingSystemEventListener.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/DelegatingSystemEventListener.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -31,7 +31,7 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
/**
* Provide CDI injection to SystemEventListener artifacts by delegating through
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -31,7 +31,6 @@
import javax.faces.event.PhaseListener;
import javax.inject.Inject;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
import org.jboss.seam.faces.event.qualifier.After;
import org.jboss.seam.faces.event.qualifier.ApplyRequestValues;
import org.jboss.seam.faces.event.qualifier.Before;
@@ -40,6 +39,7 @@
import org.jboss.seam.faces.event.qualifier.RenderResponse;
import org.jboss.seam.faces.event.qualifier.RestoreView;
import org.jboss.seam.faces.event.qualifier.UpdateModelValues;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
import org.slf4j.Logger;
/**
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -36,9 +36,9 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
import org.jboss.seam.faces.event.qualifier.Component;
import org.jboss.seam.faces.event.qualifier.View;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
/**
* A SystemEventListener used to bridge JSF system events to the CDI event
Added: modules/faces/trunk/impl/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider
===================================================================
--- modules/faces/trunk/impl/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider (rev 0)
+++ modules/faces/trunk/impl/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider 2010-04-24 21:53:25 UTC (rev 12630)
@@ -0,0 +1 @@
+org.jboss.seam.faces.beanManager.FacesServletContextBeanManagerProvider
Modified: modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/PhaseEventBridgeTest.java
===================================================================
--- modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/PhaseEventBridgeTest.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/PhaseEventBridgeTest.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -31,13 +31,13 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.faces.MockLogger;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
import org.jboss.test.faces.mock.context.MockFacesContext;
import org.jboss.test.faces.mock.lifecycle.MockLifecycle;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/SystemEventBridgeTest.java
===================================================================
--- modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/SystemEventBridgeTest.java 2010-04-24 21:53:03 UTC (rev 12629)
+++ modules/faces/trunk/impl/src/test/java/org/jboss/seam/faces/event/SystemEventBridgeTest.java 2010-04-24 21:53:25 UTC (rev 12630)
@@ -47,13 +47,13 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.faces.cdi.BeanManagerAware;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
import org.jboss.test.faces.mock.application.MockApplication;
import org.jboss.test.faces.mock.context.MockFacesContext;
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
import org.junit.Test;
import org.junit.runner.RunWith;
14 years, 8 months
Seam SVN: r12629 - in modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet: http and 1 other directory.
by seam-commits@lists.jboss.org
Author: nickarls
Date: 2010-04-24 17:53:03 -0400 (Sat, 24 Apr 2010)
New Revision: 12629
Removed:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java
Log:
BeanManagerAware for faces module
Fixed precedence
Lazy loading of providers
Weld-specific provider (Pete, can we have this in weld-extensions?)
Modified: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java 2010-04-24 02:42:24 UTC (rev 12628)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java 2010-04-24 21:53:03 UTC (rev 12629)
@@ -22,8 +22,8 @@
package org.jboss.seam.servlet.beanManager;
import javax.enterprise.inject.spi.BeanManager;
+import javax.servlet.ServletContext;
-import org.jboss.seam.servlet.http.ServletContextHelper;
import org.jboss.weld.extensions.beanManager.BeanManagerProvider;
/**
@@ -35,9 +35,22 @@
*/
public class ServletContextBeanManagerProvider implements BeanManagerProvider
{
+ private static ThreadLocal<ServletContext> servletContext = new ThreadLocal<ServletContext>()
+ {
+ protected ServletContext initialValue()
+ {
+ return null;
+ }
+ };
+
+ public static void setServletContext(ServletContext sc)
+ {
+ servletContext.set(sc);
+ }
+
public BeanManager getBeanManager()
{
- return (BeanManager) ServletContextHelper.getCurrentInstance().getAttribute(BeanManager.class.getName());
+ return (BeanManager) servletContext.get().getAttribute(BeanManager.class.getName());
}
public int getPrecedence()
Deleted: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java 2010-04-24 02:42:24 UTC (rev 12628)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java 2010-04-24 21:53:03 UTC (rev 12629)
@@ -1,63 +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.servlet.http;
-
-import javax.servlet.ServletContext;
-
-/**
- * A ThreadLocal storage for the ServletContext. The current instance is set in
- * ServletContextProducer and used in the ServletContextBeanManagerProvider.
- *
- * @author Nicklas Karlsson
- *
- */
-public class ServletContextHelper
-{
- private static ThreadLocal<ServletContext> servletContext = new ThreadLocal<ServletContext>()
- {
- protected ServletContext initialValue()
- {
- return null;
- }
- };
-
- /**
- * Returns the current instance of the ServletContext, if any
- *
- * @return The servet context or null if none is currently set
- */
- public static ServletContext getCurrentInstance()
- {
- return (servletContext.get());
- }
-
-
- /**
- * Sets the current instance of the ServletContext
- *
- * @param sc The Servlet Context
- */
- public static void setCurrentInstance(ServletContext sc)
- {
- servletContext.set(sc);
- }
-}
Modified: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java 2010-04-24 02:42:24 UTC (rev 12628)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java 2010-04-24 21:53:03 UTC (rev 12629)
@@ -29,6 +29,7 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
+import org.jboss.seam.servlet.beanManager.ServletContextBeanManagerProvider;
import org.jboss.seam.servlet.event.qualifier.Destroyed;
import org.jboss.seam.servlet.event.qualifier.Initialized;
import org.slf4j.Logger;
@@ -57,7 +58,7 @@
log.debug("Servlet context initialized with event #0", e);
servletContext = e.getServletContext();
servletContext.setAttribute(BeanManager.class.getName(), beanManager);
- ServletContextHelper.setCurrentInstance(servletContext);
+ ServletContextBeanManagerProvider.setServletContext(servletContext);
}
protected void contextDestroyed(@Observes @Destroyed ServletContextEvent e)
14 years, 8 months
Seam SVN: r12628 - in sandbox/modules: seam2-bridge and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-04-23 22:42:24 -0400 (Fri, 23 Apr 2010)
New Revision: 12628
Added:
sandbox/modules/seam2-bridge/
sandbox/modules/seam2-bridge/branches/
sandbox/modules/seam2-bridge/tags/
sandbox/modules/seam2-bridge/trunk/
Log:
added dirs for seam 2 bridge to sandbox
14 years, 8 months
Seam SVN: r12627 - sandbox.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-04-23 22:30:19 -0400 (Fri, 23 Apr 2010)
New Revision: 12627
Removed:
sandbox/trunk/
Log:
remove empty folder
14 years, 8 months
Seam SVN: r12626 - sandbox/trunk.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-04-23 22:29:34 -0400 (Fri, 23 Apr 2010)
New Revision: 12626
Removed:
sandbox/trunk/examples/
sandbox/trunk/modules/
Log:
remove empty folders
14 years, 8 months
Seam SVN: r12625 - in sandbox: modules and 9 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2010-04-23 22:27:22 -0400 (Fri, 23 Apr 2010)
New Revision: 12625
Added:
sandbox/examples/
sandbox/modules/
sandbox/modules/envconfig/
sandbox/modules/envconfig/branches/
sandbox/modules/envconfig/tags/
sandbox/modules/envconfig/trunk/
sandbox/modules/envconfig/trunk/pom.xml
sandbox/modules/envconfig/trunk/readme.txt
sandbox/modules/envconfig/trunk/src/
sandbox/modules/scheduling/
sandbox/modules/scheduling/branches/
sandbox/modules/scheduling/tags/
sandbox/modules/scheduling/trunk/
sandbox/modules/scheduling/trunk/pom.xml
sandbox/modules/scheduling/trunk/src/
sandbox/modules/xwidgets/
sandbox/modules/xwidgets/branches/
sandbox/modules/xwidgets/tags/
sandbox/modules/xwidgets/trunk/
sandbox/modules/xwidgets/trunk/examples/
sandbox/modules/xwidgets/trunk/prototype/
sandbox/modules/xwidgets/trunk/src/
Removed:
sandbox/trunk/modules/envconfig/pom.xml
sandbox/trunk/modules/envconfig/readme.txt
sandbox/trunk/modules/envconfig/src/
sandbox/trunk/modules/scheduling/pom.xml
sandbox/trunk/modules/scheduling/src/
sandbox/trunk/modules/xwidgets/examples/
sandbox/trunk/modules/xwidgets/prototype/
sandbox/trunk/modules/xwidgets/src/
Log:
restructuring
Copied: sandbox/modules/envconfig/trunk/pom.xml (from rev 12624, sandbox/trunk/modules/envconfig/pom.xml)
===================================================================
--- sandbox/modules/envconfig/trunk/pom.xml (rev 0)
+++ sandbox/modules/envconfig/trunk/pom.xml 2010-04-24 02:27:22 UTC (rev 12625)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-envconfig</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>ejb</packaging>
+
+ <name>Seam Environment Configuration</name>
+ <description>A set of CDI extensions that deal with configuration of the Java EE environment (e.g., binding to JNDI)</description>
+ <inceptionYear>2009</inceptionYear>
+
+ <developers>
+ <developer>
+ <name>Matt Corey</name>
+ <url>http://smokeandice.blogspot.com</url>
+ <timezone>GMT-05:00</timezone>
+ <roles>
+ <role>Module driver</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>dan.j.allen</id>
+ <name>Dan Allen</name>
+ <email>dan.j.allen(a)gmail.com</email>
+ <url>http://in.relation.to/Bloggers/Dan</url>
+ <organization>JBoss, by Red Hat</organization>
+ <timezone>GMT-05:00</timezone>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <properties>
+ <seam.version>3.0.0-SNAPSHOT</seam.version>
+ </properties>
+
+ <!-- Snapshots repo to get parent -->
+ <repositories>
+ <repository>
+ <id>oss.sonatype.org/jboss-snapshots</id>
+ <name>JBoss (Nexus) Snapshots Repository</name>
+ <url>http://oss.sonatype.org/content/repositories/jboss-snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <scope>provided</scope>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <configuration>
+ <ejbVersion>3.0</ejbVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/envconfig/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/envconfig/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Seam/modules/envconfig/trunk</url>
+ </scm>
+
+</project>
Copied: sandbox/modules/envconfig/trunk/readme.txt (from rev 12624, sandbox/trunk/modules/envconfig/readme.txt)
===================================================================
--- sandbox/modules/envconfig/trunk/readme.txt (rev 0)
+++ sandbox/modules/envconfig/trunk/readme.txt 2010-04-24 02:27:22 UTC (rev 12625)
@@ -0,0 +1,40 @@
+Seam Environment Configuration
+==============================
+
+Extension type: Portable Extension (PE)
+
+Example:
+
+The following bean will cause the string "Hello World!" to
+be bound to the JNDI name java:global/msg when the archive
+that contains this bean is deployed.
+
+import org.jboss.seam.envconfig.Bind;
+import org.jboss.seam.envconfig.EnvironmentBinding;
+
+public @EnvironmentBinding class EnvironmentVars
+{
+ @Bind("msg") String msg = "Hello World!";
+}
+
+You can then inject the value into a managed bean as follows:
+
+@Resource(lookup = "java:global/msg") String msg;
+
+You can also bind custom objects:
+
+// somewhere in the same deployment must be a producer for @Admin User
+@Inject @Admin @Bind("adminUser") User user;
+
+Then inject the resource:
+
+@Resource(lookup = "java:global/adminUser") User user;
+
+TODO:
+
+- Add tests (learning Arquillian first)
+- Support unbinding, either with @Unbind, or by simply handling a 'null' value for unbind
+- Support binding producer methods
+- Make 'value' optional on @Bind, using the property name for the binding if not provided (may need to qualify it with class name, possibly even module name?)
+- Implement JndiBinder as a Servlet for non-EJB containers?
+- Create web and/or REST interface to display/reprocess bindings?
Copied: sandbox/modules/envconfig/trunk/src (from rev 12624, sandbox/trunk/modules/envconfig/src)
Copied: sandbox/modules/scheduling/trunk/pom.xml (from rev 12624, sandbox/trunk/modules/scheduling/pom.xml)
===================================================================
--- sandbox/modules/scheduling/trunk/pom.xml (rev 0)
+++ sandbox/modules/scheduling/trunk/pom.xml 2010-04-24 02:27:22 UTC (rev 12625)
@@ -0,0 +1,131 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>scheduling</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Seam Scheduling Module</name>
+ <url>http://maven.apache.org</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jalopy-maven-plugin</artifactId>
+ <version>1.0-alpha-1</version>
+ </plugin>
+ <plugin>
+ <groupId>com.google.code.maven-license-plugin</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <version>1.4.0</version>
+ <configuration>
+ <basedir>${basedir}</basedir>
+ <header>${basedir}/src/etc/header.txt</header>
+ <quiet>false</quiet>
+ <failIfMissing>true</failIfMissing>
+ <aggregate>false</aggregate>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <!-- TODO: remove this dependency. -->
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>quartz</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ <version>5.10</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-se</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <version>3.1.0-Alpha1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-test</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- required by weld-core-test ... -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- ... required by weld-core-test -->
+ </dependencies>
+</project>
+
Copied: sandbox/modules/scheduling/trunk/src (from rev 12624, sandbox/trunk/modules/scheduling/src)
Copied: sandbox/modules/xwidgets/trunk/examples (from rev 12624, sandbox/trunk/modules/xwidgets/examples)
Copied: sandbox/modules/xwidgets/trunk/prototype (from rev 12624, sandbox/trunk/modules/xwidgets/prototype)
Copied: sandbox/modules/xwidgets/trunk/src (from rev 12624, sandbox/trunk/modules/xwidgets/src)
Deleted: sandbox/trunk/modules/envconfig/pom.xml
===================================================================
--- sandbox/trunk/modules/envconfig/pom.xml 2010-04-23 23:46:04 UTC (rev 12624)
+++ sandbox/trunk/modules/envconfig/pom.xml 2010-04-24 02:27:22 UTC (rev 12625)
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-envconfig</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <packaging>ejb</packaging>
-
- <name>Seam Environment Configuration</name>
- <description>A set of CDI extensions that deal with configuration of the Java EE environment (e.g., binding to JNDI)</description>
- <inceptionYear>2009</inceptionYear>
-
- <developers>
- <developer>
- <name>Matt Corey</name>
- <url>http://smokeandice.blogspot.com</url>
- <timezone>GMT-05:00</timezone>
- <roles>
- <role>Module driver</role>
- </roles>
- </developer>
- <developer>
- <id>dan.j.allen</id>
- <name>Dan Allen</name>
- <email>dan.j.allen(a)gmail.com</email>
- <url>http://in.relation.to/Bloggers/Dan</url>
- <organization>JBoss, by Red Hat</organization>
- <timezone>GMT-05:00</timezone>
- <roles>
- <role>Developer</role>
- </roles>
- </developer>
- </developers>
-
- <properties>
- <seam.version>3.0.0-SNAPSHOT</seam.version>
- </properties>
-
- <!-- Snapshots repo to get parent -->
- <repositories>
- <repository>
- <id>oss.sonatype.org/jboss-snapshots</id>
- <name>JBoss (Nexus) Snapshots Repository</name>
- <url>http://oss.sonatype.org/content/repositories/jboss-snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- </repository>
- </repositories>
-
- <dependencies>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-api</artifactId>
- <scope>provided</scope>
- <version>3.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-ejb-plugin</artifactId>
- <configuration>
- <ejbVersion>3.0</ejbVersion>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/envconfig/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/envconfig/trunk</developerConnection>
- <url>http://fisheye.jboss.org/browse/Seam/modules/envconfig/trunk</url>
- </scm>
-
-</project>
Deleted: sandbox/trunk/modules/envconfig/readme.txt
===================================================================
--- sandbox/trunk/modules/envconfig/readme.txt 2010-04-23 23:46:04 UTC (rev 12624)
+++ sandbox/trunk/modules/envconfig/readme.txt 2010-04-24 02:27:22 UTC (rev 12625)
@@ -1,40 +0,0 @@
-Seam Environment Configuration
-==============================
-
-Extension type: Portable Extension (PE)
-
-Example:
-
-The following bean will cause the string "Hello World!" to
-be bound to the JNDI name java:global/msg when the archive
-that contains this bean is deployed.
-
-import org.jboss.seam.envconfig.Bind;
-import org.jboss.seam.envconfig.EnvironmentBinding;
-
-public @EnvironmentBinding class EnvironmentVars
-{
- @Bind("msg") String msg = "Hello World!";
-}
-
-You can then inject the value into a managed bean as follows:
-
-@Resource(lookup = "java:global/msg") String msg;
-
-You can also bind custom objects:
-
-// somewhere in the same deployment must be a producer for @Admin User
-@Inject @Admin @Bind("adminUser") User user;
-
-Then inject the resource:
-
-@Resource(lookup = "java:global/adminUser") User user;
-
-TODO:
-
-- Add tests (learning Arquillian first)
-- Support unbinding, either with @Unbind, or by simply handling a 'null' value for unbind
-- Support binding producer methods
-- Make 'value' optional on @Bind, using the property name for the binding if not provided (may need to qualify it with class name, possibly even module name?)
-- Implement JndiBinder as a Servlet for non-EJB containers?
-- Create web and/or REST interface to display/reprocess bindings?
Deleted: sandbox/trunk/modules/scheduling/pom.xml
===================================================================
--- sandbox/trunk/modules/scheduling/pom.xml 2010-04-23 23:46:04 UTC (rev 12624)
+++ sandbox/trunk/modules/scheduling/pom.xml 2010-04-24 02:27:22 UTC (rev 12625)
@@ -1,131 +0,0 @@
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.seam</groupId>
- <artifactId>scheduling</artifactId>
- <packaging>jar</packaging>
- <version>1.0.0-SNAPSHOT</version>
- <name>Seam Scheduling Module</name>
- <url>http://maven.apache.org</url>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jalopy-maven-plugin</artifactId>
- <version>1.0-alpha-1</version>
- </plugin>
- <plugin>
- <groupId>com.google.code.maven-license-plugin</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <version>1.4.0</version>
- <configuration>
- <basedir>${basedir}</basedir>
- <header>${basedir}/src/etc/header.txt</header>
- <quiet>false</quiet>
- <failIfMissing>true</failIfMissing>
- <aggregate>false</aggregate>
- <encoding>UTF-8</encoding>
- </configuration>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>format</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>jsr250-api</artifactId>
- <version>1.0</version>
- </dependency>
- <!-- TODO: remove this dependency. -->
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>opensymphony</groupId>
- <artifactId>quartz</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- <classifier>jdk15</classifier>
- <version>5.10</version>
- <exclusions>
- <exclusion>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-se</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-api</artifactId>
- <version>3.1.0-Alpha1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core-test</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <!-- required by weld-core-test ... -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-harness</groupId>
- <artifactId>jboss-test-harness</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <!-- ... required by weld-core-test -->
- </dependencies>
-</project>
-
14 years, 8 months
Seam SVN: r12624 - in modules/xml/trunk/impl/src: main/java/org/jboss/seam/xml/parser/namespace and 2 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-04-23 19:46:04 -0400 (Fri, 23 Apr 2010)
New Revision: 12624
Added:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java
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/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/PropertyXmlItem.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/PackageNamespaceElementResolver.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/set-field-value-beans.xml
Log:
added shorthand field values
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-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -4,17 +4,24 @@
*/
package org.jboss.seam.xml.model;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
+import org.jboss.seam.xml.util.XmlConfigurationException;
+import org.jboss.weld.extensions.util.ReflectionUtils;
+
public class ClassXmlItem extends AbstractXmlItem
{
HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
- public ClassXmlItem(XmlItem parent, Class<?> c, String document, int lineno)
+ public ClassXmlItem(XmlItem parent, Class<?> c, Map<String, String> attributes, String document, int lineno)
{
- super(XmlItemType.CLASS, parent, c, null, null, document, lineno);
+ super(XmlItemType.CLASS, parent, c, null, attributes, document, lineno);
allowed.add(XmlItemType.ANNOTATION);
allowed.add(XmlItemType.FIELD);
allowed.add(XmlItemType.METHOD);
@@ -27,4 +34,40 @@
return allowed;
}
+ public Set<FieldValueXmlItem> getShorthandFieldValues()
+ {
+ Set<FieldValueXmlItem> values = new HashSet<FieldValueXmlItem>();
+ for (Entry<String, String> e : attributes.entrySet())
+ {
+
+ Field field = ReflectionUtils.getField(getJavaClass(), e.getKey());
+ if (field != null)
+ {
+ values.add(new FieldXmlItem(this, field, e.getValue(), document, lineno));
+ }
+ else
+ {
+ String methodName = "set" + Character.toUpperCase(e.getKey().charAt(0)) + e.getKey().substring(1);
+ if (ReflectionUtils.methodExists(getJavaClass(), methodName))
+ {
+ Set<Method> methods = ReflectionUtils.getMethods(getJavaClass());
+ for (Method m : methods)
+ {
+ if (m.getName().equals(methodName) && m.getParameterTypes().length == 1)
+ {
+ values.add(new PropertyXmlItem(this, e.getKey(), m, e.getValue(), document, lineno));
+ break;
+ }
+ }
+ }
+ else
+ {
+ throw new XmlConfigurationException("Could not resolve field: " + e.getKey(), document, lineno);
+ }
+ }
+
+ }
+ return values;
+ }
+
}
Added: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -0,0 +1,10 @@
+package org.jboss.seam.xml.model;
+
+import org.jboss.seam.xml.fieldset.FieldValueObject;
+
+public interface FieldValueXmlItem
+{
+ public FieldValueObject getFieldValue();
+
+ public String getFieldName();
+}
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-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -23,7 +23,7 @@
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
import org.jboss.seam.xml.util.XmlConfigurationException;
-public class FieldXmlItem extends AbstractXmlItem
+public class FieldXmlItem extends AbstractXmlItem implements FieldValueXmlItem
{
FieldValueSetter fieldSetter;
@@ -150,4 +150,9 @@
}
return new DirectFieldSetter(field);
}
+
+ public String getFieldName()
+ {
+ return field.getName();
+ }
}
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-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -53,6 +53,9 @@
Map<String, NamespaceElementResolver> resolvers;
+ /**
+ * builds an XML result from a parsed xml document
+ */
public XmlResult build(SaxNode root)
{
@@ -79,6 +82,7 @@
// nodes with a null namespace are whitespace nodes etc
if (node.getNamespaceUri() != null)
{
+ // ignore <alternatives> <interceptors> etc
if (node.getNamespaceUri().equals(BEANS_ROOT_NAMESPACE))
{
continue;
@@ -105,10 +109,13 @@
if (rb.getType() == XmlItemType.CLASS || rb.getType() == XmlItemType.ANNOTATION)
{
ResultType type = getItemType(rb);
+ // if we are configuring a bean
if (type == ResultType.BEAN)
{
- BeanResult<?> tp = buildAnnotatedType((ClassXmlItem) rb);
- if (rb.getJavaClass().isInterface())
+ ClassXmlItem cxml = (ClassXmlItem) rb;
+ // get the AnnotatedType information
+ BeanResult<?> tp = buildAnnotatedType(cxml);
+ if (cxml.getJavaClass().isInterface())
{
ret.addInterface(tp);
}
@@ -116,27 +123,33 @@
{
ret.addBean(tp);
}
+ // <override> or <speciailizes> need to veto the bean
if (tp.getBeanType() != BeanResultType.ADD)
{
ret.addVeto(tp.getType());
}
+ // get all the field values from the bean
+ Set<String> configuredFields = new HashSet<String>();
List<FieldValueObject> fields = new ArrayList<FieldValueObject>();
- for (FieldXmlItem xi : rb.getChildrenOfType(FieldXmlItem.class))
+ for (FieldValueXmlItem xi : cxml.getChildrenOfType(FieldValueXmlItem.class))
{
FieldValueObject f = xi.getFieldValue();
if (f != null)
{
fields.add(f);
+ configuredFields.add(xi.getFieldName());
}
}
- for (PropertyXmlItem xi : rb.getChildrenOfType(PropertyXmlItem.class))
+
+ for (FieldValueXmlItem f : cxml.getShorthandFieldValues())
{
- FieldValueObject f = xi.getFieldValue();
- if (f != null)
+ if (configuredFields.contains(f.getFieldName()))
{
- fields.add(f);
+ throw new XmlConfigurationException("Field configured in two places: " + cxml.getJavaClass().getName() + "." + f.getFieldName(), cxml.getDocument(), cxml.getLineno());
}
+ fields.add(f.getFieldValue());
}
+
if (!fields.isEmpty())
{
if (rb.getJavaClass().isInterface())
@@ -162,15 +175,9 @@
addStereotypeToResult(ret, rb);
}
}
- else if (rb.getType() == XmlItemType.VETO)
- {
- for (XmlItem it : rb.getChildren())
- {
- ret.addVeto(it.getJavaClass());
- }
- }
else if (rb.getType() == XmlItemType.GENERIC_BEAN)
{
+
GenericBeanXmlItem item = (GenericBeanXmlItem) rb;
Set<BeanResult<?>> classes = new HashSet<BeanResult<?>>();
for (ClassXmlItem c : rb.getChildrenOfType(ClassXmlItem.class))
@@ -186,6 +193,9 @@
}
}
+ /**
+ * resolves the appropriate java elements from the xml
+ */
protected XmlItem resolveNode(SaxNode node, XmlItem parent)
{
NamespaceElementResolver resolver = resolveNamepsace(node.getNamespaceUri());
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -21,7 +21,7 @@
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
import org.jboss.seam.xml.util.XmlConfigurationException;
-public class PropertyXmlItem extends AbstractXmlItem
+public class PropertyXmlItem extends AbstractXmlItem implements FieldValueXmlItem
{
FieldValueSetter fieldSetter;
@@ -120,4 +120,9 @@
return allowed;
}
+ public String getFieldName()
+ {
+ return name;
+ }
+
}
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-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -6,5 +6,5 @@
public enum XmlItemType
{
- CLASS, METHOD, FIELD, ANNOTATION, VALUE, VETO, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, SPECIALIZES, TYPE, GENERIC_BEAN;
+ CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, SPECIALIZES, TYPE, GENERIC_BEAN;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -67,7 +67,7 @@
}
else
{
- return new ClassXmlItem(parent, c, node.getDocument(), node.getLineNo());
+ return new ClassXmlItem(parent, c, node.getAttributes(), node.getDocument(), node.getLineNo());
}
}
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-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -121,7 +121,7 @@
}
else
{
- return new ClassXmlItem(parent, primType, node.getDocument(), node.getLineNo());
+ return new ClassXmlItem(parent, primType, node.getAttributes(), node.getDocument(), node.getLineNo());
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java 2010-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java 2010-04-23 23:46:04 UTC (rev 12624)
@@ -6,6 +6,8 @@
import java.math.BigDecimal;
+import javax.enterprise.util.AnnotationLiteral;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.seam.xml.test.method.QualifierEnum;
import org.testng.annotations.Test;
@@ -35,4 +37,22 @@
}
+ @Test
+ public void simpleShorthandFieldSetterTest()
+ {
+ FieldValueBean x = getReference(FieldValueBean.class, new AnnotationLiteral<FieldsetQualifier>()
+ {
+ });
+ assert x.bigDecimalValue.compareTo(BigDecimal.TEN) == 0;
+ assert x.bvalue == true;
+ assert x.dvalue == 0;
+ assert x.enumValue == QualifierEnum.A;
+ assert x.fvalue == 0;
+ assert x.getIvalue() == 11;
+ assert x.lvalue == 23;
+ assert x.svalue == 4;
+ assert x.noFieldValue == 7;
+
+ }
+
}
Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/set-field-value-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/set-field-value-beans.xml 2010-04-23 23:34:32 UTC (rev 12623)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/set-field-value-beans.xml 2010-04-23 23:46:04 UTC (rev 12624)
@@ -19,7 +19,11 @@
<test:noField>7</test:noField>
</test:FieldValueBean>
-
-
-
+ <test:FieldValueBean ivalue="10" stringValue="hello world" enumValue="A" fvalue="0" dvalue="0" bvalue="true" lvalue="23" svalue="4" bigDecimalValue="10" noField="7" >
+ <overrides/>
+ <test:init>
+ <Inject/>
+ </test:init>
+ <test:FieldsetQualifier/>
+ </test:FieldValueBean>
</beans>
\ No newline at end of file
14 years, 8 months
Seam SVN: r12623 - in modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools: interceptor and 1 other directory.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-04-23 19:34:32 -0400 (Fri, 23 Apr 2010)
New Revision: 12623
Modified:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java
Log:
added "untilHalt" attribute to insert fact interceptorbinding
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-04-23 23:22:36 UTC (rev 12622)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-04-23 23:34:32 UTC (rev 12623)
@@ -43,6 +43,7 @@
@Retention(RUNTIME)
public @interface InsertFact
{
- @Nonbinding boolean fire() default false;
+ @Nonbinding boolean fire() default false;
+ @Nonbinding boolean untilHalt() default false;
@Nonbinding String entrypoint() default "";
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java 2010-04-23 23:22:36 UTC (rev 12622)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java 2010-04-23 23:34:32 UTC (rev 12623)
@@ -54,6 +54,7 @@
public Object insertFact(InvocationContext ctx) throws Exception
{
boolean fire = false;
+ boolean untilHalt = false;
String entryPointName = null;
Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
@@ -66,6 +67,7 @@
if(manager.isInterceptorBinding(nextAnnotation.annotationType())) {
if(nextAnnotation instanceof InsertFact) {
fire = ((InsertFact) nextAnnotation).fire();
+ untilHalt = ((InsertFact) nextAnnotation).untilHalt();
entryPointName = ((InsertFact) nextAnnotation).entrypoint();
}
}
@@ -80,7 +82,11 @@
ksession.insert(retObj);
}
if(fire) {
- ksession.fireAllRules();
+ if(untilHalt) {
+
+ } else {
+ ksession.fireAllRules();
+ }
}
return retObj;
} else {
14 years, 8 months
Seam SVN: r12622 - in modules/drools/trunk: impl/src/main/java/org/jboss/seam/drools/annotations and 4 other directories.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-04-23 19:22:36 -0400 (Fri, 23 Apr 2010)
New Revision: 12622
Added:
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/FireRules.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/FireRulesInterceptor.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestConfig.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptorstestflow.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptortests.rf
Modified:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/AbortProcessInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/InterceptorsTest-beans.xml
Log:
added more interceptor tests for starting a process (signalling, aborting).
Modified: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -28,7 +28,6 @@
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;
@@ -42,7 +41,6 @@
@Target( { TYPE, METHOD, FIELD, PARAMETER })
@Documented
@Retention(RUNTIME)
-@Inherited
public @interface CEPPseudoClockConfig {
}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/FireRules.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/FireRules.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/FireRules.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -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.seam.drools.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+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.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@InterceptorBinding
+@Target( { TYPE, METHOD })
+@Documented
+@Retention(RUNTIME)
+public @interface FireRules
+{
+ @Nonbinding boolean untilHalt() default false;
+ @Nonbinding int limit() default -1;
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -50,5 +50,5 @@
String event() default "";
@Nonbinding
- String process() default "";
+ String processName() default "";
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -44,5 +44,11 @@
public @interface StartProcess
{
@Nonbinding
- String value() default "";
+ String name() default "";
+
+ @Nonbinding
+ boolean fire() default false;
+
+ @Nonbinding
+ boolean untilHalt() default false;
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/AbortProcessInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/AbortProcessInterceptor.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/AbortProcessInterceptor.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -18,9 +18,14 @@
* 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.interceptor;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
@@ -30,6 +35,7 @@
import javax.interceptor.InvocationContext;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
import org.jboss.seam.drools.annotations.flow.AbortProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,15 +46,56 @@
{
@Inject
BeanManager manager;
-
- @Inject @Any Instance<StatefulKnowledgeSession> ksessionSource;
-
+
+ @Inject
+ @Any
+ Instance<StatefulKnowledgeSession> ksessionSource;
+
private static final Logger log = LoggerFactory.getLogger(AbortProcessInterceptor.class);
-
+
@AroundInvoke
public Object abortProcess(InvocationContext ctx) throws Exception
{
- return ctx.proceed();
+
+ String processName = null;
+
+ Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
+ List<Annotation> annotationTypeList = new ArrayList<Annotation>();
+
+ for (Annotation nextAnnotation : methodAnnotations)
+ {
+ if (manager.isQualifier(nextAnnotation.annotationType()))
+ {
+ annotationTypeList.add(nextAnnotation);
+ }
+ if (manager.isInterceptorBinding(nextAnnotation.annotationType()))
+ {
+ if (nextAnnotation instanceof AbortProcess)
+ {
+ processName = ((AbortProcess) nextAnnotation).value();
+ }
+ }
+ }
+
+ StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[])annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
+ if(ksession != null) {
+ Object retObj = ctx.proceed();
+ if(processName != null && processName.length() > 0 ) {
+ Iterator<ProcessInstance> iter = ksession.getProcessInstances().iterator();
+ while(iter.hasNext()) {
+ ProcessInstance pi = iter.next();
+ if(pi.getProcessName().equals(processName)) {
+ ksession.abortProcessInstance(pi.getId());
+ }
+ }
+ } else {
+ log.info("Invalid process name: " + processName);
+ }
+ return retObj;
+ } else {
+ log.info("Could not obtain StatefulKnowledgeSession.");
+ return ctx.proceed();
+ }
}
}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/FireRulesInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/FireRulesInterceptor.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/FireRulesInterceptor.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -0,0 +1,101 @@
+/*
+ * 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.interceptor;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.jboss.seam.drools.annotations.FireRules;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@FireRules
+@Interceptor
+public class FireRulesInterceptor
+{
+ @Inject
+ BeanManager manager;
+
+ @Inject @Any Instance<StatefulKnowledgeSession> ksessionSource;
+
+ private static final Logger log = LoggerFactory.getLogger(FireRulesInterceptor.class);
+
+ @AroundInvoke
+ public Object fireRules(InvocationContext ctx) throws Exception
+ {
+ boolean untilHalt = false;
+ int limit = -1;
+
+ Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
+ List<Annotation> annotationTypeList = new ArrayList<Annotation>();
+
+ for (Annotation nextAnnotation : methodAnnotations)
+ {
+ if (manager.isQualifier(nextAnnotation.annotationType()))
+ {
+ annotationTypeList.add(nextAnnotation);
+ }
+ if (manager.isInterceptorBinding(nextAnnotation.annotationType()))
+ {
+ if (nextAnnotation instanceof FireRules)
+ {
+ untilHalt = ((FireRules) nextAnnotation).untilHalt();
+ limit = ((FireRules) nextAnnotation).limit();
+ }
+ }
+ }
+
+ final StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[])annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
+ if(ksession != null) {
+ Object retObj = ctx.proceed();
+ if(untilHalt) {
+ ksession.fireUntilHalt();
+ } else {
+ if(limit > 0) {
+ ksession.fireAllRules(limit);
+ } else {
+ ksession.fireAllRules();
+ }
+ }
+ return retObj;
+ } else {
+ log.info("Could not obtain StatefulKnowledgeSession.");
+ return ctx.proceed();
+ }
+
+ }
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -18,9 +18,14 @@
* 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.interceptor;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
@@ -30,24 +35,109 @@
import javax.interceptor.InvocationContext;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
import org.jboss.seam.drools.annotations.flow.SignalEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
@SignalEvent
@Interceptor
public class SignalEventInterceptor
{
@Inject
BeanManager manager;
-
- @Inject @Any Instance<StatefulKnowledgeSession> ksessionSource;
-
+
+ @Inject
+ @Any
+ Instance<StatefulKnowledgeSession> ksessionSource;
+
private static final Logger log = LoggerFactory.getLogger(SignalEventInterceptor.class);
-
+
@AroundInvoke
- public Object abortProcess(InvocationContext ctx) throws Exception
+ public Object signalEvent(InvocationContext ctx) throws Exception
{
- return ctx.proceed();
+ String processName = null;
+ String type = null;
+ String event = null;
+
+ Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
+ List<Annotation> annotationTypeList = new ArrayList<Annotation>();
+
+ for (Annotation nextAnnotation : methodAnnotations)
+ {
+ if (manager.isQualifier(nextAnnotation.annotationType()))
+ {
+ annotationTypeList.add(nextAnnotation);
+ }
+ if (manager.isInterceptorBinding(nextAnnotation.annotationType()))
+ {
+ if (nextAnnotation instanceof SignalEvent)
+ {
+ processName = ((SignalEvent) nextAnnotation).processName();
+ type = ((SignalEvent) nextAnnotation).type();
+ event = ((SignalEvent) nextAnnotation).event();
+ }
+ }
+ }
+
+ StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[]) annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
+ System.out.println("***** SEI ksession: " + ksession);
+ if (ksession != null)
+ {
+ Object retObj = ctx.proceed();
+ if (type != null)
+ {
+ if (processName != null && processName.length() > 0)
+ {
+ Iterator<ProcessInstance> iter = ksession.getProcessInstances().iterator();
+ while (iter.hasNext())
+ {
+ ProcessInstance pi = iter.next();
+ if (pi.getProcessName().equals(processName))
+ {
+ if (event != null && event.length() > 0)
+ {
+ System.out.println("***** signalling to process : " + type + " - " + event);
+ pi.signalEvent(type, event);
+ }
+ else
+ {
+ System.out.println("***** signalling to process : " + type + " - " + retObj);
+ pi.signalEvent(type, retObj);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (event != null && event.length() > 0)
+ {
+ System.out.println("***** signalling to ksession : " + type + " - " + event);
+ ksession.signalEvent(type, event);
+ }
+ else
+ {
+ System.out.println("***** signalling to ksession : " + type + " - " + retObj);
+ ksession.signalEvent(type, retObj);
+ }
+
+ }
+ }
+ else
+ {
+ log.error("Invalid type specified: " + type);
+ }
+ return retObj;
+ }
+ else
+ {
+ log.info("Could not obtain StatefulKnowledgeSession.");
+ return ctx.proceed();
+ }
+
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -21,6 +21,10 @@
*/
package org.jboss.seam.drools.interceptor;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
@@ -46,8 +50,47 @@
private static final Logger log = LoggerFactory.getLogger(StartProcessInterceptor.class);
@AroundInvoke
- public Object abortProcess(InvocationContext ctx) throws Exception
+ public Object startProcess(InvocationContext ctx) throws Exception
{
- return ctx.proceed();
+ String processName = null;
+ boolean fire = false;
+ boolean untilHalt = false;
+
+ Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
+ List<Annotation> annotationTypeList = new ArrayList<Annotation>();
+
+ for(Annotation nextAnnotation : methodAnnotations) {
+ if(manager.isQualifier(nextAnnotation.annotationType())) {
+ annotationTypeList.add(nextAnnotation);
+ }
+ if(manager.isInterceptorBinding(nextAnnotation.annotationType())) {
+ if(nextAnnotation instanceof StartProcess) {
+ processName = ((StartProcess) nextAnnotation).name();
+ fire = ((StartProcess) nextAnnotation).fire();
+ untilHalt = ((StartProcess) nextAnnotation).untilHalt();
+ }
+ }
+ }
+
+ final StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[])annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
+ if(ksession != null) {
+ Object retObj = ctx.proceed();
+ if(processName != null && processName.length() > 0 ) {
+ ksession.startProcess(processName);
+ if(fire) {
+ if(untilHalt) {
+ ksession.fireUntilHalt();
+ } else {
+ ksession.fireAllRules();
+ }
+ }
+ } else {
+ log.info("Invalid process name: " + processName);
+ }
+ return retObj;
+ } else {
+ log.info("Could not obtain StatefulKnowledgeSession.");
+ return ctx.proceed();
+ }
}
}
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -29,20 +29,18 @@
import java.util.Collection;
import javax.enterprise.inject.Default;
-import javax.inject.Inject;
-import javax.validation.constraints.AssertTrue;
import org.drools.runtime.ObjectFilter;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
import org.jboss.seam.drools.test.DroolsModuleFilter;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.formatter.Formatters;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.junit.Test;
@@ -59,8 +57,11 @@
.addPackages(true, new DroolsModuleFilter("interceptors"), KnowledgeBaseProducer.class.getPackage())
.addPackages(true, ResourceProvider.class.getPackage())
.addClass(Person.class).addClass(InterceptorsTestBean.class)
+ .addClass(InterceptorsTestConfig.class)
.addResource(pkgPath + "/interceptorstest.drl", ArchivePaths.create("interceptorstest.drl"))
.addResource(pkgPath + "/interceptorstestcep.drl", ArchivePaths.create("interceptorstestcep.drl"))
+ .addResource(pkgPath + "/interceptorstestflow.drl", ArchivePaths.create("interceptorstestflow.drl"))
+ .addResource(pkgPath + "/interceptortests.rf", ArchivePaths.create("interceptortests.rf"))
.addManifestResource(pkgPath + "/InterceptorsTest-beans.xml", ArchivePaths.create("beans.xml"));
// System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
@@ -107,4 +108,41 @@
assertNotNull(p);
assertTrue(p.isEligible());
}
+
+ @Test
+ public void testProcessStartAndSignal(InterceptorsTestBean ibean,
+ @Default @InterceptorsTestConfig StatefulKnowledgeSession ksession) {
+ assertNotNull(ibean);
+ assertNotNull(ksession);
+
+ ibean.getPersonForFlow();
+ Collection<?> allPeople1 = ksession.getObjects(new ObjectFilter()
+ {
+ public boolean accept(Object object)
+ {
+ return object instanceof Person;
+ }
+ });
+
+ Person p1 = (Person) allPeople1.toArray(new Object[0])[0];
+ assertNotNull(p1);
+ assertTrue(!p1.isEligible());
+
+ ibean.startProcess();
+
+ Collection<?> allPeople2 = ksession.getObjects(new ObjectFilter()
+ {
+ public boolean accept(Object object)
+ {
+ return object instanceof Person;
+ }
+ });
+
+ Person p2 = (Person) allPeople2.toArray(new Object[0])[0];
+ assertNotNull(p2);
+ assertTrue(p2.isEligible());
+
+
+
+ }
}
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -24,6 +24,9 @@
import javax.enterprise.inject.Default;
import org.jboss.seam.drools.annotations.InsertFact;
+import org.jboss.seam.drools.annotations.flow.AbortProcess;
+import org.jboss.seam.drools.annotations.flow.SignalEvent;
+import org.jboss.seam.drools.annotations.flow.StartProcess;
import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
@@ -44,4 +47,27 @@
p.setAge(33);
return p;
}
+
+ @InsertFact @Default @InterceptorsTestConfig
+ public Person getPersonForFlow() {
+ Person p = new Person();
+ p.setEligible(false);
+ p.setAge(55);
+ return p;
+ }
+
+ @StartProcess(name="interceptorstestflow", fire=true) @Default @InterceptorsTestConfig
+ public void startProcess() {
+ // this will start the process....
+ }
+
+ @SignalEvent(type="signal", processName="interceptorstestflow") @Default @InterceptorsTestConfig
+ public String signalEvent() {
+ return "continue";
+ }
+
+ @AbortProcess("interceptorstestflow") @Default @InterceptorsTestConfig
+ public void abortProcess() {
+ // this will abort the process....
+ }
}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestConfig.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestConfig.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestConfig.java 2010-04-23 23:22:36 UTC (rev 12622)
@@ -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.seam.drools.test.interceptors;
+
+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;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+public @interface InterceptorsTestConfig
+{
+
+}
Modified: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/InterceptorsTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/InterceptorsTest-beans.xml 2010-04-23 23:12:28 UTC (rev 12621)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/InterceptorsTest-beans.xml 2010-04-23 23:22:36 UTC (rev 12622)
@@ -26,6 +26,10 @@
<interceptors>
<class>org.jboss.seam.drools.interceptor.InsertFactInterceptor</class>
+ <class>org.jboss.seam.drools.interceptor.FireRulesInterceptor</class>
+ <class>org.jboss.seam.drools.interceptor.StartProcessInterceptor</class>
+ <class>org.jboss.seam.drools.interceptor.SignalEventInterceptor</class>
+ <class>org.jboss.seam.drools.interceptor.AbortProcessInterceptor</class>
</interceptors>
<d:DefaultRuleResources>
@@ -41,5 +45,23 @@
<s:value>classpath;interceptorstestcep.drl;DRL</s:value>
</d:resources>
</d:CEPPseudoClockRuleResources>
+
+
+ <d:RuleResources>
+ <s:overrides/>
+ <test:InterceptorsTestConfig/>
+ <d:resources>
+ <s:value>classpath;interceptorstestflow.drl;DRL</s:value>
+ <s:value>classpath;interceptortests.rf;DRF</s:value>
+ </d:resources>
+ </d:RuleResources>
+ <d:DroolsConfig>
+ <test:InterceptorsTestConfig/>
+ <d:ruleResources>
+ <s:Inject/>
+ <test:InterceptorsTestConfig/>
+ </d:ruleResources>
+ </d:DroolsConfig>
+
</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptorstestflow.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptorstestflow.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptorstestflow.drl 2010-04-23 23:22:36 UTC (rev 12622)
@@ -0,0 +1,15 @@
+package org.jboss.seam.drools.test.interceptors
+
+import org.jboss.seam.drools.test.interceptors.Person;
+
+rule "is person eligible for buss pass"
+lock-on-active
+ruleflow-group "BusinessRules"
+when
+ $p : Person( age >=18 )
+then
+ System.out.println("*****************\nIN RULE \n ***************");
+ modify($p) {
+ setEligible(true);
+ }
+end
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptortests.rf
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptortests.rf (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/interceptors/interceptortests.rf 2010-04-23 23:22:36 UTC (rev 12622)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://drools.org/drools-5.0/process"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
+ type="RuleFlow" name="interceptorstestflow" id="interceptorstestflow" package-name="org.jboss.seam.drools.test.interceptors" >
+
+ <header>
+ </header>
+
+ <nodes>
+ <start id="1" name="Start" x="32" y="16" width="48" height="48" />
+ <end id="2" name="End" x="16" y="168" width="80" height="40" />
+ <ruleSet id="4" name="BusinessRules" x="16" y="96" width="80" height="40" ruleFlowGroup="BusinessRules" />
+ </nodes>
+
+ <connections>
+ <connection from="4" to="2" />
+ <connection from="1" to="4" />
+ </connections>
+
+</process>
\ No newline at end of file
14 years, 8 months
Seam SVN: r12621 - in modules/xml/trunk/impl/src/test: resources/org/jboss/seam/xml/test/generic and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-04-23 19:12:28 -0400 (Fri, 23 Apr 2010)
New Revision: 12621
Modified:
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericDependant.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericMain.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml
Log:
update generic beans test
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java 2010-04-23 21:45:10 UTC (rev 12620)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java 2010-04-23 23:12:28 UTC (rev 12621)
@@ -32,4 +32,21 @@
;
}
+ @Test
+ public void genericBeansInitMethodTest()
+ {
+ GenericDependant dep = getReference(GenericDependant.class, new AnnotationLiteral<HighGenericQualifier>()
+ {
+ });
+ assert dep.initCalled;
+ dep = getReference(GenericDependant.class, new AnnotationLiteral<LowGenericQualifier>()
+ {
+ });
+ assert dep.initCalled;
+ GenericMain main = getReference(GenericMain.class, new AnnotationLiteral<LowGenericQualifier>()
+ {
+ });
+ assert main.init;
+ }
+
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericDependant.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericDependant.java 2010-04-23 21:45:10 UTC (rev 12620)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericDependant.java 2010-04-23 23:12:28 UTC (rev 12621)
@@ -7,6 +7,14 @@
@Inject
GenericMain instance;
+ boolean initCalled = false;
+
+ @Inject
+ public void init()
+ {
+ initCalled = true;
+ }
+
public int getValue()
{
return instance.getConfiguredValue() + 1;
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericMain.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericMain.java 2010-04-23 21:45:10 UTC (rev 12620)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericMain.java 2010-04-23 23:12:28 UTC (rev 12621)
@@ -1,9 +1,19 @@
package org.jboss.seam.xml.test.generic;
+import javax.inject.Inject;
+
public class GenericMain
{
int configuredValue;
+ boolean init = false;
+
+ @Inject
+ public void setup()
+ {
+ init = true;
+ }
+
public int getConfiguredValue()
{
return configuredValue;
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-04-23 21:45:10 UTC (rev 12620)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/generic/generic-beans.xml 2010-04-23 23:12:28 UTC (rev 12621)
@@ -12,12 +12,12 @@
</test:GenericDependant>
</genericBean>
- <test:GenericMain>
+ <test:GenericMain><specializes/>
<test:HighGenericQualifier/>
<test:configuredValue><value>100</value></test:configuredValue>
</test:GenericMain>
- <test:GenericMain>
+ <test:GenericMain><specializes/>
<test:LowGenericQualifier/>
<test:configuredValue><value>10</value></test:configuredValue>
</test:GenericMain>
14 years, 8 months