Search in sources :

Example 1 with AbstractManagedConnectorInstance

use of com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance in project midpoint by Evolveum.

the class ConnectorManager method createConnectorInstance.

private ConnectorInstance createConnectorInstance(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException {
    ConnectorType connectorBean = getConnector(connectorSpec, result);
    ConnectorFactory connectorFactory = determineConnectorFactory(connectorBean);
    ConnectorInstance connectorInstance;
    try {
        InternalMonitor.recordCount(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT);
        connectorInstance = connectorFactory.createConnectorInstance(connectorBean, connectorSpec.getResource().getName().toString(), connectorSpec.toString());
        // FIXME temporary -- remove when no longer needed (MID-5931)
        if (connectorInstance instanceof AbstractManagedConnectorInstance) {
            ((AbstractManagedConnectorInstance) connectorInstance).setResourceOid(connectorSpec.getResource().getOid());
        }
    } catch (ObjectNotFoundException e) {
        result.recordFatalError(e.getMessage(), e);
        throw new ObjectNotFoundException(e.getMessage(), e);
    }
    // This log message should be INFO level. It happens only occasionally.
    // If it happens often, it may be an
    // indication of a problem. Therefore it is good for admin to see it.
    LOGGER.info("Created new connector instance for {}: {} v{}", connectorSpec, connectorBean.getConnectorType(), connectorBean.getConnectorVersion());
    return connectorInstance;
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) AbstractManagedConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance) AbstractManualConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManualConnectorInstance) ConnectorFactory(com.evolveum.midpoint.provisioning.ucf.api.ConnectorFactory) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) AbstractManagedConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance)

Example 2 with AbstractManagedConnectorInstance

use of com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance in project midpoint by Evolveum.

the class ConnectorFactoryBuiltinImpl method createConnectorInstance.

@Override
public ConnectorInstance createConnectorInstance(ConnectorType connectorType, String instanceName, String desc) throws ObjectNotFoundException {
    ConnectorStruct struct = getConnectorStruct(connectorType);
    Class<? extends ConnectorInstance> connectorClass = struct.connectorClass;
    ConnectorInstance connectorInstance;
    try {
        connectorInstance = connectorClass.getDeclaredConstructor().newInstance();
    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        throw new ObjectNotFoundException("Cannot create instance of connector " + connectorClass + ": " + e.getMessage(), e);
    }
    if (connectorInstance instanceof AbstractManagedConnectorInstance) {
        setupAbstractConnectorInstance((AbstractManagedConnectorInstance) connectorInstance, instanceName, connectorType, MidPointConstants.NS_RI, struct);
    }
    if (connectorInstance instanceof RepositoryAware) {
        ((RepositoryAware) connectorInstance).setRepositoryService(repositoryService);
    }
    if (connectorInstance instanceof CaseEventDispatcherAware) {
        ((CaseEventDispatcherAware) connectorInstance).setDispatcher(caseManager);
    }
    if (connectorInstance instanceof TaskManagerAware) {
        ((TaskManagerAware) connectorInstance).setTaskManager(taskManager);
    }
    if (connectorInstance instanceof SecurityContextManagerAware) {
        ((SecurityContextManagerAware) connectorInstance).setSecurityContextManager(securityContextManager);
    }
    if (connectorInstance instanceof UcfExpressionEvaluatorAware) {
        ((UcfExpressionEvaluatorAware) connectorInstance).setUcfExpressionEvaluator(ucfExpressionEvaluator);
    }
    if (connectorInstance instanceof TracerAware) {
        ((TracerAware) connectorInstance).setTracer(tracer);
    }
    if (connectorInstance instanceof RepositoryAware) {
        ((RepositoryAware) connectorInstance).setRepositoryService(repositoryService);
    }
    return connectorInstance;
}
Also used : CaseEventDispatcherAware(com.evolveum.midpoint.casemgmt.api.CaseEventDispatcherAware) AbstractManagedConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance) TaskManagerAware(com.evolveum.midpoint.task.api.TaskManagerAware) InvocationTargetException(java.lang.reflect.InvocationTargetException) AbstractManagedConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance) SecurityContextManagerAware(com.evolveum.midpoint.security.api.SecurityContextManagerAware) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) RepositoryAware(com.evolveum.midpoint.repo.api.RepositoryAware)

Aggregations

AbstractManagedConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 CaseEventDispatcherAware (com.evolveum.midpoint.casemgmt.api.CaseEventDispatcherAware)1 ConnectorFactory (com.evolveum.midpoint.provisioning.ucf.api.ConnectorFactory)1 ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)1 AbstractManualConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManualConnectorInstance)1 RepositoryAware (com.evolveum.midpoint.repo.api.RepositoryAware)1 SecurityContextManagerAware (com.evolveum.midpoint.security.api.SecurityContextManagerAware)1 TaskManagerAware (com.evolveum.midpoint.task.api.TaskManagerAware)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1