예제 #1
0
  /** {@inheritDoc} */
  @Override
  public OperationResult execute(
      OperationContext context, ModelNode operation, ResultHandler resultHandler) {

    if (context instanceof BootOperationContext) {

      /* set Hibernate persistence provider as the default provider */
      javax.persistence.spi.PersistenceProviderResolverHolder.setPersistenceProviderResolver(
          new PersistenceProviderResolverImpl());

      PersistenceProviderAdapterRegistry.putPersistenceProviderAdaptor(
          "org.hibernate.ejb.HibernatePersistence", new HibernatePersistenceProviderAdaptor());

      final BootOperationContext updateContext = (BootOperationContext) context;
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_PERSISTENCE_UNIT, new PersistenceUnitParseProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_PERSISTENCE_ANNOTATION, new JPAAnnotationParseProcessor());
      updateContext.addDeploymentProcessor(
          Phase.DEPENDENCIES, Phase.DEPENDENCIES_JPA, new JPADependencyProcessor());
      updateContext.addDeploymentProcessor(
          Phase.INSTALL, Phase.INSTALL_PERSISTENCE_REF, new PersistenceRefProcessor());
      updateContext.addDeploymentProcessor(
          Phase.INSTALL, Phase.INSTALL_PERSISTENTUNIT, new PersistenceUnitDeploymentProcessor());
    }

    final ModelNode compensatingOperation = new ModelNode();
    compensatingOperation.get(OP).set(REMOVE);
    compensatingOperation.get(OP_ADDR).set(operation.require(OP_ADDR));

    context.getSubModel().setEmptyObject();
    resultHandler.handleResultComplete();
    return new BasicOperationResult(compensatingOperation);
  }
예제 #2
0
  /** {@inheritDoc} */
  @Override
  public OperationResult execute(
      final OperationContext context,
      final ModelNode operation,
      final ResultHandler resultHandler) {

    final ModelNode compensatingOperation =
        Util.getResourceRemoveOperation(operation.require(OP_ADDR));

    if (context instanceof BootOperationContext) {
      final BootOperationContext updateContext = (BootOperationContext) context;

      context
          .getRuntimeContext()
          .setRuntimeTask(
              new RuntimeTask() {
                @Override
                public void execute(RuntimeTaskContext context) throws OperationFailedException {
                  final ServiceTarget serviceTarget = context.getServiceTarget();
                  final EJBUtilities utilities = new EJBUtilities();
                  serviceTarget
                      .addService(EJBUtilities.SERVICE_NAME, utilities)
                      .addDependency(
                          TxnServices.JBOSS_TXN_TRANSACTION_MANAGER,
                          TransactionManager.class,
                          utilities.getTransactionManagerInjector())
                      .addDependency(
                          TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY,
                          TransactionSynchronizationRegistry.class,
                          utilities.getTransactionSynchronizationRegistryInjector())
                      .addDependency(
                          TxnServices.JBOSS_TXN_USER_TRANSACTION,
                          UserTransaction.class,
                          utilities.getUserTransactionInjector())
                      .setInitialMode(ServiceController.Mode.ACTIVE)
                      .install();
                  resultHandler.handleResultComplete(); // TODO: Listener
                }
              });

      // add the metadata parser deployment processor
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_DEPLOYMENT, new EjbJarParsingDeploymentUnitProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_ANNOTATION, new EjbAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_MESSAGE_DRIVEN_ANNOTATION,
          new MessageDrivenAnnotationProcessor());
      // Process @DependsOn after the @Singletons have been registered.
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_ANNOTATION, new EjbDependsOnAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_CONTEXT_BINDING, new EjbContextJndiBindingProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_TRANSACTION_MANAGEMENT,
          new TransactionManagementAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_LOCAL_VIEW_ANNOTATION,
          new LocalEjbViewAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_NO_INTERFACE_VIEW_ANNOTATION,
          new NoInterfaceViewAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_INJECTION_ANNOTATION,
          new EjbResourceInjectionAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_STARTUP_ANNOTATION, new StartupAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_CONCURRENCY_MANAGEMENT_ANNOTATION,
          new ConcurrencyManagementAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE, Phase.PARSE_EJB_LOCK_ANNOTATION, new LockAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_ACCESS_TIMEOUT_ANNOTATION,
          new AccessTimeoutAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_TRANSACTION_ATTR_ANNOTATION,
          new TransactionAttributeAnnotationProcessor());
      updateContext.addDeploymentProcessor(
          Phase.PARSE,
          Phase.PARSE_EJB_RESOURCE_ADAPTER_ANNOTATION,
          new ResourceAdapterAnnotationProcessor());

      updateContext.addDeploymentProcessor(
          Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB, new EjbDependencyDeploymentUnitProcessor());

      updateContext.addDeploymentProcessor(
          Phase.POST_MODULE,
          Phase.POST_MODULE_EJB_JNDI_BINDINGS,
          new EjbJndiBindingsDeploymentUnitProcessor());

      // add the real deployment processor
      // TODO: add the proper deployment processors
      // updateContext.addDeploymentProcessor(processor, priority);
    }

    context.getSubModel().setEmptyObject();
    resultHandler.handleResultComplete();
    return new BasicOperationResult(compensatingOperation);
  }