本文整理匯總了Java中javax.enterprise.inject.spi.Extension類的典型用法代碼示例。如果您正苦於以下問題:Java Extension類的具體用法?Java Extension怎麽用?Java Extension使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Extension類屬於javax.enterprise.inject.spi包,在下文中一共展示了Extension類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DeploymentImpl
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
public DeploymentImpl(
final Collection<DynamicArchiveContributor> dynamicArchiveContributors,
final ServiceRegistry serviceRegistry,
final Collection<Metadata<Extension>> extensions,
final BeansXmlModifier modifier
) {
archives = dynamicArchiveContributors.stream()
.map(it -> it.contribute(serviceRegistry, this::archiveSupplier))
.flatMap(Collection::stream)
.collect(toMap(
it -> it,
it -> new WrappedBeanDeploymentArchive(it, modifier, this::mapper)
));
this.serviceRegistry = serviceRegistry;
this.extensions = extensions;
}
示例2: init
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
public DependencyInjectionRealm init(
final ServiceRegistry serviceRegistry,
final Environments environment,
final Collection<Metadata<Extension>> extensions,
final BeansXmlModifier beansXmlModifier,
final Collection<DynamicArchiveContributor> archiveContributors
) {
LOG.trace("Starting dependency injection realm {}", contextId);
deployment = new DeploymentImpl(
archiveContributors,
serviceRegistry,
extensions,
beansXmlModifier
);
bootstrap = new WeldBootstrap()
.startContainer(contextId, environment, deployment)
.startInitialization()
.deployBeans()
.validateBeans()
.endInitialization();
return this;
}
示例3: createDeployment
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
@Deployment(name = "test")
public static Archive<?> createDeployment() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
.addClasses(
Greeter.class,
Resources.class,
CdiConfig.class
)
.addAsServiceProvider(Extension.class, CdiConfig.class)
.addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
.addAsManifestResource("META-INF/test-beans.xml", "beans.xml");
// System.out.println(archive.toString(true));
return archive;
}
示例4: createTestJar
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* Creates the JAR file containing the test infrastructure.
*
* @return The jar file.
*/
private static JavaArchive createTestJar() {
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class,
TEST_JAR_NAME);
// add resources
if (TEST_RESOURCES_DIRECTORY.exists()) {
ResourceUtils.addResources(testJar, TEST_RESOURCES_DIRECTORY,
new ResourceFilterForSuffixExclusion(
DEPLOYMENT_STRUCTURE_FILE));
}
// add common test class to the test.jar
testJar.addClass(AbstractArquillianTest.class);
testJar.addClass(AbstractServerTest.class);
// add Mockito
testJar.addPackages(true, Mockito.class.getPackage());
testJar.addPackages(true, ObjenesisStd.class.getPackage());
testJar.addPackage(Mock.class.getPackage());
// add CDI extension descriptors
addServices(testJar, Extension.class);
return testJar;
}
示例5: addServices
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* Merges the service loader descriptors for the given class and adds them
* to the jar archive.
*
* @param jar
* The jar archive.
* @param serviceClass
* The service class.
*/
private static void addServices(JavaArchive jar, Class<?> serviceClass) {
try {
File file = File.createTempFile(Extension.class.getName(), "");
file.deleteOnExit();
Enumeration<URL> resources = AbstractServerTest.class
.getClassLoader().getResources(
"META-INF/services/" + serviceClass.getName());
List<String> extensions = new ArrayList<String>();
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
List<String> lines = IOUtils.readLines(resource.openStream());
extensions.addAll(lines);
}
try (FileWriter writer = new FileWriter(file)) {
IOUtils.writeLines(extensions, null, writer);
writer.close();
jar.addAsManifestResource(file,
"services/" + serviceClass.getName());
}
} catch (IOException e) {
throw new IllegalStateException("Cannot read files", e);
}
}
示例6: createTestArchive
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
@Deployment(order = 1, name = "test-candidate")
public static WebArchive createTestArchive() {
WebArchive wa = ShrinkWrap.create(WebArchive.class, "sample.war")
.addPackage(SampleRepository.class.getPackage())
.addPackage(JPAQueryExecutor.class.getPackage())
.addPackage(Create.class.getPackage())
.addPackage(DefaultJPAConnection.class.getPackage());
wa.addAsWebInfResource("META-INF/beans.xml");
wa.addAsWebInfResource("ejb-jar.xml");
wa.addAsResource("META-INF/persistence.xml");
wa.addAsServiceProvider(Extension.class, RepositoryExtension.class);
for (File libFile : new File("target/libs").listFiles()) {
wa.addAsLibrary(libFile, libFile.getName());
}
System.out.println(
"------------------------------- sample.war --------------------------------");
System.out.println(wa.toString(true));
System.out.println("---------------------------------------------------------------------------");
return wa;
}
示例7: createTestArchive
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
@Deployment(order = 2,
name = "test-candidate")
public static WebArchive createTestArchive() {
WebArchive wa = ShrinkWrap.create(WebArchive.class, "sample.war");
wa.addClasses(Actor.class, Movie.class, SampleRepository.class,
Neo4jUplinkProducer.class,
Neo4jQueryExecutor.class,
SysoutLoggingBridge.class);
wa.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
wa.addAsWebInfResource("ejb-jar.xml");
wa.addAsServiceProvider(Extension.class, RepositoryExtension.class);
for (File libFile : new File("target/libs").listFiles()) {
wa.addAsLibrary(libFile, libFile.getName());
}
System.out.println(
"------------------------------- sample.war --------------------------------");
System.out.println(wa.toString(true));
System.out.println(
"---------------------------------------------------------------------------");
return wa;
}
示例8: getParentExtension
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* @return the Extension from the same type but registered in a hierarchic 'parent' BeanManager
*/
public static synchronized <T extends Extension> T getParentExtension(Extension extension)
{
if (usingParentExtension())
{
ClassLoader parentClassLoader = ClassUtils.getClassLoader(null).getParent();
Iterator<ExtensionStorageInfo> extIt = extensionStorage.iterator();
while (extIt.hasNext())
{
ExtensionStorageInfo extensionInfo = extIt.next();
if (!extensionInfo.isAbandoned() && // weak reference case
extension.getClass().equals(extensionInfo.getExtension().getClass()) &&
extensionInfo.getClassLoader().equals(parentClassLoader))
{
return (T) extensionInfo.getExtension();
}
}
}
return null;
}
示例9: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "messageTest.jar")
.addPackage(MessageTest.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "messageTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例10: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "simpleMessageTest.jar")
.addPackage(SimpleMessageTest.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "simpleMessageTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例11: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
final JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "messageContextTest.jar")
.addPackage(MessageContextTest.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "messageContextTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例12: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "localeMessageTest.jar")
.addPackage(ConfigurableLocaleMessageTest.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "localeMessageTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(new StringAsset(BEANS_XML_CONTENT), "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例13: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "minimalMessageTest.jar")
.addPackages(false, Filters.exclude(MessageContextTest.class),
MinimalMessagesTest.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "minimalMessageTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsResource("customMinimalMessage_en.properties")
.addAsResource("org/apache/deltaspike/test/core/api/message/MinimalMessages_en.properties")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例14: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
@ShouldThrowException(Exception.class)
public static WebArchive deploy()
{
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "invalidMessageBundleTest.jar")
.addPackage(BrokenMessageBundleClass.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "invalidMessageBundleTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}
示例15: deploy
import javax.enterprise.inject.spi.Extension; //導入依賴的package包/類
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
*/
@Deployment
public static WebArchive deploy()
{
Asset beansXml = new StringAsset(
"<beans><alternatives>" +
"<class>" + MessageFormatMessageInterpolator.class.getName() + "</class>" +
"</alternatives></beans>"
);
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "messageFormattedMessageTest.jar")
.addPackage(MessageFormattedMessageTest.class.getPackage())
.addAsManifestResource(beansXml, "beans.xml");
return ShrinkWrap
.create(WebArchive.class, "messageFormattedMessageTest.war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsServiceProvider(Extension.class,
MessageBundleExtension.class);
}