Example usage for org.springframework.util ClassUtils isPrimitiveOrWrapper

List of usage examples for org.springframework.util ClassUtils isPrimitiveOrWrapper

Introduction

In this page you can find the example usage for org.springframework.util ClassUtils isPrimitiveOrWrapper.

Prototype

public static boolean isPrimitiveOrWrapper(Class<?> clazz) 

Source Link

Document

Check if the given class represents a primitive (i.e.

Usage

From source file:com.evolveum.midpoint.prism.util.CloneUtil.java

public static <T> T clone(T orig) {
    if (orig == null) {
        return null;
    }// w  w  w . java 2 s .  c o m
    Class<? extends Object> origClass = orig.getClass();
    if (ClassUtils.isPrimitiveOrWrapper(origClass)) {
        return orig;
    }
    if (origClass.isArray()) {
        return cloneArray(orig);
    }
    if (orig instanceof PolyString) {
        // PolyString is immutable
        return orig;
    }
    if (orig instanceof String) {
        // ...and so is String
        return orig;
    }
    if (orig instanceof QName) {
        // the same here
        return orig;
    }
    if (origClass.isEnum()) {
        return orig;
    }
    //        if (orig.getClass().equals(QName.class)) {
    //            QName origQN = (QName) orig;
    //            return (T) new QName(origQN.getNamespaceURI(), origQN.getLocalPart(), origQN.getPrefix());
    //        }
    if (orig instanceof RawType) {
        return (T) ((RawType) orig).clone();
    }
    if (orig instanceof Item<?, ?>) {
        return (T) ((Item<?, ?>) orig).clone();
    }
    if (orig instanceof PrismValue) {
        return (T) ((PrismValue) orig).clone();
    }
    if (orig instanceof ObjectDelta<?>) {
        return (T) ((ObjectDelta<?>) orig).clone();
    }
    if (orig instanceof ObjectDeltaType) {
        return (T) ((ObjectDeltaType) orig).clone();
    }
    if (orig instanceof ItemDelta<?, ?>) {
        return (T) ((ItemDelta<?, ?>) orig).clone();
    }
    if (orig instanceof Definition) {
        return (T) ((Definition) orig).clone();
    }
    /*
     * In some environments we cannot clone XMLGregorianCalendar because of this:
     * Error when cloning class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl, will try serialization instead.
       * java.lang.IllegalAccessException: Class com.evolveum.midpoint.prism.util.CloneUtil can not access a member of
       * class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl with modifiers "public"
     */
    if (orig instanceof XMLGregorianCalendar) {
        return (T) XmlTypeConverter.createXMLGregorianCalendar((XMLGregorianCalendar) orig);
    }
    if (orig instanceof Cloneable) {
        T clone = javaLangClone(orig);
        if (clone != null) {
            return clone;
        }
    }
    if (orig instanceof Serializable) {
        // Brute force
        if (PERFORMANCE_ADVISOR.isDebugEnabled()) {
            PERFORMANCE_ADVISOR.debug("Cloning a Serializable ({}). It could harm performance.",
                    orig.getClass());
        }
        return (T) SerializationUtils.clone((Serializable) orig);
    }
    throw new IllegalArgumentException("Cannot clone " + orig + " (" + origClass + ")");
}

From source file:com.music.util.cache.CacheKeyGenerator.java

@Override
public Object generate(Object target, Method method, Object... params) {
    StringBuilder key = new StringBuilder();
    key.append(target.getClass().getSimpleName()).append(".").append(method.getName()).append(":");

    if (params.length == 0) {
        key.append(NO_PARAM_KEY).toString();
    }//from  w  ww.j  av a 2 s  . c  om

    for (Object param : params) {
        if (param == null) {
            key.append(NULL_PARAM_KEY);
        } else if (ClassUtils.isPrimitiveOrWrapper(param.getClass()) || param instanceof String) {
            key.append(param);
        } else if (param instanceof CacheKey) {
            key.append(((CacheKey) param).getCacheKey());
        } else {
            logger.warn("Using object " + param
                    + " as cache key. Either use key='..' or implement CacheKey. Method is " + target.getClass()
                    + "#" + method.getName());
            key.append(param.hashCode());
        }
    }

    return key.toString();
}

From source file:com.laxser.blitz.web.instruction.InstructionExecutorImpl.java

/**
 * @param inv//from   w  w  w. j  a  v a2  s . c  o m
 * @param instruction
 * @return
 * @throws StackOverflowError
 */
private Instruction translatesToInstructionObject(InvocationBean inv, Object instruction)
        throws StackOverflowError {
    int count = 0;
    while (!(instruction instanceof Instruction)) {
        if (count++ > 50) {
            throw new StackOverflowError("Unable to parse the instruction to an"
                    + " Instruction object less than " + count + " times. Is the instruction"
                    + " that returned by your controller" + " action is right?");
        }

        if (Thread.interrupted() || instruction == null) {
            return null;
        } else {
            if (instruction.getClass() != String.class
                    && !ClassUtils.isPrimitiveOrWrapper(instruction.getClass())
                    && instruction.getClass().getComponentType() == null
                    && instruction.getClass().getAnnotation(Component.class) != null) {
                SpringUtils.autowire(instruction, inv.getApplicationContext());
            }
            instruction = parseInstruction(inv, instruction);
        }
    }
    return (Instruction) instruction;
}

From source file:com.iflytek.edu.cloud.frame.spring.RequestResponseBodyMethodProcessorExt.java

@Override
protected <T> void writeWithMessageConverters(T returnValue, MethodParameter returnType,
        ServletServerHttpRequest inputMessage, ServletServerHttpResponse outputMessage)
        throws IOException, HttpMediaTypeNotAcceptableException {
    Class<?> returnValueClass = returnValue.getClass();
    HttpServletRequest servletRequest = inputMessage.getServletRequest();
    String format = servletRequest.getParameter(Constants.SYS_PARAM_KEY_FORMAT);

    MediaType contentType = MEDIA_TYPE_XML;

    if (Constants.DATA_FORMAT_JSON.equals(format))
        contentType = MEDIA_TYPE_JSON;//ww  w  .  j  ava  2s .c o m
    ;

    if (ClassUtils.isPrimitiveOrWrapper(returnValueClass)) {
        if (Constants.DATA_FORMAT_JSON.equals(format)) {
            String result = "{\"return\":\"" + returnValue + "\"}";
            write(result, contentType, outputMessage);
        } else {
            String result = "<return>" + returnValue + "</return>";
            write(result, contentType, outputMessage);
        }

    } else {

        for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
            if (messageConverter.canWrite(returnValueClass, contentType)) {
                ((HttpMessageConverter<T>) messageConverter).write(returnValue, contentType, outputMessage);
                if (logger.isDebugEnabled()) {
                    logger.debug("Written [" + returnValue + "] as \"" + contentType + "\" using ["
                            + messageConverter + "]");
                }
                return;
            }
        }
    }
}

