[jboss-cvs] JBossAS SVN: r80657 - in trunk/bootstrap/src/main/org/jboss/bootstrap: spi and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 7 08:40:54 EST 2008
Author: scott.stark at jboss.org
Date: 2008-11-07 08:40:54 -0500 (Fri, 07 Nov 2008)
New Revision: 80657
Added:
trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/TempBasicXMLDeployer.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/MCServer.java
Modified:
trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java
Log:
JBAS-6168, allow Bootstraps access to the Server KernelDeployments
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java 2008-11-07 13:38:14 UTC (rev 80656)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java 2008-11-07 13:40:54 UTC (rev 80657)
@@ -24,6 +24,7 @@
import java.net.URL;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.InstallCallbackMetaData;
@@ -31,12 +32,14 @@
import org.jboss.beans.metadata.spi.CallbackMetaData;
import org.jboss.bootstrap.AbstractServerImpl;
import org.jboss.bootstrap.BootstrapMetaData;
+import org.jboss.bootstrap.spi.microcontainer.MCServer;
import org.jboss.bootstrap.xml.BootstrapParser;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+// TODO: JBMICROCONT-383 import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
import org.jboss.kernel.plugins.event.AbstractEvent;
import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.kernel.spi.event.KernelEvent;
import org.jboss.kernel.spi.event.KernelEventManager;
import org.jboss.util.StopWatch;
@@ -48,6 +51,7 @@
* @version $Revision: 1.1 $
*/
public class ServerImpl extends AbstractServerImpl
+ implements MCServer
{
/** The bootstrap file */
public static String BOOTSTRAP_XML_NAME = "bootstrap.xml";
@@ -59,7 +63,7 @@
private Kernel kernel;
/** The kernel deployer */
- private BasicXMLDeployer kernelDeployer;
+ private TempBasicXMLDeployer kernelDeployer;
/**
* Get the kernel
@@ -70,7 +74,18 @@
{
return kernel;
}
-
+ /**
+ * Get the kernel deployments
+ * @return the kernel deployments
+ */
+ public Map<String, KernelDeployment> getDeployments()
+ {
+ Map<String, KernelDeployment> deployments = null;
+ if(kernelDeployer != null)
+ deployments = kernelDeployer.getDeployments();
+ return deployments;
+ }
+
@Override
protected void doStart(StopWatch watch) throws Throwable
{
@@ -105,7 +120,7 @@
log.debug("BootstrapURLs=" + bootstrapURLs);
// Create an xml deployer
- kernelDeployer = new BasicXMLDeployer(kernel);
+ kernelDeployer = new TempBasicXMLDeployer(kernel);
try
{
// Deploy the bootstrap urls
Added: trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/TempBasicXMLDeployer.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/TempBasicXMLDeployer.java (rev 0)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/TempBasicXMLDeployer.java 2008-11-07 13:40:54 UTC (rev 80657)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.bootstrap.microcontainer;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.BasicKernelDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * A copy of the mc BasicXMLDeployer that provides access to the KernelDeployments.
+ * TODO: replace when JBMICROCONT-383 is resolved.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TempBasicXMLDeployer extends BasicKernelDeployer
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(TempBasicXMLDeployer.class);
+
+ /** Unmarshaller factory */
+ private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+
+ /** The resolver */
+ private static final SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+
+ /** The deployments by url or name */
+ private Map<String, KernelDeployment> deploymentsByName = new ConcurrentHashMap<String, KernelDeployment>();
+
+ /**
+ * Create a new XML deployer
+ *
+ * @param kernel the kernel
+ */
+ public TempBasicXMLDeployer(Kernel kernel)
+ {
+ this(kernel, null);
+ }
+
+ /**
+ * Create a new XML deployer with mode.
+ *
+ * @param kernel the kernel
+ * @param mode the controller mode
+ */
+ public TempBasicXMLDeployer(Kernel kernel, ControllerMode mode)
+ {
+ super(kernel, mode);
+ }
+
+ public Collection<String> getDeploymentNames()
+ {
+ return deploymentsByName.keySet();
+ }
+
+ public void deploy(KernelDeployment deployment) throws Throwable
+ {
+ super.deploy(deployment);
+ deploymentsByName.put(deployment.getName(), deployment);
+ }
+
+ public void undeploy(KernelDeployment deployment)
+ {
+ deploymentsByName.remove(deployment.getName());
+ super.undeploy(deployment);
+ }
+
+ /**
+ * Undeploy a url
+ *
+ * @param url the url to undeploy
+ * @throws IllegalStateException if the url is unknown
+ */
+ public void undeploy(final URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+ undeploy(url.toString());
+ }
+
+ /**
+ * Undeploy a name deployment
+ *
+ * @param name the name of the deployment to undeploy
+ * @throws IllegalStateException if the name is unknown
+ */
+ public void undeploy(final String name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ KernelDeployment deployment = deploymentsByName.remove(name);
+ if (deployment == null)
+ throw new IllegalStateException("Unknown deployment " + name);
+ undeploy(deployment);
+ }
+
+ /**
+ * Deploy a url
+ *
+ * @param url the url to deploy
+ * @return the kernel deployment
+ * @throws Throwable for any error
+ */
+ public KernelDeployment deploy(final URL url) throws Throwable
+ {
+ final boolean trace = log.isTraceEnabled();
+
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+
+ if (trace)
+ log.trace("Parsing " + url);
+
+ long start = System.currentTimeMillis();
+
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ KernelDeployment deployment = (KernelDeployment) unmarshaller.unmarshal(url.toString(), resolver);
+ if (deployment == null)
+ throw new RuntimeException("The xml " + url + " is not well formed!");
+ deployment.setName(url.toString());
+
+ if (trace)
+ {
+ long now = System.currentTimeMillis();
+ log.trace("Parsing " + url + " took " + (now-start) + " milliseconds");
+ }
+
+ deploy(deployment);
+
+ if (trace)
+ {
+ long now = System.currentTimeMillis();
+ log.trace("Deploying " + url + " took " + (now-start) + " milliseconds");
+ }
+
+ return deployment;
+ }
+
+ /**
+ * Deploy a stream. We may be deploying XML fragments.
+ *
+ * @param deploymentName the deployment name
+ * @param stream the stream
+ * @return the kernel deployment
+ * @throws Throwable for any error
+ */
+ public KernelDeployment deploy(String deploymentName, final InputStream stream) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+
+ if (trace)
+ log.trace("Parsing " + deploymentName);
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ KernelDeployment deployment = (KernelDeployment) unmarshaller.unmarshal(stream, resolver);
+ if (deployment == null)
+ throw new RuntimeException("The deployment " + deploymentName + " is not well formed!");
+ deployment.setName(deploymentName);
+
+ deploy(deployment);
+
+ return deployment;
+ }
+
+ /**
+ * Access a read-only view of the deployer's deployments.
+ * @return the KernelDeployment map by name
+ */
+ public Map<String, KernelDeployment> getDeployments()
+ {
+ return Collections.unmodifiableMap(deploymentsByName);
+ }
+}
Property changes on: trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/TempBasicXMLDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/MCServer.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/MCServer.java (rev 0)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/MCServer.java 2008-11-07 13:40:54 UTC (rev 80657)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.bootstrap.spi.microcontainer;
+
+import java.util.Map;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+
+/**
+ * An extension of the Server interface that provides access to the
+ * mc Kernel and KernelDeployments loaded by the server prior to starting
+ * the registered Bootstraps.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface MCServer extends Server
+{
+ /**
+ *
+ * @return
+ */
+ public Kernel getKernel();
+ /**
+ *
+ * @return
+ */
+ public Map<String, KernelDeployment> getDeployments();
+}
Property changes on: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/microcontainer/MCServer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list