Java Code Examples for org.jboss.shrinkwrap.descriptor.api.Descriptor#getDescriptorName()

The following examples show how to use org.jboss.shrinkwrap.descriptor.api.Descriptor#getDescriptorName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedJCA.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@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.ironjacamar.embedded.dsl.datasources20.api.DatasourcesDescriptor ||
         descriptor instanceof org.ironjacamar.embedded.dsl.resourceadapters20.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);
}
 
Example 2
Source File: EmbeddedJCA.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void deploy(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.ironjacamar.embedded.dsl.datasources20.api.DatasourcesDescriptor ||
         descriptor instanceof org.ironjacamar.embedded.dsl.resourceadapters20.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());

   if (descriptorFile.exists())
      recursiveDelete(descriptorFile);

   FileOutputStream os = new FileOutputStream(descriptorFile);
   BufferedOutputStream bos = new BufferedOutputStream(os, BUFFER_SIZE);
   try
   {
      descriptor.exportTo(bos);
      bos.flush();
   }
   finally
   {
      try
      {
         bos.close();
      }
      catch (IOException ignore)
      {
         // Ignore
      }
   }

   log.debugf("Deploying: %s", descriptorFile);

   kernel.getMainDeployer().deploy(descriptorFile.toURI().toURL());
}