From source file:com.sinosoft.one.mvc.web.instruction.InstructionExecutorImpl.java

protected Object parseInstruction(Invocation inv, Object ins) {
    if (ClassUtils.isPrimitiveOrWrapper(ins.getClass())) {
        return Text.text(ins);
    } else if (ins instanceof CharSequence) {
        String str = ins.toString();
        if (str.length() == 0 || str.equals("@")) {
            return null;
        }/* w ww . j  a v a  2  s . com*/
        if (str.charAt(0) == '@') {
            return Text.text(str.substring(1)); // content-type?@HttpFeatures
        }
        if (str.charAt(0) == '/') {
            return new ViewInstruction(str);
        }
        if (str.startsWith("r:") || str.startsWith("redirect:")) {
            StringInstruction si = new StringInstruction(false, str.substring(str.indexOf(':') + 1));
            if (si.innerInstruction.startsWith("http://") || si.innerInstruction.startsWith("https://")) {
                return Redirect.location(si.innerInstruction);
            }
            return si;
        }
        if (str.startsWith("pr:") || str.startsWith("perm-redirect:")) {
            StringInstruction si = new StringInstruction(false, str.substring(str.indexOf(':') + 1));
            si.permanentlyWhenRedirect = true;
            if (si.innerInstruction.startsWith("http://") || si.innerInstruction.startsWith("https://")) {
                return si.permanentlyIfNecessary(Redirect.location(si.innerInstruction));
            }
            return si;
        }
        if (str.startsWith("f:") || str.startsWith("forward:")) {
            return new StringInstruction(true, str.substring(str.indexOf(':') + 1));
        }
        if (str.startsWith("e:") || str.startsWith("error:")) {
            int begin = str.indexOf(':') + 1;
            int codeEnd = str.indexOf(';');
            if (codeEnd == -1) {
                String text = str.substring(begin);
                if (text.length() > 0 && NumberUtils.isNumber(text)) {
                    return HttpError.code(Integer.parseInt(text));
                }
                return HttpError.code(500, text);
            } else {
                return HttpError.code(Integer.parseInt(str.substring(begin, codeEnd)),
                        str.substring(codeEnd + 1).trim());
            }
        }
        if (str.startsWith("s:") || str.startsWith("status:")) {
            int begin = str.indexOf(':') + 1;
            int codeEnd = str.indexOf(';', begin);
            if (codeEnd == -1) {
                inv.getResponse().setStatus(Integer.parseInt(str.substring(begin)));
                return null;
            } else {
                // setStatus(int, String)???';'??msg
                // sendError?
                inv.getResponse().setStatus(Integer.parseInt(str.substring(begin, codeEnd)));
                for (int i = codeEnd; i < str.length(); i++) {
                    if (str.charAt(i) != ' ') {
                        str = str.substring(i + 1);
                        break;
                    }
                }
            }
        }
        if (str.equals(":continue")) {
            return null;
        }
        return new StringInstruction(null, str);
    } else if (ins.getClass() == StringInstruction.class) {
        StringInstruction fr = (StringInstruction) ins;
        String str = fr.innerInstruction;
        int queryIndex = str.indexOf('?');
        for (int i = (queryIndex == -1) ? str.length() - 1 : queryIndex - 1; i >= 0; i--) {
            if (str.charAt(i) != ':') {
                continue;
            }
            if (i > 0 && str.charAt(i - 1) == '\\') { // ?
                str = str.substring(0, i - 1) + str.substring(i);
                i--;
                continue;
            }
            int cmdEnd = i;
            int cmdBeforeBegin = i - 1;
            while (cmdBeforeBegin >= 0 && str.charAt(cmdBeforeBegin) != ':') {
                cmdBeforeBegin--;
            }
            String prefix = str.subSequence(cmdBeforeBegin + 1, cmdEnd).toString();
            String body = str.subSequence(i + 1, str.length()).toString();
            if ("a".equals(prefix) || "action".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.action(body));
                } else {
                    return Forward.action(body);
                }
            }
            if ("c".equals(prefix) || "controller".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.controller(body));
                } else {
                    return Forward.controller(body);
                }
            }
            if ("m".equals(prefix) || "module".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.module(body));
                } else {
                    return Forward.module(body);
                }
            }
            logger.warn("skip the prefix '" + prefix + ":' of " + str);
            if (fr.isReirect()) {
                return fr.permanentlyIfNecessary(Redirect.location(str));
            } else if (fr.isForward()) {
                return Forward.path(str);
            } else {
                return new ViewInstruction(str);
            }
        }
        if (fr.isReirect()) {
            return fr.permanentlyIfNecessary(Redirect.location(str));
        } else if (fr.isForward()) {
            return Forward.path(str);
        }
        return new ViewInstruction(str);
    } else if (ins instanceof InputStream) {
        return new InputStreamInstruction((InputStream) ins);
    } else if (ins instanceof byte[]) {
        return new InputStreamInstruction(new ByteArrayInputStream((byte[]) ins));
    } else if (ins instanceof Reply) {
        return new ReplyInstruction((Reply) ins);
    } else {
        return Text.text(ins.toString());
    }
}

