[jboss-svn-commits] JBL Code SVN: r32172 - labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-core/src/main/java/org/drools/xml/jaxb/util.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Mar 22 14:31:42 EDT 2010


Author: salaboy21
Date: 2010-03-22 14:31:41 -0400 (Mon, 22 Mar 2010)
New Revision: 32172

Added:
   labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-core/src/main/java/org/drools/xml/jaxb/util/DroolsJaxbContextHelper.java
Log:
helper

Added: labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-core/src/main/java/org/drools/xml/jaxb/util/DroolsJaxbContextHelper.java
===================================================================
--- labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-core/src/main/java/org/drools/xml/jaxb/util/DroolsJaxbContextHelper.java	                        (rev 0)
+++ labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-core/src/main/java/org/drools/xml/jaxb/util/DroolsJaxbContextHelper.java	2010-03-22 18:31:41 UTC (rev 32172)
@@ -0,0 +1,86 @@
+/*
+ *  Copyright 2010 salaboy.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+package org.drools.xml.jaxb.util;
+
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import org.drools.command.runtime.BatchExecutionCommand;
+import org.drools.command.runtime.GetGlobalCommand;
+import org.drools.command.runtime.SetGlobalCommand;
+import org.drools.command.runtime.process.AbortWorkItemCommand;
+import org.drools.command.runtime.process.SignalEventCommand;
+import org.drools.command.runtime.process.StartProcessCommand;
+import org.drools.command.runtime.rule.FireAllRulesCommand;
+import org.drools.command.runtime.rule.InsertElementsCommand;
+import org.drools.command.runtime.rule.InsertObjectCommand;
+import org.drools.command.runtime.rule.ModifyCommand;
+import org.drools.command.runtime.rule.ModifyCommand.SetterImpl;
+import org.drools.command.runtime.rule.QueryCommand;
+import org.drools.command.runtime.rule.RetractCommand;
+import org.drools.common.DefaultFactHandle;
+import org.drools.common.DisconnectedFactHandle;
+import org.drools.runtime.impl.BatchExecutionImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
+import org.drools.runtime.rule.impl.FlatQueryResults;
+
+/**
+ *
+ * @author salaboy
+ */
+public class DroolsJaxbContextHelper {
+
+    public static final String[] JAXB_ANNOTATED_CMD = {BatchExecutionCommand.class.getName(),
+        SetGlobalCommand.class.getName(),
+        GetGlobalCommand.class.getName(),
+        FireAllRulesCommand.class.getName(),
+        InsertElementsCommand.class.getName(),
+        InsertObjectCommand.class.getName(),
+        ModifyCommand.class.getName(),
+        SetterImpl.class.getName(),
+        QueryCommand.class.getName(),
+        RetractCommand.class.getName(),
+        AbortWorkItemCommand.class.getName(),
+        SignalEventCommand.class.getName(),
+        StartProcessCommand.class.getName(),
+        BatchExecutionImpl.class.getName(),
+        ExecutionResultImpl.class.getName(),
+        DefaultFactHandle.class.getName(),
+        JaxbListWrapper.class.getName(),
+        DisconnectedFactHandle.class.getName(),
+        FlatQueryResults.class.getName()
+    };
+
+    public static JAXBContext createDroolsJaxbContext(List<String> classNames, Map<String, ?> properties) throws ClassNotFoundException, JAXBException {
+        int i = 0;
+        
+            Class<?>[] classes = new Class[classNames.size()
+                    + JAXB_ANNOTATED_CMD.length];
+
+            for (i = 0; i < classNames.size(); i++) {
+                classes[i] = Class.forName(classNames.get(i));
+            }
+            int j = 0;
+            for (i = classNames.size(); i < classes.length; i++, j++) {
+                classes[i] = Class.forName(JAXB_ANNOTATED_CMD[j]);
+            }
+            return JAXBContext.newInstance(classes, properties);
+       
+        
+    }
+}



More information about the jboss-svn-commits mailing list