Author: janb
Date: Thu Jul 24 00:08:52 2008
New Revision: 679289
URL:
http://svn.apache.org/viewvc?rev=679289&view=revLog:
Fleshing out pluggable streamobservers and verifiers.
Added:
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java (with props)
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java (with props)
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java (with props)
Modified:
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Server.java
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserver.java
maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Verifier.java
Added: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java?rev=679289&view=auto==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java (added)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java Thu Jul 24 00:08:52 2008
@@ -0,0 +1,97 @@
+/**
+ * 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.maven.mercury.spi.http.client;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+
+
+public class ObservableInputStream extends FilterInputStream
+{
+ Set<StreamObserver> observers = new HashSet<StreamObserver>();
+
+ protected ObservableInputStream(InputStream in)
+ {
+ super(in);
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ int result = in.read(b, off, len);
+ if (result != -1) {
+ notifyListeners(b, off, result);
+ }
+ return result;
+ }
+
+
+ public int read(byte[] b) throws IOException
+ {
+ int ch = in.read();
+ if (ch != -1) {
+ notifyListeners(ch);
+ }
+ return ch;
+ }
+
+ public void addObserver (StreamObserver o)
+ {
+ synchronized (this.observers)
+ {
+ this.observers.add(o);
+ }
+ }
+
+ public void addObservers (Collection<? extends StreamObserver> observers)
+ {
+ synchronized (this.observers)
+ {
+ this.observers.addAll(observers);
+ }
+ }
+
+ private void notifyListeners (byte[]b, int off, int len)
+ {
+ synchronized (this.observers)
+ {
+ for (StreamObserver o: this.observers)
+ {
+ o.bytesReady(b, off, len);
+ }
+ }
+ }
+
+ private void notifyListeners (int b)
+ {
+ synchronized (this.observers)
+ {
+ for (StreamObserver o: this.observers)
+ {
+ o.byteReady(b);
+ }
+ }
+ }
+
+}
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableInputStream.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java?rev=679289&view=auto==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java (added)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java Thu Jul 24 00:08:52 2008
@@ -0,0 +1,90 @@
+/**
+ * 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.maven.mercury.spi.http.client;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+
+
+public class ObservableOutputStream extends FilterOutputStream
+{
+ Set<StreamObserver> observers = new HashSet<StreamObserver>();
+
+
+ public ObservableOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ public void write(int b) throws IOException
+ {
+ notifyListeners(b);
+ out.write(b);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException
+ {
+ notifyListeners(b, off, len);
+ out.write(b, off, len);
+ }
+ public void addObserver (StreamObserver o)
+ {
+ synchronized (this.observers)
+ {
+ this.observers.add(o);
+ }
+ }
+
+ public void addObservers (Collection<? extends StreamObserver> observers)
+ {
+ synchronized (this.observers)
+ {
+ this.observers.addAll(observers);
+ }
+ }
+ private void notifyListeners (byte[]b, int off, int len)
+ {
+ synchronized (this.observers)
+ {
+ for (StreamObserver o: this.observers)
+ {
+ o.bytesReady(b, off, len);
+ }
+ }
+ }
+
+ private void notifyListeners (int b)
+ {
+ synchronized (this.observers)
+ {
+ for (StreamObserver o: this.observers)
+ {
+ o.byteReady(b);
+ }
+ }
+ }
+
+}
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/spi/http/client/ObservableOutputStream.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Server.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Server.java?rev=679289&r1=679288&r2=679289&view=diff==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Server.java (original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Server.java Thu Jul 24 00:08:52 2008
@@ -1,6 +1,39 @@
+/**
+ * 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.maven.mercury.transport.api;
+import java.util.Set;
+
public class Server
{
+ private Set<StreamObserverFactory> streamObserverFactories;
+
+
+
+ public Set<StreamObserverFactory> getStreamObserverFactories()
+ {
+ return streamObserverFactories;
+ }
+
+ public void setStreamObserverFactories(Set<StreamObserverFactory> factories)
+ {
+ streamObserverFactories = factories;
+ }
}
Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserver.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserver.java?rev=679289&r1=679288&r2=679289&view=diff==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserver.java (original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserver.java Thu Jul 24 00:08:52 2008
@@ -1,6 +1,25 @@
+/**
+ * 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.maven.mercury.transport.api;
public interface StreamObserver
{
-
+ void byteReady(int b);
+ void bytesReady(byte[]b, int off, int len);
}
Added: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java?rev=679289&view=auto==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java (added)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java Thu Jul 24 00:08:52 2008
@@ -0,0 +1,25 @@
+/**
+ * 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.maven.mercury.transport.api;
+
+public interface StreamObserverFactory
+{
+ public StreamObserver newInstance();
+
+}
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/StreamObserverFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Verifier.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Verifier.java?rev=679289&r1=679288&r2=679289&view=diff==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Verifier.java (original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/transport/api/Verifier.java Thu Jul 24 00:08:52 2008
@@ -1,6 +1,28 @@
+/**
+ * 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.maven.mercury.transport.api;
-public interface Verifier
+public interface Verifier extends StreamObserver
{
-
+ public String getSignature();
+ public void verifySignature (String signature);
+ public boolean isLenient();
+ public boolean isSufficient();
+ public String getExtension();
}