Java Code Examples for org.activiti.engine.impl.util.ReflectUtil#instantiate()

The following examples show how to use org.activiti.engine.impl.util.ReflectUtil#instantiate() . 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: WSDLImporterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportInheritedElement() throws Exception {
  URL url = ReflectUtil.getResource("org/activiti5/engine/impl/webservice/inherited-elements-in-types.wsdl");
  assertNotNull(url);
  importer.importFrom(url.toString());

  List<StructureDefinition> structures = sortStructures();
  assertEquals(1, structures.size());
      final Object structureTypeInst = ReflectUtil.instantiate("org.activiti.webservice.counter.StructureType");
  final Class structureType = structureTypeInst.getClass();
  this.assertStructure(structures.get(0), "inheritedRequest", new String[] { "rootElt", "inheritedElt", "newSimpleElt", 
      "newStructuredElt" }, new Class<?>[] { Short.class, Integer.class, String.class, structureType });
  assertEquals(2, structureType.getDeclaredFields().length);
  assertNotNull(structureType.getDeclaredField("booleanElt"));
  assertNotNull(structureType.getDeclaredField("dateElt"));
  assertEquals(1, structureType.getSuperclass().getDeclaredFields().length);
  assertNotNull(structureType.getSuperclass().getDeclaredField("rootElt"));
}
 
Example 2
Source File: WSDLImporterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportInheritedElement() throws Exception {
  URL url = ReflectUtil.getResource("org/activiti/engine/impl/webservice/inherited-elements-in-types.wsdl");
  assertNotNull(url);
  importer.importFrom(url.toString());

  List<StructureDefinition> structures = sortStructures();
  assertEquals(1, structures.size());
      final Object structureTypeInst = ReflectUtil.instantiate("org.activiti.webservice.counter.StructureType");
  final Class<? extends Object> structureType = structureTypeInst.getClass();
  this.assertStructure(structures.get(0), "inheritedRequest", new String[] { "rootElt", "inheritedElt", "newSimpleElt", 
      "newStructuredElt" }, new Class<?>[] { Short.class, Integer.class, String.class, structureType });
  assertEquals(2, structureType.getDeclaredFields().length);
  assertNotNull(structureType.getDeclaredField("booleanElt"));
  assertNotNull(structureType.getDeclaredField("dateElt"));
  assertEquals(1, structureType.getSuperclass().getDeclaredFields().length);
  assertNotNull(structureType.getSuperclass().getDeclaredField("rootElt"));
}
 
Example 3
Source File: WSService.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
SyncWebServiceClient getClient() {
  if (this.client == null) {
    // TODO refactor to use configuration
    SyncWebServiceClientFactory factory = (SyncWebServiceClientFactory) ReflectUtil.instantiate(ProcessEngineConfigurationImpl.DEFAULT_WS_SYNC_FACTORY);
    this.client = factory.create(this.wsdlLocation);
  }
  return this.client;
}
 
Example 4
Source File: WSService.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
SyncWebServiceClient getClient() {
    if (this.client == null) {
        // TODO refactor to use configuration
        SyncWebServiceClientFactory factory = (SyncWebServiceClientFactory) ReflectUtil.instantiate(ProcessEngineConfigurationImpl.DEFAULT_WS_SYNC_FACTORY);
        this.client = factory.create(this.wsdlLocation);
    }
    return this.client;
}
 
Example 5
Source File: DelegateActivitiEventListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected FlowableEventListener getDelegateInstance() {
    if (delegateInstance == null) {
        Object instance = ReflectUtil.instantiate(className);
        if (instance instanceof FlowableEventListener) {
            delegateInstance = (FlowableEventListener) instance;
        } else {
            // Force failing of the listener invocation, since the delegate cannot be created
            failOnException = true;
            throw new ActivitiIllegalArgumentException("Class " + className
                    + " does not implement " + FlowableEventListener.class.getName());
        }
    }
    return delegateInstance;
}
 
Example 6
Source File: ClassDelegate.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static Object defaultInstantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) {
  Object object = ReflectUtil.instantiate(className);
  applyFieldDeclaration(fieldDeclarations, object);
  return object;
}
 
Example 7
Source File: ClassDelegateUtil.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static Object instantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) {
  Object object = ReflectUtil.instantiate(className);
  applyFieldDeclaration(fieldDeclarations, object);
  return object;
}
 
Example 8
Source File: ClassDelegate.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static Object defaultInstantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) {
    Object object = ReflectUtil.instantiate(className);
    applyFieldDeclaration(fieldDeclarations, object);
    return object;
}
 
Example 9
Source File: ClassDelegateUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static Object instantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) {
    Object object = ReflectUtil.instantiate(className);
    applyFieldDeclaration(fieldDeclarations, object);
    return object;
}