org.camunda.bpm.application.ProcessApplication Java Examples

The following examples show how to use org.camunda.bpm.application.ProcessApplication. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessApplicationProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();    
  final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
  
  // must be EE Module
  if(eeModuleDescription == null) {
    return;
  }

  // discover user-provided component
  ComponentDescription paComponent = detectExistingComponent(deploymentUnit); 

  if(paComponent != null) {      
    log.log(Level.INFO, "Detected user-provided @"+ProcessApplication.class.getSimpleName()+" component with name '"+paComponent.getComponentName()+"'.");
    
    // mark this to be a process application
    ProcessApplicationAttachments.attachProcessApplicationComponent(deploymentUnit, paComponent);
    ProcessApplicationAttachments.mark(deploymentUnit);
    ProcessApplicationAttachments.markPartOfProcessApplication(deploymentUnit);
  }
}
 
Example #2
Source File: ProcessApplicationProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();    
  final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
  
  // must be EE Module
  if(eeModuleDescription == null) {
    return;
  }

  // discover user-provided component
  ComponentDescription paComponent = detectExistingComponent(deploymentUnit); 

  if(paComponent != null) {      
    log.log(Level.INFO, "Detected user-provided @"+ProcessApplication.class.getSimpleName()+" component with name '"+paComponent.getComponentName()+"'.");
    
    // mark this to be a process application
    ProcessApplicationAttachments.attachProcessApplicationComponent(deploymentUnit, paComponent);
    ProcessApplicationAttachments.mark(deploymentUnit);
    ProcessApplicationAttachments.markPartOfProcessApplication(deploymentUnit);
  }
}
 
Example #3
Source File: ParseProcessesXmlStep.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String[] getDeploymentDescriptorLocations(AbstractProcessApplication processApplication) {
  ProcessApplication annotation = processApplication.getClass().getAnnotation(ProcessApplication.class);
  if(annotation == null) {
    return new String[] {ProcessApplication.DEFAULT_META_INF_PROCESSES_XML};

  } else {
    return annotation.deploymentDescriptors();

  }
}
 
Example #4
Source File: ProcessesXmlProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {

    final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit);
    final String paClassName = processApplicationComponent.getComponentClassName();

    String[] deploymentDescriptorResourceNames = null;

    Module module = deploymentUnit.getAttachment(MODULE);

    Class<?> paClass = null;
    try {
      paClass = (Class<?>) module.getClassLoader().loadClass(paClassName);
    } catch (ClassNotFoundException e) {
      throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'.");
    }

    ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class);

    if(annotation == null) {
      deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML };

    } else {
      deploymentDescriptorResourceNames = annotation.deploymentDescriptors();

    }
    return deploymentDescriptorResourceNames;
  }
 
Example #5
Source File: ProcessesXmlProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {

    final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit);
    final String paClassName = processApplicationComponent.getComponentClassName();

    String[] deploymentDescriptorResourceNames = null;

    Module module = deploymentUnit.getAttachment(MODULE);

    Class<?> paClass = null;
    try {
      paClass = (Class<?>) module.getClassLoader().loadClass(paClassName);
    } catch (ClassNotFoundException e) {
      throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'.");
    }

    ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class);

    if(annotation == null) {
      deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML };

    } else {
      deploymentDescriptorResourceNames = annotation.deploymentDescriptors();

    }
    return deploymentDescriptorResourceNames;
  }
 
Example #6
Source File: ProcessApplicationLogger.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public ServletException paWrongTypeException(Class<?> paClass) {
  return new ServletException(exceptionMessage(
      "014",
      "Class '{}' is annotated with @{} but is not a subclass of {}",
      paClass, ProcessApplication.class.getName(), AbstractProcessApplication.class.getName()));
}
 
Example #7
Source File: ServletProcessApplicationDeployer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
  if(c == null || c.isEmpty()) {
    // skip deployments that do not carry a PA
    return;

  }

  if (c.contains(ProcessApplication.class)) {
    // this is a workaround for a bug in WebSphere-8.5 who
    // ships the annotation itself as part of the discovered classes.

    // copy into a fresh Set as we don't know if the original Set is mutable or immutable.
    c = new HashSet<Class<?>>(c);

    // and now remove the annotation itself.
    c.remove(ProcessApplication.class);
  }


  String contextPath = ctx.getContextPath();
  if(c.size() > 1) {
    // a deployment must only contain a single PA
    throw LOG.multiplePasException(c, contextPath);

  } else if(c.size() == 1) {
    Class<?> paClass = c.iterator().next();

    // validate whether it is a legal Process Application
    if(!AbstractProcessApplication.class.isAssignableFrom(paClass)) {
      throw LOG.paWrongTypeException(paClass);
    }

    // add it as listener if it's a ServletProcessApplication
    if(ServletProcessApplication.class.isAssignableFrom(paClass)) {
      LOG.detectedPa(paClass);
      ctx.addListener(paClass.getName());
    }
  }
  else {
    LOG.servletDeployerNoPaFound(contextPath);
  }

}