You are viewing a plain text version of this content. The canonical link for it is here.
Posted to droids-commits@incubator.apache.org by ol...@apache.org on 2008/11/15 13:43:58 UTC
svn commit: r714257 - in /incubator/droids/trunk/droids-core: ./
src/main/java/org/apache/droids/api/
src/main/java/org/apache/droids/protocol/file/
src/main/java/org/apache/droids/protocol/http/
src/main/java/org/apache/droids/robot/crawler/
Author: olegk
Date: Sat Nov 15 05:43:58 2008
New Revision: 714257
URL: http://svn.apache.org/viewvc?rev=714257&view=rev
Log:
Split ContentEntity interface into ContentEntity exposed to the consumer and ManagedContentEntity managed by a Droid. ManagedContentEntity provides an additional method to release underlying resources held by the entity such as temp files
Added:
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ManagedContentEntity.java
incubator/droids/trunk/droids-core/tmp.txt
Modified:
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ContentEntity.java
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Protocol.java
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/file/FileProtocol.java
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/robot/crawler/CrawlingWorker.java
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ContentEntity.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ContentEntity.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ContentEntity.java Sat Nov 15 05:43:58 2008
@@ -28,8 +28,6 @@
* <p>
* IMPORTANT: The consumer of the entity content MUST close the input stream
* returned by {@link #obtainContent()} when finished reading the content.
- * The consumer MUST call {@link #finish()} when the entity is no longer
- * needed in order to release underlying resources held by the entity.
*
* @version 1.0
*/
@@ -40,7 +38,7 @@
* MUST be closed by the consumer when finished reading content.
* <p/>
* IMPORTANT: This method MUST return a new instance of {@link InputStream}
- * to ensure the content can be consumed miore than once.
+ * to ensure the content can be consumed more than once.
*
* @return input stream
* @throws IOException
@@ -62,9 +60,4 @@
*/
String getCharset();
- /**
- * Release all underlying resources held by the entity.
- */
- void finish();
-
}
\ No newline at end of file
Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ManagedContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ManagedContentEntity.java?rev=714257&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ManagedContentEntity.java (added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/ManagedContentEntity.java Sat Nov 15 05:43:58 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.droids.api;
+
+/**
+ * Abstract interface representing a body of content managed by a {@link Droid}.
+ * <p>
+ * Droid MUST call {@link #finish()} when the entity is no longer
+ * needed in order to release underlying resources held by the entity.
+ *
+ * @version 1.0
+ */
+public interface ManagedContentEntity extends ContentEntity {
+
+ /**
+ * Release all underlying resources held by the entity.
+ */
+ void finish();
+
+}
\ No newline at end of file
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Protocol.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Protocol.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Protocol.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Protocol.java Sat Nov 15 05:43:58 2008
@@ -47,6 +47,6 @@
* @return the content of the given url
* @throws IOException
*/
- ContentEntity load(URI uri) throws IOException;
+ ManagedContentEntity load(URI uri) throws IOException;
}
\ No newline at end of file
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/file/FileProtocol.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/file/FileProtocol.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/file/FileProtocol.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/file/FileProtocol.java Sat Nov 15 05:43:58 2008
@@ -7,7 +7,7 @@
import java.io.InputStream;
import java.net.URI;
-import org.apache.droids.api.ContentEntity;
+import org.apache.droids.api.ManagedContentEntity;
import org.apache.droids.api.Protocol;
public class FileProtocol implements Protocol {
@@ -19,7 +19,7 @@
return file.canRead();
}
- public ContentEntity load(URI uri) throws IOException {
+ public ManagedContentEntity load(URI uri) throws IOException {
File file = new File(extractLocation(uri));
return new FileContentEntity(file);
}
@@ -33,7 +33,7 @@
return location;
}
- static class FileContentEntity implements ContentEntity {
+ static class FileContentEntity implements ManagedContentEntity {
private final File file;
private final String mimeType;
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java Sat Nov 15 05:43:58 2008
@@ -20,7 +20,7 @@
import java.io.InputStream;
import java.util.Locale;
-import org.apache.droids.api.ContentEntity;
+import org.apache.droids.api.ManagedContentEntity;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
@@ -28,7 +28,7 @@
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.protocol.HTTP;
-public class HttpContentEntity implements ContentEntity {
+public class HttpContentEntity implements ManagedContentEntity {
private final HttpEntity entity;
private final String mimeType;
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java Sat Nov 15 05:43:58 2008
@@ -20,7 +20,7 @@
import java.net.URI;
import java.net.URISyntaxException;
-import org.apache.droids.api.ContentEntity;
+import org.apache.droids.api.ManagedContentEntity;
import org.apache.droids.api.Protocol;
import org.apache.droids.helper.Loggable;
import org.apache.droids.norobots.ContentLoader;
@@ -58,7 +58,7 @@
this(new DroidsHttpClient());
}
- public ContentEntity load(URI uri) throws IOException {
+ public ManagedContentEntity load(URI uri) throws IOException {
HttpGet httpget = new HttpGet(uri);
HttpResponse response = httpclient.execute(httpget);
StatusLine statusline = response.getStatusLine();
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/robot/crawler/CrawlingWorker.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/robot/crawler/CrawlingWorker.java?rev=714257&r1=714256&r2=714257&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/robot/crawler/CrawlingWorker.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/robot/crawler/CrawlingWorker.java Sat Nov 15 05:43:58 2008
@@ -24,6 +24,7 @@
import org.apache.droids.api.ContentEntity;
import org.apache.droids.api.Link;
+import org.apache.droids.api.ManagedContentEntity;
import org.apache.droids.api.Parse;
import org.apache.droids.api.Parser;
import org.apache.droids.api.Protocol;
@@ -53,7 +54,7 @@
if (log.isInfoEnabled()) {
log.info("Loading " + uri);
}
- ContentEntity entity = protocol.load(uri);
+ ManagedContentEntity entity = protocol.load(uri);
try {
String contentType = entity.getMimeType();
if (log.isDebugEnabled()) {
Added: incubator/droids/trunk/droids-core/tmp.txt
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/tmp.txt?rev=714257&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/tmp.txt (added)
+++ incubator/droids/trunk/droids-core/tmp.txt Sat Nov 15 05:43:58 2008
@@ -0,0 +1,9 @@
+classes
+bin
+lib
+target
+log.txt
+.classpath
+.project
+.settings
+