Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-6553 Configuration Serialization #4274

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 13 additions & 16 deletions all/embedded/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -1,36 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<blueprint default-activation="eager"
<blueprint default-activation="eager"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<bean id="parser90" class="org.infinispan.configuration.parsing.Parser90"/>
<service ref="parser90" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>

<bean id="defaultMapReduceTaskLifecycle" class="org.infinispan.distexec.mapreduce.spi.DefaultMapReduceTaskLifecycle"/>
<service ref="defaultMapReduceTaskLifecycle" interface="org.infinispan.distexec.mapreduce.spi.MapReduceTaskLifecycle"/>
<bean id="parser" class="org.infinispan.configuration.parsing.Parser"/>
<service ref="parser" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>

<bean id="defaultDistributedTaskLifecycle" class="org.infinispan.distexec.spi.DefaultDistributedTaskLifecycle"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, surprised I didn't see this when I did a text serach :/

<service ref="defaultDistributedTaskLifecycle" interface="org.infinispan.distexec.spi.DistributedTaskLifecycle"/>

<bean id="jdbcStoreConfigurationParser90" class="org.infinispan.persistence.jdbc.configuration.JdbcStoreConfigurationParser90"/>
<service ref="jdbcStoreConfigurationParser90" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>
<bean id="jdbcStoreConfigurationParser" class="org.infinispan.persistence.jdbc.configuration.JdbcStoreConfigurationParser"/>
<service ref="jdbcStoreConfigurationParser" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>

<bean id="jpaStoreConfigurationParser90" class="org.infinispan.persistence.jpa.configuration.JpaStoreConfigurationParser90"/>
<service ref="jpaStoreConfigurationParser90" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>
<bean id="jpaStoreConfigurationParser" class="org.infinispan.persistence.jpa.configuration.JpaStoreConfigurationParser"/>
<service ref="jpaStoreConfigurationParser" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>
<bean id="jpaStoreLifecycleManager" class="org.infinispan.persistence.jpa.impl.JpaStoreLifecycleManager"/>
<service ref="jpaStoreLifecycleManager" interface="org.infinispan.lifecycle.ModuleLifecycle"/>

<bean id="levelDBStoreConfigurationParser90" class="org.infinispan.persistence.leveldb.configuration.LevelDBStoreConfigurationParser90"/>
<service ref="levelDBStoreConfigurationParser90" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>
<bean id="levelDBStoreConfigurationParser" class="org.infinispan.persistence.leveldb.configuration.LevelDBStoreConfigurationParser"/>
<service ref="levelDBStoreConfigurationParser" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>

<bean id="remoteStoreConfigurationParser90" class="org.infinispan.persistence.remote.configuration.RemoteStoreConfigurationParser90"/>
<service ref="remoteStoreConfigurationParser90" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>
<bean id="remoteStoreConfigurationParser" class="org.infinispan.persistence.remote.configuration.RemoteStoreConfigurationParser"/>
<service ref="remoteStoreConfigurationParser" interface="org.infinispan.configuration.parsing.ConfigurationParser"/>

<bean id="riverProviderDescriptor" class="org.jboss.marshalling.river.RiverProviderDescriptor"/>
<service ref="riverProviderDescriptor" interface="org.jboss.marshalling.ProviderDescriptor"/>

<bean id="serialProviderDescriptor" class="org.jboss.marshalling.serial.SerialProviderDescriptor"/>
<service ref="serialProviderDescriptor" interface="org.jboss.marshalling.ProviderDescriptor"/>

</blueprint>
Expand Up @@ -4,6 +4,7 @@

import java.util.Properties;

import org.infinispan.commons.configuration.attributes.Attribute;
import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeInitializer;
import org.infinispan.commons.configuration.attributes.AttributeSet;
Expand All @@ -22,20 +23,25 @@ public static AttributeSet attributeSet() {
};

protected AttributeSet attributes;
private final Attribute<TypedProperties> properties;

/**
* @deprecated use {@link AbstractTypedPropertiesConfiguration#AbstractTypedPropertiesConfiguration(AttributeSet)} instead
*/
@Deprecated
protected AbstractTypedPropertiesConfiguration(Properties properties) {
this.attributes = attributeSet();
this.attributes.attribute(PROPERTIES).set(immutableTypedProperties(TypedProperties.toTypedProperties(properties)));
this.attributes = attributes.protect();
this.properties = this.attributes.attribute(PROPERTIES);
this.attributes.attribute(PROPERTIES).set(immutableTypedProperties(TypedProperties.toTypedProperties(properties)));
}

