[jboss-cvs] JBossAS SVN: r60906 - in projects/osgi/trunk: deployment/src/main/org/jboss/osgi/deployers and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 26 09:03:05 EST 2007
Author: alesj
Date: 2007-02-26 09:03:05 -0500 (Mon, 26 Feb 2007)
New Revision: 60906
Added:
projects/osgi/trunk/testsuite/src/main/org/jboss/test/
projects/osgi/trunk/testsuite/src/main/org/jboss/test/scanner/
projects/osgi/trunk/testsuite/src/main/org/jboss/test/scanner/VFSDeploymentScannerImpl.java
projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/
projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Main.java
projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Server.java
projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/ServerImpl.java
projects/osgi/trunk/testsuite/src/resources/bootstrap-beans.xml
Modified:
projects/osgi/trunk/core/src/main/org/jboss/osgi/core/support/BundleDelegatingClassLoader.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/BundleActivatorDeployer.java
projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/OSGiPluginDeployer.java
Log:
Test deployment scanner.
Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/support/BundleDelegatingClassLoader.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/support/BundleDelegatingClassLoader.java 2007-02-26 13:51:40 UTC (rev 60905)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/support/BundleDelegatingClassLoader.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -129,6 +129,7 @@
* A best-guess attempt at figuring out why the class could not be found.
*
* @param name of the class we are trying to find.
+ * @param root file root to look for classes
*/
private synchronized void traceClassLoading(String name, String root)
{
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/BundleActivatorDeployer.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/BundleActivatorDeployer.java 2007-02-26 13:51:40 UTC (rev 60905)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/BundleActivatorDeployer.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.deployers;
-import org.jboss.beans.metadata.plugins.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
Modified: projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/OSGiPluginDeployer.java
===================================================================
--- projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/OSGiPluginDeployer.java 2007-02-26 13:51:40 UTC (rev 60905)
+++ projects/osgi/trunk/deployment/src/main/org/jboss/osgi/deployers/OSGiPluginDeployer.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -24,7 +24,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.beans.metadata.plugins.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
Added: projects/osgi/trunk/testsuite/src/main/org/jboss/test/scanner/VFSDeploymentScannerImpl.java
===================================================================
--- projects/osgi/trunk/testsuite/src/main/org/jboss/test/scanner/VFSDeploymentScannerImpl.java (rev 0)
+++ projects/osgi/trunk/testsuite/src/main/org/jboss/test/scanner/VFSDeploymentScannerImpl.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -0,0 +1,593 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.scanner;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSDeploymentScannerImpl implements Runnable
+{
+ private static final Logger log = Logger.getLogger(VFSDeploymentScannerImpl.class);
+ // Private Data --------------------------------------------------
+ private MainDeployer mainDeployer;
+ /** */
+ private VirtualFileFilter filter;
+ /** The ExecutorService/ThreadPool for performing scans */
+ private ScheduledExecutorService scanExecutor;
+ private ScheduledFuture activeScan;
+
+ /** The URIfied ServerHomeURL */
+ private URI serverHomeURI;
+
+ /** The list of URIs to scan */
+ private List<URI> uriList = Collections.synchronizedList(new ArrayList<URI>());
+
+ /** The list of VirtualFiles to scan */
+ private final List<VirtualFile> vdfList = Collections.synchronizedList(new ArrayList<VirtualFile>());
+
+ /** Whether to search for files inside directories whose names containing no dots */
+ private boolean doRecursiveSearch = true;
+ /** Period in ms between deployment scans */
+ private long scanPeriod = 5000;
+ private int scanCount;
+
+ /** A set of scanned VirtualFiles which have been deployed */
+ private final Map<VirtualFile, DeploymentContext> deployedMap = new ConcurrentHashMap<VirtualFile, DeploymentContext>();
+
+ // Constructor ---------------------------------------------------
+
+ public VFSDeploymentScannerImpl()
+ {
+ // empty
+ }
+
+ // Attributes ----------------------------------------------------
+
+ public void setServerHomeURI(URI serverHomeURI)
+ {
+ this.serverHomeURI = serverHomeURI;
+ }
+
+ public void setMainDeployer(MainDeployer deployer)
+ {
+ this.mainDeployer = deployer;
+ }
+
+ public VirtualFileFilter getFilterInstance()
+ {
+ return filter;
+ }
+
+ public void setFilterInstance(VirtualFileFilter filter)
+ {
+ this.filter = filter;
+ }
+
+ /**
+ * @return Returns the scanExecutor.
+ */
+ public ScheduledExecutorService getScanExecutor()
+ {
+ return this.scanExecutor;
+ }
+
+ /**
+ * @param scanExecutor The scanExecutor to set.
+ */
+ public void setScanExecutor(ScheduledExecutorService scanExecutor)
+ {
+ this.scanExecutor = scanExecutor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployment.scanner.VFSDeploymentScanner#getScanPeriod()
+ */
+ public long getScanPeriod()
+ {
+ return scanPeriod;
+ }
+ /* (non-Javadoc)
+ * @see org.jboss.deployment.scanner.VFSDeploymentScanner#setScanPeriod(long)
+ */
+ public void setScanPeriod(long period)
+ {
+ this.scanPeriod = period;
+ }
+
+ /**
+ * Are deployment scans enabled.
+ * @return is scan enabled
+ */
+ public boolean isScanEnabled()
+ {
+ return activeScan != null;
+ }
+
+ public synchronized int getScanCount()
+ {
+ return scanCount;
+ }
+ public synchronized void resetScanCount()
+ {
+ this.scanCount = 0;
+ }
+
+ /**
+ * Enable/disable deployment scans.
+ * @param scanEnabled true to enable scans, false to disable.
+ */
+ public synchronized void setScanEnabled(boolean scanEnabled)
+ {
+ if( scanEnabled == true && activeScan == null )
+ {
+ activeScan = this.scanExecutor.scheduleWithFixedDelay(this, 0,
+ scanPeriod, TimeUnit.MILLISECONDS);
+ }
+ else if( scanEnabled == false && activeScan != null )
+ {
+ activeScan.cancel(true);
+ activeScan = null;
+ }
+ }
+
+ /**
+ * @param listspec list of uris
+ * @throws URISyntaxException uri exception
+ * @throws IOException ioexception
+ */
+ public void setURIs(final String listspec) throws URISyntaxException, IOException
+ {
+ if (listspec == null)
+ {
+ this.uriList.clear();
+ return;
+ }
+ List<URI> list = new LinkedList<URI>();
+
+ StringTokenizer stok = new StringTokenizer(listspec, ",");
+ while (stok.hasMoreTokens())
+ {
+ String urispec = stok.nextToken().trim();
+
+ log.debug("Adding URI from spec: " + urispec);
+
+ URI uri = makeURI(urispec);
+
+ log.debug("URI: " + uri);
+
+ list.add(uri);
+ }
+ setURIList(list);
+ }
+
+ /**
+ * @param list uri list
+ * @throws IOException ioexception
+ */
+ public void setURIList(final List<URI> list) throws IOException
+ {
+ if (list == null)
+ {
+ return;
+ }
+
+ // start out with a fresh list
+ uriList.clear();
+
+ for(int n = 0; n < list.size(); n ++)
+ {
+ URI uri = list.get(n);
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("list element[" + n + "] is null");
+ }
+ addURI(uri);
+ }
+ log.debug("URI list: " + uriList);
+ }
+
+ public List<URI> getURIList()
+ {
+ return new ArrayList<URI>(uriList);
+ }
+
+ public void setRecursiveSearch(boolean recurse)
+ {
+ doRecursiveSearch = recurse;
+ }
+
+ public boolean getRecursiveSearch()
+ {
+ return doRecursiveSearch;
+ }
+
+ // Operations ----------------------------------------------------
+
+ public void addURI(final URI uri) throws IOException
+ {
+ if (uri == null)
+ {
+ throw new NullPointerException("uri argument cannot be null");
+ }
+ if( uriList.add(uri) == true )
+ {
+ log.debug("Added URI: " + uri);
+ VirtualFile vf = VFS.getRoot(uri);
+ vdfList.add(vf);
+ }
+ }
+
+ public void removeURI(final URI uri)
+ throws IOException
+ {
+ if (uri == null)
+ {
+ throw new NullPointerException("uri argument cannot be null");
+ }
+ VirtualFile vf = VFS.getRoot(uri);
+ vdfList.remove(vf);
+ boolean success = uriList.remove(uri);
+
+ if (success)
+ {
+ log.debug("Removed URI: " + uri);
+ }
+ }
+
+ public boolean hasURI(final URI uri)
+ {
+ if (uri == null)
+ {
+ throw new NullPointerException("uri argument cannot be null");
+ }
+ return uriList.contains(uri);
+ }
+
+ public void start() throws Exception
+ {
+ // synchronize uriList and vdfList because only at this point
+ // setVirtualFileFactory() injection has been performed
+ vdfList.clear();
+ for (URI uri : uriList)
+ {
+ VirtualFile vf = VFS.getRoot(uri);
+ vdfList.add(vf);
+ }
+
+ // Default to a single thread executor
+ if( scanExecutor == null )
+ {
+ scanExecutor = Executors.newSingleThreadScheduledExecutor(
+ new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(r, "VFSDeploymentScanner");
+ }
+ }
+ );
+ }
+ activeScan = scanExecutor.scheduleWithFixedDelay(this, 0,
+ scanPeriod, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * Executes scan
+ *
+ */
+ public void run()
+ {
+ try
+ {
+ scan();
+ }
+ catch(Throwable e)
+ {
+ log.warn("Scan failed", e);
+ }
+ finally
+ {
+ incScanCount();
+ }
+ }
+
+ public void stop()
+ {
+ if( activeScan != null )
+ {
+ activeScan.cancel(true);
+ activeScan = null;
+ }
+ }
+
+ public synchronized void scan() throws Exception
+ {
+ if (vdfList == null)
+ {
+ throw new IllegalStateException("not initialized");
+ }
+ boolean trace = log.isTraceEnabled();
+
+ // Scan for deployments
+ log.debug("Begin deployment scan");
+
+ // VirtualFiles to deploy
+ List<VirtualFile> toDeployList = new LinkedList<VirtualFile>();
+ synchronized (vdfList)
+ {
+ for (VirtualFile vf : vdfList)
+ {
+ if( trace )
+ log.trace("Checking file: "+vf);
+ if (vf.isLeaf())
+ {
+ // treat this as a deployable unit
+ toDeployList.add(vf);
+ }
+ else
+ {
+ // process (possibly recursively) the dir
+ addDeployments(toDeployList, vf);
+ }
+ }
+ }
+
+ if (trace)
+ {
+ log.trace("toDeployList: "+toDeployList);
+ }
+ LinkedList<VirtualFile> toRemoveList = new LinkedList<VirtualFile>();
+ LinkedList<VirtualFile> toCheckForUpdateList = new LinkedList<VirtualFile>();
+
+ synchronized (deployedMap)
+ {
+ // remove previously deployed URLs no longer needed
+ for (VirtualFile vf : deployedMap.keySet())
+ {
+ if (toDeployList.contains(vf))
+ {
+ toCheckForUpdateList.add(vf);
+ }
+ else
+ {
+ toRemoveList.add(vf);
+ }
+ }
+ }
+
+ // ********
+ // Undeploy
+ // ********
+
+ for (VirtualFile vf : toRemoveList)
+ {
+ undeploy(vf);
+ }
+
+ // ********
+ // Redeploy
+ // ********
+
+ // compute the DeployedURL list to update
+ ArrayList<VirtualFile> toUpdateList = new ArrayList<VirtualFile>(toCheckForUpdateList.size());
+ for (VirtualFile vf : toUpdateList)
+ {
+ DeploymentContext context = deployedMap.get(vf);
+ long modified = vf.getLastModified();
+ Long prevLastDeployed = context.getTransientAttachments().getAttachment("deployedLastModified", Long.class);
+ if (prevLastDeployed != null && prevLastDeployed.compareTo(modified) < 0)
+ {
+ if (trace)
+ {
+ log.trace("Re-deploying " + vf);
+ }
+ toUpdateList.add(vf);
+ }
+ }
+
+ // sort to update list
+ //Collections.sort(toUpdateList, sorter);
+
+ // Undeploy in order
+ for (int i = toUpdateList.size() - 1; i >= 0; i--)
+ {
+ VirtualFile vf = toUpdateList.get(i);
+ undeploy(vf);
+ }
+
+ // Deploy in order
+ for (VirtualFile vf : toUpdateList)
+ {
+ deploy(vf);
+ }
+
+ // ******
+ // Deploy
+ // ******
+
+ //Collections.sort(toDeployList, sorter);
+ for (Iterator i = toDeployList.iterator(); i.hasNext();)
+ {
+ VirtualFile vf = (VirtualFile)i.next();
+
+ // if vf is not deployed already, deploy it
+ if (!deployedMap.containsKey(vf))
+ {
+ deploy(vf);
+ }
+
+ // vf must have been deployed by now, so remove it from list
+ i.remove();
+
+ }
+ log.debug("End deployment scan");
+ }
+
+ /**
+ * Inc the scanCount and to a notifyAll.
+ *
+ */
+ protected synchronized void incScanCount()
+ {
+ scanCount ++;
+ notifyAll();
+ }
+
+ // Private -------------------------------------------------------
+
+ /**
+ * A helper to make a URI from a full/partial urispec
+ * @param urispec uri spec
+ * @return resolved uri against serverHomeURI
+ * @throws URISyntaxException uri expcetion
+ */
+ private URI makeURI(String urispec) throws URISyntaxException
+ {
+ // First replace URI with appropriate properties
+ urispec = StringPropertyReplacer.replaceProperties(urispec);
+ return serverHomeURI.resolve(urispec);
+ }
+
+ /**
+ * A helper to find all deployments under a directory vf
+ * and add them to the supplied list.
+ *
+ * We may recurse.
+ * @param list virtual file list
+ * @param root vf root
+ * @throws IOException ioexception
+ */
+ private void addDeployments(List<VirtualFile> list, VirtualFile root)
+ throws IOException
+ {
+ List<VirtualFile> components = root.getChildren();
+
+ for (VirtualFile vf : components)
+ {
+ if (vf.isLeaf())
+ {
+ // the first arg in filter.accept is not used!
+ if (filter == null || filter.accepts(vf))
+ {
+ list.add(vf);
+ }
+ }
+ else
+ {
+ if (vf.getName().indexOf('.') == -1 && this.doRecursiveSearch)
+ {
+ // recurse if not '.' in name and recursive search is enabled
+ addDeployments(list, vf);
+ }
+ else
+ {
+ list.add(vf);
+ }
+ }
+ }
+ }
+
+ /**
+ * A helper to deploy the given vf using the deployer.
+ * @param vf vristual file
+ */
+ private void deploy(final VirtualFile vf)
+ {
+ // If the deployer is null simply ignore the request
+ log.debug("Deploying: " + vf);
+ DeploymentContext context = new AbstractDeploymentContext(vf);
+ try
+ {
+ mainDeployer.addDeploymentContext(context);
+ mainDeployer.process();
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to deploy: " + vf, e);
+ // TODO: somehow need to ignore bad deployments to avoid repeated errors
+ return;
+ }
+
+ /* TODO: this differs from the previous behavior. We would need a type to metainf location
+ if we want to watch the same file as jboss4. But since not all files have a deployment
+ descriptor, we need to be able to watch the deployment root anyway.
+ */
+ try
+ {
+ long deployedLastModified = vf.getLastModified();
+ context.getTransientAttachments().addAttachment("deployedLastModified", deployedLastModified);
+ if (!deployedMap.containsKey(vf))
+ {
+ deployedMap.put(vf, context);
+ }
+ }
+ catch(IOException e)
+ {
+ log.warn("Failed to obtain lastModified for: "+vf, e);
+ }
+ }
+
+ /**
+ * A helper to undeploy the given vf using the deployer.
+ * @param vf virtual file
+ */
+ private void undeploy(final VirtualFile vf)
+ {
+ try
+ {
+ log.debug("Undeploying: " + vf);
+ DeploymentContext deployment = deployedMap.remove(vf);
+ mainDeployer.removeDeploymentContext(deployment.getName());
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to undeploy: " + vf, e);
+ }
+ }
+
+}
Added: projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Main.java
===================================================================
--- projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Main.java (rev 0)
+++ projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Main.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.server;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class Main
+{
+ public static void main(String[] args)
+ {
+ try
+ {
+ Server server = new ServerImpl();
+ server.start();
+ }
+ catch (Throwable t)
+ {
+ System.err.println("Exception while testing deployment: " + t);
+ }
+ }
+
+}
Added: projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Server.java
===================================================================
--- projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Server.java (rev 0)
+++ projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/Server.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.server;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface Server
+{
+ void start() throws Throwable;
+
+ void stop();
+}
Added: projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/ServerImpl.java
===================================================================
--- projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/ServerImpl.java (rev 0)
+++ projects/osgi/trunk/testsuite/src/main/org/jboss/test/server/ServerImpl.java 2007-02-26 14:03:05 UTC (rev 60906)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.server;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServerImpl extends BasicBootstrap implements Server
+{
+ /** The kernel deployer used to load the server deployers */
+ protected BasicXMLDeployer kernelDeployer;
+
+ /** The bootstrap file */
+ public static String BOOTSTRAP_XML_NAME = "bootstrap-beans.xml";
+
+ public void start() throws Throwable
+ {
+ // Bootstrap the core kernel
+ super.bootstrap();
+ kernelDeployer = new BasicXMLDeployer(getKernel());
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> descriptors = cl.getResources(BOOTSTRAP_XML_NAME);
+ while (descriptors.hasMoreElements())
+ {
+ URL url = descriptors.nextElement();
+ log.debug("Found: " + url);
+ deploy(url);
+ }
+ kernelDeployer.validate();
+ }
+
+ protected void deploy(URL url) throws Throwable
+ {
+ log.debug("Deploying bootstrap config: " + url);
+ kernelDeployer.deploy(url);
+ }
+
+ public void stop()
+ {
+ kernelDeployer.shutdown();
+ }
+}
Added: projects/osgi/trunk/testsuite/src/resources/bootstrap-beans.xml
===================================================================
--- projects/osgi/trunk/testsuite/src/resources/bootstrap-beans.xml (rev 0)
+++ projects/osgi/trunk/testsuite/src/resources/bootstrap-beans.xml 2007-02-26 14:03:05 UTC (rev 60906)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ The bootstrap of the test server.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- The MainDeployer -->
+ <bean name="MainDeployer" class="org.jboss.deployers.plugins.deployment.MainDeployerImpl">
+ <property name="structureDeployers">
+ <list>
+ <!-- A declared structure descriptor deployer -->
+ <bean name="DeclaredStructure" class="org.jboss.deployers.plugins.structure.vfs.explicit.DeclaredStructure" />
+ <!-- JAR Structure -->
+ <bean name="JARStructure" class="org.jboss.deployers.plugins.structure.vfs.jar.JARStructure">
+ <!-- Unless specified the default list of suffixes is .zip, .ear, .jar, ,.rar, .war, .sar, .har, .aop -->
+ <constructor>
+ <parameter>
+ <set elementClass="java.lang.String">
+ <value>.ear</value>
+ <value>.jar</value>
+ <value>.sar</value>
+ </set>
+ </parameter>
+ </constructor>
+ <property name="candidateStructureVisitorFactory">
+ <!-- Any file that is not an ordinary directory is a candidate -->
+ <bean name="JARStructureCandidates" class="org.jboss.deployers.plugins.structure.vfs.jar.JARCandidateStructureVisitorFactory">
+ <!-- A filter to exclude some obvious non-subdeployments -->
+ <property name="filter">
+ <bean name="JARFilter" class="org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter">
+ <constructor><parameter>
+ <list elementClass="java.lang.String">
+ <!-- Exclude class files as subdeployments -->
+ <value>.class</value>
+ </list>
+ </parameter></constructor>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ <!-- File Structure -->
+ <bean name="FileStructure" class="org.jboss.deployers.plugins.structure.vfs.file.FileStructure">
+ <!-- Unless specified the default list of suffixes is -service.xml, -beans.xml, -ds.xml, -aop.xml -->
+ <constructor>
+ <parameter>
+ <set elementClass="java.lang.String">
+ <value>-beans.xml</value>
+ <value>-aop.xml</value>
+ </set>
+ </parameter>
+ </constructor>
+ </bean>
+ </list>
+ </property>
+ <property name="deployers">
+ <list>
+ <!-- POJO Deployment -->
+ <bean name="BeanDeployer" class="org.jboss.deployers.plugins.deployers.kernel.BeanDeployer">
+ <property name="type">beans</property>
+ </bean>
+ <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.plugins.deployers.kernel.KernelDeploymentDeployer">
+ <property name="type">beans</property>
+ </bean>
+ <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.plugins.deployers.kernel.BeanMetaDataDeployer">
+ <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+ <property name="type">beans</property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+
+ <!-- A filter for excluding files from the scanner -->
+ <bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
+ <!-- Files starting with theses strings are ignored -->
+ <property name="prefixes">#,%,\,,.,_$</property>
+ <!-- Files ending with theses strings are ignored -->
+ <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
+ <!-- Files matching with theses strings are ignored -->
+ <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
+ </bean>
+
+ <!-- Scan for deployments -->
+ <bean name="VFSDeploymentScanner" class="org.jboss.test.scanner.VFSDeploymentScannerImpl">
+ <property name="mainDeployer"><inject bean="MainDeployer"/></property>
+ <property name="filterInstance"><inject bean="DeploymentFilter"/></property>
+ <property name="URIList">
+ <list elementClass="java.net.URI">
+ <!-- Standard hot deployment directory -->
+ <value>${jboss.server.home.url}deploy/</value>
+ </list>
+ </property>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list