Package org.jboss.as.naming

Examples of org.jboss.as.naming.ManagedReference


    this.paModule = paModule;
  }

  public void start(StartContext context) throws StartException {

    ManagedReference reference = null;
    try {

      // get the process application component
      ProcessApplicationInterface processApplication = null;
      ComponentView componentView = paComponentViewInjector.getOptionalValue();
      if(componentView != null) {
        reference = componentView.createInstance();
        processApplication = (ProcessApplicationInterface) reference.getInstance();
      } else {
        processApplication = noViewProcessApplication.getValue();
      }

      // create & populate the process application info object
      processApplicationInfo = new ProcessApplicationInfoImpl();
      processApplicationInfo.setName(processApplication.getName());
      processApplicationInfo.setProperties(processApplication.getProperties());

      referencedProcessEngines = new HashSet<ProcessEngine>();
      List<ProcessApplicationDeploymentInfo> deploymentInfos = new ArrayList<ProcessApplicationDeploymentInfo>();

      for (ServiceName deploymentServiceName : deploymentServiceNames) {

        ProcessApplicationDeploymentService value = getDeploymentService(context, deploymentServiceName);
        referencedProcessEngines.add(value.getProcessEngineInjector().getValue());

        ProcessApplicationDeployment deployment = value.getDeployment();
        if(deployment != null) {
          for (String deploymentId : deployment.getProcessApplicationRegistration().getDeploymentIds()) {
            ProcessApplicationDeploymentInfoImpl deploymentInfo = new ProcessApplicationDeploymentInfoImpl();
            deploymentInfo.setDeploymentId(deploymentId);
            deploymentInfo.setProcessEngineName(value.getProcessEngineName());
            deploymentInfos.add(deploymentInfo);
          }
        }

      }
      processApplicationInfo.setDeploymentInfo(deploymentInfos);

      if(postDeployDescription != null) {
        invokePostDeploy(processApplication);
      }

      // install the ManagedProcessApplication Service as a child to this service
      // if this service stops (at undeployment) the ManagedProcessApplication service is removed as well.
      ServiceName serviceName = ServiceNames.forManagedProcessApplication(processApplicationInfo.getName());
      MscManagedProcessApplication managedProcessApplication = new MscManagedProcessApplication(processApplicationInfo);
      context.getChildTarget().addService(serviceName, managedProcessApplication).install();

    } catch (StartException e) {
      throw e;

    } catch (Exception e) {
      throw new StartException(e);

    } finally {
      if(reference != null) {
        reference.release();
      }
    }
  }
View Full Code Here




  public void stop(StopContext context) {

    ManagedReference reference = null;
    try {

      // get the process application component
      ProcessApplicationInterface processApplication = null;
      ComponentView componentView = paComponentViewInjector.getOptionalValue();
      if(componentView != null) {
        reference = componentView.createInstance();
        processApplication = (ProcessApplicationInterface) reference.getInstance();
      } else {
        processApplication = noViewProcessApplication.getValue();
      }

      invokePreUndeploy(processApplication);

    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, "Exception while stopping process application", e);

    } finally {
      if(reference != null) {
        reference.release();
      }
    }

  }
