Skip to content

Commit 2d9ea29

Browse files
committed
1.0.0.RC2.1
1 parent be52947 commit 2d9ea29

23 files changed

+2157
-39
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ ES version Plugin Release date Command
2929
0.90.9 0.90.9.1 (S3) Jan 9, 2014 ./bin/plugin --install knapsack --url http://bit.ly/K8QwOJ
3030
0.90.10 0.90.10.1 Jan 14, 2014 ./bin/plugin --install knapsack --url http://bit.ly/1j5rOy2
3131
0.90.10 0.90.10.1 (S3) Jan 14, 2014 ./bin/plugin --install knapsack --url http://bit.ly/1d3kYkp
32-
1.0.0.RC1 1.0.0.RC1.1 Jan 16, 2014 ./bin/plugin --install knapsack --url http://bit.ly/19vmQHu
33-
1.0.0.RC1 1.0.0.RC1.1 (S3) Jan 16, 2014 ./bin/plugin --install knapsack --url http://bit.ly/1m82PHw
32+
1.0.0.RC2 1.0.0.RC2.1 Feb 3, 2014 ./bin/plugin --install knapsack --url http://bit.ly/1dYWcSR
33+
1.0.0.RC2 1.0.0.RC2.1 (S3) Feb 3, 2014 ./bin/plugin --install knapsack --url http://bit.ly/1bohsVv
3434
============= ================= ================= ===========================================================
3535

3636
The S3 version includes Amazon AWS API support, it can optionally transfer archives to S3.

pom.xml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>org.xbib.elasticsearch.plugin</groupId>
99
<artifactId>elasticsearch-knapsack</artifactId>
10-
<version>1.0.0.RC1.2</version>
10+
<version>1.0.0.RC2.1</version>
1111

1212
<packaging>jar</packaging>
1313

@@ -58,7 +58,7 @@
5858
<properties>
5959
<github.global.server>github</github.global.server>
6060
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61-
<elasticsearch.version>1.0.0.RC1</elasticsearch.version>
61+
<elasticsearch.version>1.0.0.RC2</elasticsearch.version>
6262
</properties>
6363

6464
<dependencies>
@@ -85,6 +85,7 @@
8585
<version>1.6.11</version>
8686
<type>jar</type>
8787
<scope>compile</scope>
88+
<optional>true</optional>
8889
</dependency>
8990

9091
<dependency>
@@ -104,7 +105,22 @@
104105
</dependencies>
105106