From source file:com.laxser.blitz.web.instruction.InstructionExecutorImpl.java

protected Object parseInstruction(Invocation inv, Object ins) {
    if (logger.isDebugEnabled()) {
        logger.debug("parset instruction:" + ins.getClass().getName() + ": '" + ins + "'");
    }/*from w  ww .  j  av  a2s. c  om*/
    if (ClassUtils.isPrimitiveOrWrapper(ins.getClass())) {
        return Text.text(ins);
    } else if (ins instanceof CharSequence) {
        String str = ins.toString();
        if (str.length() == 0 || str.equals("@")) {
            return null;
        }
        if (str.charAt(0) == '@') {
            return Text.text(str.substring(1)); // content-type?@HttpFeatures
        }
        if (str.charAt(0) == '/') {
            return new ViewInstruction(str);
        }
        if (str.startsWith("r:") || str.startsWith("redirect:")) {
            StringInstruction si = new StringInstruction(false, str.substring(str.indexOf(':') + 1));
            if (si.innerInstruction.startsWith("http://") || si.innerInstruction.startsWith("https://")) {
                return Redirect.location(si.innerInstruction);
            }
            return si;
        }
        if (str.startsWith("pr:") || str.startsWith("perm-redirect:")) {
            StringInstruction si = new StringInstruction(false, str.substring(str.indexOf(':') + 1));
            si.permanentlyWhenRedirect = true;
            if (si.innerInstruction.startsWith("http://") || si.innerInstruction.startsWith("https://")) {
                return si.permanentlyIfNecessary(Redirect.location(si.innerInstruction));
            }
            return si;
        }
        if (str.startsWith("f:") || str.startsWith("forward:")) {
            return new StringInstruction(true, str.substring(str.indexOf(':') + 1));
        }
        if (str.startsWith("e:") || str.startsWith("error:")) {
            int begin = str.indexOf(':') + 1;
            int codeEnd = str.indexOf(';');
            if (codeEnd == -1) {
                String text = str.substring(begin);
                if (text.length() > 0 && NumberUtils.isNumber(text)) {
                    return HttpError.code(Integer.parseInt(text));
                }
                return HttpError.code(500, text);
            } else {
                return HttpError.code(Integer.parseInt(str.substring(begin, codeEnd)),
                        str.substring(codeEnd + 1).trim());
            }
        }
        if (str.startsWith("s:") || str.startsWith("status:")) {
            int begin = str.indexOf(':') + 1;
            int codeEnd = str.indexOf(';', begin);
            if (codeEnd == -1) {
                inv.getResponse().setStatus(Integer.parseInt(str.substring(begin)));
                return null;
            } else {
                // setStatus(int, String)???';'??msg
                // sendError?
                inv.getResponse().setStatus(Integer.parseInt(str.substring(begin, codeEnd)));
                for (int i = codeEnd; i < str.length(); i++) {
                    if (str.charAt(i) != ' ') {
                        str = str.substring(i + 1);
                        break;
                    }
                }
            }
        }
        if (str.equals(":continue")) {
            return null;
        }
        return new StringInstruction(null, str);
    } else if (ins.getClass() == StringInstruction.class) {
        StringInstruction fr = (StringInstruction) ins;
        String str = fr.innerInstruction;
        int queryIndex = str.indexOf('?');
        for (int i = (queryIndex == -1) ? str.length() - 1 : queryIndex - 1; i >= 0; i--) {
            if (str.charAt(i) != ':') {
                continue;
            }
            if (i > 0 && str.charAt(i - 1) == '\\') { // ?
                str = str.substring(0, i - 1) + str.substring(i);
                i--;
                continue;
            }
            int cmdEnd = i;
            int cmdBeforeBegin = i - 1;
            while (cmdBeforeBegin >= 0 && str.charAt(cmdBeforeBegin) != ':') {
                cmdBeforeBegin--;
            }
            String prefix = str.subSequence(cmdBeforeBegin + 1, cmdEnd).toString();
            String body = str.subSequence(i + 1, str.length()).toString();
            if ("a".equals(prefix) || "action".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.action(body));
                } else {
                    return Forward.action(body);
                }
            }
            if ("c".equals(prefix) || "controller".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.controller(body));
                } else {
                    return Forward.controller(body);
                }
            }
            if ("m".equals(prefix) || "module".equals(prefix)) {
                if (fr.isReirect()) {
                    return fr.permanentlyIfNecessary(Redirect.module(body));
                } else {
                    return Forward.module(body);
                }
            }
            logger.warn("skip the prefix '" + prefix + ":' of " + str);
            if (fr.isReirect()) {
                return fr.permanentlyIfNecessary(Redirect.location(str));
            } else if (fr.isForward()) {
                return Forward.path(str);
            } else {
                return new ViewInstruction(str);
            }
        }
        if (fr.isReirect()) {
            return fr.permanentlyIfNecessary(Redirect.location(str));
        } else if (fr.isForward()) {
            return Forward.path(str);
        }
        return new ViewInstruction(str);
    } else if (ins instanceof InputStream) {
        return new InputStreamInstruction((InputStream) ins);
    } else if (ins instanceof byte[]) {
        return new InputStreamInstruction(new ByteArrayInputStream((byte[]) ins));
    } else {
        return Text.text(ins.toString());
    }
}

