Search in sources :

Example 1 with NamedBootstrapContext

use of org.jboss.as.connector.services.bootstrap.NamedBootstrapContext in project wildfly by wildfly.

the class BootstrapContextAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    String name = JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().resolveModelAttribute(context, model).asString();
    String workmanager = JcaBootstrapContextDefinition.BootstrapCtxParameters.WORKMANAGER.getAttribute().resolveModelAttribute(context, model).asString();
    boolean usingDefaultWm = false;
    CloneableBootstrapContext ctx;
    if (DEFAULT_NAME.equals(workmanager)) {
        usingDefaultWm = true;
        ctx = new NamedBootstrapContext(name);
    } else {
        ctx = new NamedBootstrapContext(name, workmanager);
    }
    ServiceTarget serviceTarget = context.getServiceTarget();
    final BootStrapContextService bootCtxService = new BootStrapContextService(ctx, name, usingDefaultWm);
    serviceTarget.addService(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(name), bootCtxService).addDependency(ConnectorServices.WORKMANAGER_SERVICE.append(workmanager), WorkManager.class, bootCtxService.getWorkManagerValueInjector()).addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, bootCtxService.getXaTerminatorInjector()).addDependency(TxnServices.JBOSS_TXN_ARJUNA_TRANSACTION_MANAGER, com.arjuna.ats.jbossatx.jta.TransactionManagerService.class, bootCtxService.getTxManagerInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, bootCtxService.getJcaConfigInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : BootStrapContextService(org.jboss.as.connector.services.bootstrap.BootStrapContextService) WorkManager(org.jboss.jca.core.api.workmanager.WorkManager) NamedBootstrapContext(org.jboss.as.connector.services.bootstrap.NamedBootstrapContext) ServiceTarget(org.jboss.msc.service.ServiceTarget) CloneableBootstrapContext(org.jboss.jca.core.api.bootstrap.CloneableBootstrapContext)

Example 2 with NamedBootstrapContext

use of org.jboss.as.connector.services.bootstrap.NamedBootstrapContext in project wildfly by wildfly.

the class MultipleResourceAdapter2 method start.

/**
 * This is called when a resource adapter instance is bootstrapped.
 *
 * @param ctx A bootstrap context containing references
 * @throws ResourceAdapterInternalException indicates bootstrap failure.
 */
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
    log.trace("start()");
    if (ctx instanceof NamedBootstrapContext) {
        NamedBootstrapContext nc = (NamedBootstrapContext) ctx;
        setBootstrapContextName(nc.getName());
        log.trace("Bootstrap-context:" + nc.getName());
    }
    WorkManager wm = ctx.getWorkManager();
    if (wm instanceof NamedWorkManager) {
        NamedWorkManager nw = (NamedWorkManager) wm;
        setWorkManagerName(nw.getName());
        log.trace("Work-manager:" + nw.getName());
    }
    Work myWork1 = new MultipleWork();
    Work myWork2 = new MultipleWork();
    Work myWork3 = new MultipleWork();
    try {
        wm.doWork(myWork1);
        wm.scheduleWork(myWork2);
        wm.startWork(myWork3);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) WorkManager(javax.resource.spi.work.WorkManager) NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) NamedBootstrapContext(org.jboss.as.connector.services.bootstrap.NamedBootstrapContext) Work(javax.resource.spi.work.Work) ResourceException(javax.resource.ResourceException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException)

Aggregations

NamedBootstrapContext (org.jboss.as.connector.services.bootstrap.NamedBootstrapContext)2 ResourceException (javax.resource.ResourceException)1 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)1 Work (javax.resource.spi.work.Work)1 WorkManager (javax.resource.spi.work.WorkManager)1 BootStrapContextService (org.jboss.as.connector.services.bootstrap.BootStrapContextService)1 NamedWorkManager (org.jboss.as.connector.services.workmanager.NamedWorkManager)1 CloneableBootstrapContext (org.jboss.jca.core.api.bootstrap.CloneableBootstrapContext)1 WorkManager (org.jboss.jca.core.api.workmanager.WorkManager)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1