001package org.cache2k.storage;
002
003/*
004 * #%L
005 * cache2k core package
006 * %%
007 * Copyright (C) 2000 - 2015 headissue GmbH, Munich
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as
011 * published by the Free Software Foundation, either version 3 of the 
012 * License, or (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU General Public 
020 * License along with this program.  If not, see
021 * <http://www.gnu.org/licenses/gpl-3.0.html>.
022 * #L%
023 */
024
025import java.io.Serializable;
026
027/**
028 * @author Jens Wilke; created: 2014-04-19
029 */
030public interface MarshallerFactory {
031
032  /**
033   * The type the marshaller is specialized for
034   */
035  Class<?> getType();
036
037  /**
038   * The higher the more specialized.
039   */
040  int getPriority();
041
042  /**
043   * Create a marshaller that is suitable for the type.
044   */
045  Marshaller createMarshaller(Class<?> _type);
046
047  /**
048   * Used to create a marshaller in a configuration that
049   * was used for marshalling. This way it is possible to
050   * add new marshallers to the system without being unable
051   * to read existing data.
052   */
053  Marshaller createMarshaller(Parameters c);
054
055  public static class Parameters implements Serializable {
056
057    private Class<?> payloadType;
058    private Class<?> marshallerFactory;
059    private Class<?> marshallerType;
060    private Object marshallerConfiguration;
061
062    public Parameters(Class<?> marshallerType) {
063      this.marshallerType = marshallerType;
064    }
065
066    public Class<?> getPayloadType() {
067      return payloadType;
068    }
069
070    public void setPayloadType(Class<?> payloadType) {
071      this.payloadType = payloadType;
072    }
073
074    public Class<?> getMarshallerFactory() {
075      return marshallerFactory;
076    }
077
078    public void setMarshallerFactory(Class<?> marshallerFactory) {
079      this.marshallerFactory = marshallerFactory;
080    }
081
082    public Object getMarshallerConfiguration() {
083      return marshallerConfiguration;
084    }
085
086    public void setMarshallerConfiguration(Object marshallerConfiguration) {
087      this.marshallerConfiguration = marshallerConfiguration;
088    }
089
090    public Class<?> getMarshallerType() {
091      return marshallerType;
092    }
093
094    public void setMarshallerType(Class<?> marshallerType) {
095      this.marshallerType = marshallerType;
096    }
097  }
098
099}