001/*
002 * flattr4j - A Java library for Flattr
003 *
004 * Copyright (C) 2011 Richard "Shred" Körber
005 *   http://flattr4j.shredzone.org
006 *
007 * This program is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License / GNU Lesser
009 * General Public License as published by the Free Software Foundation,
010 * either version 3 of the License, or (at your option) any later version.
011 *
012 * Licensed under the Apache License, Version 2.0 (the "License");
013 * you may not use this file except in compliance with the License.
014 *
015 * This program is distributed in the hope that it will be useful,
016 * but WITHOUT ANY WARRANTY; without even the implied warranty of
017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
018 */
019package org.shredzone.flattr4j.spring;
020
021import org.shredzone.flattr4j.FlattrService;
022import org.shredzone.flattr4j.oauth.AccessToken;
023import org.shredzone.flattr4j.oauth.FlattrAuthenticator;
024
025/**
026 * A service factory primarily made for Spring.
027 * <p>
028 * The factory implementation is preconfigured with the consumer key and consumer secret
029 * on constuction time, optionally also with a default access token. When the
030 * {@link FlattrServiceFactory} bean is injected, it is already properly configured and
031 * ready to use.
032 *
033 * @author Richard "Shred" Körber
034 */
035public interface FlattrServiceFactory {
036
037    /**
038     * Creates a new {@link FlattrService} instance, using a default access token. If no
039     * default access token is set, an exception will be thrown.
040     *
041     * @return {@link FlattrService} instance. Each invocation creates a new instance.
042     */
043    FlattrService getFlattrService();
044
045    /**
046     * Creates a new {@link FlattrService} instance.
047     *
048     * @param accessToken
049     *            {@link AccessToken} to be used by the {@link FlattrService}
050     * @return {@link FlattrService} instance. Each invocation creates a new instance.
051     */
052    FlattrService getFlattrService(AccessToken accessToken);
053
054    /**
055     * Creates a new {@link FlattrAuthenticator}.
056     *
057     * @return {@link FlattrAuthenticator} instance. Each invocation creates a new
058     *         instance.
059     */
060    FlattrAuthenticator getFlattrAuthenticator();
061
062}