本文整理汇总了Java中org.jboss.modules.Module.forClass方法的典型用法代码示例。如果您正苦于以下问题:Java Module.forClass方法的具体用法?Java Module.forClass怎么用?Java Module.forClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.modules.Module
的用法示例。
在下文中一共展示了Module.forClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
Module module = Module.forClass(CoreServiceActivator.class);
String deploymentName = module.getIdentifier().getName();
if (deploymentName.startsWith("deployment.")) {
deploymentName = deploymentName.replace("deployment.", "");
}
Context namingContext;
try {
namingContext = new InitialContext();
} catch (NamingException e) {
throw new ServiceRegistryException(e);
}
WunderBossService service = new WunderBossService(deploymentName,
serviceActivatorContext.getServiceRegistry(),
serviceActivatorContext.getServiceTarget(),
namingContext);
serviceActivatorContext.getServiceTarget()
.addService(WunderBossService.serviceName(deploymentName), service)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}
示例2: failsIfImportFilterExcludesNecessaryPathFromAppPackage
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void failsIfImportFilterExcludesNecessaryPathFromAppPackage() throws ModuleLoadException, IOException, Exception {
ScriptModuleLoader moduleLoader = setupClassPathDependentWithFilter("java");
boolean didFail = false;
Module.forClass(Object.class);
try {
exerciseClasspathDependentModule(moduleLoader);
} catch (java.lang.NoClassDefFoundError e) {
Assert.assertTrue(e.getMessage().contains("org/jboss/modules/Module"));
didFail = true;
}
Assert.assertTrue(didFail);
}
示例3: populateModel
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource)
throws OperationFailedException {
// deploy anything we find in the deployments folder
try {
if (requiresRuntime(context)) { // only add the steps if we are going to actually deploy now
URL deploymentsUrl = null; // directory where the deployments should be
Module module = Module.forClass(getClass());
if (module != null) {
deploymentsUrl = module.getExportedResource(NestSubsystemExtension.DEPLOYMENTS_DIR_NAME);
} else {
// if we get here, most likely we are running in a test env
deploymentsUrl = getClass().getClassLoader().getResource(
NestSubsystemExtension.DEPLOYMENTS_DIR_NAME);
}
if (deploymentsUrl != null) {
File deploymentsDir = new File(deploymentsUrl.toURI());
if (deploymentsDir.isDirectory()) {
File[] deployments = deploymentsDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".ear") || name.endsWith(".war") || name.endsWith(".jar");
}
});
if (deployments != null) {
msglog.infoDeploymentsFound(deployments.length);
int deploymentNumber = 1;
for (File deployment : deployments) {
PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(
DEPLOYMENT, deployment.getName()));
ModelNode op = Util.getEmptyOperation(ADD, deploymentAddress.toModelNode());
op.get(ENABLED).set(true);
op.get(PERSISTENT).set(false); // prevents writing this deployment out to standalone.xml
ModelNode contentItem = new ModelNode();
if (deployment.isDirectory()) {
// an exploded deployment
contentItem.get(PATH).set(deployment.getAbsolutePath());
contentItem.get(ARCHIVE).set(false);
} else {
// an unexploded deployment archive
contentItem.get(URL).set(deployment.toURI().toURL().toExternalForm());
}
op.get(CONTENT).add(contentItem);
ImmutableManagementResourceRegistration rootResourceRegistration;
rootResourceRegistration = context.getRootResourceRegistration();
OperationStepHandler handler = rootResourceRegistration.getOperationHandler(
deploymentAddress, ADD);
context.addStep(op, handler, OperationContext.Stage.MODEL);
msglog.infoDeploying(deploymentNumber++, deployment.getName());
}
} else {
msglog.errorFailedGettingDeployments(NestSubsystemExtension.DEPLOYMENTS_DIR_NAME);
}
} else {
msglog.errorBadDeploymentsDirectory(NestSubsystemExtension.DEPLOYMENTS_DIR_NAME);
}
} else {
msglog.errorMissingDeploymentsDirectory(NestSubsystemExtension.DEPLOYMENTS_DIR_NAME);
}
}
} catch (Exception e) {
throw new OperationFailedException("Deployments failed", e);
}
// finish the broker subsystem model
populateModel(operation, resource.getModel());
}
示例4: deployResources
import org.jboss.modules.Module; //导入方法依赖的package包/类
private void deployResources(OperationContext context) throws OperationFailedException{
if (requiresRuntime(context)) {
try {
Module module = Module.forClass(getClass());
if (module == null) {
return; // during testing
}
URL deployments = module.getExportedResource("deployments.properties"); //$NON-NLS-1$
if (deployments == null) {
return; // no deployments
}
BufferedReader in = new BufferedReader(new InputStreamReader(deployments.openStream()));
String deployment;
while ((deployment = in.readLine()) != null) {
PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, deployment));
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).set(deploymentAddress.toModelNode());
op.get(ENABLED).set(true);
op.get(PERSISTENT).set(false); // prevents writing this deployment out to standalone.xml
URL url = module.getExportedResource(deployment);
String urlString = url.toExternalForm();
ModelNode contentItem = new ModelNode();
contentItem.get(URL).set(urlString);
op.get(CONTENT).add(contentItem);
ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
OperationStepHandler handler = rootResourceRegistration.getOperationHandler(deploymentAddress, ADD);
context.addStep(op, handler, OperationContext.Stage.MODEL);
}
in.close();
}catch(IOException e) {
throw new OperationFailedException(e.getMessage(), e);
}
}
}
示例5: DependentClass
import org.jboss.modules.Module; //导入方法依赖的package包/类
/**
*
* Try to access a class from the application classpath
* This will fail if app import filters block it, and pass
* if it is allowed.
*
*/
public DependentClass() {
// We know Module is in the classpath of the test
Module.forClass(Object.class);
}