[jbpm-commits] JBoss JBPM SVN: r4536 - in jbpm4/trunk/modules/pvm/src: main/java/org/jbpm/pvm/internal/cmd and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Apr 10 10:22:25 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-04-10 10:22:24 -0400 (Fri, 10 Apr 2009)
New Revision: 4536

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
Modified:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
Log:
added import to jbpm configuration file parser

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -42,7 +42,7 @@
 import org.jbpm.env.WireObject;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.PvmEnvironment;
-import org.jbpm.pvm.internal.env.PvmEnvironmentFactoryParser;
+import org.jbpm.pvm.internal.env.JbpmConfigurationParser;
 import org.jbpm.pvm.internal.stream.FileStreamInput;
 import org.jbpm.pvm.internal.stream.InputStreamInput;
 import org.jbpm.pvm.internal.stream.ResourceStreamInput;
@@ -87,11 +87,11 @@
 
   private static final long serialVersionUID = 1L;
   private static final Log log = Log.getLog(JbpmConfiguration.class.getName());
-  protected static PvmEnvironmentFactoryParser pvmEnvironmentFactoryParser = new PvmEnvironmentFactoryParser();
+  protected static JbpmConfigurationParser pvmEnvironmentFactoryParser = new JbpmConfigurationParser();
 
   protected boolean isConfigured = false;
-  protected WireContext environmentFactoryCtxWireContext = null;
-  protected WireDefinition transactionCtxWireDefinition = null;
+  protected WireContext processEngineWireContext = new WireContext(new WireDefinition(), Context.CONTEXTNAME_PROCESS_ENGINE);
+  protected WireDefinition transactionWireDefinition = new WireDefinition();
 
   public JbpmConfiguration() {
     super((Configuration)null);
@@ -105,7 +105,7 @@
   }
 
   public void setSessionFactory(Object sessionFactory) {
-    environmentFactoryCtxWireContext
+    processEngineWireContext
         .getWireDefinition()
         .addDescriptor(new ProvidedObjectDescriptor(sessionFactory));
   }
@@ -137,7 +137,7 @@
 
   protected void parse(StreamInput streamSource) {
     isConfigured = true;
-    PvmEnvironmentFactoryParser.getInstance()
+    JbpmConfigurationParser.getInstance()
       .createParse()
       .setDocumentObject(this)
       .setStreamSource(streamSource)
@@ -146,22 +146,22 @@
   }
   
   public ExecutionService getExecutionService() {
-    return environmentFactoryCtxWireContext.get(ExecutionService.class);
+    return processEngineWireContext.get(ExecutionService.class);
   }
   public HistoryService getHistoryService() {
-    return environmentFactoryCtxWireContext.get(HistoryService.class);
+    return processEngineWireContext.get(HistoryService.class);
   }
   public ManagementService getManagementService() {
-    return environmentFactoryCtxWireContext.get(ManagementService.class);
+    return processEngineWireContext.get(ManagementService.class);
   }
   public TaskService getTaskService() {
-    return environmentFactoryCtxWireContext.get(TaskService.class);
+    return processEngineWireContext.get(TaskService.class);
   }
   public IdentityService getIdentityService() {
-    return environmentFactoryCtxWireContext.get(IdentityService.class);
+    return processEngineWireContext.get(IdentityService.class);
   }
   public RepositoryService getRepositoryService() {
-    return environmentFactoryCtxWireContext.get(RepositoryService.class);
+    return processEngineWireContext.get(RepositoryService.class);
   }
 
   public static EnvironmentFactory parseXmlString(String xmlString) {
@@ -182,18 +182,18 @@
     if (log.isTraceEnabled()) log.trace("opening " + environment);
 
     // set the classloader
-    ClassLoader classLoader = environmentFactoryCtxWireContext.getClassLoader();
+    ClassLoader classLoader = processEngineWireContext.getClassLoader();
     if (classLoader != null) {
       environment.setClassLoader(classLoader);
     }
 
     // add the process-engine context
-    environment.addContext(environmentFactoryCtxWireContext);
+    environment.addContext(processEngineWireContext);
 
     // add the transaction context
-    WireDefinition usedWireDefinition = transactionCtxWireDefinition;
+    WireDefinition usedWireDefinition = transactionWireDefinition;
     if (txWireObjects!=null) {
-      usedWireDefinition = new WireDefinition(transactionCtxWireDefinition, txWireObjects);
+      usedWireDefinition = new WireDefinition(transactionWireDefinition, txWireObjects);
     }
     
     WireContext transactionContext = new WireContext(usedWireDefinition, Context.CONTEXTNAME_TRANSACTION, environment, true);
@@ -215,48 +215,56 @@
   }
 
   public void close() {
-    environmentFactoryCtxWireContext.fire(WireContext.EVENT_CLOSE, null);
+    processEngineWireContext.fire(WireContext.EVENT_CLOSE, null);
   }
 
   // process-engine context delegation methods
   // ///////////////////////////////////
 
   public Object get(String key) {
-    return environmentFactoryCtxWireContext.get(key);
+    return processEngineWireContext.get(key);
   }
 
   public <T> T get(Class<T> type) {
-    return environmentFactoryCtxWireContext.get(type);
+    return processEngineWireContext.get(type);
   }
 
   public String getName() {
-    return environmentFactoryCtxWireContext.getName();
+    return processEngineWireContext.getName();
   }
 
   public boolean has(String key) {
-    return environmentFactoryCtxWireContext.has(key);
+    return processEngineWireContext.has(key);
   }
 
   public Set<String> keys() {
-    return environmentFactoryCtxWireContext.keys();
+    return processEngineWireContext.keys();
   }
 
   public Object set(String key, Object value) {
-    return environmentFactoryCtxWireContext.set(key, value);
+    return processEngineWireContext.set(key, value);
   }
