improve plugin api

This commit is contained in:
Sebastian Sdorra
2010-12-18 13:37:34 +01:00
parent abd04009b3
commit 8646be6733
7 changed files with 491 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
/**
* 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.plugin;
/**
*
* @author Sebastian Sdorra
*/
public interface PluginFilter
{
/**
* Method description
*
*
* @param plugin
*
* @return
*/
public boolean accept(PluginInformation plugin);
}

View File

@@ -50,6 +50,86 @@ import javax.xml.bind.annotation.XmlRootElement;
public class PluginInformation implements Validateable
{
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final PluginInformation other = (PluginInformation) obj;
if ((this.artifactId == null)
? (other.artifactId != null)
: !this.artifactId.equals(other.artifactId))
{
return false;
}
if ((this.author == null)
? (other.author != null)
: !this.author.equals(other.author))
{
return false;
}
if ((this.groupId == null)
? (other.groupId != null)
: !this.groupId.equals(other.groupId))
{
return false;
}
if ((this.version == null)
? (other.version != null)
: !this.version.equals(other.version))
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 7;
hash = 53 * hash + ((this.artifactId != null)
? this.artifactId.hashCode()
: 0);
hash = 53 * hash + ((this.groupId != null)
? this.groupId.hashCode()
: 0);
hash = 53 * hash + ((this.version != null)
? this.version.hashCode()
: 0);
return hash;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
@@ -120,6 +200,17 @@ public class PluginInformation implements Validateable
return name;
}
/**
* Method description
*
*
* @return
*/
public PluginState getState()
{
return state;
}
/**
* Method description
*
@@ -212,6 +303,17 @@ public class PluginInformation implements Validateable
this.name = name;
}
/**
* Method description
*
*
* @param state
*/
public void setState(PluginState state)
{
this.state = state;
}
/**
* Method description
*
@@ -251,6 +353,9 @@ public class PluginInformation implements Validateable
/** Field description */
private String name;
/** Field description */
private PluginState state;
/** Field description */
private String url;

View File

@@ -60,6 +60,14 @@ public interface PluginManager
*/
public void uninstall(String id);
/**
* Method description
*
*
* @param id
*/
public void update(String id);
//~--- get methods ----------------------------------------------------------
/**
@@ -72,6 +80,24 @@ public interface PluginManager
*/
public PluginInformation get(String id);
/**
* Method description
*
*
* @param filter
*
* @return
*/
public Collection<PluginInformation> get(PluginFilter filter);
/**
* Method description
*
*
* @return
*/
public Collection<PluginInformation> getAll();
/**
* Method description
*
@@ -80,6 +106,14 @@ public interface PluginManager
*/
public Collection<PluginInformation> getAvailable();
/**
* Method description
*
*
* @return
*/
public Collection<PluginInformation> getAvailableUpdates();
/**
* Method description
*

View File

@@ -0,0 +1,43 @@
/**
* 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.plugin;
/**
*
* @author Sebastian Sdorra
*/
public enum PluginState
{
CORE, AVAILABLE, INSTALLED, UPDATE_AVAILABLE;
}

View File

@@ -0,0 +1,74 @@
/**
* 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.plugin;
/**
*
* @author Sebastian Sdorra
*/
public class StatePluginFilter implements PluginFilter
{
/**
* Constructs ...
*
*
* @param state
*/
public StatePluginFilter(PluginState state)
{
this.state = state;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param plugin
*
* @return
*/
@Override
public boolean accept(PluginInformation plugin)
{
return state == plugin.getState();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private PluginState state;
}