Tabnine Logo
ShrinkWrap.getDefaultDomain
Code IndexAdd Tabnine to your IDE (free)

How to use
getDefaultDomain
method
in
org.jboss.shrinkwrap.api.ShrinkWrap

Best Java code snippets using org.jboss.shrinkwrap.api.ShrinkWrap.getDefaultDomain (Showing top 19 results out of 315)

origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Creates a new archive of the specified type. The archive will be be backed by the default {@link Configuration}.
 * Invoking this method is functionally equivalent to calling {@link ArchiveFactory#create(Class, String)} upon
 * {@link Domain#getArchiveFactory()} upon the domain returned by {@link ShrinkWrap#getDefaultDomain()}.
 *
 * @param type
 *            The type of the archive e.g. {@link WebArchive}
 * @param archiveName
 *            The name of the archive
 * @return An {@link Assignable} archive base
 * @throws IllegalArgumentException
 *             either argument is not specified
 */
public static <T extends Assignable> T create(final Class<T> type, final String archiveName)
  throws IllegalArgumentException {
  // Precondition checks
  if (type == null) {
    throw new IllegalArgumentException("Type must be specified");
  }
  if (archiveName == null || archiveName.length() == 0) {
    throw new IllegalArgumentException("ArchiveName must be specified");
  }
  // Delegate to the default domain's archive factory for creation
  return ShrinkWrap.getDefaultDomain().getArchiveFactory().create(type, archiveName);
}
origin: shrinkwrap/shrinkwrap

/**
 * Creates a new archive of the specified type. The archive will be be backed by the default {@link Configuration}.
 * Invoking this method is functionally equivalent to calling {@link ArchiveFactory#create(Class, String)} upon
 * {@link Domain#getArchiveFactory()} upon the domain returned by {@link ShrinkWrap#getDefaultDomain()}.
 *
 * @param type
 *            The type of the archive e.g. {@link WebArchive}
 * @param archiveName
 *            The name of the archive
 * @return An {@link Assignable} archive base
 * @throws IllegalArgumentException
 *             either argument is not specified
 */
public static <T extends Assignable> T create(final Class<T> type, final String archiveName)
  throws IllegalArgumentException {
  // Precondition checks
  if (type == null) {
    throw new IllegalArgumentException("Type must be specified");
  }
  if (archiveName == null || archiveName.length() == 0) {
    throw new IllegalArgumentException("ArchiveName must be specified");
  }
  // Delegate to the default domain's archive factory for creation
  return ShrinkWrap.getDefaultDomain().getArchiveFactory().create(type, archiveName);
}
origin: shrinkwrap/shrinkwrap

/**
 * Creates a new archive of the specified type. The archive will be be backed by the default {@link Configuration}.
 * specific to this {@link ArchiveFactory}. Generates a random name for the archive and adds proper extension based
 * on the service descriptor properties file if extension property is present (e.g.
 * shrinkwrap/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.spec.JavaArchive)
 *
 * Invoking this method is functionally equivalent to calling {@link ArchiveFactory#create(Class)} upon
 * {@link Domain#getArchiveFactory()} upon the domain returned by {@link ShrinkWrap#getDefaultDomain()}.
 *
 * @param type
 *            The type of the archive e.g. {@link WebArchive}
 * @return An {@link Assignable} archive base
 * @throws IllegalArgumentException
 *             if type is not specified
 * @throws UnknownExtensionTypeException
 *             If no extension mapping is found for the specified type
 */
public static <T extends Assignable> T create(final Class<T> type) throws IllegalArgumentException,
  UnknownExtensionTypeException {
  // Precondition checks
  if (type == null) {
    throw new IllegalArgumentException("Type must be specified");
  }
  // Delegate to the default domain's archive factory for creation
  return ShrinkWrap.getDefaultDomain().getArchiveFactory().create(type);
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Creates a new archive of the specified type. The archive will be be backed by the default {@link Configuration}.
 * specific to this {@link ArchiveFactory}. Generates a random name for the archive and adds proper extension based
 * on the service descriptor properties file if extension property is present (e.g.
 * shrinkwrap/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.spec.JavaArchive)
 *
 * Invoking this method is functionally equivalent to calling {@link ArchiveFactory#create(Class)} upon
 * {@link Domain#getArchiveFactory()} upon the domain returned by {@link ShrinkWrap#getDefaultDomain()}.
 *
 * @param type
 *            The type of the archive e.g. {@link WebArchive}
 * @return An {@link Assignable} archive base
 * @throws IllegalArgumentException
 *             if type is not specified
 * @throws UnknownExtensionTypeException
 *             If no extension mapping is found for the specified type
 */
public static <T extends Assignable> T create(final Class<T> type) throws IllegalArgumentException,
  UnknownExtensionTypeException {
  // Precondition checks
  if (type == null) {
    throw new IllegalArgumentException("Type must be specified");
  }
  // Delegate to the default domain's archive factory for creation
  return ShrinkWrap.getDefaultDomain().getArchiveFactory().create(type);
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Creates a new archive of the specified type as imported from the specified {@link File}. The file is expected to
 * be encoded as ZIP (ie. JAR/WAR/EAR). The name of the archive will be set to {@link File#getName()}. The archive
 * will be be backed by the {@link Configuration} within the {@link ShrinkWrap#getDefaultDomain()}
 *
 * @param type
 *            The type of the archive e.g. {@link org.jboss.shrinkwrap.api.spec.WebArchive}
 * @param archiveFile
 *            the archiveName to use
 * @return An {@link Assignable} view
 * @throws IllegalArgumentException
 *             If either argument is not supplied, if the specified {@link File} does not exist, or is not a valid
 *             ZIP file
 * @throws org.jboss.shrinkwrap.api.importer.ArchiveImportException
 *             If an error occurred during the import process
 */
public static <T extends Assignable> T createFromZipFile(final Class<T> type, final File archiveFile)
  throws IllegalArgumentException, ArchiveImportException {
  // Delegate
  return getDefaultDomain().getArchiveFactory().createFromZipFile(type, archiveFile);
}
origin: shrinkwrap/shrinkwrap

/**
 * Creates a new archive of the specified type as imported from the specified {@link File}. The file is expected to
 * be encoded as ZIP (ie. JAR/WAR/EAR). The name of the archive will be set to {@link File#getName()}. The archive
 * will be be backed by the {@link Configuration} within the {@link ShrinkWrap#getDefaultDomain()}
 *
 * @param type
 *            The type of the archive e.g. {@link org.jboss.shrinkwrap.api.spec.WebArchive}
 * @param archiveFile
 *            the archiveName to use
 * @return An {@link Assignable} view
 * @throws IllegalArgumentException
 *             If either argument is not supplied, if the specified {@link File} does not exist, or is not a valid
 *             ZIP file
 * @throws org.jboss.shrinkwrap.api.importer.ArchiveImportException
 *             If an error occurred during the import process
 */
public static <T extends Assignable> T createFromZipFile(final Class<T> type, final File archiveFile)
  throws IllegalArgumentException, ArchiveImportException {
  // Delegate
  return getDefaultDomain().getArchiveFactory().createFromZipFile(type, archiveFile);
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Creates a new {@link Filter} instance using the given impl class name, constructor arguments and type
 *
 * @param filterClassName
 * @param ctorTypes
 * @param ctorArguments
 * @return
 */
@SuppressWarnings("unchecked")
private static Filter<ArchivePath> getFilterInstance(final String filterClassName, final Class<?>[] ctorTypes,
  final Object[] ctorArguments) {
  // Precondition checks
  assert filterClassName != null && filterClassName.length() > 0 : "Filter class name must be specified";
  assert ctorTypes != null : "Construction types must be specified";
  assert ctorArguments != null : "Construction arguments must be specified";
  assert ctorTypes.length == ctorArguments.length : "The number of ctor arguments and their types must match";
  // Find the filter impl class in the configured CLs
  final Class<Filter<ArchivePath>> filterClass;
  try {
    filterClass = (Class<Filter<ArchivePath>>) ClassLoaderSearchUtil.findClassFromClassLoaders(filterClassName,
      ShrinkWrap.getDefaultDomain().getConfiguration().getClassLoaders());
  } catch (final ClassNotFoundException cnfe) {
    throw new IllegalStateException("Could not find filter implementation class " + filterClassName
      + " in any of the configured CLs", cnfe);
  }
  // Make the new instance
  return SecurityActions.newInstance(filterClass, ctorTypes, ctorArguments, Filter.class);
}
origin: org.wildfly.swarm/wildfly-swarm-container

private void createShrinkWrapDomain() throws ModuleLoadException {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Thread.currentThread().setContextClassLoader(Container.class.getClassLoader());
      Module appModule = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("swarm.application"));
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    this.domain = ShrinkWrap.getDefaultDomain();
    this.domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (IOException e) {
    e.printStackTrace();
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

private void createShrinkWrapDomain() throws ModuleLoadException {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Thread.currentThread().setContextClassLoader(Container.class.getClassLoader());
      Module appModule = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("swarm.application"));
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    this.domain = ShrinkWrap.getDefaultDomain();
    this.domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (IOException e) {
    e.printStackTrace();
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
origin: shrinkwrap/shrinkwrap

/**
 * Creates a new {@link Filter} instance using the given impl class name, constructor arguments and type
 *
 * @param filterClassName
 * @param ctorTypes
 * @param ctorArguments
 * @return
 */
@SuppressWarnings("unchecked")
private static Filter<ArchivePath> getFilterInstance(final String filterClassName, final Class<?>[] ctorTypes,
  final Object[] ctorArguments) {
  // Precondition checks
  assert filterClassName != null && filterClassName.length() > 0 : "Filter class name must be specified";
  assert ctorTypes != null : "Construction types must be specified";
  assert ctorArguments != null : "Construction arguments must be specified";
  assert ctorTypes.length == ctorArguments.length : "The number of ctor arguments and their types must match";
  // Find the filter impl class in the configured CLs
  final Class<Filter<ArchivePath>> filterClass;
  try {
    filterClass = (Class<Filter<ArchivePath>>) ClassLoaderSearchUtil.findClassFromClassLoaders(filterClassName,
      ShrinkWrap.getDefaultDomain().getConfiguration().getClassLoaders());
  } catch (final ClassNotFoundException cnfe) {
    throw new IllegalStateException("Could not find filter implementation class " + filterClassName
      + " in any of the configured CLs", cnfe);
  }
  // Make the new instance
  return SecurityActions.newInstance(filterClass, ctorTypes, ctorArguments, Filter.class);
}
origin: org.teiid/thorntail-runtime

public static VDBArchive archiveFromCurrentApp() throws Exception {
  Configuration config = ShrinkWrap.getDefaultDomain().getConfiguration();
  ArrayList<ClassLoader> existing = new ArrayList<>();
  Iterator<ClassLoader> it = config.getClassLoaders().iterator();
  while (it.hasNext()) {
    existing.add(it.next());
  }
  existing.add(VDBArchive.class.getClassLoader());
  ConfigurationBuilder builder = new ConfigurationBuilder();
  builder.classLoaders(existing);
  builder.extensionLoader(new ServiceExtensionLoader(existing));
  Domain domain = ShrinkWrap.createDomain(builder);
  final VDBArchive archive = domain.getArchiveFactory().create(VDBArchive.class, determineName());
  //final VDBArchive archive = ShrinkWrap.create(VDBArchive.class, determineName());
  final DefaultDeploymentFactory factory = new DefaultVDBDeploymentFactory();
  factory.setup(archive);
  archive.addAllDependencies();
  return archive;
}
origin: shrinkwrap/shrinkwrap

@Override
protected MemoryMapArchive createNewArchive() {
  return new MemoryMapArchiveImpl(ShrinkWrap.getDefaultDomain().getConfiguration());
}
origin: org.wildfly.swarm/container-api

private void createShrinkWrapDomain() throws ModuleLoadException {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Thread.currentThread().setContextClassLoader(Container.class.getClassLoader());
      Module appModule = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("swarm.application"));
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    this.domain = ShrinkWrap.getDefaultDomain();
    this.domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    this.domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (IOException e) {
    e.printStackTrace();
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
origin: shrinkwrap/shrinkwrap

/**
 * Ensures all calls to get the default domain return the same reference
 */
@Test
public void getDefaultDomain() {
  // Get the default domain twice
  final Domain domain1 = ShrinkWrap.getDefaultDomain();
  final Domain domain2 = ShrinkWrap.getDefaultDomain();
  // Ensure they exist
  TestCase.assertNotNull("Domain should exist", domain1);
  TestCase.assertNotNull("Domain should exist", domain2);
  // Ensure they're not equal
  TestCase.assertSame(
    "Obtaining the default domain should always return the same instance (idempotent operation)", domain1,
    domain2);
}
origin: shrinkwrap/shrinkwrap

/**
 * Test to ensure MemoryMap archives can be created with a name
 *
 * @throws Exception
 */
@Test
public void testConstructorWithName() throws Exception {
  String name = "test.jar";
  MemoryMapArchive tmp = new MemoryMapArchiveImpl(name, ShrinkWrap.getDefaultDomain().getConfiguration());
  Assert.assertEquals("Should return the same name as construtor arg", name, tmp.getName());
}
origin: shrinkwrap/shrinkwrap

/**
 * Ensures we can create a new Archive fro a ZIP file via an {@link ArchiveFactory}
 */
@Test
public void shouldBeAbleToimportZipFileViaArchiveFactory() throws Exception {
  // Get the test file
  final File testFile = delegate.getExistingResource();
  // Make a new archive via the default domain
  final JavaArchive archive = ShrinkWrap.getDefaultDomain().getArchiveFactory()
    .createFromZipFile(JavaArchive.class, testFile);
  // Assert
  Assert.assertNotNull("Should not return a null archive", archive);
  Assert.assertEquals("name of the archive imported from a ZIP file was not as expected", testFile.getName(),
    archive.getName());
  delegate.assertContent(archive, testFile);
}
origin: io.thorntail/container

private void createShrinkWrapDomain() {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    Domain domain = ShrinkWrap.getDefaultDomain();
    domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedImporter.class, ExplodedImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (Exception e) {
    SwarmMessages.MESSAGES.shrinkwrapDomainSetupFailed(e);
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
origin: thorntail/thorntail

private void createShrinkWrapDomain() {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    Domain domain = ShrinkWrap.getDefaultDomain();
    domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedImporter.class, ExplodedImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (Exception e) {
    SwarmMessages.MESSAGES.shrinkwrapDomainSetupFailed(e);
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
origin: org.wildfly.swarm/container

private void createShrinkWrapDomain() {
  ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
  try {
    if (isFatJar()) {
      Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
      Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
    }
    Domain domain = ShrinkWrap.getDefaultDomain();
    domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(ExplodedImporter.class, ExplodedImporterImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
    domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
  } catch (Exception e) {
    SwarmMessages.MESSAGES.shrinkwrapDomainSetupFailed(e);
  } finally {
    Thread.currentThread().setContextClassLoader(originalCl);
  }
}
org.jboss.shrinkwrap.apiShrinkWrapgetDefaultDomain

Javadoc

Returns a single domain with default configuration for use in applications with no explicit configuration or isolation requirements.

Popular methods of ShrinkWrap

  • create
  • createFromZipFile
    Creates a new archive of the specified type as imported from the specified File. The file is expecte
  • createDomain
    Creates a new Domain containing configuration properties from the supplied ConfigurationBuilder. Arc

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now