From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java

public static <T> T recurseReflect(final T obj, final DoInReflectionCallback callback) {
    if (obj == null) {
        return null;
    }//from   ww  w  .  j  a va  2  s.c  o m
    ReflectionUtils.doWithFields(obj.getClass(), new FieldCallback() {

        public void doWith(Field arg0) throws IllegalArgumentException, IllegalAccessException {

            if (!ClassUtils.isPrimitiveOrWrapper(arg0.getType()) && !ClassUtils.isPrimitiveArray(arg0.getType())
                    && !ClassUtils.isPrimitiveWrapperArray(arg0.getType()) && !arg0.getType().isEnum()
                    && (isLexBigClass(arg0.getType()) || Collection.class.isAssignableFrom(arg0.getType())
                            || Map.class.isAssignableFrom(arg0.getType()))) {

                arg0.setAccessible(true);
                Object recurse = arg0.get(obj);

                if (recurse != null) {

                    if (CycleDetectingCallback.class.isAssignableFrom(recurse.getClass())) {
                        System.out.println("ere");
                    }

                    if (Collection.class.isAssignableFrom(recurse.getClass())) {
                        Collection collection = (Collection) recurse;
                        for (Object o : collection) {
                            if (callback.actionRequired(o)) {
                                collection.remove(o);
                                collection.add(recurseReflect(o, callback));
                            } else {
                                recurseReflect(o, callback);
                            }
                        }
                    } else if (Map.class.isAssignableFrom(recurse.getClass())) {
                        Map map = (Map) recurse;
                        for (Object key : map.keySet()) {
                            Object value = map.get(key);
                            if (callback.actionRequired(key) || callback.actionRequired(value)) {
                                map.remove(key);
                                map.put(recurseReflect(key, callback), recurseReflect(value, callback));
                            } else {
                                recurseReflect(key, callback);
                                recurseReflect(value, callback);
                            }
                        }
                    } else {
                        if (callback.actionRequired(recurse)) {
                            Object newObject = recurseReflect(recurse, callback);
                            arg0.set(obj, newObject);
                        } else {
                            recurseReflect(recurse, callback);
                        }
                    }
                }
            }
        }
    });

    return callback.doInReflection(obj);
}

