| | |
| | | * @throws org.opends.server.types.InitializationException Exception while |
| | | * initializing the workflow element |
| | | */ |
| | | public WorkflowElement loadAndRegisterWorkflowElement(String workflowName) |
| | | public WorkflowElement<?> loadAndRegisterWorkflowElement(String workflowName) |
| | | throws ConfigException, InitializationException { |
| | | ServerManagementContext managementContext = |
| | | ServerManagementContext.getInstance(); |
| | |
| | | { |
| | | try |
| | | { |
| | | loadAndRegisterWorkflowElement(configuration); |
| | | WorkflowElement<?> we = loadAndRegisterWorkflowElement(configuration); |
| | | |
| | | // Notify observers who want to be notify when new workflow elements |
| | | // are created. |
| | | WorkflowElement.notifyStateUpdate(we); |
| | | } |
| | | catch (InitializationException de) |
| | | { |
| | |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // FIXME -- We should try to perform some check to determine whether the |
| | | // worklfow element is in use. |
| | | // workflow element is in use. |
| | | return true; |
| | | } |
| | | |
| | |
| | | ); |
| | | |
| | | |
| | | WorkflowElement workflowElement = |
| | | WorkflowElement<?> workflowElement = |
| | | DirectoryServer.getWorkflowElement( |
| | | configuration.getWorkflowElementId()); |
| | | if (workflowElement != null) |
| | | { |
| | | // Notify to observers that the workflow element is now disabled |
| | | ObservableWorkflowElementState observableState = |
| | | workflowElement.getObservableState(); |
| | | observableState.setWorkflowElementEnabled(false); |
| | | observableState.notifyObservers(); |
| | | |
| | | // Remove the workflow element |
| | | DirectoryServer.deregisterWorkflowElement(workflowElement); |
| | | workflowElement.finalizeWorkflowElement(); |
| | | } |
| | |
| | | |
| | | |
| | | // Get the existing workflow element if it's already enabled. |
| | | WorkflowElement existingWorkflowElement = |
| | | DirectoryServer.getWorkflowElement( |
| | | configuration.getWorkflowElementId()); |
| | | WorkflowElement<?> existingWorkflowElement = |
| | | DirectoryServer.getWorkflowElement(configuration.getWorkflowElementId()); |
| | | |
| | | // If the new configuration has the workflow element disabled, |
| | | // then disable it if it is enabled, or do nothing if it's already disabled. |
| | |
| | | { |
| | | if (existingWorkflowElement != null) |
| | | { |
| | | // Notify to observers that the workflow element is now disabled |
| | | ObservableWorkflowElementState observableState = |
| | | existingWorkflowElement.getObservableState(); |
| | | observableState.setWorkflowElementEnabled(false); |
| | | observableState.notifyObservers(); |
| | | |
| | | // Remove the workflow element |
| | | DirectoryServer.deregisterWorkflowElement(existingWorkflowElement); |
| | | existingWorkflowElement.finalizeWorkflowElement(); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | loadAndRegisterWorkflowElement(configuration); |
| | | WorkflowElement<?> we = loadAndRegisterWorkflowElement(configuration); |
| | | |
| | | // Notify observers who want to be notify when new workflow elements |
| | | // are created. |
| | | WorkflowElement.notifyStateUpdate(we); |
| | | } |
| | | catch (InitializationException de) |
| | | { |
| | |
| | | * ID of an existing workflow during workflow |
| | | * registration. |
| | | */ |
| | | WorkflowElement loadAndRegisterWorkflowElement( |
| | | WorkflowElement<?> loadAndRegisterWorkflowElement( |
| | | WorkflowElementCfg workflowElementCfg |
| | | ) throws InitializationException |
| | | { |
| | | // Load the workflow element class |
| | | String className = workflowElementCfg.getJavaClass(); |
| | | WorkflowElement workflowElement = |
| | | WorkflowElement<?> workflowElement = |
| | | loadWorkflowElement(className, workflowElementCfg, true); |
| | | |
| | | try |
| | |
| | | * @throws InitializationException If a problem occurred while attempting |
| | | * to initialize the workflow element. |
| | | */ |
| | | private WorkflowElement loadWorkflowElement( |
| | | private WorkflowElement<?> loadWorkflowElement( |
| | | String className, |
| | | WorkflowElementCfg configuration, |
| | | boolean initialize |
| | |
| | | { |
| | | WorkflowElementCfgDefn definition; |
| | | ClassPropertyDefinition propertyDefinition; |
| | | // I cannot use the parameterized type WorflowElement<?> |
| | | // because it would break the line WorkflowElement.class below. |
| | | // Use SuppressWarning because we know the cast is safe. |
| | | @SuppressWarnings("unchecked") |
| | | Class<? extends WorkflowElement> workflowElementClass; |
| | | WorkflowElement<? extends WorkflowElementCfg> workflowElement; |
| | | |
| | | definition = WorkflowElementCfgDefn.getInstance(); |
| | | propertyDefinition = |
| | | definition.getJavaClassPropertyDefinition(); |
| | | workflowElementClass = |
| | | propertyDefinition.loadClass(className, WorkflowElement.class); |
| | | workflowElement = |
| | | // Again, use SuppressWarning because we know the cast is safe |
| | | @SuppressWarnings("unchecked") |
| | | WorkflowElement<? extends WorkflowElementCfg> workflowElement = |
| | | (WorkflowElement<? extends WorkflowElementCfg>) |
| | | workflowElementClass.newInstance(); |
| | | |