+  
+  public void addProcessEngineWireDefinition(WireDefinition wireDefinition) {
+    processEngineWireContext.getWireDefinition().addWireDefinition(wireDefinition);
+  }
 
+  public void addTransactionWireDefinition(WireDefinition wireDefinition) {
+    transactionWireDefinition.addWireDefinition(wireDefinition);
+  }
+
   // getters and setters //////////////////////////////////////////////////////
 
-  public void setTransactionCtxWireDefinition(WireDefinition blockWireDefinition) {
-    this.transactionCtxWireDefinition = blockWireDefinition;
+  public void setTransactionWireDefinition(WireDefinition transactionWireDefinition) {
+    this.transactionWireDefinition = transactionWireDefinition;
   }
-  public WireContext getEnvironmentFactoryCtxWireContext() {
-    return environmentFactoryCtxWireContext;
+  public WireContext getProcessEngineWireContext() {
+    return processEngineWireContext;
   }
-  public void setEnvironmentFactoryCtxWireContext(WireContext applicationWireContext) {
-    this.environmentFactoryCtxWireContext = applicationWireContext;
+  public void setProcessEngineWireContext(WireContext processEngineWireContext) {
+    this.processEngineWireContext = processEngineWireContext;
   }
-  public WireDefinition getTransactionCtxWireDefinition() {
-    return transactionCtxWireDefinition;
+  public WireDefinition getTransactionWireDefinition() {
+    return transactionWireDefinition;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -49,12 +49,9 @@
     long deploymentDbid = repositorySession.deploy(deployment);
     
     if (deployment.hasProblems()) {
-      String problemsText = deployment.getProblemsText();
-      if (problemsText!=null) {
-        String errorMsg = "problems during deployment of "+deployment+": "+problemsText;
-        log.info(errorMsg);
-        throw new JbpmException(errorMsg);
-      }
+      JbpmException jbpmException = deployment.getJbpmException();
+      log.info("problems during deployment of "+deployment+": "+jbpmException.getMessage());
+      throw  jbpmException;
     }
     
     return deploymentDbid;

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java (from rev 4513, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.jbpm.pvm.internal.env;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/** parses the <code>jbpm-configuration</code>, which is assumed the document element
+ * and can contain the {@link EnvironmentFactoryXmlParser process-engine}
+ * context and the {@link EnvironmentXmlParser environment} context.
+ * 
+ * See {@link Parser} for usage instructions.
+ *   
+ * @author Tom Baeyens
+ */
+public class JbpmConfigurationParser extends Parser {
+
+  private static final long serialVersionUID = 1L;
+
+  Parser environmentFactoryXmlParser = new WireParser();
+  Parser environmentXmlParser = new WireParser();
+
+  protected static JbpmConfigurationParser INSTANCE = new JbpmConfigurationParser();
+  
+  public static JbpmConfigurationParser getInstance() {
+    return INSTANCE;
+  }
+
+  /** parses the given stream source with {@link #getInstance() the current parser}. */
+  static EnvironmentFactory parse(StreamInput streamSource) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) getInstance()
+           .createParse()
+           .setStreamSource(streamSource)
+           .execute()
+           .checkProblems("environment configuration "+streamSource)
+           .getDocumentObject();
+    return environmentFactory;
+  }
+  
+  public Object parseDocument(Document document, Parse parse) {
+    Element documentElement = document.getDocumentElement();
+    
+    // if the default environment factory was already set in the parse
+    JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) parse.getDocumentObject();
+    if (jbpmConfiguration==null) {
+      jbpmConfiguration = new JbpmConfiguration();
+      parse.setDocumentObject(jbpmConfiguration);
+    }
+    
+    for (Element importElement : XmlUtil.elements(documentElement, "import")) {
+      if (importElement.hasAttribute("resource")) {
+        String resource = importElement.getAttribute("resource");
+        Parse importParse = createParse()
+          .setResource(resource)
+          .execute();
+        
+        importParse.addProblems(importParse.getProblems());
+        
+        JbpmConfiguration importedConfiguration = (JbpmConfiguration) importParse.getDocumentObject();
+        
+        WireDefinition importedProcessEngineWireDefinition = importedConfiguration.getProcessEngineWireContext().getWireDefinition();
+        jbpmConfiguration.addProcessEngineWireDefinition(importedProcessEngineWireDefinition);
+
+        WireDefinition importedTransactionWireDefinition = importedConfiguration.getTransactionWireDefinition();
+        jbpmConfiguration.addTransactionWireDefinition(importedTransactionWireDefinition);
+      }
+    }
+
+    WireDefinition processEngineWireDefinition = getProcessEngineWireDefinition(documentElement, parse);
+    jbpmConfiguration.addProcessEngineWireDefinition(processEngineWireDefinition);
+
+    WireDefinition transactionWireDefinition = getTransactionWireDefinition(documentElement, parse);
+    jbpmConfiguration.addTransactionWireDefinition(transactionWireDefinition);
+
+    parse.setDocumentObject(jbpmConfiguration);
+
+    return jbpmConfiguration;
+  }
+
+  WireDefinition getProcessEngineWireDefinition(Element documentElement, Parse parse) {
+    Element processEngineElement = XmlUtil.element(documentElement, "process-engine-context");
+    if (processEngineElement != null) {
+      return (WireDefinition) environmentFactoryXmlParser.parseDocumentElement(processEngineElement, parse);
+    }
+    return null;
+  }
+
+  WireDefinition getTransactionWireDefinition(Element documentElement, Parse parse) {
+    Element txCtxElement = XmlUtil.element(documentElement, "transaction-context");
+    if (txCtxElement != null) {
+      return (WireDefinition) environmentXmlParser.parseDocumentElement(txCtxElement, parse);
+    }
+    return null;
+  }
+
+  public Parser getEnvironmentFactoryXmlParser() {
+    return environmentFactoryXmlParser;
+  }
+  public void setEnvironmentFactoryXmlParser(Parser applicationWireXmlParser) {
+    this.environmentFactoryXmlParser = applicationWireXmlParser;
+  }
+  public Parser getEnvironmentXmlParser() {
+    return environmentXmlParser;
+  }
+  public void setEnvironmentXmlParser(Parser blockWireXmlParser) {
+    this.environmentXmlParser = blockWireXmlParser;
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.jbpm.pvm.internal.env;
-
-import org.jbpm.env.Context;
-import org.jbpm.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
-import org.jbpm.pvm.internal.stream.StreamInput;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireDefinition;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/** main parser. It parses the <code>jbpm-configuration</code>, which is assumed the document element
- * and can contain the {@link EnvironmentFactoryXmlParser process-engine}
- * context and the {@link EnvironmentXmlParser environment} context.
- * 
- * See {@link Parser} for usage instructions.
- *   
- * @author Tom Baeyens
- */
-public class PvmEnvironmentFactoryParser extends Parser {
-
-  private static final long serialVersionUID = 1L;
-
-  Parser environmentFactoryXmlParser = new WireParser();
-  Parser environmentXmlParser = new WireParser();
-
-  protected static PvmEnvironmentFactoryParser INSTANCE = new PvmEnvironmentFactoryParser();
-  
-  public static PvmEnvironmentFactoryParser getInstance() {
-    return INSTANCE;
-  }
-
-  /** parses the given stream source with {@link #getInstance() the current parser}. */
-  static EnvironmentFactory parse(StreamInput streamSource) {
-    EnvironmentFactory environmentFactory = (EnvironmentFactory) getInstance()
-           .createParse()
-           .setStreamSource(streamSource)
-           .execute()
-           .checkProblems("environment configuration "+streamSource)
-           .getDocumentObject();
-    return environmentFactory;
-  }
-  
-  public Object parseDocument(Document document, Parse parse) {
-    Element documentElement = document.getDocumentElement();
-    
-    // if the default environment factory was already set in the parse
-    JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) parse.getDocumentObject();
-    if (jbpmConfiguration==null) {
-      jbpmConfiguration = new JbpmConfiguration();
-      parse.setDocumentObject(jbpmConfiguration);
-    }
-
-    WireDefinition environmentFactoryWireDefinition = getApplicationWireDefinition(documentElement, parse);
-    WireDefinition environmentWireDefinition = getBlockWireDefinition(documentElement, parse);
-
-    // create the application wire context from the definition
-    WireContext environmentFactoryWireContext = new WireContext(environmentFactoryWireDefinition, Context.CONTEXTNAME_PROCESS_ENGINE);
-    // propagate the parser classloader to the application context
-    environmentFactoryWireContext.setClassLoader(classLoader);
-
-    // configure the default environment factory
-    jbpmConfiguration.setEnvironmentFactoryCtxWireContext(environmentFactoryWireContext);
-    jbpmConfiguration.setTransactionCtxWireDefinition(environmentWireDefinition);
-    
-    parse.setDocumentObject(jbpmConfiguration);
-
-    return jbpmConfiguration;
-  }
-
-  WireDefinition getApplicationWireDefinition(Element documentElement, Parse parse) {
-    Element applicationElement = XmlUtil.element(documentElement, "process-engine-context");
-    if (applicationElement != null) {
-      return (WireDefinition) environmentFactoryXmlParser.parseDocumentElement(applicationElement, parse);
-    }
-    return null;
-  }
-
-  WireDefinition getBlockWireDefinition(Element documentElement, Parse parse) {
-    Element blockElement = XmlUtil.element(documentElement, "transaction-context");
-    if (blockElement != null) {
-      return (WireDefinition) environmentXmlParser.parseDocumentElement(blockElement, parse);
-    }
-    return null;
-  }
-
-  public Parser getEnvironmentFactoryXmlParser() {
-    return environmentFactoryXmlParser;
-  }
-  public void setEnvironmentFactoryXmlParser(Parser applicationWireXmlParser) {
-    this.environmentFactoryXmlParser = applicationWireXmlParser;
-  }
-  public Parser getEnvironmentXmlParser() {
-    return environmentXmlParser;
-  }
-  public void setEnvironmentXmlParser(Parser blockWireXmlParser) {
-    this.environmentXmlParser = blockWireXmlParser;
-  }
-}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -54,13 +54,9 @@
     deployerManager.deploy(deploymentImpl);
 
     if (deploymentImpl.hasProblems()) {
-      for (Problem problem: deploymentImpl.getProblems()) {
-        Throwable cause = problem.getCause();
-        if (cause!=null) {
-          log.debug("deployment exception", cause);
-        }
-      }
-      throw new JbpmException("problems during deployment: "+deploymentImpl.getProblemsText());
+      JbpmException jbpmException = deploymentImpl.getJbpmException();
+      log.info("problems during deployment of "+deployment+": "+jbpmException.getMessage());
+      throw  jbpmException;
     } else {
       
       repositoryCache.set(deploymentImpl.getDbid(), deploymentImpl.getObjects());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -197,8 +197,17 @@
     // otherwise, use the current environment classloader
     return Thread.currentThread().getContextClassLoader();
   }
-
   
+  public void addWireDefinition(WireDefinition wireDefinition) {
+    if ( (wireDefinition!=null)
+         && (wireDefinition.getDescriptors()!=null)
+       ) {
+      for (Descriptor descriptor: wireDefinition.getDescriptors().values()) {
+        addDescriptor(descriptor);
+      }
+    }
+  }
+  
   public Map<String, Descriptor> getDescriptors() {
     return descriptors;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -190,11 +190,9 @@
    * 'warning'. */
   public Parse checkProblems(String description) {
     if (hasProblems()) {
-      String errorMsg = "problems during parse of "+description+":"+getProblemsText();
-      log.info(errorMsg);
-      if (errorMsg!=null) {
-        throw new JbpmException(errorMsg);
-      }
+      JbpmException jbpmException = getJbpmException();
+      log.info("problems during parse of "+description+": "+jbpmException.getMessage());
+      throw  jbpmException;
     }
     return this;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -26,6 +26,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.jbpm.JbpmException;
 import org.jbpm.Problem;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
@@ -73,6 +74,14 @@
     addProblem(msg, e, ProblemImpl.TYPE_ERROR);
   }
 
+  /** add all problems */
+  public void addProblems(List<Problem> problems) {
+    if (this.problems==null) {
+      this.problems = new ArrayList<ProblemImpl>();
+    }
+    this.problems.addAll((List)problems);
+  }
+
   /** adds a problem with {@link ProblemImpl#TYPE_WARNING severity warning}.*/
   public void addWarning(String msg) {
     addWarning(msg, null);
@@ -99,45 +108,27 @@
   public void setProblems(List<Problem> problems) {
     this.problems = (List)problems;
   }
-  
-  
-  public String getProblemsText() {
+
+  public JbpmException getJbpmException() {
+    if (! hasProblems()) {
+      return null;
+    }
+    
+    Throwable cause = null;
+    
+    StringBuffer errorMsg = new StringBuffer();
     if (problems!=null) {
-      StringBuffer errorBuffer = null;
-      StringBuffer warningBuffer = null;
+      
       for (Problem p : getProblems()) {
-        if (p.getSeverity().equals(ProblemImpl.TYPE_ERROR)) {
-          if (errorBuffer==null) {
-            errorBuffer = new StringBuffer();
-            errorBuffer.append("errors:");
-            errorBuffer.append(NEWLINE);
-          }
-          errorBuffer.append(NEWLINE);
-          errorBuffer.append("  ");
-          errorBuffer.append(p.toString());
-        } else {
-          if (warningBuffer==null) {
-            warningBuffer = new StringBuffer();
-            warningBuffer.append("warnings:");
-            warningBuffer.append(NEWLINE);
-          }
-          warningBuffer.append(NEWLINE);
-          warningBuffer.append("  ");
-          warningBuffer.append(p.toString());
+        errorMsg.append(NEWLINE);
+        errorMsg.append("  ");
+        errorMsg.append(p.toString());
+        
+        if (p.getCause()!=null) {
+          cause = new JbpmException(p.getCause());
         }
       }
-      if (errorBuffer!=null) {
-        if (warningBuffer!=null) {
-          errorBuffer.append(NEWLINE);
-          errorBuffer.append(warningBuffer.toString());
-        }
-        return errorBuffer.toString(); 
-      }
-      if (warningBuffer!=null) {
-        warningBuffer.append(NEWLINE);
-        return warningBuffer.toString();
-      }
     }
-    return null;
+    return new JbpmException(errorMsg.toString(), cause);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java	2009-04-10 12:03:38 UTC (rev 4535)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java	2009-04-10 14:22:24 UTC (rev 4536)
@@ -364,7 +364,7 @@
     index++;
     assertEquals("close", events.get(index).eventName);
     JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) environmentFactory;
-    WireContext applicationWireContext = jbpmConfiguration.getEnvironmentFactoryCtxWireContext();
+    WireContext applicationWireContext = jbpmConfiguration.getProcessEngineWireContext();
     assertEquals(applicationWireContext, events.get(index).source);
     assertNull(events.get(index).info);
   }




More information about the jbpm-commits mailing list