From source file:com.laxser.blitz.web.paramresolver.ParameterNameDiscovererImpl.java

protected String getParameterRawName(Class<?> clz) {
    if (ClassUtils.isPrimitiveOrWrapper(clz) //
            || clz == String.class // 
            || Map.class.isAssignableFrom(clz) //
            || Collection.class.isAssignableFrom(clz) //
            || clz.isArray() //
            || clz == MultipartFile.class) {
        return null;
    }//  www. j  a va 2 s . c o  m
    if (clz == MultipartFile.class) {
        return null;
    }
    return ClassUtils.getShortNameAsProperty(clz);
}

From source file:com.ebay.jetstream.management.HtmlResourceFormatter.java

protected void formatProperty(Object bean, PropertyDescriptor pd) throws Exception {
    PrintWriter pw = getWriter();
    Method getter = pd.getReadMethod();
    Class<?> pclass = pd.getPropertyType();
    ManagedAttribute attr = getter.getAnnotation(ManagedAttribute.class);
    String text = attr != null ? attr.description() : null;
    if (CommonUtils.isEmptyTrimmed(text)) {
        text = pd.getDisplayName();//from  w w  w . j a v  a2 s.co  m
    } else {
        text = pd.getDisplayName() + " (" + text + ")";
    }
    pw.print(text + ": " + pclass.getName() + " = ");
    getter.setAccessible(true);
    Object value = getter.invoke(bean);
    Method setter = pd.getWriteMethod();
    attr = setter == null ? null : setter.getAnnotation(ManagedAttribute.class);
    boolean isComplex = !(String.class.isAssignableFrom(pclass) || ClassUtils.isPrimitiveOrWrapper(pclass));
    if (isComplex) {
        value = StringEscapeUtils.escapeXml(getSerializer().getXMLStringRepresentation(value));
    }
    if (attr == null) {
        if (isComplex) {
            pushElement("code", null);
        }
        pw.println(value);
        if (isComplex) {
            popElement();
        }
    } else {
        pw.println(attr.description());
        pushElement("form",
                "action=" + makePath(getPrefix(), getPath(), isComplex ? "?form" : "?" + pd.getName())
                        + " method=" + (isComplex ? "POST" : "GET"));
        if (isComplex) {
            pw.print("<TEXTAREA name=" + pd.getName() + " rows=4 cols=32>" + value + "</TEXTAREA>");
        } else {
            pw.print("<input type=text name=" + pd.getName() + " value=\"" + value + "\"/>");
        }
        pw.println("<input type=submit Value=\"Go\"/>");
        popElement();
    }
    pw.println("<P/>");
}

