SpaceConfig.java

package org.microspace.space;

import java.util.regex.Pattern;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.microspace.specific.MicroSpaceAccessorGenerator;
import org.microspace.transport.specific.JGroupsTransportGenerator;

/**
 * Space configuration.
 * 
 * @author Gaspar Sinai - {@literal gaspar.sinai@microspace.org}
 * @version 2016-06-26
 */
public class SpaceConfig {
	
	private AccessorGenerator accessorGenerator;
	private ClusterTransportGenerator transportGenerator;
	// Serialize fields at lock operation so that an exception can be thrown before commit.
	private boolean serialized;
	private boolean fileBackup;
	private boolean clusterBackup;
	
	private boolean fileRecover;
	private String  backupFileName;
	private Pattern skipFileBackup;
	
	private String clusterName;
	private boolean syncCluster;
	private long clusterRecoveryTimeout;
	
	private boolean remoteSpace;
	
	public SpaceConfig () {
		accessorGenerator = new MicroSpaceAccessorGenerator();
		transportGenerator = new JGroupsTransportGenerator();
		serialized = false;
		backupFileName = "./microspace";
		fileRecover = false;
		skipFileBackup = Pattern.compile(".*NoSuchClass1|.*NoSuchClass2");
		// Wait 1 minutes 
		clusterBackup = false;
		clusterName = "Microspace";
		syncCluster = true;
		clusterRecoveryTimeout = Long.MAX_VALUE;
		remoteSpace = false;
	}

	public AccessorGenerator getAccessGenerator() {
		return accessorGenerator;
	}

	public AccessorGenerator getAccessorGenerator() {
		return accessorGenerator;
	}

	public void setAccessorGenerator(AccessorGenerator accessorGenerator) {
		this.accessorGenerator = accessorGenerator;
	}

	public ClusterTransportGenerator getClusterTransportGenerator() {
		return transportGenerator;
	}

	public void setClusterTransportGenerator(ClusterTransportGenerator transportGenerator) {
		this.transportGenerator = transportGenerator;
	}

	public boolean isSerialized() {
		return serialized;
	}

	public void setSerialized(boolean serialized) {
		this.serialized = serialized;
	}

	public boolean isFileBackup() {
		return fileBackup;
	}

	public void setFileBackup(boolean fileBackup) {
		this.fileBackup = fileBackup;
	}

	public boolean isClusterBackup() {
		return clusterBackup;
	}

	public void setClusterBackup(boolean clusterBackup) {
		this.clusterBackup = clusterBackup;
	}

	public String getBackupFileName() {
		return backupFileName;
	}

	public void setBackupFileName(String backupFileName) {
		this.backupFileName = backupFileName;
	}

	public boolean isFileRecover() {
		return fileRecover;
	}

	public void setFileRecover(boolean fileRecover) {
		this.fileRecover = fileRecover;
	}

	public Pattern getSkipFileBackup() {
		return skipFileBackup;
	}

	public void setSkipFileBackup(Pattern skipFileBackup) {
		this.skipFileBackup = skipFileBackup;
	}

	public String getClusterName() {
		return clusterName;
	}

	public void setClusterName(String clusterName) {
		this.clusterName = clusterName;
	}

    public boolean isSyncCluster() {
		return syncCluster;
	}

	public void setSyncCluster(boolean syncCluster) {
		this.syncCluster = syncCluster;
	}

	public long getClusterRecoveryTimeout() {
		return clusterRecoveryTimeout;
	}

	public void setClusterRecoveryTimeout(long clusterRecoveryTimeout) {
		this.clusterRecoveryTimeout = clusterRecoveryTimeout;
	}

	public boolean isRemoteSpace() {
		return remoteSpace;
	}

	public void setRemoteSpace(boolean remoteSpace) {
		this.remoteSpace = remoteSpace;
	}

	@Override
    public String toString() {
    	return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}