* initial commit

git-svn-id: svn+ssh://svn.synyx.de/var/svn/synyx/opensource/synyx-plugin/trunk@2910 5a64d73e-33d6-4ccc-9058-23f8668ecac9
This commit is contained in:
Oliver Gierke
2008-10-06 20:04:03 +00:00
parent a674ee153b
commit 7a025a8b2c
9 changed files with 275 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
plugin-metadata/.project Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>plugin-metadata</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,12 @@
#Mon Oct 06 19:06:04 CEST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

View File

@@ -0,0 +1,8 @@
#Mon Oct 06 19:02:01 CEST 2008
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
version=1

33
plugin-metadata/pom.xml Normal file
View File

@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.synyx.plugin</groupId>
<artifactId>plugin-metadata</artifactId>
<version>0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.synyx.plugin</groupId>
<artifactId>plugin-core</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,52 @@
package org.synyx.plugin.metadata;
import org.synyx.plugin.core.Plugin;
/**
* Abstract base class for plugins based on {@code PluginMetadata}. Plugins
* based on this class can be selected from the {@code PluginRegistry} via an
* instance of {@code PluginMetadata}. Therefore you can regard this as a role
* model implementation of a base class for certain delimiter implmentations.
*
* @author Oliver Gierke - gierke@synyx.de
*/
public abstract class AbstractMetadataBasedPlugin implements
Plugin<PluginMetadata>, MetadataProvider {
private PluginMetadata metadata;
/**
* Creates a new instance of {@code AbstractMetadataBasedPlugin}.
*
* @param name
* @param version
*/
public AbstractMetadataBasedPlugin(String name, String version) {
this.metadata = new SimplePluginMetadata(name, version);
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.Plugin#supports(java.lang.Object)
*/
public boolean supports(PluginMetadata delimiter) {
return getMetadata().equals(delimiter);
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.MetadataProvider#getMetadata()
*/
public PluginMetadata getMetadata() {
return metadata;
}
}

View File

@@ -0,0 +1,17 @@
package org.synyx.plugin.metadata;
/**
* Interface for plugins providing metadata information. Usually the plugins
* will implement this interface themselves.
*
* @author Oliver Gierke - gierke@synyx.de
*/
public interface MetadataProvider {
/**
* Returns the plugins metadata.
*
* @return the plugins metadata
*/
public PluginMetadata getMetadata();
}

View File

@@ -0,0 +1,26 @@
package org.synyx.plugin.metadata;
/**
* Basic interface to define a set of metadata information for plugins.
*
* @author Oliver Gierke - gierke@synyx.de
*/
public interface PluginMetadata {
/**
* Returns a unique plugin name. Plugins return a metadata implementation
* have to ensure uniqueness of this name.
*
* @return the name of the plugin
*/
String getName();
/**
* Returns the plugin version. This allows rudimentary versioning
* possibilities.
*
* @return the version of the plugin
*/
String getVersion();
}

View File

@@ -0,0 +1,97 @@
package org.synyx.plugin.metadata;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
/**
* Value object style implementation of {@code PluginMetadata}.
*
* @author Oliver Gierke - gierke@synyx.de
*/
public class SimplePluginMetadata implements PluginMetadata {
private String name;
private String version;
/**
* Creates a new instance of {@code SimplePluginMetadata}.
*
* @param name
* @param version
*/
public SimplePluginMetadata(String name, String version) {
this.name = name;
this.version = version;
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.PluginMetadata#getName()
*/
public String getName() {
return name;
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.PluginMetadata#getVersion()
*/
public String getVersion() {
return version;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format("%s:%s", getName(), getVersion());
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PluginMetadata)) {
return false;
}
PluginMetadata that = (PluginMetadata) obj;
boolean sameName = StringUtils.equals(this.getName(), that.getName());
boolean sameVersion =
StringUtils.equals(this.getName(), that.getName());
return sameName && sameVersion;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return ObjectUtils.hashCode(name) + ObjectUtils.hashCode(version);
}
}