protected void initJpa() { if (jpaPersistenceUnitName != null) { jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName); } if (jpaEntityManagerFactory != null) { sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager)); JPAVariableSerializer jpaType = (JPAVariableSerializer) variableSerializers.getSerializerByName(JPAVariableSerializer.NAME); // Add JPA-type if (jpaType == null) { // We try adding the variable right after byte serializer, if available int serializableIndex = variableSerializers.getSerializerIndexByName(ValueType.BYTES.getName()); if (serializableIndex > -1) { variableSerializers.addSerializer(new JPAVariableSerializer(), serializableIndex); } else { variableSerializers.addSerializer(new JPAVariableSerializer()); } } } }
public VariableSerializers join(VariableSerializers other) { DefaultVariableSerializers copy = new DefaultVariableSerializers(); // "other" serializers override existing ones if their names match for (TypedValueSerializer<?> thisSerializer : serializerList) { TypedValueSerializer<?> serializer = other.getSerializerByName(thisSerializer.getName()); if (serializer == null) { serializer = thisSerializer; } copy.addSerializer(serializer); } // add all "other" serializers that did not exist before to the end of the list for (TypedValueSerializer<?> otherSerializer : other.getSerializers()) { if (!copy.serializerMap.containsKey(otherSerializer.getName())) { copy.addSerializer(otherSerializer); } } return copy; }
public static VariableSerializers getSerializers() { if (Context.getCommandContext() != null) { VariableSerializers variableSerializers = Context.getProcessEngineConfiguration().getVariableSerializers(); VariableSerializers paSerializers = getCurrentPaSerializers(); if (paSerializers != null) { return variableSerializers.join(paSerializers); } else { return variableSerializers; } } else { throw LOG.serializerOutOfContextException(); } }
protected void registerSerializers(ProcessEngineConfigurationImpl processEngineConfiguration) { List<TypedValueSerializer<?>> spinDataFormatSerializers = lookupSpinSerializers(); VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); int javaObjectSerializerIdx = variableSerializers.getSerializerIndexByName(JavaObjectSerializer.NAME); for (TypedValueSerializer<?> spinSerializer : spinDataFormatSerializers) { // add before java object serializer variableSerializers.addSerializer(spinSerializer, javaObjectSerializerIdx); } }
protected void initSerialization() { if (variableSerializers == null) { variableSerializers = new DefaultVariableSerializers(); if (customPreVariableSerializers != null) { for (TypedValueSerializer<?> customVariableType : customPreVariableSerializers) { variableSerializers.addSerializer(customVariableType); } } // register built-in serializers variableSerializers.addSerializer(new NullValueSerializer()); variableSerializers.addSerializer(new StringValueSerializer()); variableSerializers.addSerializer(new BooleanValueSerializer()); variableSerializers.addSerializer(new ShortValueSerializer()); variableSerializers.addSerializer(new IntegerValueSerializer()); variableSerializers.addSerializer(new LongValueSerlializer()); variableSerializers.addSerializer(new DateValueSerializer()); variableSerializers.addSerializer(new DoubleValueSerializer()); variableSerializers.addSerializer(new ByteArrayValueSerializer()); variableSerializers.addSerializer(new JavaObjectSerializer()); variableSerializers.addSerializer(new FileValueSerializer()); if (customPostVariableSerializers != null) { for (TypedValueSerializer<?> customVariableType : customPostVariableSerializers) { variableSerializers.addSerializer(customVariableType); } } } }
/** * Checks, if Java serialization will be used and if it is allowed to be used. * @param variableName * @param value */ protected void checkJavaSerialization(String variableName, TypedValue value) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); if (value instanceof SerializableValue && !processEngineConfiguration.isJavaSerializationFormatEnabled()) { SerializableValue serializableValue = (SerializableValue) value; // if Java serialization is prohibited if (!serializableValue.isDeserialized()) { String javaSerializationDataFormat = Variables.SerializationDataFormats.JAVA.getName(); String requestedDataFormat = serializableValue.getSerializationDataFormat(); if (requestedDataFormat == null) { // check if Java serializer will be used final TypedValueSerializer serializerForValue = TypedValueField.getSerializers() .findSerializerForValue(serializableValue, processEngineConfiguration.getFallbackSerializerFactory()); if (serializerForValue != null) { requestedDataFormat = serializerForValue.getSerializationDataformat(); } } if (javaSerializationDataFormat.equals(requestedDataFormat)) { throw ProcessEngineLogger.CORE_LOGGER.javaSerializationProhibitedException(variableName); } } } }
protected void ensureSerializerInitialized() { if (serializerName != null && serializer == null) { serializer = getSerializers().getSerializerByName(serializerName); if (serializer == null) { serializer = getFallbackSerializer(serializerName); } if (serializer == null) { throw LOG.serializerNotDefinedException(this); } } }
protected void initSerialization() { if (variableSerializers == null) { variableSerializers = new DefaultVariableSerializers(); if (customPreVariableSerializers != null) { for (TypedValueSerializer<?> customVariableType : customPreVariableSerializers) { variableSerializers.addSerializer(customVariableType); } } // register built-in serializers variableSerializers.addSerializer(new NullValueSerializer()); variableSerializers.addSerializer(new StringValueSerializer()); variableSerializers.addSerializer(new BooleanValueSerializer()); variableSerializers.addSerializer(new ShortValueSerializer()); variableSerializers.addSerializer(new IntegerValueSerializer()); variableSerializers.addSerializer(new LongValueSerlializer()); variableSerializers.addSerializer(new DateValueSerializer()); variableSerializers.addSerializer(new DoubleValueSerializer()); variableSerializers.addSerializer(new ByteArrayValueSerializer()); variableSerializers.addSerializer(new JavaObjectSerializer()); variableSerializers.addSerializer(new FileValueSerializer()); if (customPostVariableSerializers != null) { for (TypedValueSerializer<?> customVariableType : customPostVariableSerializers) { variableSerializers.addSerializer(customVariableType); } } } }
protected void registerSerializers(ProcessEngineConfigurationImpl processEngineConfiguration) { List<TypedValueSerializer<?>> spinDataFormatSerializers = lookupSpinSerializers(); VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); int javaObjectSerializerIdx = variableSerializers.getSerializerIndexByName(JavaObjectSerializer.NAME); for (TypedValueSerializer<?> spinSerializer : spinDataFormatSerializers) { // add before java object serializer variableSerializers.addSerializer(spinSerializer, javaObjectSerializerIdx); } }
/** * Checks, if Java serialization will be used and if it is allowed to be used. * @param variableName * @param value */ protected void checkJavaSerialization(String variableName, TypedValue value) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); if (value instanceof SerializableValue && !processEngineConfiguration.isJavaSerializationFormatEnabled()) { SerializableValue serializableValue = (SerializableValue) value; // if Java serialization is prohibited if (!serializableValue.isDeserialized()) { String javaSerializationDataFormat = Variables.SerializationDataFormats.JAVA.getName(); String requestedDataFormat = serializableValue.getSerializationDataFormat(); if (requestedDataFormat == null) { // check if Java serializer will be used final TypedValueSerializer serializerForValue = TypedValueField.getSerializers() .findSerializerForValue(serializableValue, processEngineConfiguration.getFallbackSerializerFactory()); if (serializerForValue != null) { requestedDataFormat = serializerForValue.getSerializationDataformat(); } } if (javaSerializationDataFormat.equals(requestedDataFormat)) { throw ProcessEngineLogger.CORE_LOGGER.javaSerializationProhibitedException(variableName); } } } }
protected void ensureSerializerInitialized() { if (serializerName != null && serializer == null) { serializer = getSerializers().getSerializerByName(serializerName); if (serializer == null) { serializer = getFallbackSerializer(serializerName); } if (serializer == null) { throw LOG.serializerNotDefinedException(this); } } }
protected void initJpa() { if (jpaPersistenceUnitName != null) { jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName); } if (jpaEntityManagerFactory != null) { sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager)); JPAVariableSerializer jpaType = (JPAVariableSerializer) variableSerializers.getSerializerByName(JPAVariableSerializer.NAME); // Add JPA-type if (jpaType == null) { // We try adding the variable right after byte serializer, if available int serializableIndex = variableSerializers.getSerializerIndexByName(ValueType.BYTES.getName()); if (serializableIndex > -1) { variableSerializers.addSerializer(new JPAVariableSerializer(), serializableIndex); } else { variableSerializers.addSerializer(new JPAVariableSerializer()); } } } }
protected void initializeVariableSerializers(AbstractProcessApplication abstractProcessApplication) { VariableSerializers paVariableSerializers = abstractProcessApplication.getVariableSerializers(); if (paVariableSerializers == null) { paVariableSerializers = new DefaultVariableSerializers(); abstractProcessApplication.setVariableSerializers(paVariableSerializers); } for (TypedValueSerializer<?> serializer : lookupSpinSerializers(abstractProcessApplication.getProcessApplicationClassloader())) { paVariableSerializers.addSerializer(serializer); } }
public VariableSerializers join(VariableSerializers other) { DefaultVariableSerializers copy = new DefaultVariableSerializers(); // "other" serializers override existing ones if their names match for (TypedValueSerializer<?> thisSerializer : serializerList) { TypedValueSerializer<?> serializer = other.getSerializerByName(thisSerializer.getName()); if (serializer == null) { serializer = thisSerializer; } copy.addSerializer(serializer); } // add all "other" serializers that did not exist before to the end of the list for (TypedValueSerializer<?> otherSerializer : other.getSerializers()) { if (!copy.serializerMap.containsKey(otherSerializer.getName())) { copy.addSerializer(otherSerializer); } } return copy; }
protected TypedValueSerializer determineSerializer(VariableSerializers serializers, TypedValue value) { TypedValueSerializer serializer = serializers.findSerializerForValue(value); if(serializer.getType() == ValueType.BYTES){ throw new ProcessEngineException("Variables of type ByteArray cannot be used to query"); } else if(serializer.getType() == ValueType.FILE){ throw new ProcessEngineException("Variables of type File cannot be used to query"); } else if(serializer instanceof JPAVariableSerializer) { if(wrappedQueryValue.getOperator() != QueryOperator.EQUALS) { throw new ProcessEngineException("JPA entity variables can only be used in 'variableValueEquals'"); } } else { if(!serializer.getType().isPrimitiveValueType()) { throw new ProcessEngineException("Object values cannot be used to query"); } } return serializer; }
protected void ensureSerializerInitialized() { if (serializerName != null && serializer == null) { serializer = getSerializers().getSerializerByName(serializerName); if (serializer == null) { serializer = getFallbackSerializer(serializerName); } if (serializer == null) { throw LOG.serializerNotDefinedException(this); } } }
public static VariableSerializers getSerializers() { if (Context.getCommandContext() != null) { VariableSerializers variableSerializers = Context.getProcessEngineConfiguration().getVariableSerializers(); VariableSerializers paSerializers = getCurrentPaSerializers(); if (paSerializers != null) { return variableSerializers.join(paSerializers); } else { return variableSerializers; } } else { throw LOG.serializerOutOfContextException(); } }
protected void initJpa() { if (jpaPersistenceUnitName != null) { jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName); } if (jpaEntityManagerFactory != null) { sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager)); JPAVariableSerializer jpaType = (JPAVariableSerializer) variableSerializers.getSerializerByName(JPAVariableSerializer.NAME); // Add JPA-type if (jpaType == null) { // We try adding the variable right after byte serializer, if available int serializableIndex = variableSerializers.getSerializerIndexByName(ValueType.BYTES.getName()); if (serializableIndex > -1) { variableSerializers.addSerializer(new JPAVariableSerializer(), serializableIndex); } else { variableSerializers.addSerializer(new JPAVariableSerializer()); } } } }
@Before public void init() { runtimeService = engineRule.getRuntimeService(); taskService = engineRule.getTaskService(); ((ProcessEngineConfigurationImpl) engineRule.getProcessEngine().getProcessEngineConfiguration()) .getVariableSerializers() .addSerializer(new JavaCustomSerializer()); }
public VariableSerializers join(VariableSerializers other) { DefaultVariableSerializers copy = new DefaultVariableSerializers(); // "other" serializers override existing ones if their names match for (TypedValueSerializer<?> thisSerializer : serializerList) { TypedValueSerializer<?> serializer = other.getSerializerByName(thisSerializer.getName()); if (serializer == null) { serializer = thisSerializer; } copy.addSerializer(serializer); } // add all "other" serializers that did not exist before to the end of the list for (TypedValueSerializer<?> otherSerializer : other.getSerializers()) { if (!copy.serializerMap.containsKey(otherSerializer.getName())) { copy.addSerializer(otherSerializer); } } return copy; }