From source file:org.arrow.data.neo4j.store.impl.ProcessInstanceStoreImpl.java

/**
 * {@inheritDoc}/*from  www  .  jav  a 2  s .  co  m*/
 */
private ProcessInstance store(BpmnNodeEntitySpecification event, Map<String, Object> map, SubProcessEntity sub,
        ProcessInstance parentPi) {

    GraphDatabaseAPI api = (GraphDatabaseAPI) template.getGraphDatabaseService();
    Transaction transaction = api.tx().unforced().begin();
    try {

        Node eventNode = template.getPersistentState(event);

        Assert.notNull(eventNode, "start event must not be null");
        Assert.notNull(map, "variables map must not be null");

        final Node node = getProcessInstance();

        Node processNode;
        if (sub instanceof CallActivityTask || sub == null) {

            if (sub != null) {
                Node processTrigger = template.getPersistentState(sub);
                node.createRelationshipTo(processTrigger, DynamicRelationshipType.withName("PROCESS_TRIGGER"));
            }

            Iterable<Relationship> relationships;

            if (event instanceof ReceiveTask) {
                MessageEventDefinition definition = ((ReceiveTask) event).getMessageEventDefinition();
                Node source = template.getPersistentState(definition);

                relationships = source.getRelationships(Direction.OUTGOING,
                        DynamicRelationshipType.withName("PROCESS"));
            } else {
                relationships = eventNode.getRelationships(Direction.OUTGOING,
                        DynamicRelationshipType.withName("PROCESS_OF_STARTEVENT"));
            }

            processNode = relationships.iterator().next().getEndNode();
        } else {
            processNode = template.getPersistentState(sub);
        }

        transaction.acquireWriteLock(processNode);

        for (String key : map.keySet()) {
            Object value = map.get(key);
            Class<?> cls = value.getClass();

            if (cls.isArray() || ClassUtils.isPrimitiveOrWrapper(cls)) {
                node.setProperty("variables-" + key, value);
            } else if (conversionService.canConvert(cls, String.class)) {
                value = conversionService.convert(value, String.class);
                node.setProperty("variables-" + key, value);
                node.setProperty("variables-" + key + "-type", cls.getName());
            } else {
                node.setProperty("variables-" + key, toXml(value));
                node.setProperty("variables-" + key + "-type", cls.getName());
            }
        }

        if (parentPi != null) {
            Node parentPiNode = template.getPersistentState(parentPi);
            node.createRelationshipTo(parentPiNode,
                    DynamicRelationshipType.withName("PARENT_PROCESS_INSTANCE"));
        }

        node.setProperty("key", processNode.getProperty("id"));
        node.createRelationshipTo(processNode, DynamicRelationshipType.withName("PROCESS"));

        transaction.success();
        return executionService.data().processInstance().findOne(node.getId());
    } catch (Throwable throwable) {
        transaction.failure();
        throw new RuntimeException(throwable);
    } finally {
        transaction.close();
    }

}