-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split ImageJ service framework into scijava-common
This code was migrated and adapted from ImageJ: https://github.com/imagej/imagej This new shared library will enable ImageJ and SCIFIO to have a common base for plugin extensibility.
- Loading branch information
Showing
113 changed files
with
17,545 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<factorypath> | ||
<factorypathentry enabled="true" id="M2_REPO/net/java/sezpoz/sezpoz/1.9/sezpoz-1.9.jar" kind="VARJAR" runInBatchMode="true"/> | ||
</factorypath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.classpath | ||
.project | ||
.settings | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#Fri Feb 15 15:28:28 CST 2013 | ||
org.eclipse.jdt.apt.aptEnabled=true | ||
org.eclipse.jdt.apt.genSrcDir=target/classes | ||
org.eclipse.jdt.apt.reconcileEnabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.scijava</groupId> | ||
<artifactId>pom-scijava</artifactId> | ||
<version>1.28</version> | ||
</parent> | ||
|
||
<artifactId>scijava-common</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<name>SciJava Common</name> | ||
<description>SciJava Common is a service framework. It provides an extensible mechanism for service discovery, driven by the SezPoz library, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.java.sezpoz</groupId> | ||
<artifactId>sezpoz</artifactId> | ||
<version>${sezpoz.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bushe</groupId> | ||
<artifactId>eventbus</artifactId> | ||
<version>1.4</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<packageName>org.scijava</packageName> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>buildnumber-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/scijava/scijava-common.git</connection> | ||
<developerConnection>scm:git:git@github.com:scijava/scijava-common.git</developerConnection> | ||
<tag>HEAD</tag> | ||
<url>https://github.com/scijava/scijava-common</url> | ||
</scm> | ||
|
||
<!-- NB: for project parent --> | ||
<repositories> | ||
<repository> | ||
<id>imagej.releases</id> | ||
<url>http://maven.imagej.net/content/repositories/releases</url> | ||
</repository> | ||
<repository> | ||
<id>imagej.snapshots</id> | ||
<url>http://maven.imagej.net/content/repositories/snapshots</url> | ||
</repository> | ||
</repositories> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* #%L | ||
* ImageJ software for multidimensional image processing and analysis. | ||
* %% | ||
* Copyright (C) 2009 - 2013 Board of Regents of the University of | ||
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck | ||
* Institute of Molecular Cell Biology and Genetics. | ||
* %% | ||
* 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. | ||
* | ||
* 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 COPYRIGHT HOLDERS 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. | ||
* | ||
* The views and conclusions contained in the software and documentation are | ||
* those of the authors and should not be interpreted as representing official | ||
* policies, either expressed or implied, of any organization. | ||
* #L% | ||
*/ | ||
|
||
package org.scijava; | ||
|
||
import java.util.List; | ||
|
||
import org.scijava.event.EventSubscriber; | ||
import org.scijava.event.EventUtils; | ||
|
||
/** | ||
* Abstract base class for {@link Contextual} objects. | ||
* <p> | ||
* This class enforces a single call to {@link #setContext}, throwing an | ||
* {@link IllegalStateException} if the context is already set. It also | ||
* registers the object's {@link org.scijava.event.EventHandler} methods with | ||
* the {@link org.scijava.event.EventService}, if any, at the time the context | ||
* is assigned. This frees subclasses from the burden of maintaining | ||
* {@link EventSubscriber} references manually. | ||
* </p> | ||
* | ||
* @author Curtis Rueden | ||
*/ | ||
public abstract class AbstractContextual implements Contextual { | ||
|
||
/** This application context associated with the object. */ | ||
private Context context; | ||
|
||
/** | ||
* The list of event subscribers, maintained to avoid garbage collection. | ||
* | ||
* @see org.scijava.event.EventService#subscribe(Object) | ||
*/ | ||
private List<EventSubscriber<?>> subscribers; | ||
|
||
// -- Object methods -- | ||
|
||
@Override | ||
public void finalize() { | ||
// unregister any event handling methods | ||
EventUtils.unsubscribe(getContext(), subscribers); | ||
} | ||
|
||
// -- Contextual methods -- | ||
|
||
@Override | ||
public Context getContext() { | ||
return context; | ||
} | ||
|
||
@Override | ||
public void setContext(final Context context) { | ||
if (this.context != null) { | ||
throw new IllegalStateException("Context already set"); | ||
} | ||
this.context = context; | ||
|
||
// NB: Subscribe to all events handled by this object. | ||
// This greatly simplifies event handling for subclasses. | ||
subscribers = EventUtils.subscribe(context, this); | ||
} | ||
|
||
} |
Oops, something went wrong.