106107
<build>
107-
108+
<resources>
109+
<resource>
110+
<directory>${basedir}/src/main/resources</directory>
111+
<filtering>true</filtering>
112+
<includes>
113+
<include>es-plugin.properties</include>
114+
</includes>
115+
</resource>
116+
<resource>
117+
<directory>${basedir}/src/main/resources</directory>
118+
<filtering>false</filtering>
119+
<excludes>
120+
<exclude>es-plugin.properties</exclude>
121+
</excludes>
122+
</resource>
123+
</resources>
108124
<plugins>
109125
<plugin>
110126
<groupId>org.apache.maven.plugins</groupId>
@@ -171,6 +187,23 @@
171187
<encoding>UTF-8</encoding>
172188
</configuration>
173189
</plugin>
190+
<plugin>
191+
<groupId>org.codehaus.mojo</groupId>
192+
<artifactId>buildnumber-maven-plugin</artifactId>
193+
<version>1.2</version>
194+
<executions>
195+
<execution>
196+
<phase>validate</phase>
197+
<goals>
198+
<goal>create</goal>
199+
</goals>
200+
</execution>
201+
</executions>
202+
<configuration>
203+
<doCheck>false</doCheck>
204+
<doUpdate>false</doUpdate>
205+
</configuration>
206+
</plugin>
174207
<plugin>
175208
<artifactId>maven-project-info-reports-plugin</artifactId>
176209
<version>2.7</version>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
package org.xbib.classloader;
3+
4+
import java.io.ByteArrayOutputStream;
5+
import java.io.IOException;
6+
import java.io.InputStream;
7+
import java.security.cert.Certificate;
8+
import java.util.jar.Attributes;
9+
import java.util.jar.Manifest;
10+
11+
public abstract class AbstractResourceHandle implements ResourceHandle {
12+
13+
public byte[] getBytes() throws IOException {
14+
InputStream in = getInputStream();
15+
try {
16+
return load(in);
17+
} finally {
18+
if (in != null) {
19+
try {
20+
in.close();
21+
} catch (Exception ignored) {
22+
}
23+
}
24+
}
25+
}
26+
27+
public Manifest getManifest() throws IOException {
28+
return null;
29+
}
30+
31+
public Certificate[] getCertificates() {
32+
return null;
33+
}
34+
35+
public Attributes getAttributes() throws IOException {
36+
Manifest m = getManifest();
37+
if (m == null) {
38+
return null;
39+
}
40+
41+
String entry = getUrl().getFile();
42+
return m.getAttributes(entry);
43+
}
44+
45+
public void close() {
46+
}
47+
48+
public String toString() {
49+
return "[" + getName() + ": " + getUrl() + "; code source: " + getCodeSourceUrl() + "]";
50+
}
51+
52+
static byte[] load(InputStream inputStream) throws IOException {
53+
try {
54+
byte[] buffer = new byte[4096];
55+
ByteArrayOutputStream out = new ByteArrayOutputStream();
56+
for (int count = inputStream.read(buffer); count >= 0; count = inputStream.read(buffer)) {
57+
out.write(buffer, 0, count);
58+
}
59+
return out.toByteArray();
60+
} finally {
61+
if (inputStream != null) {
62+
try {
63+
inputStream.close();
64+
} catch (Exception ignored) {
65+
}
66+
}
67+
}
68+
}
69+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
package org.xbib.classloader;
3+
4+
import java.net.URL;
5+
import java.util.Collection;
6+
import java.util.Enumeration;
7+
import java.util.Iterator;
8+
import java.util.NoSuchElementException;
9+
10+
public class ResourceEnumeration implements Enumeration<URL> {
11+
12+
private Iterator iterator;
13+
14+
private final String resourceName;
15+
16+
private URL next;
17+
18+
public ResourceEnumeration(Collection resourceLocations, String resourceName) {
19+
this.iterator = resourceLocations.iterator();
20+
this.resourceName = resourceName;
21+
}
22+
23+
public boolean hasMoreElements() {
24+
fetchNext();
25+
return (next != null);
26+
}
27+
28+
public URL nextElement() {
29+
fetchNext();
30+
// save next into a local variable and clear the next field
31+
URL next = this.next;
32+
this.next = null;
33+
// if we didn't have a next throw an exception
34+
if (next == null) {
35+
throw new NoSuchElementException();
36+
}
37+
return next;
38+
}
39+
40+
private void fetchNext() {
41+
if (iterator == null) {
42+
return;
43+
}
44+
if (next != null) {
45+
return;
46+
}
47+
try {
48+
while (iterator.hasNext()) {
49+
ResourceLocation resourceLocation = (ResourceLocation) iterator.next();
50+
ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName);
51+
if (resourceHandle != null) {
52+
next = resourceHandle.getUrl();
53+
return;
54+
}
55+
}
56+
// no more elements
57+
// clear the iterator so it can be GCed
58+
iterator = null;
59+
} catch (IllegalStateException e) {
60+
// Jar file was closed... this means the resource finder was destroyed
61+
// clear the iterator so it can be GCed
62+
iterator = null;
63+
throw e;
64+
}
65+
}
66+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
package org.xbib.classloader;
3+
4+
import java.net.URL;
5+
import java.util.Enumeration;
6+
7+
/**
8+
* Abstraction of resource searching policy. Given resource name, the resource
9+
* finder performs implementation-specific lookup, and, if it is able to locate
10+
* the resource, returns the {@link AbstractResourceHandle handle(s)} or URL(s)
11+
* of it.
12+
*/
13+
public interface ResourceFinder {
14+
15+
/**
16+
* Find the resource by name and return URL of it if found.
17+
*
18+
* @param name the resource name
19+
* @return resource URL or null if resource was not found
20+
*/
21+
URL findResource(String name);
22+
23+
/**
24+
* Find all resources with given name and return enumeration of their URLs.
25+
*
26+
* @param name the resource name
27+
* @return enumeration of resource URLs (possibly empty).
28+
*/
29+
Enumeration<URL> findResources(String name);
30+
31+
/**
32+
* Get the resource by name and, if found, open connection to it and return
33+
* the {@link AbstractResourceHandle handle} of it.
34+
*
35+
* @param name the resource name
36+
* @return resource handle or null if resource was not found
37+
*/
38+
ResourceHandle getResource(String name);
39+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
package org.xbib.classloader;
3+
4+
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.net.URL;
7+
import java.security.cert.Certificate;
8+
import java.util.jar.Attributes;
9+
import java.util.jar.Manifest;
10+
11+
/**
12+
* This is a handle (a connection) to some resource, which may
13+
* be a class, native library, text file, image, etc. Handles are returned
14+
* by a ResourceFinder. A resource handle allows easy access to the resource data
15+
* (using methods {@link #getInputStream} or {@link #getBytes}) as well as
16+
* access resource metadata, such as attributes, certificates, etc.
17+
* <p/>
18+
* As soon as the handle is no longer in use, it should be explicitly
19+
* {@link #close}d, similarly to I/O streams.
20+
*/
21+
public interface ResourceHandle {
22+
/**
23+
* Return the name of the resource. The name is a "/"-separated path
24+
* name that identifies the resource.
25+
*/
26+
String getName();
27+
28+
/**
29+
* Returns the URL of the resource.
30+
*/
31+
URL getUrl();
32+
33+
/**
34+
* Does this resource refer to a directory. Directory resources are commly used
35+
* as the basis for a URL in client application. A directory resource has 0 bytes for it's content.
36+
*/
37+
boolean isDirectory();
38+
39+
/**
40+
* Returns the CodeSource URL for the class or resource.
41+
*/
42+
URL getCodeSourceUrl();
43+
44+
/**
45+
* Returns and InputStream for reading this resource data.
46+
*/
47+
InputStream getInputStream() throws IOException;
48+
49+
/**
50+
* Returns the length of this resource data, or -1 if unknown.
51+
*/
52+
int getContentLength();
53+
54+
/**
55+
* Returns this resource data as an array of bytes.
56+
*/
57+
byte[] getBytes() throws IOException;
58+
59+
/**
60+
* Returns the Manifest of the JAR file from which this resource
61+
* was loaded, or null if none.
62+
*/
63+
Manifest getManifest() throws IOException;
64+
65+
/**
66+
* Return the Certificates of the resource, or null if none.
67+
*/
68+
Certificate[] getCertificates();
69+
70+
/**
71+
* Return the Attributes of the resource, or null if none.
72+
*/
73+
Attributes getAttributes() throws IOException;
74+
75+
/**
76+
* Closes a connection to the resource indentified by this handle. Releases
77+
* any I/O objects associated with the handle.
78+
*/
79+
void close();
80+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
package org.xbib.classloader;
3+
4+
import java.io.IOException;
5+
import java.net.URL;
6+
import java.util.jar.Manifest;
7+
8+
/**
9+
* This is a location which is searched by
10+
*/
11+
public interface ResourceLocation {
12+
13+
URL getCodeSource();
14+
15+
ResourceHandle getResourceHandle(String resourceName);
16+
17+
Manifest getManifest() throws IOException;
18+
19+
void close();
20+
}

0 commit comments

Comments
 (0)