1818 * @see ASP3Reader
1919 * @author thsc
2020 */
21- public class ASP3Engine implements ASP3ChunkStorage , ASP3ProtocolEngine {
21+ public abstract class ASP3Engine implements ASP3ChunkStorage , ASP3ProtocolEngine {
2222 public static final String ANONYMOUS_OWNER = "anon" ;
2323 static String DEFAULT_OWNER = ANONYMOUS_OWNER ;
2424 static int DEFAULT_INIT_ERA = 0 ;
@@ -31,9 +31,9 @@ public class ASP3Engine implements ASP3ChunkStorage, ASP3ProtocolEngine {
3131 protected ASP3Memento memento = null ;
3232
3333 private final ASP3Reader reader ;
34- /* private */ final ASP3Storage chunkStorage ;
34+ /* private */ final private ASP3Storage chunkStorage ;
3535
36- ASP3Engine (ASP3Storage chunkStorage , ASP3Reader reader )
36+ protected ASP3Engine (ASP3Storage chunkStorage , ASP3Reader reader )
3737 throws ASP3Exception , IOException {
3838
3939 this .chunkStorage = chunkStorage ;
@@ -45,9 +45,9 @@ public class ASP3Engine implements ASP3ChunkStorage, ASP3ProtocolEngine {
4545 }
4646 */
4747 }
48-
49- ASP3Engine ( ASP3Storage chunkStorage ) throws ASP3Exception , IOException {
50- this ( chunkStorage , null ) ;
48+
49+ ASP3Storage getStorage () {
50+ return this . chunkStorage ;
5151 }
5252
5353 //////////////////////////////////////////////////////////////////////
@@ -71,26 +71,11 @@ public void removeRecipient(CharSequence urlTarget, CharSequence recipients) thr
7171
7272 @ Override
7373 public void add (CharSequence urlTarget , CharSequence message ) throws IOException {
74- ASP3Chunk chunk = this .chunkStorage .getChunk (urlTarget , this .era );
74+ ASP3Chunk2Send chunk = this .chunkStorage .getChunk (urlTarget , this .era );
7575
7676 chunk .add (message );
7777 }
7878
79- @ Override
80- public ASP3Chunk getChunk (CharSequence urlTarget , int era ) throws IOException {
81- return this .chunkStorage .getChunk (urlTarget , era );
82- }
83-
84- @ Override
85- public List <ASP3Chunk > getChunks (int era ) throws IOException {
86- return this .chunkStorage .getChunks (era );
87- }
88-
89- @ Override
90- public void dropChunks (int era ) throws IOException {
91- this .chunkStorage .dropChunks (era );
92- }
93-
9479 //////////////////////////////////////////////////////////////////////
9580 // ProtocolEngine //
9681 //////////////////////////////////////////////////////////////////////
@@ -198,7 +183,7 @@ public void handleConnection(InputStream is, OutputStream os) {
198183 do {
199184 lastRound = workingEra == currentEra ;
200185
201- List <ASP3Chunk > chunks = this .chunkStorage .getChunks (workingEra );
186+ List <ASP3Chunk2Send > chunks = this .chunkStorage .getChunks (workingEra );
202187 //<<<<<<<<<<<<<<<<<<debug
203188 b = new StringBuilder ();
204189 b .append (this .getLogStart ());
@@ -207,7 +192,7 @@ public void handleConnection(InputStream is, OutputStream os) {
207192 System .out .println (b .toString ());
208193 //>>>>>>>>>>>>>>>>>>>debug
209194
210- for (ASP3Chunk chunk : chunks ) {
195+ for (ASP3Chunk2Send chunk : chunks ) {
211196 //<<<<<<<<<<<<<<<<<<debug
212197 b = new StringBuilder ();
213198 b .append (this .getLogStart ());
@@ -369,7 +354,7 @@ private synchronized void incrementEra() throws IOException {
369354 this .chunkStorage .dropChunks (this .era );
370355 }
371356
372- private void sendChunk (ASP3Chunk chunk , DataOutputStream dos )
357+ private void sendChunk (ASP3Chunk2Send chunk , DataOutputStream dos )
373358 throws IOException {
374359
375360 //<<<<<<<<<<<<<<<<<<debug
@@ -434,7 +419,7 @@ private void sendChunk(ASP3Chunk chunk, DataOutputStream dos)
434419 * @param chunk
435420 * @return
436421 */
437- private boolean isPublic (ASP3Chunk chunk ) {
422+ private boolean isPublic (ASP3Chunk2Send chunk ) {
438423 return chunk .getRecipients ().isEmpty ();
439424 }
440425
0 commit comments