View Full Code Here

    });
  }

  protected void performDeployment() throws StartException {

    ManagedReference reference = null;
    try {

      // get process engine
      ProcessEngine processEngine = processEngineInjector.getValue();

      // get the process application component
      ProcessApplicationInterface processApplication = null;
      ComponentView componentView = paComponentViewInjector.getOptionalValue();
      if(componentView != null) {
        reference = componentView.createInstance();
        processApplication = (ProcessApplicationInterface) reference.getInstance();
      } else {
        processApplication = noViewProcessApplication.getValue();
      }

      // get the application name
      String processApplicationName = processApplication.getName();

      // build the deployment
      final RepositoryService repositoryService = processEngine.getRepositoryService();

      final ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());

      // enable duplicate filtering
      deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false));

      // enable resuming of previous versions:
      if(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_RESUME_PREVIOUS_VERSIONS, true)) {
        deploymentBuilder.resumePreviousVersions();
      }

      // set the name for the deployment
      String deploymentName = processArchive.getName();
      if(deploymentName == null || deploymentName.isEmpty()) {
        deploymentName = processApplicationName;
      }
      deploymentBuilder.name(deploymentName);

      // add deployment resources
      for (Entry<String, byte[]> resource : deploymentMap.entrySet()) {
        deploymentBuilder.addInputStream(resource.getKey(), new ByteArrayInputStream(resource.getValue()));
      }

      // let the process application component add resources to the deployment.
      processApplication.createDeployment(processArchive.getName(), deploymentBuilder);

      Collection<String> resourceNames = deploymentBuilder.getResourceNames();
      if(!resourceNames.isEmpty()) {
        logDeploymentSummary(resourceNames, deploymentName, processApplicationName);
        // perform the actual deployment
        deployment = Tccl.runUnderClassloader(new Tccl.Operation<ProcessApplicationDeployment>() {

          public ProcessApplicationDeployment run() {
            return deploymentBuilder.deploy();
          }

        }, module.getClassLoader());

      } else {
        LOGGER.info("Not creating a deployment for process archive '" + processArchive.getName() + "': no resources provided.");

      }

    } catch (Exception e) {
      throw new StartException("Could not register process application with shared process engine ",e);

    } finally {
      if(reference != null) {
        reference.release();
      }
    }
  }
View Full Code Here

        withContext = method.getParameterTypes().length == 1;
    }

    /** {@inheritDoc} */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = instanceRef.get();
        final Object instance = reference.getInstance();
        try {
            Method method = this.method;
            if (withContext) {
                if (changeMethod) {
                    final Method oldMethod = context.getMethod();
View Full Code Here

        this.instanceRef = instanceRef;
    }

    /** {@inheritDoc} */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = instanceRef.get();
        final Object instance = reference.getInstance();
        try {
            return method.invoke(instance, context.getParameters());
        } catch (IllegalAccessException e) {
            final IllegalAccessError n = new IllegalAccessError(e.getMessage());
            n.setStackTrace(e.getStackTrace());
View Full Code Here

    }

    protected <T> T createViewInstanceProxy(final Class<T> viewInterface, final Map<Object, Object> contextData, final ServiceName serviceName) {
        final ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer().getRequiredService(serviceName);
        final ComponentView view = (ComponentView) serviceController.getValue();
        final ManagedReference instance = view.createInstance(contextData);
        return viewInterface.cast(instance.getInstance());
    }
View Full Code Here

        this.componentInstantiator = componentInstantiator;
        this.referenceReference = referenceReference;
    }

    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference existing = referenceReference.get();
        if (existing == null) {
            final ManagedReference reference = componentInstantiator.getReference();
            boolean ok = false;
            try {
                referenceReference.set(reference);
                context.setTarget(reference.getInstance());
                Object result = context.proceed();
                ok = true;
                return result;
            } finally {
                context.setTarget(null);
                if (!ok) {
                    reference.release();
                    referenceReference.set(null);
                }
            }
        } else {
            return context.proceed();
View Full Code Here

    public Object processInvocation(final InterceptorContext context) throws Exception {
        Object target = targetReference.get().getInstance();
        if (target == null) {
            throw new IllegalStateException("No injection target found");
        }
        ManagedReference reference = factory.getReference();
        boolean ok = false;
        try {
            valueReference.set(reference);
            field.set(target, reference.getInstance());
            Object result = context.proceed();
            ok = true;
            return result;
        } finally {
            if (! ok) {
                valueReference.set(null);
                reference.release();
            }
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object getInstance() {
        final ManagedReference managedReference = this.instanceReference.get();
        return managedReference.getInstance();
    }
View Full Code Here

        withContext = method.getParameterTypes().length == 1;
    }

    /** {@inheritDoc} */
    public Object processInvocation(final InterceptorContext context) throws Exception {
        final ManagedReference reference = instanceRef.get();
        final Object instance = reference.getInstance();
        try {
            Method method = this.method;
            if (withContext) {
                if (changeMethod) {
                    final Method oldMethod = context.getMethod();
View Full Code Here

TOP

Related Classes of org.jboss.as.naming.ManagedReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.