/** * Create an instance of the embedded container * @param fullProfile Should a full JCA 1.6 profile be used * @return The instance */ public static Embedded create(boolean fullProfile) { return new EmbeddedJCA(fullProfile); } }
/** * Remove ShrinkWrap deployment * @param deployment The deployment * @exception IOException Thrown if the deployment cant be removed */ private void removeDeployment(File deployment) throws IOException { if (deployment == null) throw new IllegalArgumentException("Deployment is null"); if (deployment.exists()) { shrinkwrapDeployments.remove(deployment); if (shrinkwrapDeployments.size() == 0) shrinkwrapDeployments = null; recursiveDelete(deployment); } }
/** * Shutdown * @exception Throwable If an error occurs */ public void shutdown() throws Throwable { if (!started) throw new IllegalStateException("Container not started"); if (shrinkwrapDeployments != null && shrinkwrapDeployments.size() > 0) { List<File> copy = new ArrayList<File>(shrinkwrapDeployments); for (File f : copy) { removeDeployment(f); } } if (fullProfile) { undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml"); } kernel.shutdown(); started = false; }
/** * Undeploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void undeploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); log.debugf("Undeploying: %s", raaFile); if (shrinkwrapDeployments == null || !shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " not deployed"); kernel.getMainDeployer().undeploy(raaFile.toURI().toURL()); removeDeployment(raaFile); }
deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml");
/** * Shutdown * @exception Throwable If an error occurs */ public void shutdown() throws Throwable { if (!started) throw new IllegalStateException("Container not started"); if (shrinkwrapDeployments != null && shrinkwrapDeployments.size() > 0) { List<File> copy = new ArrayList<File>(shrinkwrapDeployments); for (File f : copy) { removeDeployment(f); } } if (fullProfile) { undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml"); undeploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml"); } kernel.shutdown(); started = false; }
/** * Undeploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void undeploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); log.debugf("Undeploying: %s", raaFile); if (shrinkwrapDeployments == null || !shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " not deployed"); kernel.getMainDeployer().undeploy(raaFile.toURI().toURL()); removeDeployment(raaFile); }
deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "naming.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "transaction.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "stdio.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "jca.xml"); deploy(SecurityActions.getClassLoader(EmbeddedJCA.class), "ds.xml");
/** * Remove ShrinkWrap deployment * @param deployment The deployment * @exception IOException Thrown if the deployment cant be removed */ private void removeDeployment(File deployment) throws IOException { if (deployment == null) throw new IllegalArgumentException("Deployment is null"); if (deployment.exists()) { shrinkwrapDeployments.remove(deployment); if (shrinkwrapDeployments.size() == 0) shrinkwrapDeployments = null; recursiveDelete(deployment); } }
/** * Create an instance of the embedded container * @param fullProfile Should a full JCA 1.6 profile be used * @return The instance */ public static Embedded create(boolean fullProfile) { return new EmbeddedJCA(fullProfile); } }
/** * Recursive delete * @param f The file handler * @exception IOException Thrown if a file could not be deleted */ private void recursiveDelete(File f) throws IOException { if (f != null && f.exists()) { File[] files = f.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { recursiveDelete(files[i]); } else { if (!files[i].delete()) throw new IOException("Could not delete " + files[i]); } } } if (!f.delete()) throw new IOException("Could not delete " + f); } } }
/** * Recursive delete * @param f The file handler * @exception IOException Thrown if a file could not be deleted */ private void recursiveDelete(File f) throws IOException { if (f != null && f.exists()) { File[] files = f.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { recursiveDelete(files[i]); } else { if (!files[i].delete()) throw new IOException("Could not delete " + files[i]); } } } if (!f.delete()) throw new IOException("Could not delete " + f); } } }
/** * {@inheritDoc} */ public void undeploy(Descriptor descriptor) throws Throwable { if (descriptor == null) throw new IllegalArgumentException("Descriptor is null"); if (descriptor.getDescriptorName() == null) throw new IllegalArgumentException("Descriptor name is null"); if (!(descriptor instanceof InputStreamDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources10.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources11.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources12.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources13.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters10.api.ResourceAdaptersDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters11.api.ResourceAdaptersDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters12.api.ResourceAdaptersDescriptor)) throw new IllegalArgumentException("Unsupported descriptor: " + descriptor.getClass().getName()); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File descriptorFile = new File(parentDirectory, descriptor.getDescriptorName()); log.debugf("Undeploying: %s", descriptorFile); kernel.getMainDeployer().undeploy(descriptorFile.toURI().toURL()); recursiveDelete(descriptorFile); }
/** * {@inheritDoc} */ public void undeploy(Descriptor descriptor) throws Throwable { if (descriptor == null) throw new IllegalArgumentException("Descriptor is null"); if (descriptor.getDescriptorName() == null) throw new IllegalArgumentException("Descriptor name is null"); if (!(descriptor instanceof InputStreamDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources10.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources11.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources12.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.datasources13.api.DatasourcesDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters10.api.ResourceAdaptersDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters11.api.ResourceAdaptersDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters12.api.ResourceAdaptersDescriptor || descriptor instanceof org.jboss.jca.embedded.dsl.resourceadapters13.api.ResourceAdaptersDescriptor)) throw new IllegalArgumentException("Unsupported descriptor: " + descriptor.getClass().getName()); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File descriptorFile = new File(parentDirectory, descriptor.getDescriptorName()); log.debugf("Undeploying: %s", descriptorFile); kernel.getMainDeployer().undeploy(descriptorFile.toURI().toURL()); recursiveDelete(descriptorFile); }
/** * Deploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void deploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!raa.getName().endsWith(".rar")) throw new IllegalArgumentException(raa.getName() + " doesn't end with .rar"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); if (shrinkwrapDeployments != null && shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " already deployed"); if (raaFile.exists()) recursiveDelete(raaFile); raa.as(ZipExporter.class).exportTo(raaFile, true); if (shrinkwrapDeployments == null) shrinkwrapDeployments = new ArrayList<File>(1); shrinkwrapDeployments.add(raaFile); log.debugf("Deploying: %s", raaFile); kernel.getMainDeployer().deploy(raaFile.toURI().toURL()); }
recursiveDelete(descriptorFile);
/** * Deploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void deploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!raa.getName().endsWith(".rar")) throw new IllegalArgumentException(raa.getName() + " doesn't end with .rar"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); if (shrinkwrapDeployments != null && shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " already deployed"); if (raaFile.exists()) recursiveDelete(raaFile); raa.as(ZipExporter.class).exportTo(raaFile, true); if (shrinkwrapDeployments == null) shrinkwrapDeployments = new ArrayList<File>(1); shrinkwrapDeployments.add(raaFile); log.debugf("Deploying: %s", raaFile); kernel.getMainDeployer().deploy(raaFile.toURI().toURL()); }