org.ow2.bonita.connector.core
Class Connector

java.lang.Object
  extended by org.ow2.bonita.connector.core.Connector
All Implemented Interfaces:
TxHook
Direct Known Subclasses:
MultiInstantiator, ProcessConnector

public abstract class Connector
extends java.lang.Object
implements TxHook

The abstract class Connector is the superclass of all classes that represent connectors.

Author:
Matthieu Chaffotte

Field Summary
 boolean validation
          Enables or not a validation before executing the connector.
 
Constructor Summary
Connector()
           
 
Method Summary
protected
<K,V> java.util.Map<K,java.lang.Object[]>
bonitaListToArrayMap(java.util.List<java.util.List<java.lang.Object>> array, java.lang.Class<K> key, java.lang.Class<V> value)
           
protected
<K,V> java.util.Map<K,V>
bonitaListToMap(java.util.List<java.util.List<java.lang.Object>> array, java.lang.Class<K> key, java.lang.Class<V> value)
           
protected static java.util.List<ConnectorError> checkGraphicalAnnotations(java.lang.Class<? extends Connector> c)
           
protected static java.util.List<ConnectorError> checkRuntimeAnnotations(java.lang.Class<? extends Connector> c)
           
 boolean containsErrors()
          Returns true if the Connector contains errors.
 void execute()
          Execute the content of the Connector.
 void execute(APIAccessor accessor, ActivityInstance activityInstance)
          Method of the interface to be implemented.
Put in all your required user-defined operations.
protected abstract  void executeConnector()
          Execute the specific content of the Connector.
static boolean fieldExists(java.lang.Class<? extends Connector> c, java.lang.String fieldName)
          Checks whether the given field name belongs to an existing connector field
protected static java.lang.reflect.Field getField(java.lang.Class<? extends Connector> c, java.lang.String fieldName)
          Returns the Field given by its Class and its name.
static java.lang.String getFieldName(java.lang.String methodName)
          Gives the field name from its method name.
static java.lang.String getGetterName(java.lang.String fieldName)
           
static java.lang.reflect.Type getGetterReturnType(java.lang.Class<? extends Connector> classConnector, java.lang.String outputName)
           
 java.util.List<Getter> getGetters()
          Obtains the getter list of the connector
static java.lang.reflect.Method getMethod(java.lang.Class<?> connectorClass, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
           
 java.util.List<Setter> getSetters()
          Obtains the setter list of the connector
protected static boolean isFieldExist(java.lang.Class<? extends Connector> c, java.lang.String fieldName)
          Checks if the field exists in this connector.
 java.util.List<ConnectorError> validate()
          Checks if all required fields are set.
static java.util.List<ConnectorError> validateConnector(java.lang.Class<? extends Connector> c)
          Checks whether the Connector is valid and well-formed.
protected abstract  java.util.List<ConnectorError> validateValues()
          Checks if field values are well-set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validation

public boolean validation
Enables or not a validation before executing the connector.

Constructor Detail

Connector

public Connector()
Method Detail

validateConnector

public static java.util.List<ConnectorError> validateConnector(java.lang.Class<? extends Connector> c)
Checks whether the Connector is valid and well-formed.

Parameters:
c - the Connector Class
Returns:
a list of errors if there is any errors; null otherwise

checkGraphicalAnnotations

protected static java.util.List<ConnectorError> checkGraphicalAnnotations(java.lang.Class<? extends Connector> c)

checkRuntimeAnnotations

protected static java.util.List<ConnectorError> checkRuntimeAnnotations(java.lang.Class<? extends Connector> c)

isFieldExist

protected static boolean isFieldExist(java.lang.Class<? extends Connector> c,
                                      java.lang.String fieldName)
Checks if the field exists in this connector.

Parameters:
c - the connector class
fieldName - the field name
Returns:
true if the field exist; false otherwise

fieldExists

public static boolean fieldExists(java.lang.Class<? extends Connector> c,
                                  java.lang.String fieldName)
Checks whether the given field name belongs to an existing connector field

Parameters:
c - the connector
fieldName - the field name
Returns:
true if the field is a connector one; false otherwise

getField

protected static java.lang.reflect.Field getField(java.lang.Class<? extends Connector> c,
                                                  java.lang.String fieldName)
Returns the Field given by its Class and its name.

Parameters:
c - the class of the wanted field
fieldName - the name of the wanted field
Returns:
the wanted Field

getFieldName

public static java.lang.String getFieldName(java.lang.String methodName)
Gives the field name from its method name.

Parameters:
methodName - the method name of the field
Returns:
the field name from its method name

getGetterName

public static java.lang.String getGetterName(java.lang.String fieldName)

execute

public final void execute()
                   throws java.lang.Exception
Execute the content of the Connector. If the connector contains error an IllegalStateException is thrown

Throws:
java.lang.Exception - if an exception occurs

executeConnector

protected abstract void executeConnector()
                                  throws java.lang.Exception
Execute the specific content of the Connector.

Throws:
java.lang.Exception - if an exception occurs

validateValues

protected abstract java.util.List<ConnectorError> validateValues()
Checks if field values are well-set.

Returns:
a list containing ConnectorError; an empty list otherwise

validate

public final java.util.List<ConnectorError> validate()
Checks if all required fields are set.

Returns:
a list containing ConnectorError; an empty list otherwise

containsErrors

public final boolean containsErrors()
Returns true if the Connector contains errors.

Returns:
true if the Connector contains errors; false otherwise

execute

public void execute(APIAccessor accessor,
                    ActivityInstance activityInstance)
             throws java.lang.Exception
Description copied from interface: TxHook
Method of the interface to be implemented.
Put in all your required user-defined operations.

Specified by:
execute in interface TxHook
Parameters:
accessor - The APIAccessor interface to access: RuntimeAPI, ManagementAPI, DefinitionAPI, CommandAPI.
activityInstance - the record of the current activity.
Throws:
java.lang.Exception - If an Exception has occurred.
See Also:
TxHook.execute(APIAccessor, ActivityInstance)

getSetters

public final java.util.List<Setter> getSetters()
Obtains the setter list of the connector

Returns:
the list of setters

getGetters

public final java.util.List<Getter> getGetters()
Obtains the getter list of the connector

Returns:
the list of getters

bonitaListToMap

protected <K,V> java.util.Map<K,V> bonitaListToMap(java.util.List<java.util.List<java.lang.Object>> array,
                                                   java.lang.Class<K> key,
                                                   java.lang.Class<V> value)

bonitaListToArrayMap

protected <K,V> java.util.Map<K,java.lang.Object[]> bonitaListToArrayMap(java.util.List<java.util.List<java.lang.Object>> array,
                                                                         java.lang.Class<K> key,
                                                                         java.lang.Class<V> value)

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class<?> connectorClass,
                                                 java.lang.String methodName,
                                                 java.lang.Class<?>[] paramTypes)

getGetterReturnType

public static java.lang.reflect.Type getGetterReturnType(java.lang.Class<? extends Connector> classConnector,
                                                         java.lang.String outputName)


Copyright © 2010 BonitaSoft. All Rights Reserved.