[jbpm-commits] JBoss JBPM SVN: r3235 - in projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config: internal and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Dec 5 12:50:06 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-12-05 12:50:06 -0500 (Fri, 05 Dec 2008)
New Revision: 3235

Added:
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/EmbeddedBeansDeployer.java
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/KernelLocator.java
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java
Log:
Cleanup API packages

Added: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/EmbeddedBeansDeployer.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/EmbeddedBeansDeployer.java	                        (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/EmbeddedBeansDeployer.java	2008-12-05 17:50:06 UTC (rev 3235)
@@ -0,0 +1,105 @@
+/*
+ * 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.jboss.bpm.api.config.internal;
+
+// $Id$
+
+import java.net.URL;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Boostrap the Microcontainer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-Jun-2008
+ */
+public class EmbeddedBeansDeployer extends BasicBootstrap
+{
+  // Provide logging
+  final Logger log = LoggerFactory.getLogger(EmbeddedBeansDeployer.class);
+
+  private Kernel kernel;
+  private BasicXMLDeployer deployer;
+
+  public EmbeddedBeansDeployer()
+  {
+    // Get or bootstrap the kernel
+    kernel = KernelLocator.getKernel();
+    if (kernel == null)
+    {
+      try
+      {
+        super.bootstrap();
+        kernel = super.getKernel();
+        log.debug("bootstrap kernel: " + kernel);
+      }
+      catch (Throwable e)
+      {
+        throw new IllegalStateException("Cannot bootstrap kernel", e);
+      }
+    }
+    deployer = new BasicXMLDeployer(kernel);
+  }
+
+  /**
+   * Deploy MC beans from URL
+   */
+  public void deploy(URL url)
+  {
+    log.debug("deploy: " + url);
+    try
+    {
+      deployer.deploy(url);
+      deployer.validate();
+
+      // The KernelLocator is expected to get deployed as a bean
+      if (KernelLocator.getKernel() == null)
+        throw new IllegalStateException("KernelLocator not deployed as MC bean");
+
+    }
+    catch (Throwable e)
+    {
+      throw new IllegalStateException("Cannot deploy beans from: " + url, e);
+    }
+  }
+
+  /**
+   * Undeploy MC beans from URL
+   */
+  public void undeploy(URL url)
+  {
+    log.debug("undeploy: " + url);
+    try
+    {
+      deployer.undeploy(url);
+    }
+    catch (Throwable e)
+    {
+      throw new IllegalStateException("Cannot undeploy beans from: " + url, e);
+    }
+  }
+}
\ No newline at end of file


Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/EmbeddedBeansDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/KernelLocator.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/KernelLocator.java	                        (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/KernelLocator.java	2008-12-05 17:50:06 UTC (rev 3235)
@@ -0,0 +1,47 @@
+/*
+ * 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.jboss.bpm.api.config.internal;
+
+//$Id$
+
+import org.jboss.kernel.Kernel;
+
+/**
+ * Locate the single instance of the kernel 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class KernelLocator
+{
+   private static Kernel kernel;
+
+   public static Kernel getKernel()
+   {
+      return KernelLocator.kernel;
+   }
+
+   public void setKernel(Kernel kernel)
+   {
+      KernelLocator.kernel = kernel;
+   }
+}
\ No newline at end of file


Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/KernelLocator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java	                        (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java	2008-12-05 17:50:06 UTC (rev 3235)
@@ -0,0 +1,93 @@
+/*
+ * 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.jboss.bpm.api.config.internal;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.bpm.api.NotImplementedException;
+import org.jboss.bpm.api.config.ConfigurationProvider;
+import org.jboss.bpm.api.service.ProcessEngine;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+
+/**
+ * The ProcessEngineProvider provides a ProcessEngine through a given configuration method
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class MicrocontainerConfigurationProvider implements ConfigurationProvider
+{
+  /** The process engine bean name - jBPMEngine */
+  public static final String BEAN_NAME = "BPMProcessEngine";
+  /** The default bean config: jbpm-cfg-beans.xml */
+  public static final String JBPM_ENGINE_CONFIG = "jbpm-cfg-beans.xml";
+
+  private ProcessEngine engine;
+
+  @Override
+  public ProcessEngine getProcessEngine()
+  {
+    if (engine == null)
+    {
+      Kernel kernel = KernelLocator.getKernel();
+      if (kernel == null)
+      {
+        EmbeddedBeansDeployer deployer = new EmbeddedBeansDeployer();
+        deployer.deploy(getDefaultConfigURL());
+      }
+      engine = getProcessEngineBean();
+    }
+    return engine;
+  }
+
+  @Override
+  public ProcessEngine getProcessEngine(URL cfgURL)
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public ProcessEngine getProcessEngine(String cfgXML)
+  {
+    throw new NotImplementedException();
+  }
+
+  @SuppressWarnings("deprecation")
+  private ProcessEngine getProcessEngineBean()
+  {
+    Kernel kernel = KernelLocator.getKernel();
+    KernelRegistryEntry entry = kernel.getRegistry().getEntry(BEAN_NAME);
+    ProcessEngine engine = (ProcessEngine)entry.getTarget();
+    return engine;
+  }
+
+  private URL getDefaultConfigURL()
+  {
+    URL cfgURL = Thread.currentThread().getContextClassLoader().getResource(JBPM_ENGINE_CONFIG);
+    if (cfgURL == null)
+      throw new IllegalStateException("Cannot find resource: " + JBPM_ENGINE_CONFIG);
+    return cfgURL;
+  }
+}
\ No newline at end of file


Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list