mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-23 07:52:13 +01:00
added decorator api for repository manager
This commit is contained in:
40
scm-core/src/main/java/sonia/scm/Decorator.java
Normal file
40
scm-core/src/main/java/sonia/scm/Decorator.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||
* nor the names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
/**
|
||||
* Marker interface for all decorator classes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
public interface Decorator {}
|
||||
240
scm-core/src/main/java/sonia/scm/ManagerDecorator.java
Normal file
240
scm-core/src/main/java/sonia/scm/ManagerDecorator.java
Normal file
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||
* nor the names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Basic decorator for manager classes
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
public class ManagerDecorator<T extends ModelObject, E extends Exception>
|
||||
implements Manager<T, E>, Decorator
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param decorated
|
||||
*/
|
||||
public ManagerDecorator(Manager<T, E> decorated)
|
||||
{
|
||||
this.decorated = decorated;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
decorated.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
*
|
||||
* @throws E
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void create(T object) throws E, IOException
|
||||
{
|
||||
decorated.create(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
*
|
||||
* @throws E
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void delete(T object) throws E, IOException
|
||||
{
|
||||
decorated.delete(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void init(SCMContextProvider context)
|
||||
{
|
||||
decorated.init(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
*
|
||||
* @throws E
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void modify(T object) throws E, IOException
|
||||
{
|
||||
decorated.modify(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
*
|
||||
* @throws E
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void refresh(T object) throws E, IOException
|
||||
{
|
||||
decorated.refresh(object);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public T get(String id)
|
||||
{
|
||||
return decorated.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<T> getAll()
|
||||
{
|
||||
return decorated.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param comparator
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<T> getAll(Comparator<T> comparator)
|
||||
{
|
||||
return decorated.getAll(comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<T> getAll(int start, int limit)
|
||||
{
|
||||
return decorated.getAll(start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param comparator
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<T> getAll(Comparator<T> comparator, int start, int limit)
|
||||
{
|
||||
return decorated.getAll(comparator, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getLastModified()
|
||||
{
|
||||
return decorated.getLastModified();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Manager<T, E> decorated;
|
||||
}
|
||||
@@ -47,7 +47,9 @@ import java.util.Collection;
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @deprecated use {@link RepositoryManagerDecorator} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractRepositoryManagerDecorator
|
||||
implements RepositoryManager
|
||||
{
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||
* binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||
* nor the names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.ManagerDecorator;
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.plugin.ExtensionPoint;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Decorator for {@link RepositoryManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
@ExtensionPoint
|
||||
public class RepositoryManagerDecorator
|
||||
extends ManagerDecorator<Repository, RepositoryException>
|
||||
implements RepositoryManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param decorated
|
||||
*/
|
||||
public RepositoryManagerDecorator(RepositoryManager decorated)
|
||||
{
|
||||
super(decorated);
|
||||
this.decorated = decorated;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param hook
|
||||
*/
|
||||
@Override
|
||||
public void addHook(RepositoryHook hook)
|
||||
{
|
||||
decorated.addHook(hook);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param hooks
|
||||
*/
|
||||
@Override
|
||||
public void addHooks(Collection<RepositoryHook> hooks)
|
||||
{
|
||||
decorated.addHooks(hooks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
@Override
|
||||
public void addListener(RepositoryListener listener)
|
||||
{
|
||||
decorated.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param listeners
|
||||
*/
|
||||
@Override
|
||||
public void addListeners(Collection<RepositoryListener> listeners)
|
||||
{
|
||||
decorated.addListeners(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void fireHookEvent(Repository repository, RepositoryHookEvent event)
|
||||
{
|
||||
decorated.fireHookEvent(repository, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
* @param event
|
||||
*
|
||||
* @throws RepositoryNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public void fireHookEvent(String type, String name, RepositoryHookEvent event)
|
||||
throws RepositoryNotFoundException
|
||||
{
|
||||
decorated.fireHookEvent(type, name, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param event
|
||||
*
|
||||
* @throws RepositoryNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public void fireHookEvent(String id, RepositoryHookEvent event)
|
||||
throws RepositoryNotFoundException
|
||||
{
|
||||
decorated.fireHookEvent(id, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public void importRepository(Repository repository)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
decorated.importRepository(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param hook
|
||||
*/
|
||||
@Override
|
||||
public void removeHook(RepositoryHook hook)
|
||||
{
|
||||
decorated.removeHook(hook);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
@Override
|
||||
public void removeListener(RepositoryListener listener)
|
||||
{
|
||||
decorated.removeListener(listener);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Repository get(String type, String name)
|
||||
{
|
||||
return decorated.get(type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public BlameViewer getBlameViewer(Repository repository)
|
||||
throws RepositoryException
|
||||
{
|
||||
return decorated.getBlameViewer(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public ChangesetViewer getChangesetViewer(Repository repository)
|
||||
throws RepositoryException
|
||||
{
|
||||
return decorated.getChangesetViewer(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Type> getConfiguredTypes()
|
||||
{
|
||||
return decorated.getConfiguredTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public DiffViewer getDiffViewer(Repository repository)
|
||||
throws RepositoryException
|
||||
{
|
||||
return decorated.getDiffViewer(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Repository getFromRequest(HttpServletRequest request)
|
||||
{
|
||||
return decorated.getFromRequest(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param uri
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Repository getFromTypeAndUri(String type, String uri)
|
||||
{
|
||||
return decorated.getFromTypeAndUri(type, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param uri
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Repository getFromUri(String uri)
|
||||
{
|
||||
return decorated.getFromUri(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public RepositoryHandler getHandler(String type)
|
||||
{
|
||||
return decorated.getHandler(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public RepositoryBrowser getRepositoryBrowser(Repository repository)
|
||||
throws RepositoryException
|
||||
{
|
||||
return decorated.getRepositoryBrowser(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Type> getTypes()
|
||||
{
|
||||
return decorated.getTypes();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private RepositoryManager decorated;
|
||||
}
|
||||
Reference in New Issue
Block a user