To deploy programmatically, use the following code: public void deployProcessDefinition(String fileName) { | ProcessDefinition processDefinition = readProcessDefinition( | new FileInputStream(fileName), fileName); | deployProcessDefinition(processDefinition); | // build and deploy web module, if the language is BPEL | if (processDefinition instanceof BpelProcessDefinition) | deployWebModule((BpelProcessDefinition) processDefinition, fileName); | } The file name is expected to reference a process archive. The support methods are presented below. private ProcessDefinition readProcessDefinition(InputStream fileSource, String fileName) | throws IOException { | try { | ProcessArchive processArchive = new ProcessArchive(new ZipInputStream(fileSource)); | log.debug("loaded process archive: " + fileName); | | ProcessDefinition processDefinition = processArchive.parseProcessDefinition(); | log.debug("read process definition: " + processDefinition.getName()); | | return processDefinition; | } | finally { | fileSource.close(); | } | } | | private void deployProcessDefinition(ProcessDefinition processDefinition) { | JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); | try { | if (processDefinition instanceof BpelProcessDefinition) { | BpelGraphSession graphSession = BpelGraphSession.getContextInstance(jbpmContext); | graphSession.deployProcessDefinition((BpelProcessDefinition) processDefinition); | } | else | jbpmContext.deployProcessDefinition(processDefinition); | log.info("deployed process definition: " + processDefinition.getName()); | } | catch (RuntimeException e) { | jbpmContext.setRollbackOnly(); | throw e; | } | finally { | jbpmContext.close(); | } | } | | private void deployWebModule(BpelProcessDefinition processDefinition, String fileName) { | File moduleFile = new File(deployDirectory, extractFilePrefix(fileName) + ".war"); | | WebModuleBuilder builder = new WebModuleBuilder(); | builder.setModuleFile(moduleFile); | builder.buildModule(processDefinition); | | if (builder.getProblemHandler().getProblemCount() > 0) | throw new BpelException("could not build web module for: " + processDefinition); | | log.info("deployed web module: " + moduleFile.getName()); | } | | private static String extractFilePrefix(String fileName) { | int dotIndex = fileName.lastIndexOf('.'); | return dotIndex != -1 ? fileName.substring(0, dotIndex) : fileName; | } | } In method deployWebModule, the variable deployDirectory references the app server's deploy directory. Inside JBoss, this directory can be retrieved from the system properties as follows. String deployDirectory = System.getProperty("jboss.server.home.dir") + File.separatorChar + "deploy"; The above snippets were adapted from class DeploymentServlet; you can review its source in our online repository.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163241#4163241 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163241 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user