protected AbstractTypedPropertiesConfiguration(AttributeSet attributes) {
this.attributes = attributes.checkProtection();
this.attributes.attribute(PROPERTIES).set(immutableTypedProperties(properties()));
this.properties = this.attributes.attribute(PROPERTIES);
if (properties.isModified()) {
properties.set(immutableTypedProperties(properties.get()));
}
}

@Override
Expand All @@ -44,7 +50,7 @@ public String toString() {
}

public TypedProperties properties() {
return this.attributes.attribute(PROPERTIES).get();
return properties.get();
}

@Override
Expand Down
Expand Up @@ -3,7 +3,11 @@
import java.util.ArrayList;
import java.util.List;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.infinispan.commons.CacheException;
import org.infinispan.commons.util.Util;

/**
* Attribute. This class implements a configuration attribute value holder. A configuration attribute is defined by an {@link AttributeDefinition}.
Expand Down Expand Up @@ -64,6 +68,10 @@ public boolean isImmutable() {
return definition.isImmutable();
}

public boolean isPersistent() {
return definition.isAutoPersist();
}

public boolean isModified() {
return modified;
}
Expand Down Expand Up @@ -189,4 +197,20 @@ public void reset() {
value = definition.getDefaultValue();
modified = false;
}

void write(XMLStreamWriter writer, String name) throws XMLStreamException {
if (modified && value != null) {
Class<?> klass = value.getClass();
if (klass == Class.class) {
writer.writeAttribute(name, ((Class) value).getName());
} else if (klass.isEnum()) {
writer.writeAttribute(name, ((Enum) value).name());
} else if (Util.isBasicType(klass)) {
writer.writeAttribute(name, value.toString());
} else {
writer.writeAttribute(name, klass.getName());
}
}
}

}
@@ -1,6 +1,7 @@
package org.infinispan.commons.configuration.attributes;

import org.infinispan.commons.CacheConfigurationException;
import org.infinispan.commons.util.Util;

/**
*
Expand All @@ -23,17 +24,21 @@
*/
public final class AttributeDefinition<T> {
private final String name;
private final String xmlName;
private final T defaultValue;
private boolean immutable;
private final boolean immutable;
private final boolean autoPersist;
private final AttributeCopier copier;
private final AttributeInitializer<? extends T> initializer;
private final AttributeValidator<? super T> validator;
private final Class<?> type;

AttributeDefinition(String name, T initialValue, Class<T> type, boolean immutable, AttributeCopier copier, AttributeValidator<? super T> validator, AttributeInitializer<? extends T> initializer) {
AttributeDefinition(String name, String xmlName, T initialValue, Class<T> type, boolean immutable, boolean autoPersist, AttributeCopier copier, AttributeValidator<? super T> validator, AttributeInitializer<? extends T> initializer) {
this.name = name;
this.xmlName = xmlName;
this.defaultValue = initialValue;
this.immutable = immutable;
this.autoPersist = autoPersist;
this.copier = copier;
this.initializer = initializer;
this.validator = validator;
Expand All @@ -44,6 +49,10 @@ public String name() {
return name;
}

public String xmlName() {
return xmlName;
}

@SuppressWarnings("unchecked")
public Class<T> getType() {
return (Class<T>) type;
Expand All @@ -57,6 +66,10 @@ public boolean isImmutable() {
return immutable;
}

public boolean isAutoPersist() {
return autoPersist;
}

public AttributeCopier copier() {
return copier;
}
Expand Down Expand Up @@ -98,6 +111,8 @@ public static final class Builder<T> {
private final Class<?> type;

private boolean immutable = false;
private boolean autoPersist = true;
private String xmlName;
private AttributeCopier copier = null;
private AttributeInitializer<? extends T> initializer;
private AttributeValidator<? super T> validator;
Expand All @@ -124,13 +139,23 @@ public Builder<T> initializer(AttributeInitializer<? extends T> initializer) {
return this;
}

public Builder<T> autoPersist(boolean autoPersist) {
this.autoPersist = autoPersist;
return this;
}

public Builder<T> validator(AttributeValidator<? super T> validator) {
this.validator = validator;
return this;
}

public Builder<T> xmlName(String xmlName) {
this.xmlName = xmlName;
return this;
}

public AttributeDefinition<T> build() {
return new AttributeDefinition(name, defaultValue, type, immutable, copier, validator, initializer);
return new AttributeDefinition(name, xmlName == null ? Util.xmlify(name) : xmlName, defaultValue, type, immutable, autoPersist, copier, validator, initializer);
}
}

Expand Down