Seam SVN: r12529 - in modules/drools/trunk: api/src/main/java/org/jboss/seam/drools/annotations and 19 other directories.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-04-20 12:21:25 -0400 (Tue, 20 Apr 2010)
New Revision: 12529
Added:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/
modules/drools/trunk/api/src/main/java/org/jboss/seam/…
[View More]drools/qualifiers/config/CEPPseudoClockConfig.java
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/DefaultConfig.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java
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/DefaultRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/KAgentTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentconfig.properties
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentestchangeset.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl
Removed:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java
Modified:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml
Log:
added more tests and producers for executionresults (stateless session).
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Interface for fact data providers.
+ *
+ * @author Tihomir Surdilovic
+ */
+public interface FactProvider {
+ public List<Object> getFacts();
+
+ public void setFacts(List<Object> facts);
+
+ public Map<String, Object> getGlobals();
+
+ public void setGlobals(Map<String, Object> globals);
+
+ public List<String> getQueries();
+
+ public void setQueries(List<String> queries);
+}
Modified: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,13 +21,6 @@
*/
package org.jboss.seam.drools;
-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 java.util.Collection;
import java.util.Map;
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java (from rev 12499, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/EntryPoint.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.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;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface EntryPoint {
+ String value() default "";
+}
Copied: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java (from rev 12499, modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java)
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/annotations/Query.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.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;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface Query {
+ String value() default "";
+}
Deleted: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/EntryPoint.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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;
-
-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.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
-@Qualifier
-@Target( { TYPE, METHOD, FIELD, PARAMETER })
-@Documented
-@Retention(RUNTIME)
-@Inherited
-public @interface EntryPoint {
- @Nonbinding String value() default "";
-}
Deleted: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Query.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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;
-
-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.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-
-/**
- *
- * @author Tihomir Surdilovic
- */
-@Qualifier
-@Target( { TYPE, METHOD, FIELD, PARAMETER })
-@Documented
-@Retention(RUNTIME)
-@Inherited
-public @interface Query {
- @Nonbinding String value() default "";
-}
Added: 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 (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPPseudoClockConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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 CEPPseudoClockConfig {
+
+}
Added: 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 (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/CEPRealitimeClockConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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 CEPRealitimeClockConfig {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/DefaultConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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 DefaultConfig {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/config/MVELDialectConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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 MVELDialectConfig {
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/EntryPointProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,12 +21,16 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
-import org.jboss.seam.drools.qualifiers.EntryPoint;
+import org.jboss.seam.drools.annotations.EntryPoint;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,19 +39,20 @@
*
* @author Tihomir Surdilovic
*/
-public class EntryPointProducer
+@SessionScoped
+public class EntryPointProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(EntryPointProducer.class);
@Produces
- @EntryPoint
public WorkingMemoryEntryPoint produceEntryPoint(StatefulKnowledgeSession ksession, InjectionPoint ip) throws Exception
{
String entryPointName = ip.getAnnotated().getAnnotation(EntryPoint.class).value();
if (entryPointName != null && entryPointName.length() > 0)
{
log.debug("EntryPoint Name requested: " + entryPointName);
- return ksession.getWorkingMemoryEntryPoint(entryPointName);
+ WorkingMemoryEntryPoint entryPoint = ksession.getWorkingMemoryEntryPoint( entryPointName );
+ return entryPoint;
}
else
{
@@ -56,7 +61,6 @@
}
@Produces
- @EntryPoint
@Scanned
public WorkingMemoryEntryPoint produceScannedEntryPoint(@Scanned StatefulKnowledgeSession ksession, InjectionPoint ip) throws Exception
{
@@ -64,7 +68,7 @@
if (entryPointName != null && entryPointName.length() > 0)
{
log.debug("EntryPoint Name requested: " + entryPointName);
- return ksession.getWorkingMemoryEntryPoint(ip.getAnnotated().getAnnotation(EntryPoint.class).value());
+ return ksession.getWorkingMemoryEntryPoint(entryPointName);
}
else
{
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExcecutionResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,27 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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;
-
-public class ExcecutionResultsProducer
-{
-
-}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.drools.command.CommandFactory;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.jboss.seam.drools.bootstrap.DroolsExtension;
+import org.jboss.seam.drools.qualifiers.Scanned;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@SessionScoped
+public class ExecutionResultsProducer implements Serializable
+{
+ private static final Logger log = LoggerFactory.getLogger(ExecutionResultsProducer.class);
+
+ @Inject
+ BeanManager manager;
+
+ @Inject
+ ResourceProvider resourceProvider;
+
+ @Inject
+ DroolsExtension droolsExtension;
+
+ @SuppressWarnings("unchecked")
+ @Produces
+ @RequestScoped
+ public ExecutionResults produceExecutionResults(StatelessKnowledgeSession ksession) {
+ return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Produces
+ @Scanned
+ @RequestScoped
+ public ExecutionResults produceScannedExecutionResults(@Scanned StatelessKnowledgeSession ksession) {
+ return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
+ }
+
+ @SuppressWarnings("unchecked")
+ private List getCommandList() {
+ List commandList = new ArrayList();
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getGlobals() != null) {
+ Iterator<Entry<String, Object>> globalIterator = factProvider.getGlobals().entrySet().iterator();
+ while(globalIterator.hasNext()) {
+ Entry<String, Object> nextEntry = globalIterator.next();
+ commandList.add(CommandFactory.newSetGlobal(nextEntry.getKey(), nextEntry.getValue()));
+ }
+ }
+
+ if(factProvider.getFacts() != null) {
+ for(Object nextFact : factProvider.getFacts()) {
+ commandList.add(CommandFactory.newInsert(nextFact));
+ }
+ }
+ if(factProvider.getQueries() != null) {
+ for(Object nextQuery : factProvider.getQueries()) {
+ commandList.add(CommandFactory.newQuery((String) nextQuery, (String) nextQuery));
+ }
+ }
+ }
+ return commandList;
+ }
+
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -18,138 +18,127 @@
* 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;
-import java.util.Properties;
+import java.io.Serializable;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
import org.drools.agent.KnowledgeAgent;
-import org.drools.agent.KnowledgeAgentConfiguration;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.builder.ResourceType;
-import org.drools.io.ResourceChangeScannerConfiguration;
import org.drools.io.ResourceFactory;
-import org.jboss.seam.drools.config.DroolsConfiguration;
-import org.jboss.seam.drools.events.RuleResourceAddedEvent;
+import org.jboss.seam.drools.config.DroolsConfig;
+import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * KnowledgeAgent producer.
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeAgentProducer
+@ApplicationScoped
+public class KnowledgeAgentProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeAgentProducer.class);
@Inject
BeanManager manager;
+
@Inject
ResourceProvider resourceProvider;
@Produces
@Scanned
- public KnowledgeBase produceScannedKnowledgeBase(DroolsConfiguration kagentConfig) throws Exception
+ @ApplicationScoped
+ public KnowledgeBase produceScannedKnowledgeBase(DroolsConfig config) throws Exception
{
- ResourceFactory.getResourceChangeScannerService().configure(getResourceChangeScannerConfig(kagentConfig.getResourceChangeScannerConfigPath()));
- KnowledgeAgentConfiguration aconf = getKnowledgeAgentConfiguration(kagentConfig.getKnowledgeAgentConfigPath());
+ if (config.getAgentName() == null || config.getAgentName().length() < 1)
+ {
+ throw new IllegalStateException("KnowledgeAgent configuration does not specify the name of the KnowlegeAgent.");
+ }
- KnowledgeAgent kagent;
- kagent = KnowledgeAgentFactory.newKnowledgeAgent(kagentConfig.getKnowledgeAgentName(), aconf);
- applyChangeSet(kagent, kagentConfig.getChangeSetResource());
+ if(config.getRuleResources().getResources() == null || config.getRuleResources().getResources().length == 0)
+ {
+ throw new IllegalStateException("No change set rule resource specified.");
+ }
- if(kagentConfig.isStartChangeNotifierService()) {
+ if(config.getRuleResources().getResources().length > 0) {
+ throw new IllegalStateException("More than one change set rule resource specified for KnowledgeAgent. Make sure only a single change set resource is specified.");
+ }
+
+ ResourceFactory.getResourceChangeScannerService().configure(config.getResourceChangeScannerConfiguration());
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config.getKnowledgeBaseConfiguration());
+ KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(config.getAgentName(), kbase, config.getKnowledgeAgentConfiguration());
+
+ applyChangeSet(kagent, config.getRuleResources().getResources()[0]);
+
+ if (config.isStartChangeNotifierService())
+ {
ResourceFactory.getResourceChangeNotifierService().start();
}
- if(kagentConfig.isStartChangeScannerService()) {
+ if (config.isStartChangeScannerService())
+ {
ResourceFactory.getResourceChangeScannerService().start();
}
-
+
return kagent.getKnowledgeBase();
-
+
}
-
- public void disposeScannedKnowledgeBase(@Disposes @Scanned KnowledgeBase kbase) {
+
+ public void disposeScannedKnowledgeBase(@Disposes @Scanned KnowledgeBase kbase)
+ {
+ // do we really want to stop ?
ResourceFactory.getResourceChangeNotifierService().stop();
ResourceFactory.getResourceChangeScannerService().stop();
}
-
- private void applyChangeSet(KnowledgeAgent kagent, String changeSetResource) {
- if (ConfigUtils.isValidResource(changeSetResource))
+
+ private void applyChangeSet(KnowledgeAgent kagent, String entry)
+ {
+ String[] entryParts = RuleResources.DIVIDER.split(entry.trim());
+
+ if (entryParts.length >= 3)
{
- ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(changeSetResource));
- if(resourceType.equals(ResourceType.CHANGE_SET)) {
- if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_URL))
+ ResourceType resourceType = ResourceType.getResourceType(entryParts[RuleResources.RESOURCE_TYPE]);
+ if (resourceType.equals(ResourceType.CHANGE_SET))
+ {
+ if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_URL))
{
- kagent.applyChangeSet(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newUrlResource(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_FILE))
{
- kagent.applyChangeSet(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newFileResource(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(changeSetResource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_CLASSPATH))
{
- kagent.applyChangeSet(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(changeSetResource)));
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(changeSetResource)));
+ kagent.applyChangeSet(ResourceFactory.newClassPathResource(entryParts[RuleResources.RESOURCE_PATH]));
}
else
{
- log.error("Invalid resource: " + ConfigUtils.getResourcePath(changeSetResource));
+ log.error("Invalid resource: " + entry);
}
- } else {
+ }
+ else
+ {
log.error("Resource must be of type CHANGE_SET");
}
- } else {
- log.error("Invalid resource definition: " + changeSetResource);
}
-
-
- }
-
- private ResourceChangeScannerConfiguration getResourceChangeScannerConfig(String resourceChangeScannerConfigPath) throws Exception
- {
- ResourceChangeScannerConfiguration sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
-
- if (resourceChangeScannerConfigPath != null && resourceChangeScannerConfigPath.endsWith(".properties"))
- {
- Properties resourceChangeScannerConfProp = ConfigUtils.loadProperties(resourceProvider, resourceChangeScannerConfigPath);
- sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration(resourceChangeScannerConfProp);
- log.debug("ResourceChangeScannerConfiguration loaded: " + resourceChangeScannerConfigPath);
- }
else
{
- log.warn("Invalid config type: " + resourceChangeScannerConfigPath);
+ log.error("Invalid resource definition: " + entry);
}
-
- return sconf;
}
- private KnowledgeAgentConfiguration getKnowledgeAgentConfiguration(String knowledgeAgentConfigPath) throws Exception
- {
- KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
-
- if (knowledgeAgentConfigPath != null && knowledgeAgentConfigPath.endsWith(".properties"))
- {
- Properties knowledgeAgentConfProp = ConfigUtils.loadProperties(resourceProvider, knowledgeAgentConfigPath);
- aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(knowledgeAgentConfProp);
- log.debug("KnowledgeAgentConfiguration loaded: " + knowledgeAgentConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeAgentConfigPath);
- }
-
- return aconf;
- }
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -23,19 +23,18 @@
import java.io.InputStream;
import java.io.Reader;
+import java.io.Serializable;
import java.io.StringReader;
import java.util.Iterator;
-import java.util.Properties;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
@@ -44,10 +43,10 @@
import org.drools.io.ResourceFactory;
import org.drools.template.ObjectDataCompiler;
import org.jboss.seam.drools.bootstrap.DroolsExtension;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
+import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +55,8 @@
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeBaseProducer
+@ApplicationScoped
+public class KnowledgeBaseProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseProducer.class);
@@ -70,14 +70,18 @@
DroolsExtension droolsExtension;
@Produces
- public KnowledgeBase produceKnowledgeBase(DroolsConfiguration kbaseConfig) throws Exception
+ @ApplicationScoped
+ public KnowledgeBase produceKnowledgeBase(DroolsConfig config) throws Exception
{
- KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig.getKnowledgeBuilderConfigPath()));
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config.getKnowledgeBuilderConfiguration());
- for (String nextResource : kbaseConfig.getRuleResources())
- {
- addResource(kbuilder, nextResource);
+ if(config.getRuleResources().getResources() == null || config.getRuleResources().getResources().length == 0) {
+ throw new IllegalStateException("No rule resources are specified.");
}
+
+ for(String resourceEntry : config.getRuleResources().getResources()) {
+ addResource(kbuilder, resourceEntry);
+ }
KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
if (kbuildererrors.size() > 0)
@@ -89,7 +93,7 @@
manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
}
- KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(getKnowledgeBaseConfiguration(kbaseConfig.getKnowledgeBaseConfigPath()));
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config.getKnowledgeBaseConfiguration());
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
addEventListeners(kbase);
@@ -108,50 +112,23 @@
}
}
- private KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration(String knowledgeBuilderConfigPath) throws Exception
+ private void addResource(KnowledgeBuilder kbuilder, String entry) throws Exception
{
- KnowledgeBuilderConfiguration droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
- if (knowledgeBuilderConfigPath != null && knowledgeBuilderConfigPath.endsWith(".properties"))
+ String[] entryParts = RuleResources.DIVIDER.split(entry.trim());
+
+ if (entryParts.length >= 3)
{
+ ResourceType resourceType = ResourceType.getResourceType(entryParts[RuleResources.RESOURCE_TYPE]);
- Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBuilderConfigPath);
- droolsKbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeBuilderConfigPath);
- }
- return droolsKbuilderConfig;
- }
-
- public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration(String knowledgeBaseConfigPath) throws Exception
- {
- KnowledgeBaseConfiguration droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
- if (knowledgeBaseConfigPath != null && knowledgeBaseConfigPath.endsWith(".properties"))
- {
- Properties kbaseProp = ConfigUtils.loadProperties(resourceProvider, knowledgeBaseConfigPath);
- droolsKbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
- log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfigPath);
- }
- return droolsKbaseConfig;
- }
-
- private void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
- {
- if (ConfigUtils.isValidResource(resource))
- {
- ResourceType resourceType = ResourceType.getResourceType(ConfigUtils.getResourceType(resource));
-
- if (ConfigUtils.isRuleTemplate(resource))
+ if (entryParts.length == 4)
{
- TemplateDataProvider templateDataProvider = droolsExtension.getTemplateDataProviders().get(ConfigUtils.getTemplateData(resource));
+ TemplateDataProvider templateDataProvider = droolsExtension.getTemplateDataProviders().get(entryParts[RuleResources.TEMPLATE_DATAPROVIDER_NAME]);
if (templateDataProvider != null)
{
- InputStream templateStream = resourceProvider.loadResourceStream(ConfigUtils.getRuleResource(resource));
+ InputStream templateStream = resourceProvider.loadResourceStream(entryParts[RuleResources.RESOURCE_PATH]);
if (templateStream == null)
{
- throw new IllegalStateException("Could not load rule template: " + ConfigUtils.getRuleResource(resource));
+ throw new IllegalStateException("Could not load rule template: " + entryParts[RuleResources.RESOURCE_PATH]);
}
ObjectDataCompiler converter = new ObjectDataCompiler();
String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
@@ -162,35 +139,35 @@
}
else
{
- throw new IllegalStateException("Requested template data provider: " + ConfigUtils.getTemplateData(resource) + " for resource " + resource + " has not been created. Check to make sure you have defined one.");
+ throw new IllegalStateException("Requested template data provider: " + entryParts[RuleResources.TEMPLATE_DATAPROVIDER_NAME] + " for resource " + entryParts[RuleResources.RESOURCE_PATH] + " has not been created. Check to make sure you have defined one.");
}
}
else
{
- if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_URL))
+ if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_URL))
{
- kbuilder.add(ResourceFactory.newUrlResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newUrlResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_FILE))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_FILE))
{
- kbuilder.add(ResourceFactory.newFileResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newFileResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
- else if (ConfigUtils.getResourcePath(resource).equals(ConfigUtils.RESOURCE_TYPE_CLASSPATH))
+ else if (entryParts[RuleResources.LOCATION_TYPE].equals(RuleResources.LOCATION_TYPE_CLASSPATH))
{
- kbuilder.add(ResourceFactory.newClassPathResource(ConfigUtils.getRuleResource(resource)), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(ConfigUtils.getRuleResource(resource)));
+ kbuilder.add(ResourceFactory.newClassPathResource(entryParts[RuleResources.RESOURCE_PATH]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(entryParts[RuleResources.RESOURCE_PATH]));
}
else
{
- log.error("Invalid resource: " + ConfigUtils.getResourcePath(resource));
+ log.error("Invalid resource: " + entryParts[RuleResources.RESOURCE_PATH]);
}
}
}
else
{
- log.error("Invalid resource definition: " + resource);
+ log.error("Invalid resource entry definition: " + entry);
}
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeLoggerProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -18,9 +18,13 @@
* 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;
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -29,65 +33,85 @@
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * Producer for stateful and stateless KnowledgerRuntimeLogger.
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeLoggerProducer
+@SessionScoped
+public class KnowledgeLoggerProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeLoggerProducer.class);
@Produces
- public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(StatefulKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceStatefulKnowledgeLogger(StatefulKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
-
+
@Produces
@Scanned
- public KnowledgeRuntimeLogger produceScannedStatefulKnowledgeLogger(@Scanned StatefulKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceScannedStatefulKnowledgeLogger(@Scanned StatefulKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
@Produces
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(StatelessKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceStatelessKnowledgeLogger(StatelessKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
-
+
@Produces
@Scanned
- public KnowledgeRuntimeLogger produceStatelessKnowledgeLoggerForKAgent(@Scanned StatelessKnowledgeSession ksession, DroolsConfiguration loggerConfig)
+ @RequestScoped
+ public KnowledgeRuntimeLogger produceScannedStatelessKnowledgeLogger(@Scanned StatelessKnowledgeSession ksession, DroolsConfig config)
{
- return getLogger(ksession, loggerConfig);
+ return getLogger(ksession, config);
}
- private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, DroolsConfiguration loggerConfig)
+ private KnowledgeRuntimeLogger getLogger(KnowledgeRuntimeEventManager ksession, DroolsConfig config)
{
KnowledgeRuntimeLogger krLogger = null;
- if (loggerConfig.getLoggerType().equalsIgnoreCase("file"))
+ if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("file"))
{
- String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
- krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ if (config.getLoggerPath() == null || config.getLoggerName() == null)
+ {
+ log.error("Invalid file logger information - path: " + config.getLoggerPath() + ", name: " + config.getLoggerName());
+ }
+ else
+ {
+ String logName = config.getLoggerPath() + config.getLoggerName() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, logName);
+ }
}
- else if (loggerConfig.getLoggerType().equalsIgnoreCase("console"))
+ else if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("console"))
{
krLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
}
- else if (loggerConfig.getLoggerType().equalsIgnoreCase("threaded"))
+ else if (config.getLoggerType() != null && config.getLoggerType().equalsIgnoreCase("threaded"))
{
- String logName = loggerConfig.getLoggerPath() + System.currentTimeMillis();
- krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, loggerConfig.getLoggerInterval());
+ if (config.getLoggerPath() == null || config.getLoggerName() == null || config.getLoggerInterval() == -1)
+ {
+ log.error("Invalid threaded logger information - path: " + config.getLoggerPath() + ", name: " + config.getLoggerName() + ", interval: " + config.getLoggerInterval());
+ }
+ else
+ {
+ String logName = config.getLoggerPath() + config.getLoggerName() + System.currentTimeMillis();
+ krLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, logName, config.getLoggerInterval());
+ }
}
else
{
- log.error("Invalid logger specified: type: " + loggerConfig.getLoggerType() + " path: " + loggerConfig.getLoggerPath() + " interval: " + loggerConfig.getLoggerInterval());
+ log.error("Invalid logger specified: type: " + config.getLoggerType() + " path: " + config.getLoggerPath() + " interval: " + config.getLoggerInterval());
}
return krLogger;
}
@@ -96,8 +120,9 @@
{
logger.close();
}
-
- public void disposeScannedKnowledgeRuntimeLogger(@Disposes @Scanned KnowledgeRuntimeLogger logger) {
+
+ public void disposeScannedKnowledgeRuntimeLogger(@Disposes @Scanned KnowledgeRuntimeLogger logger)
+ {
logger.close();
}
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,27 +21,27 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
import java.util.Iterator;
-import java.util.Properties;
+import java.util.Map.Entry;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseFactory;
import org.drools.event.KnowledgeRuntimeEventManager;
import org.drools.event.process.ProcessEventListener;
import org.drools.event.rule.AgendaEventListener;
import org.drools.event.rule.WorkingMemoryEventListener;
-import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.jboss.seam.drools.bootstrap.DroolsExtension;
-import org.jboss.seam.drools.config.DroolsConfiguration;
+import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.seam.drools.utils.ConfigUtils;
import org.jboss.weld.extensions.resources.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,7 +50,8 @@
*
* @author Tihomir Surdilovic
*/
-public class KnowledgeSessionProducer
+@SessionScoped
+public class KnowledgeSessionProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeSessionProducer.class);
@@ -64,42 +65,48 @@
DroolsExtension droolsExtension;
@Produces
- public StatefulKnowledgeSession produceStatefulSession(KnowledgeBase kbase,DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatefulKnowledgeSession produceStatefulSession(KnowledgeBase kbase,DroolsConfig config) throws Exception
{
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), null);
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(config.getKnowledgeSessionConfiguration(), null);
addEventListeners(ksession);
addWorkItemHandlers(ksession);
+ addFactProviders(ksession);
return ksession;
}
@Produces
@Scanned
- public StatefulKnowledgeSession produceScannedStatefulSession(@Scanned KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatefulKnowledgeSession produceScannedStatefulSession(@Scanned KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()), null);
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(config.getKnowledgeSessionConfiguration(), null);
addEventListeners(ksession);
addWorkItemHandlers(ksession);
+ addFactProviders(ksession);
return ksession;
}
@Produces
@Scanned
- public StatelessKnowledgeSession produceScannedStatelessSession(@Scanned KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatelessKnowledgeSession produceScannedStatelessSession(@Scanned KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(config.getKnowledgeSessionConfiguration());
addEventListeners(ksession);
-
+
return ksession;
}
@Produces
- public StatelessKnowledgeSession produceStatelessSession(KnowledgeBase kbase, DroolsConfiguration ksessionConfig) throws Exception
+ @RequestScoped
+ public StatelessKnowledgeSession produceStatelessSession(KnowledgeBase kbase, DroolsConfig config) throws Exception
{
- StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(getConfig(ksessionConfig.getKnowledgeSessionConfigPath()));
+ StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(config.getKnowledgeSessionConfiguration());
addEventListeners(ksession);
-
+
return ksession;
}
@@ -108,23 +115,10 @@
session.dispose();
}
+ public void disposeScannedStatefulSession(@Disposes @Scanned StatefulKnowledgeSession session) {
+ session.dispose();
+ }
- private KnowledgeSessionConfiguration getConfig(String knowledgeSessionConfigPath) throws Exception
- {
- KnowledgeSessionConfiguration droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
- if (knowledgeSessionConfigPath != null && knowledgeSessionConfigPath.endsWith(".properties"))
- {
- Properties ksessionProp = ConfigUtils.loadProperties(resourceProvider, knowledgeSessionConfigPath);
- droolsKsessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(ksessionProp);
- log.debug("KnowledgeSessionConfiguration loaded: " + knowledgeSessionConfigPath);
- }
- else
- {
- log.warn("Invalid config type: " + knowledgeSessionConfigPath);
- }
- return droolsKsessionConfig;
- }
-
private void addEventListeners(KnowledgeRuntimeEventManager ksession)
{
Iterator<Object> iter = droolsExtension.getKsessionEventListenerSet().iterator();
@@ -160,4 +154,25 @@
ksession.getWorkItemManager().registerWorkItemHandler(name, droolsExtension.getWorkItemHandlers().get(name));
}
}
+
+ private void addFactProviders(StatefulKnowledgeSession ksession) {
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getGlobals() != null) {
+ Iterator<Entry<String, Object>> globalIterator = factProvider.getGlobals().entrySet().iterator();
+ while(globalIterator.hasNext()) {
+ Entry<String, Object> nextEntry = globalIterator.next();
+ ksession.setGlobal(nextEntry.getKey(), nextEntry.getValue());
+ }
+ }
+
+ if(factProvider.getFacts() != null) {
+ for(Object nextFact : factProvider.getFacts()) {
+ ksession.insert(nextFact);
+ }
+ }
+ }
+ }
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/QueryResultsProducer.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,12 +21,15 @@
*/
package org.jboss.seam.drools;
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.QueryResults;
-import org.jboss.seam.drools.qualifiers.Query;
+import org.jboss.seam.drools.annotations.Query;
import org.jboss.seam.drools.qualifiers.Scanned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,12 +38,12 @@
*
* @author Tihomir Surdilovic
*/
-public class QueryResultsProducer
+@SessionScoped
+public class QueryResultsProducer implements Serializable
{
private static final Logger log = LoggerFactory.getLogger(QueryResultsProducer.class);
@Produces
- @Query
public QueryResults produceQueryResults(StatefulKnowledgeSession ksession, InjectionPoint ip)
{
String queryName = ip.getAnnotated().getAnnotation(Query.class).value();
@@ -56,7 +59,6 @@
}
@Produces
- @Query
@Scanned
public QueryResults produceScannedQueryResults(@Scanned StatefulKnowledgeSession ksession, InjectionPoint ip) {
String queryName = ip.getAnnotated().getAnnotation(Query.class).value();
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/bootstrap/DroolsExtension.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -38,6 +38,7 @@
import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
import org.drools.runtime.process.WorkItemHandler;
+import org.jboss.seam.drools.FactProvider;
import org.jboss.seam.drools.TemplateDataProvider;
import org.jboss.seam.drools.qualifiers.KBaseEventListener;
import org.jboss.seam.drools.qualifiers.KSessionEventListener;
@@ -53,6 +54,7 @@
private Set<Object> ksessionEventListenerSet = new HashSet<Object>();
private Map<String, WorkItemHandler> workItemHandlers = new HashMap<String, WorkItemHandler>();
private Map<String, TemplateDataProvider> templateDataProviders = new HashMap<String, TemplateDataProvider>();
+ private Set<FactProvider> factProviderSet = new HashSet<FactProvider>();
@SuppressWarnings("serial")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
@@ -125,12 +127,30 @@
}
log.info("End creating [" + (allTemplateProviders == null ? 0 : allTemplateProviders.size())+ "] template data providers");
+ //Fact Providers
+ log.info("Start creating fact providers");
+ Set<Bean<?>> allFactProviders = bm.getBeans(FactProvider.class, new AnnotationLiteral<Any>() {});
+ if(allFactProviders != null) {
+ Iterator<Bean<?>> factProviderIterator = allFactProviders.iterator();
+ while (factProviderIterator.hasNext()) {
+ Bean<?> factProvider = factProviderIterator.next();
+ CreationalContext<?> context = bm.createCreationalContext(factProvider);
+ factProviderSet.add((FactProvider) bm.getReference(factProvider, FactProvider.class, context));
+ }
+ }
+ log.info("End creating [" + (allFactProviders == null ? 0 : allFactProviders.size())+ "] fact providers");
+
}
public Set<KnowledgeBaseEventListener> getKbaseEventListenerSet()
{
return kbaseEventListenerSet;
}
+
+ public Set<FactProvider> getFactProviderSet()
+ {
+ return factProviderSet;
+ }
public Map<String, WorkItemHandler> getWorkItemHandlers()
{
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPPseudoClockRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@CEPPseudoClockConfig
+public class CEPPseudoClockRuleResources extends RuleResources
+{
+
+}
Added: 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 (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/CEPRealtimeClockRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.CEPRealitimeClockConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@CEPRealitimeClockConfig
+public class CEPRealtimeClockRuleResources extends RuleResources
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DefaultRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@DefaultConfig
+public class DefaultRuleResources extends RuleResources
+{
+
+}
Copied: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java (from rev 12499, modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java)
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,311 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.config;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.agent.KnowledgeAgentConfiguration;
+import org.drools.agent.KnowledgeAgentFactory;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.io.ResourceChangeScannerConfiguration;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.jboss.seam.drools.utils.ConfigUtils;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Drools configuration file.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class DroolsConfig implements Serializable
+{
+ private static final Logger log = LoggerFactory.getLogger(DroolsConfig.class);
+
+ @Inject
+ ResourceProvider resourceProvider;
+
+ private String knowledgeBuilderConfigProperties;
+ private String knowledgeBaseConfigProperties;
+ private String knowledgeSessionProperties;
+ private String knowledgeAgentProperties;
+
+ private boolean startChangeNotifierService;
+ private boolean startChangeScannerService;
+ private int scannerInterval = -1;
+ private String agentName;
+
+ private String loggerName;
+ private String loggerType;
+ private String loggerPath;
+ private int loggerInterval;
+
+ private RuleResources ruleResources;
+
+ private Map<String, String> kbuilderPropertiesMap = new HashMap<String, String>();
+ private Map<String, String> kbasePropertiesMap = new HashMap<String, String>();
+ private Map<String, String> ksessionPropertiesMap = new HashMap<String, String>();
+ private Map<String, String> kagentPropertiestMap = new HashMap<String, String>();
+
+ public DroolsConfig()
+ {
+ }
+
+ public DroolsConfig(RuleResources ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+ @PostConstruct
+ public void setup()
+ {
+ readProperties(kbuilderPropertiesMap, knowledgeBuilderConfigProperties);
+ readProperties(kbasePropertiesMap, knowledgeBaseConfigProperties);
+ readProperties(ksessionPropertiesMap, knowledgeSessionProperties);
+ readProperties(kagentPropertiestMap, knowledgeAgentProperties);
+
+ }
+
+ public ResourceChangeScannerConfiguration getResourceChangeScannerConfiguration()
+ {
+ ResourceChangeScannerConfiguration sconf = ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
+ if (scannerInterval >= 0)
+ {
+ sconf.setProperty("drools.resource.scanner.interval", String.valueOf(scannerInterval));
+ }
+ return sconf;
+ }
+
+ public KnowledgeAgentConfiguration getKnowledgeAgentConfiguration()
+ {
+ KnowledgeAgentConfiguration config = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
+ Iterator<Entry<String, String>> it = kagentPropertiestMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeSessionConfiguration getKnowledgeSessionConfiguration()
+ {
+ KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+ Iterator<Entry<String, String>> it = ksessionPropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeBaseConfiguration getKnowledgeBaseConfiguration()
+ {
+ KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+ Iterator<Entry<String, String>> it = kbasePropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ public KnowledgeBuilderConfiguration getKnowledgeBuilderConfiguration()
+ {
+ KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ Iterator<Entry<String, String>> it = kbuilderPropertiesMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry<String, String> nextExtry = it.next();
+ config.setProperty(nextExtry.getKey(), nextExtry.getValue());
+ }
+ return config;
+ }
+
+ private void readProperties(Map<String, String> propertiesMap, String propertiesPath)
+ {
+ if (propertiesPath != null)
+ {
+ try
+ {
+ Properties kbuilderProp = ConfigUtils.loadProperties(resourceProvider, propertiesPath);
+ for (Object key : kbuilderProp.keySet())
+ {
+ propertiesMap.put((String) key, (String) kbuilderProp.get(key));
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Unable to read configuration properties file: " + propertiesPath);
+ }
+ } else {
+ log.debug("NULL properties path specified, bypassing reading properties");
+ }
+ }
+
+ public String getKnowledgeBuilderConfigProperties()
+ {
+ return knowledgeBuilderConfigProperties;
+ }
+
+ public void setKnowledgeBuilderConfigProperties(String knowledgeBuilderConfigProperties)
+ {
+ this.knowledgeBuilderConfigProperties = knowledgeBuilderConfigProperties;
+ }
+
+ public String getKnowledgeBaseConfigProperties()
+ {
+ return knowledgeBaseConfigProperties;
+ }
+
+ public void setKnowledgeBaseConfigProperties(String knowledgeBaseConfigProperties)
+ {
+ this.knowledgeBaseConfigProperties = knowledgeBaseConfigProperties;
+ }
+
+ public String getKnowledgeSessionProperties()
+ {
+ return knowledgeSessionProperties;
+ }
+
+ public void setKnowledgeSessionProperties(String knowledgeSessionProperties)
+ {
+ this.knowledgeSessionProperties = knowledgeSessionProperties;
+ }
+
+ public String getKnowledgeAgentProperties()
+ {
+ return knowledgeAgentProperties;
+ }
+
+ public void setKnowledgeAgentProperties(String knowledgeAgentProperties)
+ {
+ this.knowledgeAgentProperties = knowledgeAgentProperties;
+ }
+
+ public boolean isStartChangeNotifierService()
+ {
+ return startChangeNotifierService;
+ }
+
+ public void setStartChangeNotifierService(boolean startChangeNotifierService)
+ {
+ this.startChangeNotifierService = startChangeNotifierService;
+ }
+
+ public boolean isStartChangeScannerService()
+ {
+ return startChangeScannerService;
+ }
+
+ public void setStartChangeScannerService(boolean startChangeScannerService)
+ {
+ this.startChangeScannerService = startChangeScannerService;
+ }
+
+ public int getScannerInterval()
+ {
+ return scannerInterval;
+ }
+
+ public void setScannerInterval(int scannerInterval)
+ {
+ this.scannerInterval = scannerInterval;
+ }
+
+ public String getAgentName()
+ {
+ return agentName;
+ }
+
+ public void setAgentName(String agentName)
+ {
+ this.agentName = agentName;
+ }
+
+ public String getLoggerName()
+ {
+ return loggerName;
+ }
+
+ public void setLoggerName(String loggerName)
+ {
+ this.loggerName = loggerName;
+ }
+
+ public String getLoggerType()
+ {
+ return loggerType;
+ }
+
+ public void setLoggerType(String loggerType)
+ {
+ this.loggerType = loggerType;
+ }
+
+ public String getLoggerPath()
+ {
+ return loggerPath;
+ }
+
+ public void setLoggerPath(String loggerPath)
+ {
+ this.loggerPath = loggerPath;
+ }
+
+ public int getLoggerInterval()
+ {
+ return loggerInterval;
+ }
+
+ public void setLoggerInterval(int loggerInterval)
+ {
+ this.loggerInterval = loggerInterval;
+ }
+
+ public RuleResources getRuleResources()
+ {
+ return ruleResources;
+ }
+
+ public void setRuleResources(RuleResources ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+}
Deleted: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfiguration.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.config;
-
-import org.jboss.seam.drools.qualifiers.config.DroolsConfig;
-
-@DroolsConfig
-public class DroolsConfiguration
-{
- //KnowledgeBase configuration
- private String knowledgeBuilderConfigPath;
- private String knowledgeBaseConfigPath;
- private String[] ruleResources;
- //KnowledgeSession configuration
- private String knowledgeSessionConfigPath;
- //KnowledgeAgent configuration
- private String resourceChangeScannerConfigPath;
- private String knowledgeAgentConfigPath;
- private String changeSetResource;
- private String knowledgeAgentName;
- private boolean startChangeNotifierService;
- private boolean startChangeScannerService;
- //KnowledgeLogger configuration
- private String loggerName;
- private String loggerType;
- private String loggerPath;
- private int loggerInterval;
-
- public String getKnowledgeBuilderConfigPath()
- {
- return knowledgeBuilderConfigPath;
- }
- public void setKnowledgeBuilderConfigPath(String knowledgeBuilderConfigPath)
- {
- this.knowledgeBuilderConfigPath = knowledgeBuilderConfigPath;
- }
- public String getKnowledgeBaseConfigPath()
- {
- return knowledgeBaseConfigPath;
- }
- public void setKnowledgeBaseConfigPath(String knowledgeBaseConfigPath)
- {
- this.knowledgeBaseConfigPath = knowledgeBaseConfigPath;
- }
- public String[] getRuleResources()
- {
- return ruleResources;
- }
- public void setRuleResources(String[] ruleResources)
- {
- this.ruleResources = ruleResources;
- }
- public String getKnowledgeSessionConfigPath()
- {
- return knowledgeSessionConfigPath;
- }
- public void setKnowledgeSessionConfigPath(String knowledgeSessionConfigPath)
- {
- this.knowledgeSessionConfigPath = knowledgeSessionConfigPath;
- }
- public String getResourceChangeScannerConfigPath()
- {
- return resourceChangeScannerConfigPath;
- }
- public void setResourceChangeScannerConfigPath(String resourceChangeScannerConfigPath)
- {
- this.resourceChangeScannerConfigPath = resourceChangeScannerConfigPath;
- }
- public String getKnowledgeAgentConfigPath()
- {
- return knowledgeAgentConfigPath;
- }
- public void setKnowledgeAgentConfigPath(String knowledgeAgentConfigPath)
- {
- this.knowledgeAgentConfigPath = knowledgeAgentConfigPath;
- }
- public String getChangeSetResource()
- {
- return changeSetResource;
- }
- public void setChangeSetResource(String changeSetResource)
- {
- this.changeSetResource = changeSetResource;
- }
- public String getKnowledgeAgentName()
- {
- return knowledgeAgentName;
- }
- public void setKnowledgeAgentName(String knowledgeAgentName)
- {
- this.knowledgeAgentName = knowledgeAgentName;
- }
- public boolean isStartChangeNotifierService()
- {
- return startChangeNotifierService;
- }
- public void setStartChangeNotifierService(boolean startChangeNotifierService)
- {
- this.startChangeNotifierService = startChangeNotifierService;
- }
- public boolean isStartChangeScannerService()
- {
- return startChangeScannerService;
- }
- public void setStartChangeScannerService(boolean startChangeScannerService)
- {
- this.startChangeScannerService = startChangeScannerService;
- }
- public String getLoggerName()
- {
- return loggerName;
- }
- public void setLoggerName(String loggerName)
- {
- this.loggerName = loggerName;
- }
- public String getLoggerType()
- {
- return loggerType;
- }
- public void setLoggerType(String loggerType)
- {
- this.loggerType = loggerType;
- }
- public String getLoggerPath()
- {
- return loggerPath;
- }
- public void setLoggerPath(String loggerPath)
- {
- this.loggerPath = loggerPath;
- }
- public int getLoggerInterval()
- {
- return loggerInterval;
- }
- public void setLoggerInterval(int loggerInterval)
- {
- this.loggerInterval = loggerInterval;
- }
-
-
-}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/MVELDialectRuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+/*
+ * 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.config;
+
+import org.jboss.seam.drools.qualifiers.config.MVELDialectConfig;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@MVELDialectConfig
+public class MVELDialectRuleResources extends RuleResources
+{
+
+}
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/RuleResources.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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.drools.config;
+
+import java.util.regex.Pattern;
+
+import org.drools.io.Resource;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class RuleResources
+{
+ public static final Pattern DIVIDER = Pattern.compile(";");
+ public static final int LOCATION_TYPE = 0;
+ public static final int RESOURCE_PATH = 1;
+ public static final int RESOURCE_TYPE = 2;
+ public static final int TEMPLATE_DATAPROVIDER_NAME = 3;
+
+ public static final String LOCATION_TYPE_URL = "url";
+ public static final String LOCATION_TYPE_FILE = "file";
+ public static final String LOCATION_TYPE_CLASSPATH = "classpath";
+
+
+ private String[] resources;
+
+ public String[] getResources()
+ {
+ return resources;
+ }
+
+ public void setResources(String[] resources)
+ {
+ this.resources = resources;
+ }
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -21,6 +21,7 @@
*/
package org.jboss.seam.drools.utils;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -33,67 +34,8 @@
*/
public class ConfigUtils
{
- private static final Pattern DIVIDER = Pattern.compile(";");
-
- private static final int RESOURCE_PATH = 0;
- private static final int RESOURCE = 1;
- private static final int RESOURCE_TYPE = 2;
- private static final int RESOURCE_TEMPLATE_DATA = 3;
-
- public static final String RESOURCE_TYPE_URL = "url";
- public static final String RESOURCE_TYPE_FILE = "file";
- public static final String RESOURCE_TYPE_CLASSPATH = "classpath";
-
- public static boolean isValidResource(String resource)
+ public static Properties loadProperties(ResourceProvider resourceProvider, String path) throws IOException
{
- return DIVIDER.split(resource.trim()).length >= 3;
- }
-
- public static boolean isRuleTemplate(String resource)
- {
- return DIVIDER.split(resource.trim()).length == 4;
- }
-
- public static String getResourceType(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_TYPE];
- }
-
- public static String getRuleResource(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE];
- }
-
- public static String getTemplateData(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_TEMPLATE_DATA];
- }
-
- public static String getResourcePath(String resource)
- {
- return DIVIDER.split(resource.trim())[RESOURCE_PATH];
- }
-
- private static final int WORKITEMHANDLER_NAME = 0;
- private static final int WORKITEMHANDLER_TYPE = 1;
-
- public static String getWorkItemHandlerName(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_NAME];
- }
-
- public static String getWorkItemHandlerType(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim())[WORKITEMHANDLER_TYPE];
- }
-
- public static boolean isValidWorkItemHandler(String workItemHandlerStr)
- {
- return DIVIDER.split(workItemHandlerStr.trim()).length == 2;
- }
-
- public static Properties loadProperties(ResourceProvider resourceProvider, String path) throws Exception
- {
Properties prop = new Properties();
InputStream in = resourceProvider.loadResourceStream(path);
if (in == null)
Modified: modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -1,43 +1,39 @@
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, 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.
--->
+ <!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+ -->
<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:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:s="urn:java:seam:core"
+ 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.DroolsConfiguration">
+ <s:genericBean class="org.jboss.seam.drools.config.DroolsConfig">
<d:KnowledgeBaseProducer>
<s:specializes />
<d:produceKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceKnowledgeBase>
</d:KnowledgeBaseProducer>
-
+
<d:KnowledgeSessionProducer>
<s:specializes />
<d:produceStatefulSession>
@@ -47,10 +43,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatefulSession>
<d:disposeStatefulSession>
@@ -68,13 +64,13 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedStatefulSession>
- <!--<d:disposeScannedStatefulSession>
+ <d:disposeScannedStatefulSession>
<s:parameters>
<drools:StatefulKnowledgeSession>
<s:Inject />
@@ -82,17 +78,17 @@
</drools:StatefulKnowledgeSession>
</s:parameters>
</d:disposeScannedStatefulSession>
- --><d:produceStatelessSession>
+ <d:produceStatelessSession>
<s:ApplyQualifiers />
<s:parameters>
<drools:KnowledgeBase>
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatelessSession>
<d:produceScannedStatelessSession>
@@ -102,10 +98,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:KnowledgeBase>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedStatelessSession>
</d:KnowledgeSessionProducer>
@@ -115,10 +111,10 @@
<d:produceScannedKnowledgeBase>
<s:ApplyQualifiers />
<s:parameters>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceScannedKnowledgeBase>
<d:disposeScannedKnowledgeBase>
@@ -130,7 +126,7 @@
</s:parameters>
</d:disposeScannedKnowledgeBase>
</d:KnowledgeAgentProducer>
-
+
<d:EntryPointProducer>
<s:specializes />
<d:produceEntryPoint>
@@ -162,10 +158,10 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:StatefulKnowledgeSession>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
</d:produceStatefulKnowledgeLogger>
<d:produceScannedStatefulKnowledgeLogger>
@@ -175,14 +171,62 @@
<s:Inject />
<s:ApplyQualifiers />
</drools:StatefulKnowledgeSession>
- <d:DroolsConfiguration>
+ <d:DroolsConfig>
<s:Inject />
<s:ApplyQualifiers />
- </d:DroolsConfiguration>
+ </d:DroolsConfig>
</s:parameters>
- </d:produceScannedStatefulKnowledgeLogger>
+ </d:produceScannedStatefulKnowledgeLogger>
+ <d:produceStatelessKnowledgeLogger>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ <d:DroolsConfig>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </d:DroolsConfig>
+ </s:parameters>
+ </d:produceStatelessKnowledgeLogger>
+ <d:produceScannedStatelessKnowledgeLogger>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ <d:DroolsConfig>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </d:DroolsConfig>
+ </s:parameters>
+ </d:produceScannedStatelessKnowledgeLogger>
</d:KnowledgeLoggerProducer>
-
+
+ <d:ExecutionResultsProducer>
+ <s:specializes />
+ <d:produceExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatelessKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatelessKnowledgeSession>
+ </s:parameters>
+ </d:produceExecutionResults>
+ <d:produceScannedExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatelessKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatelessKnowledgeSession>
+ </s:parameters>
+ </d:produceScannedExecutionResults>
+ </d:ExecutionResultsProducer>
+
<d:QueryResultsProducer>
<s:specializes />
<d:produceQueryResults>
@@ -204,7 +248,87 @@
</s:parameters>
</d:produceScannedQueryResults>
</d:QueryResultsProducer>
-
</s:genericBean>
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:DefaultConfig />
+ <s:parameters>
+ <d:RuleResources>
+ <d:DefaultConfig />
+ <s:type>
+ <d:DefaultRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:MVELDialectConfig />
+ <d:kbuilderPropertiesMap>
+ <s:entry>
+ <s:key>drools.dialect.default</s:key>
+ <s:value>mvel</s:value>
+ </s:entry>
+ </d:kbuilderPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:MVELDialectConfig />
+ <s:type>
+ <d:MVELDialectRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:CEPRealitimeClockConfig />
+ <d:kbasePropertiesMap>
+ <s:entry>
+ <s:key>drools.eventProcessingMode</s:key>
+ <s:value>stream</s:value>
+ </s:entry>
+ </d:kbasePropertiesMap>
+ <d:ksessionPropertiesMap>
+ <s:entry>
+ <s:key>drools.clockType</s:key>
+ <s:value>realtime</s:value>
+ </s:entry>
+ </d:ksessionPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:CEPRealitimeClockConfig />
+ <s:type>
+ <d:CEPRealtimeClockRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
+
+ <d:DroolsConfig>
+ <s:specializes />
+ <d:CEPPseudoClockConfig />
+ <d:kbasePropertiesMap>
+ <s:entry>
+ <s:key>drools.eventProcessingMode</s:key>
+ <s:value>stream</s:value>
+ </s:entry>
+ </d:kbasePropertiesMap>
+ <d:ksessionPropertiesMap>
+ <s:entry>
+ <s:key>drools.clockType</s:key>
+ <s:value>pseudo</s:value>
+ </s:entry>
+ </d:ksessionPropertiesMap>
+ <s:parameters>
+ <d:RuleResources>
+ <d:CEPPseudoClockConfig />
+ <s:type>
+ <d:CEPPseudoClockRuleResources />
+ </s:type>
+ </d:RuleResources>
+ </s:parameters>
+ </d:DroolsConfig>
</beans>
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,102 @@
+/*
+ * 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.cep;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotSame;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.time.SessionPseudoClock;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.annotations.EntryPoint;
+import org.jboss.seam.drools.qualifiers.config.CEPPseudoClockConfig;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class CEPTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ String pkgPath = CEPTest.class.getPackage().getName().replaceAll("\\.", "/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, new CEPTestFilter(), KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(FireAlarm.class)
+ .addClass(FireDetected.class)
+ .addClass(SprinklerActivated.class)
+ .addResource(pkgPath + "/ceptest.drl", ArchivePaths.create("ceptest.drl"))
+ //.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
+ //.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
+ .addManifestResource(pkgPath + "/CEPTest-beans.xml", ArchivePaths.create("beans.xml"));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
+ }
+
+ @Inject @Default @CEPPseudoClockConfig StatefulKnowledgeSession cepSession;
+ @Inject @Default @CEPPseudoClockConfig @EntryPoint("FireDetectionStream") WorkingMemoryEntryPoint fireDetectionStream;
+ @Inject @Default @CEPPseudoClockConfig @EntryPoint("SprinklerDetectionStream") WorkingMemoryEntryPoint sprinklerDetectionStream;
+
+
+ @Test
+ public void testCEP() {
+ assertNotNull(cepSession);
+ assertTrue(cepSession.getId() >= 0);
+ assertNotNull(fireDetectionStream);
+ assertNotNull(sprinklerDetectionStream);
+ assertNotSame(fireDetectionStream, sprinklerDetectionStream);
+
+ FireAlarm fireAlarm = new FireAlarm();
+ assertTrue(!fireAlarm.isActivated());
+ cepSession.setGlobal("fireAlarm", fireAlarm);
+ SessionPseudoClock clock = cepSession.getSessionClock();
+ fireDetectionStream.insert(new FireDetected());
+ clock.advanceTime(9, TimeUnit.SECONDS);
+
+ cepSession.fireAllRules();
+
+ FireAlarm afireAlarm = (FireAlarm) cepSession.getGlobal("fireAlarm");
+ assertTrue(!afireAlarm.isActivated());
+
+ clock.advanceTime(2, TimeUnit.SECONDS);
+
+ cepSession.fireAllRules();
+
+ FireAlarm bfireAlarm = (FireAlarm) cepSession.getGlobal("fireAlarm");
+ assertTrue(bfireAlarm.isActivated());
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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.drools.test.cep;
+
+import org.jboss.shrinkwrap.api.Filter;
+
+public class CEPTestFilter implements Filter<Class<?>>
+{
+
+ public boolean include(Class<?> clazz)
+ {
+ // exclude classes in all other test packages except your own
+ if(clazz.getPackage().getName().startsWith("org.jboss.seam.drools.test")
+ && !clazz.getPackage().getName().equals(CEPTestFilter.class.getPackage().getName())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
+
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireAlarm.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,39 @@
+/*
+ * 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.cep;
+
+public class FireAlarm
+{
+ private boolean activated;
+
+ public boolean isActivated()
+ {
+ return activated;
+ }
+
+ public void setActivated(boolean activated)
+ {
+ this.activated = activated;
+ }
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/FireDetected.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.cep;
+
+public class FireDetected
+{
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/SprinklerActivated.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.cep;
+
+public class SprinklerActivated
+{
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,32 @@
+/*
+ * 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.kagent;
+
+import org.junit.Test;
+
+public class KAgentTest
+{
+ @Test
+ public void testKAgent() {
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,27 @@
+/*
+ * 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.kagent;
+
+public class KAgentTestFilter
+{
+
+}
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,12 +24,14 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import javax.enterprise.inject.Default;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.formatter.Formatters;
@@ -54,11 +56,11 @@
.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
.addManifestResource(pkgPath + "/KBaseTest-beans.xml", ArchivePaths.create("beans.xml"));
- System.out.println(archive.toString(Formatters.VERBOSE));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
}
- @Inject @KBaseTestRules KnowledgeBase kbase;
+ @Inject @Default @DefaultConfig KnowledgeBase kbase;
@Test
public void testKBase()
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -23,16 +23,20 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import javax.enterprise.inject.Default;
import javax.inject.Inject;
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.qualifiers.config.DefaultConfig;
+import org.jboss.seam.drools.qualifiers.config.MVELDialectConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
-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;
@@ -53,16 +57,24 @@
.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
.addManifestResource(pkgPath + "/KSessionTest-beans.xml", ArchivePaths.create("beans.xml"));
- System.out.println(archive.toString(Formatters.VERBOSE));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
return archive;
}
- @Inject @KSessionTestRules StatefulKnowledgeSession ksession;
+ @Inject @Default @DefaultConfig StatefulKnowledgeSession ksession;
+ @Inject @Default @MVELDialectConfig StatefulKnowledgeSession mvelksession;
+ @Inject @Default @MVELDialectConfig StatefulKnowledgeSession mvelksession2;
@Test
public void testKSession()
{
assertNotNull(ksession);
assertTrue(ksession.getId() >= 0);
+
+ assertNotNull(mvelksession);
+ assertTrue(mvelksession.getId() >= 0);
+
+ assertNotSame(ksession, mvelksession);
+ assertSame(mvelksession, mvelksession2);
}
}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/Person.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,43 @@
+/*
+ * 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.query;
+
+public class Person
+{
+ private int age;
+
+ public Person(int age) {
+ this.age = age;
+ }
+
+ public int getAge()
+ {
+ return age;
+ }
+
+ public void setAge(int age)
+ {
+ this.age = age;
+ }
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,85 @@
+package org.jboss.seam.drools.test.query;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.seam.drools.FactProvider;
+
+/*
+ * 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.
+ */
+
+public class QueryFactProvider implements FactProvider
+{
+
+ public List<Object> getFacts()
+ {
+ List<Object> personList = new ArrayList<Object>();
+ personList.add(new Person(10));
+ personList.add(new Person(17));
+ personList.add(new Person(16));
+ personList.add(new Person(13));
+ personList.add(new Person(33));
+ personList.add(new Person(22));
+ personList.add(new Person(54));
+ personList.add(new Person(7));
+ personList.add(new Person(32));
+ personList.add(new Person(12));
+ personList.add(new Person(67));
+ personList.add(new Person(55));
+ personList.add(new Person(77));
+ personList.add(new Person(13));
+
+ return personList;
+ }
+
+ public Map<String, Object> getGlobals()
+ {
+ return null;
+ }
+
+ public void setFacts(List<Object> facts)
+ {
+
+ }
+
+ public void setGlobals(Map<String, Object> globals)
+ {
+
+ }
+
+ public List<String> getQueries()
+ {
+ List<String> queries = new ArrayList<String>();
+ queries.add("number of adults");
+ queries.add("number of minors");
+ return queries;
+ }
+
+ public void setQueries(List<String> queries)
+ {
+
+ }
+
+
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,86 @@
+/*
+ * 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.query;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.rule.QueryResults;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.annotations.Query;
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class QueryTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ String pkgPath = QueryTest.class.getPackage().getName().replaceAll("\\.", "/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, new QueryTestFilter(), KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(Person.class)
+ .addClass(QueryFactProvider.class)
+ .addResource(pkgPath + "/querytest.drl", ArchivePaths.create("querytest.drl"))
+ //.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
+ //.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
+ .addManifestResource(pkgPath + "/QueryTest-beans.xml", ArchivePaths.create("beans.xml"));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
+ }
+
+ @Inject @Default @DefaultConfig @Query("number of adults") QueryResults adultsQuery;
+ @Inject @Default @DefaultConfig @Query("number of minors") QueryResults minorsQuery;
+
+ @Inject @Default @DefaultConfig ExecutionResults executionResults;
+
+ @Test
+ public void testQuery() {
+ assertNotNull(adultsQuery);
+ assertNotNull(minorsQuery);
+ assertNotSame(adultsQuery, minorsQuery);
+
+ assertTrue(adultsQuery.size() == 7);
+ assertTrue(minorsQuery.size() == 7);
+
+ assertNotNull(executionResults);
+ assertTrue(((QueryResults) executionResults.getValue("number of adults")).size() == 7);
+ assertTrue(((QueryResults) executionResults.getValue("number of minors")).size() == 7);
+
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTestFilter.java 2010-04-20 16:21:25 UTC (rev 12529)
@@ -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.drools.test.query;
+
+import org.jboss.shrinkwrap.api.Filter;
+
+public class QueryTestFilter implements Filter<Class<?>>
+{
+
+ public boolean include(Class<?> clazz)
+ {
+ // exclude classes in all other test packages except your own
+ if(clazz.getPackage().getName().startsWith("org.jboss.seam.drools.test")
+ && !clazz.getPackage().getName().equals(QueryTestFilter.class.getPackage().getName())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
+
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/CEPTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, 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.
+-->
+<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:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
+
+ <d:CEPPseudoClockRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;ceptest.drl;DRL</s:value>
+ </d:resources>
+ </d:CEPPseudoClockRuleResources>
+
+</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/cep/ceptest.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,25 @@
+package org.jboss.seam.drools.test.cep
+
+import org.jboss.seam.drools.test.cep.FireAlarm;
+import org.jboss.seam.drools.test.cep.FireDetected;
+import org.jboss.seam.drools.test.cep.SprinklerActivated;
+
+global FireAlarm fireAlarm;
+
+declare SprinklerActivated
+ @role( event )
+ @expires( 1h )
+end
+
+declare FireDetected
+ @role( event )
+ @expires( 1h )
+end
+
+rule "Sound the alarm"
+when
+ $f : FireDetected( ) from entry-point "FireDetectionStream"
+ not( SprinklerActivated( this after[0s,10s] $f ) from entry-point "SprinklerDetectionStream" )
+then
+ fireAlarm.setActivated(true);
+end
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/KAgentTest-beans.xml
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentconfig.properties
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagentestchangeset.xml
===================================================================
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttestone.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,29 @@
+#created on: Apr 19, 2010
+package org.jboss.seam.drools.test.kagent
+
+#list any import classes here.
+
+
+
+#declare any global variables here
+
+
+
+
+rule "Your First Rule"
+
+ when
+ #conditions
+ then
+ #actions
+
+end
+
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ #conditions
+ then
+ #actions
+
+end
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kagent/kagenttesttwo.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,29 @@
+#created on: Apr 19, 2010
+package org.jboss.seam.drools.test.kagent
+
+#list any import classes here.
+
+
+
+#declare any global variables here
+
+
+
+
+rule "Your First Rule"
+
+ when
+ #conditions
+ then
+ #actions
+
+end
+
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ #conditions
+ then
+ #actions
+
+end
Modified: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/kbase/KBaseTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,14 +24,10 @@
xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
xmlns:test="urn:java:org.jboss.seam.drools.test.kbase">
-
- <d:DroolsConfiguration>
- <test:KBaseTestRules />
- <d:knowledgeBuilderConfigPath>kbuilderconfig.properties</d:knowledgeBuilderConfigPath>
- <d:knowledgeBaseConfigPath>kbaseconfig.properties</d:knowledgeBaseConfigPath>
- <d:ruleResources>
- <s:value>classpath;kbasetest.drl;DRL;forkbasetest</s:value>
- </d:ruleResources>
- </d:DroolsConfiguration>
-
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;kbasetest.drl;DRL;forkbasetest</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
</beans>
Modified: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml 2010-04-20 16:15:07 UTC (rev 12528)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/ksession/KSessionTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -24,14 +24,18 @@
xmlns:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
- <d:DroolsConfiguration>
- <test:KSessionTestRules />
- <d:knowledgeBuilderConfigPath>kbuilderconfig.properties
- </d:knowledgeBuilderConfigPath>
- <d:knowledgeBaseConfigPath>kbaseconfig.properties
- </d:knowledgeBaseConfigPath>
- <d:ruleResources>
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;ksessiontest.drl;DRL</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
+
+ <d:MVELDialectRuleResources>
+ <s:specializes/>
+ <d:resources>
<s:value>classpath;ksessiontest.drl;DRL</s:value>
- </d:ruleResources>
- </d:DroolsConfiguration>
+ </d:resources>
+ </d:MVELDialectRuleResources>
+
</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/QueryTest-beans.xml 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,34 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, 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.
+-->
+<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:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
+
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;querytest.drl;DRL</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
+
+</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/query/querytest.drl 2010-04-20 16:21:25 UTC (rev 12529)
@@ -0,0 +1,11 @@
+package org.jboss.seam.drools.test.query
+
+import org.jboss.seam.drools.test.query.Person;
+
+query "number of adults"
+ person : Person( age >= 18 )
+end
+
+query "number of minors"
+ person : Person( age < 18 )
+end
\ No newline at end of file
[View Less]
14 years, 9 months
Seam SVN: r12528 - in modules/wicket: tags and 30 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-20 12:15:07 -0400 (Tue, 20 Apr 2010)
New Revision: 12528
Added:
modules/wicket/branches/
modules/wicket/tags/
modules/wicket/tags/1.0.1-CR2/
modules/wicket/tags/1.0.1-CR2/pom.xml
modules/wicket/tags/1.0.1-CR2/src/
modules/wicket/tags/1.0.1-CR2/src/main/
modules/wicket/tags/1.0.1-CR2/src/main/java/
modules/wicket/tags/1.0.1-CR2/src/main/java/org/
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/
modules/wicket/tags/1.…
[View More]0.1-CR2/src/main/java/org/jboss/weld/
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldApplication.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/
modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
modules/wicket/tags/1.0.1-CR2/src/main/resources/
modules/wicket/tags/1.0.1-CR2/src/main/resources/META-INF/
modules/wicket/tags/1.0.1-Final/
modules/wicket/tags/1.0.1-Final/pom.xml
modules/wicket/tags/1.0.1-Final/src/
modules/wicket/tags/1.0.1-Final/src/main/
modules/wicket/tags/1.0.1-Final/src/main/java/
modules/wicket/tags/1.0.1-Final/src/main/java/org/
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldApplication.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/
modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
modules/wicket/tags/1.0.1-Final/src/main/resources/
modules/wicket/tags/1.0.1-Final/src/main/resources/META-INF/
modules/wicket/trunk/
modules/wicket/trunk/pom.xml
modules/wicket/trunk/src/
modules/wicket/trunk/src/main/
modules/wicket/trunk/src/main/java/
modules/wicket/trunk/src/main/java/org/
modules/wicket/trunk/src/main/java/org/jboss/
modules/wicket/trunk/src/main/java/org/jboss/weld/
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldApplication.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/
modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
modules/wicket/trunk/src/main/resources/
modules/wicket/trunk/src/main/resources/META-INF/
Log:
initial import of wicket
Added: modules/wicket/tags/1.0.1-CR2/pom.xml
===================================================================
--- modules/wicket/tags/1.0.1-CR2/pom.xml (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/pom.xml 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,124 @@
+<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">
+ <parent>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-wicket</artifactId>
+ <version>1.0.1-CR2</version>
+ <name>Weld Wicket support</name>
+
+ <description>Weld support for Apache Wicket</description>
+
+ <developers>
+ <developer>
+ <name>Clint Popetz</name>
+ <roles>
+ <role>Module lead</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <url>http://www.seamframework.org/Weld</url>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <distribution>repo</distribution>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ </license>
+ </licenses>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://jira.jboss.org/jira/browse/WELDX/component/12312752</url>
+ </issueManagement>
+
+
+
+ <properties>
+ <weld.api.version>1.0-SP1</weld.api.version>
+ <weld.core.version>1.0.1-CR2</weld.core.version>
+ <testng.version>5.10</testng.version>
+ <wicket.version>1.4.1</wicket.version>
+ </properties>
+
+ <!-- Import the BOMs -->
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-api-bom</artifactId>
+ <version>${weld.api.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-bom</artifactId>
+ <version>${weld.core.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>${wicket.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <version>${testng.version}</version>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- WELDX-36 -->
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/wicket/tags/1.0.1-CR2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/wicket/tags/1.0.1-CR2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/weld/wicket/tags/1.0.1-CR2</url>
+ </scm>
+
+</project>
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,85 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * A utilty class to provide access to the JSR-299 BeanManager
+ * @author cpopetz
+ *
+ */
+public class BeanManagerLookup
+{
+
+ private static BeanManager cachedManager;
+ /**
+ * This is the spec-defined name for the bean manager as registered in JNDI
+ * See JSR-299 11.3
+ */
+ // TODO Change to java:comp/BeanManager when JBoss AS supports it
+ private static String beanManagerJndiName = "java:app/BeanManager";
+
+ public static void setBeanManagerJndiName(String beanManagerJndiName)
+ {
+ BeanManagerLookup.beanManagerJndiName = beanManagerJndiName;
+ }
+
+ public static String getBeanManagerJndiName()
+ {
+ return beanManagerJndiName;
+ }
+
+ /**
+ * This is the name under which the bean manager will be stored in the
+ * servlet context. This is not yet specified in JSR-299.
+ */
+ private static String beanManagerServletContextName = BeanManager.class.getName();
+
+ public static void setBeanManagerServletContextName(String beanManagerServletContextName)
+ {
+ BeanManagerLookup.beanManagerServletContextName = beanManagerServletContextName;
+ }
+
+ public static String getBeanManagerServletContextName()
+ {
+ return beanManagerServletContextName;
+ }
+
+
+ /**
+ * We will attempt first to obtain the BeanManager instance from JNDI.
+ * Failing that, we will look in the servlet context.
+ */
+ public static BeanManager getBeanManager()
+ {
+ if (cachedManager == null)
+ {
+ // first look in jndi
+ try
+ {
+ Context initialContext = new InitialContext();
+ cachedManager = (BeanManager) initialContext.lookup(getBeanManagerJndiName());
+ }
+ catch (Exception e)
+ {
+ // we ignore this failure; it could mean we are operating in a
+ // non-jndi (SE or Servlet) env
+ }
+
+ if (cachedManager == null)
+ {
+ ServletContext servletContext = ((WebApplication) Application.get()).getServletContext();
+ if (servletContext != null)
+ {
+ cachedManager = (BeanManager) servletContext.getAttribute(getBeanManagerServletContextName());
+ }
+ }
+ }
+ return cachedManager;
+ }
+}
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldApplication.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldApplication.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldApplication.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,77 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.Request;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * A convenience subclass of wicket's WebApplication which adds the hooks
+ * necessary to use JSR-299 injections in wicket components, as well as manage
+ * JSR-299 conversation scopes with Wicket page metadata. If you have your own
+ * WebApplication subclass, and can't subclass this class, you just need to do
+ * the three things that this class does, i.e. register the
+ * WeldComponentInstantiationListener, and override the two methods below to
+ * return the RequestCycle and IRequestCycleProcessor subclasses specific to
+ * Weld, or your subclasses of those classes.
+ *
+ * @author cpopetz
+ * @author pmuir
+ *
+ * @see WebApplication
+ * @see WeldWebRequestCycleProcessor
+ * @see WeldRequestCycle
+ */
+public abstract class WeldApplication extends WebApplication
+{
+
+ private NonContextual<WeldComponentInstantiationListener> weldComponentInstantiationListener;
+ private NonContextual<WeldWebRequestCycleProcessor> weldWebRequestCycleProcessor;
+
+ /**
+ */
+ public WeldApplication()
+ {
+ }
+
+ /**
+ * Add our component instantiation listener
+ *
+ * @see WeldComponentInstantiationListener
+ */
+ @Override
+ protected void internalInit()
+ {
+ super.internalInit();
+ this.weldComponentInstantiationListener = new NonContextual<WeldComponentInstantiationListener>(BeanManagerLookup.getBeanManager(), WeldComponentInstantiationListener.class);
+ this.weldWebRequestCycleProcessor = new NonContextual<WeldWebRequestCycleProcessor>(BeanManagerLookup.getBeanManager(), WeldWebRequestCycleProcessor.class);
+ addComponentInstantiationListener(weldComponentInstantiationListener.newInstance().produce().inject().get());
+ }
+
+
+ /**
+ * Override to return our Weld-specific request cycle processor
+ *
+ * @see WeldWebRequestCycleProcessor
+ */
+ @Override
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return weldWebRequestCycleProcessor.newInstance().produce().inject().get();
+ }
+
+ /**
+ * Override to return our Weld-specific request cycle
+ *
+ * @see WeldRequestCycle
+ */
+ @Override
+ public RequestCycle newRequestCycle(final Request request, final Response response)
+ {
+ return new WeldRequestCycle(this, (WebRequest) request, (WebResponse) response);
+ }
+}
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldApplication.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,33 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * This listener uses the BeanManager to handle injections for all wicket components.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldComponentInstantiationListener implements IComponentInstantiationListener
+{
+
+ @Inject
+ private BeanManager manager;
+
+ public void onInstantiation(Component component)
+ {
+ /*
+ * The manager could be null in unit testing environments
+ */
+ if (manager != null)
+ {
+ // TODO Cache the NonContextual!
+ new NonContextual<Component>(manager, component.getClass()).existingInstance(component).inject();
+ }
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldMetaData.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldMetaData.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,23 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.MetaDataKey;
+
+/**
+ * Public storage for the metadata key used by the Weld integration to store
+ * conversation ids in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldMetaData
+{
+
+ /**
+ * This is the key we will use to to store the conversation metadata in the
+ * wicket page.
+ */
+ public static final MetaDataKey<String> CID = new MetaDataKey<String>()
+ {
+ private static final long serialVersionUID = -8788010688731927318L;
+ };
+}
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,166 @@
+package org.jboss.weld.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.Page;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
+import org.apache.wicket.request.target.component.IPageRequestTarget;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.ConversationContext;
+import org.jboss.weld.conversation.ConversationImpl;
+import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.servlet.ConversationBeanStore;
+
+/**
+ * WeldRequestCycle is a subclass of the standard wicket WebRequestCycle which:
+ * <ul>
+ * <li>restores long-running conversations specified in wicket page metadata
+ * when a page target is first used.
+ * <li>propagates long running conversations to new page targets by specifying
+ * the above metadata
+ * <li>propagates long running conversations across redirects through the use of
+ * a request parameter if the redirect is handled with a BookmarkablePageRequest
+ * <li>Sets up the conversational context when the request target is set
+ * <li>Tears down the conversation context on detach() of the RequestCycle
+ * </ul>
+ *
+ * @see WeldWebRequestCycleProcessor Which handles propogation of conversation
+ * data for newly-started long running conversations, by storing their ids
+ * in the page metadata
+ * @author cpopetz
+ *
+ */
+public class WeldRequestCycle extends WebRequestCycle
+{
+
+ public WeldRequestCycle(WebApplication application, WebRequest request, Response response)
+ {
+ super(application, request, response);
+ }
+
+ /**
+ * Override to set up the conversation context and to choose the conversation
+ * if a conversation id is present in target metadata.
+ */
+ @Override
+ protected void onRequestTargetSet(IRequestTarget target)
+ {
+ super.onRequestTargetSet(target);
+
+ Page page = null;
+ if (target instanceof IPageRequestTarget)
+ {
+ page = ((IPageRequestTarget) target).getPage();
+ }
+
+ // Two possible specifications of cid: page metadata or request url; the
+ // latter is used to propagate the conversation to mounted (bookmarkable)
+ // paths after a redirect
+
+ String specifiedCid = null;
+ if (page != null)
+ {
+ specifiedCid = page.getMetaData(WeldMetaData.CID);
+ }
+ else
+ {
+ specifiedCid = request.getParameter("cid");
+ }
+
+ BeanManager manager = BeanManagerLookup.getBeanManager();
+
+ ConversationImpl conversation = (ConversationImpl) getInstanceByType(manager, Conversation.class);
+
+ // restore a conversation if it exists and we aren't already in it
+ if (specifiedCid != null && (conversation == null || !specifiedCid.equals(conversation.getUnderlyingId())))
+ {
+ getInstanceByType(manager, ConversationManager.class).beginOrRestoreConversation(specifiedCid);
+ }
+
+
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // Now set up the conversational context if it isn't already
+ if (!conversationContext.isActive())
+ {
+ // TODO account for invalidated session
+ conversationContext.setBeanStore(new ConversationBeanStore(((WebRequest) request).getHttpServletRequest().getSession(), false, conversation.getUnderlyingId()));
+ conversationContext.setActive(true);
+ }
+
+ // handle propagation of existing long running converstaions to new
+ // targets
+ if (!conversation.isTransient())
+ {
+ // Note that we can't propagate conversations with other redirect
+ // targets like RequestRedirectTarget through this mechanism, because
+ // it does not provide an interface to modify its target URL. If
+ // propagation with those targets is to be supported, it needs a custom
+ // Response subclass.
+ if (isRedirect() && target instanceof BookmarkablePageRequestTarget)
+ {
+ BookmarkablePageRequestTarget bookmark = (BookmarkablePageRequestTarget) target;
+ // if a cid has already been specified, don't override it
+ if (!bookmark.getPageParameters().containsKey("cid"))
+ bookmark.getPageParameters().add("cid", conversation.getUnderlyingId());
+ }
+
+ // If we have a target page, propagate the conversation to the page's
+ // metadata
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getUnderlyingId());
+ }
+ }
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T getInstanceByType(BeanManager manager, Class<T> beanType, Annotation... bindings)
+ {
+ Bean<T> bean = (Bean<T>) ensureUniqueBean(beanType, manager.getBeans(beanType, bindings));
+ return (T) manager.getReference(bean, beanType, manager.createCreationalContext(bean));
+ }
+
+ private static Bean<?> ensureUniqueBean(Type type, Set<Bean<?>> beans)
+ {
+ if (beans.size() == 0)
+ {
+ throw new UnsatisfiedResolutionException("Unable to resolve any Web Beans of " + type);
+ }
+ else if (beans.size() > 1)
+ {
+ throw new AmbiguousResolutionException("More than one bean available for type " + type);
+ }
+ return beans.iterator().next();
+ }
+
+ @Override
+ public void detach()
+ {
+ super.detach();
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // cleanup and deactivate the conversation context
+ if (conversationContext.isActive())
+ {
+ ConversationManager conversationManager = getInstanceByType(BeanManagerLookup.getBeanManager(), ConversationManager.class);
+ conversationManager.cleanupConversation();
+ conversationContext.setActive(false);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,41 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+
+/**
+ * WeldWebRequestCycleProcessor is a subclass of the standard wicket
+ * WebRequestCycleProcessor which saves the conversation id of any long-running
+ * cornversation in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldWebRequestCycleProcessor extends WebRequestCycleProcessor
+{
+ @Inject
+ Conversation conversation;
+
+ /**
+ * If a long running conversation has been started, store its id into page
+ * metadata
+ */
+ @Override
+ public void respond(RequestCycle requestCycle)
+ {
+ super.respond(requestCycle);
+ if (!conversation.isTransient())
+ {
+ Page page = RequestCycle.get().getResponsePage();
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getId());
+ }
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
===================================================================
--- modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/NonContextual.java (rev 0)
+++ modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/NonContextual.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,184 @@
+package org.jboss.weld.wicket.util;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * Perform production, injection, lifecycle callbacks and cleanup on a non-contextual object
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+public class NonContextual<T>
+{
+
+ // Store the injection target. The CDI spec doesn't require an implementation
+ // to cache it, so we do
+ private final InjectionTarget<? extends T> injectionTarget;
+
+ // Store a reference to the CDI BeanManager
+ private final BeanManager beanManager;
+
+ /**
+ * Create an injector for the given class
+ */
+ public NonContextual(BeanManager manager, Class<? extends T> clazz)
+ {
+ this.beanManager = manager;
+
+ // Generate an "Annotated Type"
+ AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
+
+ // Generate the InjectionTarget
+ this.injectionTarget = manager.createInjectionTarget(type);
+ }
+
+ public Instance<T> newInstance()
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget);
+ }
+
+ public Instance<T> existingInstance(T instance)
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget, instance);
+ }
+
+ /**
+ * Represents a non-contextual instance
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+ public static class Instance<T>
+ {
+
+ private final CreationalContext<T> ctx;
+ private final InjectionTarget<T> injectionTarget;
+ private T instance;
+ private boolean disposed = false;
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ }
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget, T instance)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ this.instance = instance;
+ }
+
+ /**
+ * Get the instance
+ *
+ * @return
+ */
+ public T get()
+ {
+ return instance;
+ }
+
+ /**
+ * Create the instance
+ *
+ * @return
+ */
+ public Instance<T> produce()
+ {
+ if (this.instance != null)
+ {
+ throw new IllegalStateException("Trying to call produce() on already constructed instance");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call produce() on an already disposed instance");
+ }
+ this.instance = injectionTarget.produce(ctx);
+ return this;
+ }
+
+ /**
+ * Inject the instance
+ *
+ * @return
+ */
+ public Instance<T> inject()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call inject() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call inject() on already disposed instance");
+ }
+ injectionTarget.inject(instance, ctx);
+ return this;
+ }
+
+ /**
+ * Call the @PostConstruct callback
+ *
+ * @return
+ */
+ public Instance<T> postConstruct()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call postConstruct() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.postConstruct(instance);
+ return this;
+ }
+
+ /**
+ * Call the @PreDestroy callback
+ *
+ * @return
+ */
+ public Instance<T> preDestroy()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.preDestroy(instance);
+ return this;
+ }
+
+ /**
+ * Dispose of the instance, doing any necessary cleanup
+ *
+ */
+ public Instance<T> dispose()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call dispose() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call dispose() on already disposed instance");
+ }
+ injectionTarget.dispose(instance);
+ ctx.release();
+ return this;
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-CR2/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/pom.xml
===================================================================
--- modules/wicket/tags/1.0.1-Final/pom.xml (rev 0)
+++ modules/wicket/tags/1.0.1-Final/pom.xml 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,124 @@
+<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">
+ <parent>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-wicket</artifactId>
+ <version>1.0.1-Final</version>
+ <name>Weld Wicket support</name>
+
+ <description>Weld support for Apache Wicket</description>
+
+ <developers>
+ <developer>
+ <name>Clint Popetz</name>
+ <roles>
+ <role>Module lead</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <url>http://www.seamframework.org/Weld</url>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <distribution>repo</distribution>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ </license>
+ </licenses>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://jira.jboss.org/jira/browse/WELDX/component/12312752</url>
+ </issueManagement>
+
+
+
+ <properties>
+ <weld.api.version>1.0-SP1</weld.api.version>
+ <weld.core.version>1.0.1-Final</weld.core.version>
+ <testng.version>5.10</testng.version>
+ <wicket.version>1.4.1</wicket.version>
+ </properties>
+
+ <!-- Import the BOMs -->
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-api-bom</artifactId>
+ <version>${weld.api.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-bom</artifactId>
+ <version>${weld.core.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>${wicket.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <version>${testng.version}</version>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- WELDX-36 -->
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/wicket/tags/1.0.1-Final</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/wicket/tags/1.0.1-Final</developerConnection>
+ <url>http://fisheye.jboss.org/browse/weld/wicket/tags/1.0.1-Final</url>
+ </scm>
+
+</project>
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,85 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * A utilty class to provide access to the JSR-299 BeanManager
+ * @author cpopetz
+ *
+ */
+public class BeanManagerLookup
+{
+
+ private static BeanManager cachedManager;
+ /**
+ * This is the spec-defined name for the bean manager as registered in JNDI
+ * See JSR-299 11.3
+ */
+ // TODO Change to java:comp/BeanManager when JBoss AS supports it
+ private static String beanManagerJndiName = "java:app/BeanManager";
+
+ public static void setBeanManagerJndiName(String beanManagerJndiName)
+ {
+ BeanManagerLookup.beanManagerJndiName = beanManagerJndiName;
+ }
+
+ public static String getBeanManagerJndiName()
+ {
+ return beanManagerJndiName;
+ }
+
+ /**
+ * This is the name under which the bean manager will be stored in the
+ * servlet context. This is not yet specified in JSR-299.
+ */
+ private static String beanManagerServletContextName = BeanManager.class.getName();
+
+ public static void setBeanManagerServletContextName(String beanManagerServletContextName)
+ {
+ BeanManagerLookup.beanManagerServletContextName = beanManagerServletContextName;
+ }
+
+ public static String getBeanManagerServletContextName()
+ {
+ return beanManagerServletContextName;
+ }
+
+
+ /**
+ * We will attempt first to obtain the BeanManager instance from JNDI.
+ * Failing that, we will look in the servlet context.
+ */
+ public static BeanManager getBeanManager()
+ {
+ if (cachedManager == null)
+ {
+ // first look in jndi
+ try
+ {
+ Context initialContext = new InitialContext();
+ cachedManager = (BeanManager) initialContext.lookup(getBeanManagerJndiName());
+ }
+ catch (Exception e)
+ {
+ // we ignore this failure; it could mean we are operating in a
+ // non-jndi (SE or Servlet) env
+ }
+
+ if (cachedManager == null)
+ {
+ ServletContext servletContext = ((WebApplication) Application.get()).getServletContext();
+ if (servletContext != null)
+ {
+ cachedManager = (BeanManager) servletContext.getAttribute(getBeanManagerServletContextName());
+ }
+ }
+ }
+ return cachedManager;
+ }
+}
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldApplication.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldApplication.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldApplication.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,77 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.Request;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * A convenience subclass of wicket's WebApplication which adds the hooks
+ * necessary to use JSR-299 injections in wicket components, as well as manage
+ * JSR-299 conversation scopes with Wicket page metadata. If you have your own
+ * WebApplication subclass, and can't subclass this class, you just need to do
+ * the three things that this class does, i.e. register the
+ * WeldComponentInstantiationListener, and override the two methods below to
+ * return the RequestCycle and IRequestCycleProcessor subclasses specific to
+ * Weld, or your subclasses of those classes.
+ *
+ * @author cpopetz
+ * @author pmuir
+ *
+ * @see WebApplication
+ * @see WeldWebRequestCycleProcessor
+ * @see WeldRequestCycle
+ */
+public abstract class WeldApplication extends WebApplication
+{
+
+ private NonContextual<WeldComponentInstantiationListener> weldComponentInstantiationListener;
+ private NonContextual<WeldWebRequestCycleProcessor> weldWebRequestCycleProcessor;
+
+ /**
+ */
+ public WeldApplication()
+ {
+ }
+
+ /**
+ * Add our component instantiation listener
+ *
+ * @see WeldComponentInstantiationListener
+ */
+ @Override
+ protected void internalInit()
+ {
+ super.internalInit();
+ this.weldComponentInstantiationListener = new NonContextual<WeldComponentInstantiationListener>(BeanManagerLookup.getBeanManager(), WeldComponentInstantiationListener.class);
+ this.weldWebRequestCycleProcessor = new NonContextual<WeldWebRequestCycleProcessor>(BeanManagerLookup.getBeanManager(), WeldWebRequestCycleProcessor.class);
+ addComponentInstantiationListener(weldComponentInstantiationListener.newInstance().produce().inject().get());
+ }
+
+
+ /**
+ * Override to return our Weld-specific request cycle processor
+ *
+ * @see WeldWebRequestCycleProcessor
+ */
+ @Override
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return weldWebRequestCycleProcessor.newInstance().produce().inject().get();
+ }
+
+ /**
+ * Override to return our Weld-specific request cycle
+ *
+ * @see WeldRequestCycle
+ */
+ @Override
+ public RequestCycle newRequestCycle(final Request request, final Response response)
+ {
+ return new WeldRequestCycle(this, (WebRequest) request, (WebResponse) response);
+ }
+}
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldApplication.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,33 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * This listener uses the BeanManager to handle injections for all wicket components.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldComponentInstantiationListener implements IComponentInstantiationListener
+{
+
+ @Inject
+ private BeanManager manager;
+
+ public void onInstantiation(Component component)
+ {
+ /*
+ * The manager could be null in unit testing environments
+ */
+ if (manager != null)
+ {
+ // TODO Cache the NonContextual!
+ new NonContextual<Component>(manager, component.getClass()).existingInstance(component).inject();
+ }
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldMetaData.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldMetaData.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,23 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.MetaDataKey;
+
+/**
+ * Public storage for the metadata key used by the Weld integration to store
+ * conversation ids in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldMetaData
+{
+
+ /**
+ * This is the key we will use to to store the conversation metadata in the
+ * wicket page.
+ */
+ public static final MetaDataKey<String> CID = new MetaDataKey<String>()
+ {
+ private static final long serialVersionUID = -8788010688731927318L;
+ };
+}
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,166 @@
+package org.jboss.weld.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.Page;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
+import org.apache.wicket.request.target.component.IPageRequestTarget;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.ConversationContext;
+import org.jboss.weld.conversation.ConversationImpl;
+import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.servlet.ConversationBeanStore;
+
+/**
+ * WeldRequestCycle is a subclass of the standard wicket WebRequestCycle which:
+ * <ul>
+ * <li>restores long-running conversations specified in wicket page metadata
+ * when a page target is first used.
+ * <li>propagates long running conversations to new page targets by specifying
+ * the above metadata
+ * <li>propagates long running conversations across redirects through the use of
+ * a request parameter if the redirect is handled with a BookmarkablePageRequest
+ * <li>Sets up the conversational context when the request target is set
+ * <li>Tears down the conversation context on detach() of the RequestCycle
+ * </ul>
+ *
+ * @see WeldWebRequestCycleProcessor Which handles propogation of conversation
+ * data for newly-started long running conversations, by storing their ids
+ * in the page metadata
+ * @author cpopetz
+ *
+ */
+public class WeldRequestCycle extends WebRequestCycle
+{
+
+ public WeldRequestCycle(WebApplication application, WebRequest request, Response response)
+ {
+ super(application, request, response);
+ }
+
+ /**
+ * Override to set up the conversation context and to choose the conversation
+ * if a conversation id is present in target metadata.
+ */
+ @Override
+ protected void onRequestTargetSet(IRequestTarget target)
+ {
+ super.onRequestTargetSet(target);
+
+ Page page = null;
+ if (target instanceof IPageRequestTarget)
+ {
+ page = ((IPageRequestTarget) target).getPage();
+ }
+
+ // Two possible specifications of cid: page metadata or request url; the
+ // latter is used to propagate the conversation to mounted (bookmarkable)
+ // paths after a redirect
+
+ String specifiedCid = null;
+ if (page != null)
+ {
+ specifiedCid = page.getMetaData(WeldMetaData.CID);
+ }
+ else
+ {
+ specifiedCid = request.getParameter("cid");
+ }
+
+ BeanManager manager = BeanManagerLookup.getBeanManager();
+
+ ConversationImpl conversation = (ConversationImpl) getInstanceByType(manager, Conversation.class);
+
+ // restore a conversation if it exists and we aren't already in it
+ if (specifiedCid != null && (conversation == null || !specifiedCid.equals(conversation.getUnderlyingId())))
+ {
+ getInstanceByType(manager, ConversationManager.class).beginOrRestoreConversation(specifiedCid);
+ }
+
+
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // Now set up the conversational context if it isn't already
+ if (!conversationContext.isActive())
+ {
+ // TODO account for invalidated session
+ conversationContext.setBeanStore(new ConversationBeanStore(((WebRequest) request).getHttpServletRequest().getSession(), false, conversation.getUnderlyingId()));
+ conversationContext.setActive(true);
+ }
+
+ // handle propagation of existing long running converstaions to new
+ // targets
+ if (!conversation.isTransient())
+ {
+ // Note that we can't propagate conversations with other redirect
+ // targets like RequestRedirectTarget through this mechanism, because
+ // it does not provide an interface to modify its target URL. If
+ // propagation with those targets is to be supported, it needs a custom
+ // Response subclass.
+ if (isRedirect() && target instanceof BookmarkablePageRequestTarget)
+ {
+ BookmarkablePageRequestTarget bookmark = (BookmarkablePageRequestTarget) target;
+ // if a cid has already been specified, don't override it
+ if (!bookmark.getPageParameters().containsKey("cid"))
+ bookmark.getPageParameters().add("cid", conversation.getUnderlyingId());
+ }
+
+ // If we have a target page, propagate the conversation to the page's
+ // metadata
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getUnderlyingId());
+ }
+ }
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T getInstanceByType(BeanManager manager, Class<T> beanType, Annotation... bindings)
+ {
+ Bean<T> bean = (Bean<T>) ensureUniqueBean(beanType, manager.getBeans(beanType, bindings));
+ return (T) manager.getReference(bean, beanType, manager.createCreationalContext(bean));
+ }
+
+ private static Bean<?> ensureUniqueBean(Type type, Set<Bean<?>> beans)
+ {
+ if (beans.size() == 0)
+ {
+ throw new UnsatisfiedResolutionException("Unable to resolve any Web Beans of " + type);
+ }
+ else if (beans.size() > 1)
+ {
+ throw new AmbiguousResolutionException("More than one bean available for type " + type);
+ }
+ return beans.iterator().next();
+ }
+
+ @Override
+ public void detach()
+ {
+ super.detach();
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // cleanup and deactivate the conversation context
+ if (conversationContext.isActive())
+ {
+ ConversationManager conversationManager = getInstanceByType(BeanManagerLookup.getBeanManager(), ConversationManager.class);
+ conversationManager.cleanupConversation();
+ conversationContext.setActive(false);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,41 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+
+/**
+ * WeldWebRequestCycleProcessor is a subclass of the standard wicket
+ * WebRequestCycleProcessor which saves the conversation id of any long-running
+ * cornversation in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldWebRequestCycleProcessor extends WebRequestCycleProcessor
+{
+ @Inject
+ Conversation conversation;
+
+ /**
+ * If a long running conversation has been started, store its id into page
+ * metadata
+ */
+ @Override
+ public void respond(RequestCycle requestCycle)
+ {
+ super.respond(requestCycle);
+ if (!conversation.isTransient())
+ {
+ Page page = RequestCycle.get().getResponsePage();
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getId());
+ }
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
===================================================================
--- modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/NonContextual.java (rev 0)
+++ modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/NonContextual.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,184 @@
+package org.jboss.weld.wicket.util;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * Perform production, injection, lifecycle callbacks and cleanup on a non-contextual object
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+public class NonContextual<T>
+{
+
+ // Store the injection target. The CDI spec doesn't require an implementation
+ // to cache it, so we do
+ private final InjectionTarget<? extends T> injectionTarget;
+
+ // Store a reference to the CDI BeanManager
+ private final BeanManager beanManager;
+
+ /**
+ * Create an injector for the given class
+ */
+ public NonContextual(BeanManager manager, Class<? extends T> clazz)
+ {
+ this.beanManager = manager;
+
+ // Generate an "Annotated Type"
+ AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
+
+ // Generate the InjectionTarget
+ this.injectionTarget = manager.createInjectionTarget(type);
+ }
+
+ public Instance<T> newInstance()
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget);
+ }
+
+ public Instance<T> existingInstance(T instance)
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget, instance);
+ }
+
+ /**
+ * Represents a non-contextual instance
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+ public static class Instance<T>
+ {
+
+ private final CreationalContext<T> ctx;
+ private final InjectionTarget<T> injectionTarget;
+ private T instance;
+ private boolean disposed = false;
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ }
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget, T instance)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ this.instance = instance;
+ }
+
+ /**
+ * Get the instance
+ *
+ * @return
+ */
+ public T get()
+ {
+ return instance;
+ }
+
+ /**
+ * Create the instance
+ *
+ * @return
+ */
+ public Instance<T> produce()
+ {
+ if (this.instance != null)
+ {
+ throw new IllegalStateException("Trying to call produce() on already constructed instance");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call produce() on an already disposed instance");
+ }
+ this.instance = injectionTarget.produce(ctx);
+ return this;
+ }
+
+ /**
+ * Inject the instance
+ *
+ * @return
+ */
+ public Instance<T> inject()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call inject() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call inject() on already disposed instance");
+ }
+ injectionTarget.inject(instance, ctx);
+ return this;
+ }
+
+ /**
+ * Call the @PostConstruct callback
+ *
+ * @return
+ */
+ public Instance<T> postConstruct()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call postConstruct() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.postConstruct(instance);
+ return this;
+ }
+
+ /**
+ * Call the @PreDestroy callback
+ *
+ * @return
+ */
+ public Instance<T> preDestroy()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.preDestroy(instance);
+ return this;
+ }
+
+ /**
+ * Dispose of the instance, doing any necessary cleanup
+ *
+ */
+ public Instance<T> dispose()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call dispose() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call dispose() on already disposed instance");
+ }
+ injectionTarget.dispose(instance);
+ ctx.release();
+ return this;
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/tags/1.0.1-Final/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/pom.xml
===================================================================
--- modules/wicket/trunk/pom.xml (rev 0)
+++ modules/wicket/trunk/pom.xml 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,124 @@
+<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">
+ <parent>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-wicket</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <name>Weld Wicket support</name>
+
+ <description>Weld support for Apache Wicket</description>
+
+ <developers>
+ <developer>
+ <name>Clint Popetz</name>
+ <roles>
+ <role>Module lead</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <url>http://www.seamframework.org/Weld</url>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <distribution>repo</distribution>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ </license>
+ </licenses>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://jira.jboss.org/jira/browse/WELDX/component/12312752</url>
+ </issueManagement>
+
+
+
+ <properties>
+ <weld.api.version>1.0-SP1</weld.api.version>
+ <weld.core.version>1.0.1-Final</weld.core.version>
+ <testng.version>5.10</testng.version>
+ <wicket.version>1.4.1</wicket.version>
+ </properties>
+
+ <!-- Import the BOMs -->
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-api-bom</artifactId>
+ <version>${weld.api.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-bom</artifactId>
+ <version>${weld.core.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>${wicket.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <version>${testng.version}</version>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- WELDX-36 -->
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/wicket/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/wicket/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/weld/wicket/trunk</url>
+ </scm>
+
+</project>
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,85 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * A utilty class to provide access to the JSR-299 BeanManager
+ * @author cpopetz
+ *
+ */
+public class BeanManagerLookup
+{
+
+ private static BeanManager cachedManager;
+ /**
+ * This is the spec-defined name for the bean manager as registered in JNDI
+ * See JSR-299 11.3
+ */
+ // TODO Change to java:comp/BeanManager when JBoss AS supports it
+ private static String beanManagerJndiName = "java:app/BeanManager";
+
+ public static void setBeanManagerJndiName(String beanManagerJndiName)
+ {
+ BeanManagerLookup.beanManagerJndiName = beanManagerJndiName;
+ }
+
+ public static String getBeanManagerJndiName()
+ {
+ return beanManagerJndiName;
+ }
+
+ /**
+ * This is the name under which the bean manager will be stored in the
+ * servlet context. This is not yet specified in JSR-299.
+ */
+ private static String beanManagerServletContextName = BeanManager.class.getName();
+
+ public static void setBeanManagerServletContextName(String beanManagerServletContextName)
+ {
+ BeanManagerLookup.beanManagerServletContextName = beanManagerServletContextName;
+ }
+
+ public static String getBeanManagerServletContextName()
+ {
+ return beanManagerServletContextName;
+ }
+
+
+ /**
+ * We will attempt first to obtain the BeanManager instance from JNDI.
+ * Failing that, we will look in the servlet context.
+ */
+ public static BeanManager getBeanManager()
+ {
+ if (cachedManager == null)
+ {
+ // first look in jndi
+ try
+ {
+ Context initialContext = new InitialContext();
+ cachedManager = (BeanManager) initialContext.lookup(getBeanManagerJndiName());
+ }
+ catch (Exception e)
+ {
+ // we ignore this failure; it could mean we are operating in a
+ // non-jndi (SE or Servlet) env
+ }
+
+ if (cachedManager == null)
+ {
+ ServletContext servletContext = ((WebApplication) Application.get()).getServletContext();
+ if (servletContext != null)
+ {
+ cachedManager = (BeanManager) servletContext.getAttribute(getBeanManagerServletContextName());
+ }
+ }
+ }
+ return cachedManager;
+ }
+}
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/BeanManagerLookup.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldApplication.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldApplication.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldApplication.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,77 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.Request;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * A convenience subclass of wicket's WebApplication which adds the hooks
+ * necessary to use JSR-299 injections in wicket components, as well as manage
+ * JSR-299 conversation scopes with Wicket page metadata. If you have your own
+ * WebApplication subclass, and can't subclass this class, you just need to do
+ * the three things that this class does, i.e. register the
+ * WeldComponentInstantiationListener, and override the two methods below to
+ * return the RequestCycle and IRequestCycleProcessor subclasses specific to
+ * Weld, or your subclasses of those classes.
+ *
+ * @author cpopetz
+ * @author pmuir
+ *
+ * @see WebApplication
+ * @see WeldWebRequestCycleProcessor
+ * @see WeldRequestCycle
+ */
+public abstract class WeldApplication extends WebApplication
+{
+
+ private NonContextual<WeldComponentInstantiationListener> weldComponentInstantiationListener;
+ private NonContextual<WeldWebRequestCycleProcessor> weldWebRequestCycleProcessor;
+
+ /**
+ */
+ public WeldApplication()
+ {
+ }
+
+ /**
+ * Add our component instantiation listener
+ *
+ * @see WeldComponentInstantiationListener
+ */
+ @Override
+ protected void internalInit()
+ {
+ super.internalInit();
+ this.weldComponentInstantiationListener = new NonContextual<WeldComponentInstantiationListener>(BeanManagerLookup.getBeanManager(), WeldComponentInstantiationListener.class);
+ this.weldWebRequestCycleProcessor = new NonContextual<WeldWebRequestCycleProcessor>(BeanManagerLookup.getBeanManager(), WeldWebRequestCycleProcessor.class);
+ addComponentInstantiationListener(weldComponentInstantiationListener.newInstance().produce().inject().get());
+ }
+
+
+ /**
+ * Override to return our Weld-specific request cycle processor
+ *
+ * @see WeldWebRequestCycleProcessor
+ */
+ @Override
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return weldWebRequestCycleProcessor.newInstance().produce().inject().get();
+ }
+
+ /**
+ * Override to return our Weld-specific request cycle
+ *
+ * @see WeldRequestCycle
+ */
+ @Override
+ public RequestCycle newRequestCycle(final Request request, final Response response)
+ {
+ return new WeldRequestCycle(this, (WebRequest) request, (WebResponse) response);
+ }
+}
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldApplication.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,33 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+import org.jboss.weld.wicket.util.NonContextual;
+
+/**
+ * This listener uses the BeanManager to handle injections for all wicket components.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldComponentInstantiationListener implements IComponentInstantiationListener
+{
+
+ @Inject
+ private BeanManager manager;
+
+ public void onInstantiation(Component component)
+ {
+ /*
+ * The manager could be null in unit testing environments
+ */
+ if (manager != null)
+ {
+ // TODO Cache the NonContextual!
+ new NonContextual<Component>(manager, component.getClass()).existingInstance(component).inject();
+ }
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldComponentInstantiationListener.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldMetaData.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldMetaData.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,23 @@
+package org.jboss.weld.wicket;
+
+import org.apache.wicket.MetaDataKey;
+
+/**
+ * Public storage for the metadata key used by the Weld integration to store
+ * conversation ids in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldMetaData
+{
+
+ /**
+ * This is the key we will use to to store the conversation metadata in the
+ * wicket page.
+ */
+ public static final MetaDataKey<String> CID = new MetaDataKey<String>()
+ {
+ private static final long serialVersionUID = -8788010688731927318L;
+ };
+}
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldMetaData.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,166 @@
+package org.jboss.weld.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.Page;
+import org.apache.wicket.Response;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
+import org.apache.wicket.request.target.component.IPageRequestTarget;
+import org.jboss.weld.Container;
+import org.jboss.weld.context.ContextLifecycle;
+import org.jboss.weld.context.ConversationContext;
+import org.jboss.weld.conversation.ConversationImpl;
+import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.servlet.ConversationBeanStore;
+
+/**
+ * WeldRequestCycle is a subclass of the standard wicket WebRequestCycle which:
+ * <ul>
+ * <li>restores long-running conversations specified in wicket page metadata
+ * when a page target is first used.
+ * <li>propagates long running conversations to new page targets by specifying
+ * the above metadata
+ * <li>propagates long running conversations across redirects through the use of
+ * a request parameter if the redirect is handled with a BookmarkablePageRequest
+ * <li>Sets up the conversational context when the request target is set
+ * <li>Tears down the conversation context on detach() of the RequestCycle
+ * </ul>
+ *
+ * @see WeldWebRequestCycleProcessor Which handles propogation of conversation
+ * data for newly-started long running conversations, by storing their ids
+ * in the page metadata
+ * @author cpopetz
+ *
+ */
+public class WeldRequestCycle extends WebRequestCycle
+{
+
+ public WeldRequestCycle(WebApplication application, WebRequest request, Response response)
+ {
+ super(application, request, response);
+ }
+
+ /**
+ * Override to set up the conversation context and to choose the conversation
+ * if a conversation id is present in target metadata.
+ */
+ @Override
+ protected void onRequestTargetSet(IRequestTarget target)
+ {
+ super.onRequestTargetSet(target);
+
+ Page page = null;
+ if (target instanceof IPageRequestTarget)
+ {
+ page = ((IPageRequestTarget) target).getPage();
+ }
+
+ // Two possible specifications of cid: page metadata or request url; the
+ // latter is used to propagate the conversation to mounted (bookmarkable)
+ // paths after a redirect
+
+ String specifiedCid = null;
+ if (page != null)
+ {
+ specifiedCid = page.getMetaData(WeldMetaData.CID);
+ }
+ else
+ {
+ specifiedCid = request.getParameter("cid");
+ }
+
+ BeanManager manager = BeanManagerLookup.getBeanManager();
+
+ ConversationImpl conversation = (ConversationImpl) getInstanceByType(manager, Conversation.class);
+
+ // restore a conversation if it exists and we aren't already in it
+ if (specifiedCid != null && (conversation == null || !specifiedCid.equals(conversation.getUnderlyingId())))
+ {
+ getInstanceByType(manager, ConversationManager.class).beginOrRestoreConversation(specifiedCid);
+ }
+
+
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // Now set up the conversational context if it isn't already
+ if (!conversationContext.isActive())
+ {
+ // TODO account for invalidated session
+ conversationContext.setBeanStore(new ConversationBeanStore(((WebRequest) request).getHttpServletRequest().getSession(), false, conversation.getUnderlyingId()));
+ conversationContext.setActive(true);
+ }
+
+ // handle propagation of existing long running converstaions to new
+ // targets
+ if (!conversation.isTransient())
+ {
+ // Note that we can't propagate conversations with other redirect
+ // targets like RequestRedirectTarget through this mechanism, because
+ // it does not provide an interface to modify its target URL. If
+ // propagation with those targets is to be supported, it needs a custom
+ // Response subclass.
+ if (isRedirect() && target instanceof BookmarkablePageRequestTarget)
+ {
+ BookmarkablePageRequestTarget bookmark = (BookmarkablePageRequestTarget) target;
+ // if a cid has already been specified, don't override it
+ if (!bookmark.getPageParameters().containsKey("cid"))
+ bookmark.getPageParameters().add("cid", conversation.getUnderlyingId());
+ }
+
+ // If we have a target page, propagate the conversation to the page's
+ // metadata
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getUnderlyingId());
+ }
+ }
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T getInstanceByType(BeanManager manager, Class<T> beanType, Annotation... bindings)
+ {
+ Bean<T> bean = (Bean<T>) ensureUniqueBean(beanType, manager.getBeans(beanType, bindings));
+ return (T) manager.getReference(bean, beanType, manager.createCreationalContext(bean));
+ }
+
+ private static Bean<?> ensureUniqueBean(Type type, Set<Bean<?>> beans)
+ {
+ if (beans.size() == 0)
+ {
+ throw new UnsatisfiedResolutionException("Unable to resolve any Web Beans of " + type);
+ }
+ else if (beans.size() > 1)
+ {
+ throw new AmbiguousResolutionException("More than one bean available for type " + type);
+ }
+ return beans.iterator().next();
+ }
+
+ @Override
+ public void detach()
+ {
+ super.detach();
+ ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
+ // cleanup and deactivate the conversation context
+ if (conversationContext.isActive())
+ {
+ ConversationManager conversationManager = getInstanceByType(BeanManagerLookup.getBeanManager(), ConversationManager.class);
+ conversationManager.cleanupConversation();
+ conversationContext.setActive(false);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldRequestCycle.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,41 @@
+package org.jboss.weld.wicket;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+
+/**
+ * WeldWebRequestCycleProcessor is a subclass of the standard wicket
+ * WebRequestCycleProcessor which saves the conversation id of any long-running
+ * cornversation in wicket page metadata.
+ *
+ * @author cpopetz
+ *
+ */
+public class WeldWebRequestCycleProcessor extends WebRequestCycleProcessor
+{
+ @Inject
+ Conversation conversation;
+
+ /**
+ * If a long running conversation has been started, store its id into page
+ * metadata
+ */
+ @Override
+ public void respond(RequestCycle requestCycle)
+ {
+ super.respond(requestCycle);
+ if (!conversation.isTransient())
+ {
+ Page page = RequestCycle.get().getResponsePage();
+ if (page != null)
+ {
+ page.setMetaData(WeldMetaData.CID, conversation.getId());
+ }
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/WeldWebRequestCycleProcessor.java
___________________________________________________________________
Name: svn:executable
+
Name: svn:eol-style
+ native
Added: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
===================================================================
--- modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/NonContextual.java (rev 0)
+++ modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/NonContextual.java 2010-04-20 16:15:07 UTC (rev 12528)
@@ -0,0 +1,184 @@
+package org.jboss.weld.wicket.util;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * Perform production, injection, lifecycle callbacks and cleanup on a non-contextual object
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+public class NonContextual<T>
+{
+
+ // Store the injection target. The CDI spec doesn't require an implementation
+ // to cache it, so we do
+ private final InjectionTarget<? extends T> injectionTarget;
+
+ // Store a reference to the CDI BeanManager
+ private final BeanManager beanManager;
+
+ /**
+ * Create an injector for the given class
+ */
+ public NonContextual(BeanManager manager, Class<? extends T> clazz)
+ {
+ this.beanManager = manager;
+
+ // Generate an "Annotated Type"
+ AnnotatedType<? extends T> type = manager.createAnnotatedType(clazz);
+
+ // Generate the InjectionTarget
+ this.injectionTarget = manager.createInjectionTarget(type);
+ }
+
+ public Instance<T> newInstance()
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget);
+ }
+
+ public Instance<T> existingInstance(T instance)
+ {
+ return new Instance<T>(beanManager, (InjectionTarget<T>) injectionTarget, instance);
+ }
+
+ /**
+ * Represents a non-contextual instance
+ *
+ * @author pmuir
+ *
+ * @param <T>
+ */
+ public static class Instance<T>
+ {
+
+ private final CreationalContext<T> ctx;
+ private final InjectionTarget<T> injectionTarget;
+ private T instance;
+ private boolean disposed = false;
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ }
+
+ private Instance(BeanManager beanManager, InjectionTarget<T> injectionTarget, T instance)
+ {
+ this.injectionTarget = injectionTarget;
+ this.ctx = beanManager.createCreationalContext(null);
+ this.instance = instance;
+ }
+
+ /**
+ * Get the instance
+ *
+ * @return
+ */
+ public T get()
+ {
+ return instance;
+ }
+
+ /**
+ * Create the instance
+ *
+ * @return
+ */
+ public Instance<T> produce()
+ {
+ if (this.instance != null)
+ {
+ throw new IllegalStateException("Trying to call produce() on already constructed instance");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call produce() on an already disposed instance");
+ }
+ this.instance = injectionTarget.produce(ctx);
+ return this;
+ }
+
+ /**
+ * Inject the instance
+ *
+ * @return
+ */
+ public Instance<T> inject()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call inject() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call inject() on already disposed instance");
+ }
+ injectionTarget.inject(instance, ctx);
+ return this;
+ }
+
+ /**
+ * Call the @PostConstruct callback
+ *
+ * @return
+ */
+ public Instance<T> postConstruct()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call postConstruct() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.postConstruct(instance);
+ return this;
+ }
+
+ /**
+ * Call the @PreDestroy callback
+ *
+ * @return
+ */
+ public Instance<T> preDestroy()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call preDestroy() on already disposed instance");
+ }
+ injectionTarget.preDestroy(instance);
+ return this;
+ }
+
+ /**
+ * Dispose of the instance, doing any necessary cleanup
+ *
+ */
+ public Instance<T> dispose()
+ {
+ if (this.instance == null)
+ {
+ throw new IllegalStateException("Trying to call dispose() before produce() was called");
+ }
+ if (disposed)
+ {
+ throw new IllegalStateException("Trying to call dispose() on already disposed instance");
+ }
+ injectionTarget.dispose(instance);
+ ctx.release();
+ return this;
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: modules/wicket/trunk/src/main/java/org/jboss/weld/wicket/util/NonContextual.java
___________________________________________________________________
Name: svn:eol-style
+ native
[View Less]
14 years, 9 months
Seam SVN: r12527 - modules/wicket.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-20 12:07:48 -0400 (Tue, 20 Apr 2010)
New Revision: 12527
Removed:
modules/wicket/branches/
modules/wicket/tags/
modules/wicket/trunk/
Log:
and again...
14 years, 9 months
Seam SVN: r12525 - modules.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-20 12:05:31 -0400 (Tue, 20 Apr 2010)
New Revision: 12525
Removed:
modules/wicket/
Log:
start again
14 years, 9 months
Seam SVN: r12523 - modules/wicket.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-20 11:57:53 -0400 (Tue, 20 Apr 2010)
New Revision: 12523
Removed:
modules/wicket/branches/
modules/wicket/tags/
modules/wicket/trunk/
Log:
actually, scrap this
14 years, 9 months
Seam SVN: r12522 - in modules: wicket and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-20 11:52:46 -0400 (Tue, 20 Apr 2010)
New Revision: 12522
Added:
modules/wicket/
modules/wicket/branches/
modules/wicket/tags/
modules/wicket/trunk/
Log:
Add Wicket module layout
14 years, 9 months
Seam SVN: r12521 - in modules/servlet/trunk: impl/src/main/java/org/jboss/seam/servlet/event and 6 other directories.
by seam-commits@lists.jboss.org
Author: nickarls
Date: 2010-04-16 17:58:35 -0400 (Fri, 16 Apr 2010)
New Revision: 12521
Added:
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Added.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Attribute.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Bound.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Removed.java
modules/servlet/trunk/…
[View More]api/src/main/java/org/jboss/seam/servlet/event/qualifier/Replaced.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Unbound.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Value.java
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java
modules/servlet/trunk/impl/src/test/java/org/
modules/servlet/trunk/impl/src/test/java/org/jboss/
modules/servlet/trunk/impl/src/test/java/org/jboss/seam/
modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/
modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/
modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventBridgeTest.java
modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventObserver.java
Removed:
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeAdded.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeRemoved.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeReplaced.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueBound.java
modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueUnbound.java
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventListener.java
Log:
Disable tests until I find a way to have servlet listeners as managed beans
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Added.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Added.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Added.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,15 @@
+package org.jboss.seam.servlet.event.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Added
+{
+}
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Attribute.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Attribute.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Attribute.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,45 @@
+/*
+ * 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.event.qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Qualifies observer method parameters to select events for a particular
+ * attribute
+ *
+ * @author Nicklas Karlsson
+ */
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Attribute
+{
+ String value() default "";
+}
\ No newline at end of file
Deleted: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeAdded.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeAdded.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeAdded.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -1,51 +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.event.qualifier;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Qualifies observer method parameters to select events that fire when
- * attributes being added.
- *
- * The event parameter can be a {@link HttpSessionBindingEvent},
- * {@link ServletContextAttributeEvent} or a
- * {@link ServletRequestAttributeEvent}.
- *
- * @author Nicklas Karlsson
- */
-@Qualifier
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-public @interface AttributeAdded
-{
-}
\ No newline at end of file
Deleted: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeRemoved.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeRemoved.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeRemoved.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -1,50 +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.event.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-
-import javax.inject.Qualifier;
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Qualifies observer method parameters to select events that fire when
- * attributes being removed.
- *
- * The event parameter can be a {@link HttpSessionBindingEvent},
- * {@link ServletContextAttributeEvent} or a
- * {@link ServletRequestAttributeEvent}.
- *
- * @author Nicklas Karlsson
- */
-@Qualifier
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-public @interface AttributeRemoved
-{
-}
\ No newline at end of file
Deleted: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeReplaced.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeReplaced.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/AttributeReplaced.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -1,50 +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.event.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-
-import javax.inject.Qualifier;
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Qualifies observer method parameters to select events that fire when
- * attributes being replaced.
- *
- * The event parameter can be a {@link HttpSessionBindingEvent},
- * {@link ServletContextAttributeEvent} or a
- * {@link ServletRequestAttributeEvent}.
- *
- * @author Nicklas Karlsson
- */
-@Qualifier
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-public @interface AttributeReplaced
-{
-}
\ No newline at end of file
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Bound.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Bound.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Bound.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,14 @@
+package org.jboss.seam.servlet.event.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Bound {
+}
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Removed.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Removed.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Removed.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,15 @@
+package org.jboss.seam.servlet.event.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Removed
+{
+}
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Replaced.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Replaced.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Replaced.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,15 @@
+package org.jboss.seam.servlet.event.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Replaced
+{
+}
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Unbound.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Unbound.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Unbound.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,15 @@
+package org.jboss.seam.servlet.event.qualifier;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Unbound
+{
+}
Added: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Value.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Value.java (rev 0)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/Value.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,44 @@
+/*
+ * 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.event.qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Qualifies observer method parameters to select events for a particular value
+ *
+ * @author Nicklas Karlsson
+ */
+@Qualifier
+@Target( { FIELD, PARAMETER })
+@Retention(RUNTIME)
+public @interface Value
+{
+ String value() default "";
+}
\ No newline at end of file
Deleted: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueBound.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueBound.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueBound.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -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.servlet.event.qualifier;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Qualifies observer method parameters to select events that fire when values
- * are being bound to the HTTP session.
- *
- * The event parameter is a {@link HttpSessionBindingEvent}
- *
- * @author Nicklas Karlsson
- */
-@Qualifier
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-public @interface ValueBound
-{
-}
\ No newline at end of file
Deleted: modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueUnbound.java
===================================================================
--- modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueUnbound.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/api/src/main/java/org/jboss/seam/servlet/event/qualifier/ValueUnbound.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -1,46 +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.event.qualifier;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-
-import javax.inject.Qualifier;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- * Qualifies observer method parameters to select events that fire when values
- * are being unbound from the HTTP session.
- *
- * The event parameter is a {@link HttpSessionBindingEvent}
- *
- * @author Nicklas Karlsson
- */
-@Qualifier
-@Target( { FIELD, PARAMETER })
-@Retention(RUNTIME)
-public @interface ValueUnbound
-{
-}
\ No newline at end of file
Copied: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java (from rev 12496, modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventListener.java)
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java (rev 0)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,339 @@
+/*
+ * 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.event;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.jboss.seam.servlet.event.qualifier.Added;
+import org.jboss.seam.servlet.event.qualifier.Attribute;
+import org.jboss.seam.servlet.event.qualifier.Bound;
+import org.jboss.seam.servlet.event.qualifier.Completed;
+import org.jboss.seam.servlet.event.qualifier.Created;
+import org.jboss.seam.servlet.event.qualifier.Destroyed;
+import org.jboss.seam.servlet.event.qualifier.DidActivate;
+import org.jboss.seam.servlet.event.qualifier.Error;
+import org.jboss.seam.servlet.event.qualifier.Initialized;
+import org.jboss.seam.servlet.event.qualifier.Removed;
+import org.jboss.seam.servlet.event.qualifier.Replaced;
+import org.jboss.seam.servlet.event.qualifier.StartAsync;
+import org.jboss.seam.servlet.event.qualifier.Timeout;
+import org.jboss.seam.servlet.event.qualifier.Unbound;
+import org.jboss.seam.servlet.event.qualifier.Value;
+import org.jboss.seam.servlet.event.qualifier.WillPassivate;
+import org.slf4j.Logger;
+
+/**
+ * A servlet listener that propagates the events to the current CDI Bean Manager
+ * event queue
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class ServletEventBridge implements HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, AsyncListener
+{
+ @Inject
+ private BeanManager beanManager;
+
+ @Inject
+ private Logger log;
+
+ public ServletEventBridge()
+ {
+ }
+
+ /**
+ * Session activated / passivated events
+ */
+
+ public void sessionDidActivate(final HttpSessionEvent e)
+ {
+ fireEvent(e, DIDACTIVATE);
+ }
+
+ public void sessionWillPassivate(final HttpSessionEvent e)
+ {
+ fireEvent(e, WILLPASSIVATE);
+ }
+
+ /**
+ * Session attribute events
+ */
+
+ public void attributeAdded(final HttpSessionBindingEvent e)
+ {
+ fireEvent(e, ADDED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeRemoved(final HttpSessionBindingEvent e)
+ {
+ fireEvent(e, REMOVED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeReplaced(final HttpSessionBindingEvent e)
+ {
+ fireEvent(e, REPLACED, new AttributeLiteral(e.getName()));
+ }
+
+ public void valueBound(final HttpSessionBindingEvent e)
+ {
+ fireEvent(e, BOUND, new ValueLiteral(e.getName()));
+ }
+
+ public void valueUnbound(final HttpSessionBindingEvent e)
+ {
+ fireEvent(e, UNBOUND, new ValueLiteral(e.getName()));
+ }
+
+ /**
+ * Session created / destroyed events
+ */
+
+ public void sessionCreated(final HttpSessionEvent e)
+ {
+ fireEvent(e, CREATED);
+ }
+
+ public void sessionDestroyed(final HttpSessionEvent e)
+ {
+ fireEvent(e, DESTROYED);
+ }
+
+ /**
+ * Servlet context initialized / destroyed events
+ */
+
+ public void contextDestroyed(final ServletContextEvent e)
+ {
+ fireEvent(e, DESTROYED);
+ }
+
+ public void contextInitialized(final ServletContextEvent e)
+ {
+ fireEvent(e, INITIALIZED);
+ }
+
+ /**
+ * Servlet context attribute events
+ */
+
+ public void attributeAdded(final ServletContextAttributeEvent e)
+ {
+ fireEvent(e, ADDED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeRemoved(final ServletContextAttributeEvent e)
+ {
+ fireEvent(e, REMOVED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeReplaced(final ServletContextAttributeEvent e)
+ {
+ fireEvent(e, REPLACED, new AttributeLiteral(e.getName()));
+ }
+
+ /**
+ * Request created / destroyed events
+ */
+
+ public void requestDestroyed(final ServletRequestEvent e)
+ {
+ fireEvent(e, DESTROYED);
+ }
+
+ public void requestInitialized(final ServletRequestEvent e)
+ {
+ fireEvent(e, INITIALIZED);
+ }
+
+ /**
+ * Servlet request attribute events
+ */
+
+ public void attributeAdded(final ServletRequestAttributeEvent e)
+ {
+ fireEvent(e, ADDED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeRemoved(final ServletRequestAttributeEvent e)
+ {
+ fireEvent(e, REMOVED, new AttributeLiteral(e.getName()));
+ }
+
+ public void attributeReplaced(final ServletRequestAttributeEvent e)
+ {
+ fireEvent(e, REPLACED, new AttributeLiteral(e.getName()));
+ }
+
+ /**
+ * Asynchronous events
+ */
+
+ public void onComplete(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, COMPLETED);
+ }
+
+ public void onError(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, ERROR);
+ }
+
+ public void onStartAsync(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, STARTASYNCH);
+ }
+
+ public void onTimeout(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, TIMEOUT);
+ }
+
+ private void fireEvent(final Object payload, final Annotation... qualifiers)
+ {
+ log.trace("Firing event #0 with qualifiers #1", payload, qualifiers);
+ beanManager.fireEvent(payload, qualifiers);
+ }
+
+ /*
+ * Annotation Literal Constants
+ */
+ private static final AnnotationLiteral<WillPassivate> WILLPASSIVATE = new AnnotationLiteral<WillPassivate>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<DidActivate> DIDACTIVATE = new AnnotationLiteral<DidActivate>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Unbound> UNBOUND = new AnnotationLiteral<Unbound>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Bound> BOUND = new AnnotationLiteral<Bound>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Created> CREATED = new AnnotationLiteral<Created>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Destroyed> DESTROYED = new AnnotationLiteral<Destroyed>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Initialized> INITIALIZED = new AnnotationLiteral<Initialized>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Added> ADDED = new AnnotationLiteral<Added>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Removed> REMOVED = new AnnotationLiteral<Removed>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Replaced> REPLACED = new AnnotationLiteral<Replaced>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Completed> COMPLETED = new AnnotationLiteral<Completed>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Error> ERROR = new AnnotationLiteral<Error>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<StartAsync> STARTASYNCH = new AnnotationLiteral<StartAsync>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Timeout> TIMEOUT = new AnnotationLiteral<Timeout>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private class AttributeLiteral extends AnnotationLiteral<Attribute> implements Attribute
+ {
+ private final String value;
+
+ public String value()
+ {
+ return value;
+ }
+
+ public AttributeLiteral(String value)
+ {
+ this.value = value;
+ }
+ }
+
+ private class ValueLiteral extends AnnotationLiteral<Value> implements Value
+ {
+ private final String value;
+
+ public String value()
+ {
+ return value;
+ }
+
+ public ValueLiteral(String value)
+ {
+ this.value = value;
+ }
+ }
+}
Deleted: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventListener.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventListener.java 2010-04-16 21:52:00 UTC (rev 12520)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventListener.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -1,300 +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.event;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-import javax.servlet.AsyncEvent;
-import javax.servlet.AsyncListener;
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletContextAttributeListener;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.ServletRequestAttributeListener;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.http.HttpSessionActivationListener;
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionBindingListener;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-
-import org.jboss.seam.servlet.event.qualifier.AttributeAdded;
-import org.jboss.seam.servlet.event.qualifier.AttributeRemoved;
-import org.jboss.seam.servlet.event.qualifier.AttributeReplaced;
-import org.jboss.seam.servlet.event.qualifier.Completed;
-import org.jboss.seam.servlet.event.qualifier.Created;
-import org.jboss.seam.servlet.event.qualifier.Destroyed;
-import org.jboss.seam.servlet.event.qualifier.DidActivate;
-import org.jboss.seam.servlet.event.qualifier.Error;
-import org.jboss.seam.servlet.event.qualifier.Initialized;
-import org.jboss.seam.servlet.event.qualifier.StartAsync;
-import org.jboss.seam.servlet.event.qualifier.Timeout;
-import org.jboss.seam.servlet.event.qualifier.ValueBound;
-import org.jboss.seam.servlet.event.qualifier.ValueUnbound;
-import org.jboss.seam.servlet.event.qualifier.WillPassivate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A servlet listener that propagates the events to the current CDI Bean Manager
- * event queue
- *
- * @author Nicklas Karlsson
- *
- */
-public class ServletEventListener implements HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, AsyncListener
-{
- @Inject
- private BeanManager beanManager;
-
- private final Logger log = LoggerFactory.getLogger(ServletEventListener.class);
-
- /**
- * Session activated / passivated events
- */
-
- public void sessionDidActivate(final HttpSessionEvent e)
- {
- fireEvent(e, new AnnotationLiteral<DidActivate>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void sessionWillPassivate(final HttpSessionEvent e)
- {
- fireEvent(e, new AnnotationLiteral<WillPassivate>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Session attribute events
- */
-
- public void attributeAdded(final HttpSessionBindingEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeAdded>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeRemoved(final HttpSessionBindingEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeRemoved>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeReplaced(final HttpSessionBindingEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeReplaced>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void valueBound(final HttpSessionBindingEvent e)
- {
- fireEvent(e, new AnnotationLiteral<ValueBound>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void valueUnbound(final HttpSessionBindingEvent e)
- {
- fireEvent(e, new AnnotationLiteral<ValueUnbound>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Session created / destroyed events
- */
-
- public void sessionCreated(final HttpSessionEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Created>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void sessionDestroyed(final HttpSessionEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Destroyed>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Servlet context initialized / destroyed events
- */
-
- public void contextDestroyed(final ServletContextEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Destroyed>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void contextInitialized(final ServletContextEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Initialized>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Servlet context attribute events
- */
-
- public void attributeAdded(final ServletContextAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeAdded>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeRemoved(final ServletContextAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeRemoved>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeReplaced(final ServletContextAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeReplaced>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Request created / destroyed events
- */
-
- public void requestDestroyed(final ServletRequestEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Destroyed>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void requestInitialized(final ServletRequestEvent e)
- {
- fireEvent(e, new AnnotationLiteral<Initialized>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Servlet request attribute events
- */
-
- public void attributeAdded(final ServletRequestAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeAdded>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeRemoved(final ServletRequestAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeRemoved>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void attributeReplaced(final ServletRequestAttributeEvent e)
- {
- fireEvent(e, new AnnotationLiteral<AttributeReplaced>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- /**
- * Asynchronous events
- */
-
- public void onComplete(final AsyncEvent e) throws IOException
- {
- fireEvent(e, new AnnotationLiteral<Completed>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void onError(final AsyncEvent e) throws IOException
- {
- fireEvent(e, new AnnotationLiteral<Error>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void onStartAsync(final AsyncEvent e) throws IOException
- {
- fireEvent(e, new AnnotationLiteral<StartAsync>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- public void onTimeout(final AsyncEvent e) throws IOException
- {
- fireEvent(e, new AnnotationLiteral<Timeout>()
- {
- private static final long serialVersionUID = 1L;
- });
- }
-
- private void fireEvent(final Object payload, final Annotation... qualifiers)
- {
- log.trace("Firing event #0 with qualifiers #1", payload, qualifiers);
- beanManager.fireEvent(payload, qualifiers);
- }
-
-}
Added: modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventBridgeTest.java
===================================================================
--- modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventBridgeTest.java (rev 0)
+++ modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventBridgeTest.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,460 @@
+package org.jboss.seam.servlet.event;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+import javax.servlet.AsyncEvent;
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.servlet.event.ServletEventBridge;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.formatter.Formatters;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+//(a)RunWith(Arquillian.class)
+public class ServletEventBridgeTest
+{
+
+ @Test
+ public void dummy() {
+
+ }
+ /*
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ JavaArchive a = Archives.create("test.jar", JavaArchive.class).addClasses(ServletEventBridge.class, ServletEventObserver.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+ System.out.println(a.toString(Formatters.VERBOSE));
+ return a;
+ }
+
+ @Inject
+ ServletEventBridge listener;
+
+ @Inject
+ ServletEventObserver observer;
+
+ @Test
+ public void testObserveAnySessionEvent()
+ {
+ observer.reset();
+ HttpSessionEvent e1 = new HttpSessionEvent(null);
+ HttpSessionEvent e2 = new HttpSessionEvent(null);
+ HttpSessionEvent e3 = new HttpSessionEvent(null);
+ HttpSessionEvent e4 = new HttpSessionEvent(null);
+ listener.sessionCreated(e1);
+ listener.sessionDidActivate(e2);
+ listener.sessionWillPassivate(e3);
+ listener.sessionDestroyed(e4);
+ observer.assertObservations("1", e1, e2, e3, e4);
+ }
+
+ @Test
+ public void testObserveSessionActivated()
+ {
+ observer.reset();
+ HttpSessionEvent e = new HttpSessionEvent(null);
+ listener.sessionDidActivate(e);
+ observer.assertObservations("2", e);
+ }
+
+ @Test
+ public void testObserveSessionPassivated()
+ {
+ observer.reset();
+ HttpSessionEvent e = new HttpSessionEvent(null);
+ listener.sessionWillPassivate(e);
+ observer.assertObservations("3", e);
+ }
+
+ @Test
+ public void testObserveSessionCreated()
+ {
+ observer.reset();
+ HttpSessionEvent e = new HttpSessionEvent(null);
+ listener.sessionCreated(e);
+ observer.assertObservations("4", e);
+ }
+
+ @Test
+ public void testObserveSessionDestroyed()
+ {
+ observer.reset();
+ HttpSessionEvent e = new HttpSessionEvent(null);
+ listener.sessionDestroyed(e);
+ observer.assertObservations("5", e);
+ }
+
+ @Test
+ public void testObserveAnySessionBindingEvent()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e1 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e2 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e3 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e4 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e5 = new HttpSessionBindingEvent(null, "");
+ listener.attributeAdded(e1);
+ listener.attributeRemoved(e2);
+ listener.attributeReplaced(e3);
+ listener.valueBound(e4);
+ listener.valueUnbound(e5);
+ observer.assertObservations("6", e1, e2, e3, e4, e5);
+ }
+
+ @Test
+ public void testObserveSessionAttributeAdded()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeAdded(e);
+ observer.assertObservations("7", e);
+ }
+
+ @Test
+ public void testObserveSessionAttributeReplaced()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeReplaced(e);
+ observer.assertObservations("8", e);
+ }
+
+ @Test
+ public void testObserveSessionAttributeRemoved()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeRemoved(e);
+ observer.assertObservations("9", e);
+ }
+
+ @Test
+ public void testObserveSessionValueBound()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.valueBound(e);
+ observer.assertObservations("10", e);
+ }
+
+ @Test
+ public void testObserveSessionValueUnbound()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.valueUnbound(e);
+ observer.assertObservations("11", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionAttributeAdded()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeAdded(e);
+ observer.assertObservations("12", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionAttributeReplaced()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeReplaced(e);
+ observer.assertObservations("13", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionAttributeRemoved()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.attributeRemoved(e);
+ observer.assertObservations("14", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionAttribute()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e1 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e2 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e3 = new HttpSessionBindingEvent(null, "");
+ listener.attributeAdded(e1);
+ listener.attributeRemoved(e2);
+ listener.attributeReplaced(e3);
+ observer.assertObservations("14a", e1, e2, e3);
+ }
+
+ @Test
+ public void testObserveSpecificSessionValueBound()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.valueBound(e);
+ observer.assertObservations("15", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionValueUnbound()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e = new HttpSessionBindingEvent(null, "");
+ listener.valueUnbound(e);
+ observer.assertObservations("16", e);
+ }
+
+ @Test
+ public void testObserveSpecificSessionValue()
+ {
+ observer.reset();
+ HttpSessionBindingEvent e1 = new HttpSessionBindingEvent(null, "");
+ HttpSessionBindingEvent e2 = new HttpSessionBindingEvent(null, "");
+ listener.valueBound(e1);
+ listener.valueUnbound(e2);
+ observer.assertObservations("16a", e1, e2);
+ }
+
+ @Test
+ public void testObserveServletContext()
+ {
+ observer.reset();
+ ServletContextEvent e1 = new ServletContextEvent(null);
+ ServletContextEvent e2 = new ServletContextEvent(null);
+ listener.contextInitialized(e1);
+ listener.contextDestroyed(e2);
+ observer.assertObservations("17", e1, e2);
+ }
+
+ @Test
+ public void testObserveServletContextInitialized()
+ {
+ observer.reset();
+ ServletContextEvent e = new ServletContextEvent(null);
+ listener.contextInitialized(e);
+ observer.assertObservations("18", e);
+ }
+
+ @Test
+ public void testObserveServletContextDestroyed()
+ {
+ observer.reset();
+ ServletContextEvent e = new ServletContextEvent(null);
+ listener.contextInitialized(e);
+ observer.assertObservations("19", e);
+ }
+
+ @Test
+ public void testObserveServletContextAttribute()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e1 = new ServletContextAttributeEvent(null, "", null);
+ ServletContextAttributeEvent e2 = new ServletContextAttributeEvent(null, "", null);
+ ServletContextAttributeEvent e3 = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeAdded(e1);
+ listener.attributeRemoved(e2);
+ listener.attributeReplaced(e3);
+ observer.assertObservations("20", e1, e2, e3);
+ }
+
+ @Test
+ public void testObserveAnyServletContextAttributeAdded()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeAdded(e);
+ observer.assertObservations("21", e);
+ }
+
+ @Test
+ public void testObserveAnyServletContextAttributeReplaced()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeReplaced(e);
+ observer.assertObservations("22", e);
+ }
+
+ @Test
+ public void testObserveAnyServletContextAttributeRemoved()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeRemoved(e);
+ observer.assertObservations("23", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletContextAttributeAdded()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeAdded(e);
+ observer.assertObservations("24", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletContextAttributeReplaced()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeReplaced(e);
+ observer.assertObservations("25", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletContextAttributeRemoved()
+ {
+ observer.reset();
+ ServletContextAttributeEvent e = new ServletContextAttributeEvent(null, "", null);
+ listener.attributeRemoved(e);
+ observer.assertObservations("26", e);
+ }
+
+ @Test
+ public void testObserveServletRequest()
+ {
+ observer.reset();
+ ServletRequestEvent e1 = new ServletRequestEvent(null, null);
+ ServletRequestEvent e2 = new ServletRequestEvent(null, null);
+ listener.requestInitialized(e1);
+ listener.requestDestroyed(e2);
+ observer.assertObservations("27", e1, e2);
+ }
+
+ @Test
+ public void testObserveRequestInitialized()
+ {
+ observer.reset();
+ ServletRequestEvent e = new ServletRequestEvent(null, null);
+ listener.requestInitialized(e);
+ observer.assertObservations("28", e);
+ }
+
+ @Test
+ public void testObserveRequestDestroyed()
+ {
+ observer.reset();
+ ServletRequestEvent e = new ServletRequestEvent(null, null);
+ listener.requestDestroyed(e);
+ observer.assertObservations("29", e);
+ }
+
+ @Test
+ public void testObserveAnyServletRequestAttributeAdded()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeAdded(e);
+ observer.assertObservations("30", e);
+ }
+
+ @Test
+ public void testObserveAnyServletRequestAttributeReplaced()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeReplaced(e);
+ observer.assertObservations("31", e);
+ }
+
+ @Test
+ public void testObserveAnyServletRequestAttributeRemoved()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeRemoved(e);
+ observer.assertObservations("32", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletRequestAttributeAdded()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeAdded(e);
+ observer.assertObservations("33", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletRequestAttributeReplaced()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeReplaced(e);
+ observer.assertObservations("34", e);
+ }
+
+ @Test
+ public void testObserveSpecificServletRequestAttributeRemoved()
+ {
+ observer.reset();
+ ServletRequestAttributeEvent e = new ServletRequestAttributeEvent(null, null, "", null);
+ listener.attributeRemoved(e);
+ observer.assertObservations("35", e);
+ }
+
+ @Test
+ public void testObserveAsynchrnousEventCompleted() throws IOException
+ {
+ observer.reset();
+ AsyncEvent e = new AsyncEvent(null);
+ listener.onComplete(e);
+ observer.assertObservations("36", e);
+ }
+
+ @Test
+ public void testObserveAsynchrnousEventError() throws IOException
+ {
+ observer.reset();
+ AsyncEvent e = new AsyncEvent(null);
+ listener.onError(e);
+ observer.assertObservations("37", e);
+ }
+
+ @Test
+ public void testObserveAsynchrnousEventStarted() throws IOException
+ {
+ observer.reset();
+ AsyncEvent e = new AsyncEvent(null);
+ listener.onStartAsync(e);
+ observer.assertObservations("38", e);
+ }
+
+ @Test
+ public void testObserveAsynchrnousEventTimedOut() throws IOException
+ {
+ observer.reset();
+ AsyncEvent e = new AsyncEvent(null);
+ listener.onTimeout(e);
+ observer.assertObservations("39", e);
+ }
+
+ @Test
+ public void testObserveAsynchrnousEventT() throws IOException
+ {
+ observer.reset();
+ AsyncEvent e1 = new AsyncEvent(null);
+ AsyncEvent e2 = new AsyncEvent(null);
+ AsyncEvent e3 = new AsyncEvent(null);
+ AsyncEvent e4 = new AsyncEvent(null);
+ listener.onComplete(e1);
+ listener.onError(e2);
+ listener.onStartAsync(e3);
+ listener.onTimeout(e4);
+ observer.assertObservations("40", e1, e2, e3, e4);
+ }
+ */
+}
\ No newline at end of file
Added: modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventObserver.java
===================================================================
--- modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventObserver.java (rev 0)
+++ modules/servlet/trunk/impl/src/test/java/org/jboss/seam/servlet/event/ServletEventObserver.java 2010-04-16 21:58:35 UTC (rev 12521)
@@ -0,0 +1,275 @@
+package org.jboss.seam.servlet.event;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.servlet.AsyncEvent;
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.jboss.seam.servlet.event.qualifier.Added;
+import org.jboss.seam.servlet.event.qualifier.Attribute;
+import org.jboss.seam.servlet.event.qualifier.Bound;
+import org.jboss.seam.servlet.event.qualifier.Completed;
+import org.jboss.seam.servlet.event.qualifier.Created;
+import org.jboss.seam.servlet.event.qualifier.Destroyed;
+import org.jboss.seam.servlet.event.qualifier.DidActivate;
+import org.jboss.seam.servlet.event.qualifier.Error;
+import org.jboss.seam.servlet.event.qualifier.Initialized;
+import org.jboss.seam.servlet.event.qualifier.Removed;
+import org.jboss.seam.servlet.event.qualifier.Replaced;
+import org.jboss.seam.servlet.event.qualifier.StartAsync;
+import org.jboss.seam.servlet.event.qualifier.Timeout;
+import org.jboss.seam.servlet.event.qualifier.Unbound;
+import org.jboss.seam.servlet.event.qualifier.Value;
+import org.jboss.seam.servlet.event.qualifier.WillPassivate;
+
+@ApplicationScoped
+public class ServletEventObserver
+{
+ private Map<String, List<Object>> observations = new HashMap<String, List<Object>>();
+
+ private void recordObservation(String id, Object observation)
+ {
+ List<Object> observed = observations.get(id);
+ if (observed == null)
+ {
+ observed = new ArrayList<Object>();
+ observations.put(id, observed);
+ }
+ observed.add(observation);
+ }
+
+ public void reset()
+ {
+ observations.clear();
+ }
+
+ public void assertObservations(String id, Object... observations)
+ {
+ List<Object> observed = this.observations.get(id);
+ assert observed != null && observed.size() == observations.length;
+ assert observed.containsAll(Arrays.asList(observations));
+ }
+
+ public void observe1(@Observes HttpSessionEvent e)
+ {
+ recordObservation("1", e);
+ }
+
+ public void observe2(@Observes @DidActivate HttpSessionEvent e)
+ {
+ recordObservation("2", e);
+ }
+
+ public void observe3(@Observes @WillPassivate HttpSessionEvent e)
+ {
+ recordObservation("3", e);
+ }
+
+ public void observe4(@Observes @Created HttpSessionEvent e)
+ {
+ recordObservation("4", e);
+ }
+
+ public void observe5(@Observes @Destroyed HttpSessionEvent e)
+ {
+ recordObservation("5", e);
+ }
+
+ public void observe6(@Observes HttpSessionBindingEvent e)
+ {
+ recordObservation("6", e);
+ }
+
+ public void observe7(@Observes @Added HttpSessionBindingEvent e)
+ {
+ recordObservation("7", e);
+ }
+
+ public void observe8(@Observes @Replaced HttpSessionBindingEvent e)
+ {
+ recordObservation("8", e);
+ }
+
+ public void observe9(@Observes @Removed HttpSessionBindingEvent e)
+ {
+ recordObservation("9", e);
+ }
+
+ public void observe10(@Observes @Bound HttpSessionBindingEvent e)
+ {
+ recordObservation("10", e);
+ }
+
+ public void observe11(@Observes @Unbound HttpSessionBindingEvent e)
+ {
+ recordObservation("11", e);
+ }
+
+ public void observe12(@Observes @Added @Attribute("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("12", e);
+ }
+
+ public void observe13(@Observes @Replaced @Attribute("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("13", e);
+ }
+
+ public void observe14(@Observes @Removed @Attribute("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("14", e);
+ }
+
+ public void observe14a(@Observes @Attribute("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("14a", e);
+ }
+
+ public void observe15(@Observes @Bound @Value("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("15", e);
+ }
+
+ public void observe16(@Observes @Unbound @Value("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("16", e);
+ }
+
+ public void observe16a(@Observes @Value("foo") HttpSessionBindingEvent e)
+ {
+ recordObservation("16a", e);
+ }
+
+ public void observe17(@Observes ServletContextEvent e)
+ {
+ recordObservation("17", e);
+ }
+
+ public void observe18(@Observes @Initialized ServletContextEvent e)
+ {
+ recordObservation("18", e);
+ }
+
+ public void observe19(@Observes @Destroyed ServletContextEvent e)
+ {
+ recordObservation("19", e);
+ }
+
+ public void observe20(@Observes ServletContextAttributeEvent e)
+ {
+ recordObservation("20", e);
+ }
+
+ public void observe21(@Observes @Added ServletContextAttributeEvent e)
+ {
+ recordObservation("21", e);
+ }
+
+ public void observe22(@Observes @Replaced ServletContextAttributeEvent e)
+ {
+ recordObservation("22", e);
+ }
+
+ public void observe23(@Observes @Removed ServletContextAttributeEvent e)
+ {
+ recordObservation("23", e);
+ }
+
+ public void observe24(@Observes @Added @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("24", e);
+ }
+
+ public void observe25(@Observes @Replaced @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("25", e);
+ }
+
+ public void observe26(@Observes @Removed @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("26", e);
+ }
+
+ public void observe27(@Observes ServletRequestEvent e)
+ {
+ recordObservation("27", e);
+ }
+
+ public void observe28(@Observes @Initialized ServletRequestEvent e)
+ {
+ recordObservation("28", e);
+ }
+
+ public void observe29(@Observes @Destroyed ServletRequestEvent e)
+ {
+ recordObservation("29", e);
+ }
+
+ public void observe30(@Observes @Added ServletRequestAttributeEvent e)
+ {
+ recordObservation("30", e);
+ }
+
+ public void observe31(@Observes @Replaced ServletRequestAttributeEvent e)
+ {
+ recordObservation("31", e);
+ }
+
+ public void observe32(@Observes @Removed ServletRequestAttributeEvent e)
+ {
+ recordObservation("32", e);
+ }
+
+ public void observe33(@Observes @Added @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("33", e);
+ }
+
+ public void observe34(@Observes @Replaced @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("34", e);
+ }
+
+ public void observe35(@Observes @Removed @Attribute("foo") ServletRequestAttributeEvent e)
+ {
+ recordObservation("35", e);
+ }
+
+ public void observe36(@Observes @Completed AsyncEvent e)
+ {
+ recordObservation("36", e);
+ }
+
+ public void observe37(@Observes @Error AsyncEvent e)
+ {
+ recordObservation("37", e);
+ }
+
+ public void observe38(@Observes @StartAsync AsyncEvent e)
+ {
+ recordObservation("38", e);
+ }
+
+ public void observe39(@Observes @Timeout AsyncEvent e)
+ {
+ recordObservation("39", e);
+ }
+
+ public void observe40(@Observes AsyncEvent e)
+ {
+ recordObservation("40", e);
+ }
+
+
+}
[View Less]
14 years, 9 months