Skip to content

Commit 3bedcb0

Browse files
committed
refactoring again
1 parent 0a32ae0 commit 3bedcb0

File tree

74 files changed

+114
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+114
-230
lines changed

src/net/sharksystem/Utils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem;
22

3-
import net.sharksystem.asap.internals.ASAP;
3+
import net.sharksystem.asap.ASAP;
44

55
import java.io.File;
66
import java.util.ArrayList;

src/net/sharksystem/asap/internals/ASAP.java renamed to src/net/sharksystem/asap/ASAP.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.asap.internals;
1+
package net.sharksystem.asap;
22

33
import java.util.Random;
44

@@ -32,7 +32,7 @@ public static String createUniqueID() {
3232
Moreover, we are already in the 21. century - could reduce bit even more. We ignore that obvious fact
3333
at first.
3434
35-
Calcuations: 2^64 = 1,8.. * 10^19; we take a..z and A..Z and 0..9 -> 62 digits
35+
Calculations: 2^64 = 1,8.. * 10^19; we take a..z and A..Z and 0..9 -> 62 digits
3636
62^11 = 5,2.. * 10^19 we need 11 digits
3737
*/
3838

src/net/sharksystem/asap/internals/ASAPException.java renamed to src/net/sharksystem/asap/ASAPException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.asap.internals;
1+
package net.sharksystem.asap;
22

33
/**
44
*

src/net/sharksystem/asap/ASAPInternalPeerWrapper.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package net.sharksystem.asap;
22

3-
import net.sharksystem.asap.internals.ASAPException;
43
import net.sharksystem.asap.internals.ASAPInternalOnlinePeersChangedListener;
54
import net.sharksystem.asap.internals.ASAPInternalPeer;
65

76
import java.io.IOException;
87
import java.io.InputStream;
98
import java.io.OutputStream;
9+
import java.util.Set;
1010

1111
public abstract class ASAPInternalPeerWrapper extends ASAPListenerManagingPeer
1212
implements ASAPInternalOnlinePeersChangedListener {
@@ -34,7 +34,20 @@ public void handleConnection(InputStream is, OutputStream os) throws IOException
3434
}
3535

3636
@Override
37-
public void onlinePeersChanged(ASAPInternalPeer peer) {
38-
this.environmentChangesListenerManager.notifyListeners(peer.getOnlinePeers());
37+
public void notifyOnlinePeersChanged(ASAPInternalPeer peer) {
38+
this.notifyOnlinePeersChanged(peer.getOnlinePeers());
39+
}
40+
41+
public void notifyOnlinePeersChanged(Set<CharSequence> peerList) {
42+
StringBuilder sb = new StringBuilder();
43+
sb.append("#online peers: ");
44+
sb.append(peerList.size());
45+
for(CharSequence peerName : peerList) {
46+
sb.append(" | ");
47+
sb.append(peerName);
48+
}
49+
50+
this.log(sb.toString());
51+
this.environmentChangesListenerManager.notifyListeners(peerList);
3952
}
4053
}

src/net/sharksystem/asap/ASAPMessageSender.java

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package net.sharksystem.asap;
22

3-
import net.sharksystem.asap.internals.ASAPException;
4-
53
public interface ASAPMessageSender {
64
/**
75
* Send a message

src/net/sharksystem/asap/ASAPPeerService.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.sharksystem.asap;
22

33
import net.sharksystem.asap.internals.ASAPChunkReceivedListener;
4-
import net.sharksystem.asap.internals.ASAPException;
54
import net.sharksystem.asap.internals.ASAPInternalPeer;
65

76
import java.io.IOException;

src/net/sharksystem/asap/internals/ASAPSecurityException.java renamed to src/net/sharksystem/asap/ASAPSecurityException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.asap.internals;
1+
package net.sharksystem.asap;
22

33
public class ASAPSecurityException extends ASAPException {
44
public ASAPSecurityException() {

src/net/sharksystem/asap/apps/gossip/GossipUI.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.apps.gossip;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.internals.*;
45
import net.sharksystem.asap.util.Helper;
56
import net.sharksystem.cmdline.TCPStream;

src/net/sharksystem/asap/apps/testsupport/ASAPMessagesMock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.apps.testsupport;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44
import net.sharksystem.asap.internals.ASAPMessages;
55
import net.sharksystem.asap.internals.MessageIter;
66

src/net/sharksystem/asap/apps/testsupport/ASAPPeerWrapperMock.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import net.sharksystem.asap.ASAPListenerManagingPeer;
44
import net.sharksystem.asap.ASAPPeerService;
5-
import net.sharksystem.asap.internals.ASAP;
5+
import net.sharksystem.asap.ASAP;
66
import net.sharksystem.asap.internals.ASAPChunkReceivedListener;
7-
import net.sharksystem.asap.internals.ASAPException;
7+
import net.sharksystem.asap.ASAPException;
88
import net.sharksystem.asap.internals.ASAPMessages;
9-
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
109

1110
import java.io.IOException;
1211
import java.io.InputStream;

src/net/sharksystem/asap/apps/testsupport/ASAPTestPeerWrapperFS.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem.asap.apps.testsupport;
22

33
import net.sharksystem.asap.ASAPPeerFS;
4-
import net.sharksystem.asap.internals.ASAPException;
4+
import net.sharksystem.asap.ASAPException;
55

66
import java.io.IOException;
77
import java.net.ServerSocket;

src/net/sharksystem/asap/internals/ASAPAbstractOnlineMessageSender.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
4+
35
import java.io.IOException;
46
import java.util.*;
57

src/net/sharksystem/asap/internals/ASAPChunkStorage.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
4+
35
import java.io.IOException;
46
import java.util.List;
57

src/net/sharksystem/asap/internals/ASAPChunkStorageFS.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package net.sharksystem.asap.internals;
22

33
import net.sharksystem.Utils;
4+
import net.sharksystem.asap.ASAP;
5+
import net.sharksystem.asap.ASAPException;
46
import net.sharksystem.asap.util.Log;
57

68
import java.io.File;

src/net/sharksystem/asap/internals/ASAPConnectionHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAPConnection;
45

56
import java.io.IOException;

src/net/sharksystem/asap/internals/ASAPDefaultProtocolEngine.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAP_1_0;
45
import net.sharksystem.asap.protocol.ASAP_AssimilationPDU_1_0;
56
import net.sharksystem.asap.protocol.ASAP_Interest_PDU_1_0;

src/net/sharksystem/asap/internals/ASAPEngine.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAP;
4+
import net.sharksystem.asap.ASAPException;
35
import net.sharksystem.asap.management.ASAPManagementStorage;
46
import net.sharksystem.asap.management.ASAPManagementStorageImpl;
57
import net.sharksystem.asap.protocol.*;

src/net/sharksystem/asap/internals/ASAPEngineFS.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAP_1_0;
45

56
import java.io.File;

src/net/sharksystem/asap/internals/ASAPInMemoMessages.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sharksystem.asap.internals;
22

33
import net.sharksystem.Utils;
4+
import net.sharksystem.asap.ASAPException;
45
import net.sharksystem.asap.util.Log;
56

67
import java.io.IOException;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package net.sharksystem.asap.internals;
22

33
public interface ASAPInternalOnlinePeersChangedListener {
4-
void onlinePeersChanged(ASAPInternalPeer engine);
4+
void notifyOnlinePeersChanged(ASAPInternalPeer engine);
55
}

src/net/sharksystem/asap/internals/ASAPInternalPeer.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.ASAPSecurityException;
35
import net.sharksystem.asap.protocol.*;
46
import net.sharksystem.crypto.BasicKeyStore;
57

@@ -89,13 +91,9 @@ public interface ASAPInternalPeer extends ASAPConnectionHandler {
8991
* @param urlTarget
9092
* @param recipients
9193
* @param messageAsBytes
92-
* @param era
9394
* @throws IOException
9495
* @throws ASAPException
9596
*/
96-
void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence urlTarget, Set<CharSequence> recipients,
97-
byte[] messageAsBytes, int era) throws IOException, ASAPException;
98-
9997
void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence urlTarget, Set<CharSequence> recipients,
10098
byte[] messageAsBytes) throws IOException, ASAPException;
10199

src/net/sharksystem/asap/internals/ASAPInternalPeerFS.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package net.sharksystem.asap.internals;
22

33
import net.sharksystem.Utils;
4+
import net.sharksystem.asap.ASAP;
5+
import net.sharksystem.asap.ASAPException;
6+
import net.sharksystem.asap.ASAPSecurityException;
47
import net.sharksystem.asap.management.ASAPManagementMessageHandler;
58
import net.sharksystem.asap.protocol.*;
69
import net.sharksystem.asap.util.Helper;
@@ -389,7 +392,7 @@ private void notifyOnlinePeersChangedListener() {
389392

390393
if(this.onlinePeersChangedListeners != null) {
391394
for(ASAPInternalOnlinePeersChangedListener listener: this.onlinePeersChangedListeners) {
392-
listener.onlinePeersChanged(this);
395+
listener.notifyOnlinePeersChanged(this);
393396
}
394397
}
395398
}
@@ -554,7 +557,7 @@ public void deactivateOnlineMessages() {
554557
public void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence urlTarget,
555558
byte[] messageAsBytes) throws IOException, ASAPException {
556559

557-
this.sendOnlineASAPAssimilateMessage(format, urlTarget, null, messageAsBytes, ASAP.INITIAL_ERA);
560+
this.sendOnlineASAPAssimilateMessage(format, urlTarget, null, messageAsBytes);
558561
}
559562

560563
@Override
@@ -566,12 +569,14 @@ public void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence ur
566569
Set<CharSequence> recipients, byte[] messageAsBytes)
567570
throws IOException, ASAPException {
568571

569-
this.sendOnlineASAPAssimilateMessage(format, urlTarget, recipients, messageAsBytes, ASAP.INITIAL_ERA);
570-
}
572+
int era = ASAP.INITIAL_ERA; // init
571573

572-
public void sendOnlineASAPAssimilateMessage(CharSequence format, CharSequence urlTarget,
573-
Set<CharSequence> recipients, byte[] messageAsBytes, int era)
574-
throws IOException, ASAPException {
574+
try {
575+
era = this.getASAPEngine(format).getEra();
576+
} catch (ASAPException e) {
577+
// no engine.. ok
578+
System.out.println(this.getLogStart() + "send message with format but no engine exists (yet): " + format);
579+
}
575580

576581
// setup online message sender thread
577582
Log.writeLog(this, "setup online message sender object");

src/net/sharksystem/asap/internals/ASAPMessages.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
4+
35
import java.io.IOException;
46
import java.util.Iterator;
57

src/net/sharksystem/asap/internals/ASAPOnlineMessageSender.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
4+
35
import java.io.IOException;
46
import java.util.Set;
57

src/net/sharksystem/asap/internals/ASAPOnlineMessageSenderEngineSide.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAPConnection;
45
import net.sharksystem.asap.protocol.ASAPOnlineMessageSource;
56
import net.sharksystem.asap.protocol.ASAP_1_0;

src/net/sharksystem/asap/internals/ASAPProtocolEngine.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAP_1_0;
45
import net.sharksystem.asap.protocol.ASAP_AssimilationPDU_1_0;
56
import net.sharksystem.asap.protocol.ASAP_Interest_PDU_1_0;

src/net/sharksystem/asap/internals/ASAPSingleProcessOnlineMessageSender.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.protocol.ASAPConnection;
45
import net.sharksystem.asap.protocol.ASAPOnlineMessageSource;
56

src/net/sharksystem/asap/internals/ASAPStorage.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.internals;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.management.ASAPManagementStorage;
45

56
import java.io.IOException;

src/net/sharksystem/asap/management/ASAPManagementMessage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.management;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44
import net.sharksystem.asap.protocol.ASAP_1_0;
55
import net.sharksystem.asap.protocol.ASAP_PDU_1_0;
66

src/net/sharksystem/asap/management/ASAPManagementMessageHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.management;
22

3+
import net.sharksystem.asap.ASAPException;
34
import net.sharksystem.asap.internals.*;
45
import net.sharksystem.asap.protocol.ASAP_1_0;
56

src/net/sharksystem/asap/management/ASAPManagementStorage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.management;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44

55
import java.io.IOException;
66
import java.util.Collection;

src/net/sharksystem/asap/management/ASAPManagementStorageImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem.asap.management;
22

33
import net.sharksystem.asap.internals.ASAPEngine;
4-
import net.sharksystem.asap.internals.ASAPException;
4+
import net.sharksystem.asap.ASAPException;
55

66
import java.io.IOException;
77
import java.util.Collection;

src/net/sharksystem/asap/protocol/ASAPCryptoMessage.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
4-
import net.sharksystem.asap.internals.ASAPSecurityException;
3+
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.ASAPSecurityException;
55
import net.sharksystem.crypto.BasicKeyStore;
66
import net.sharksystem.crypto.ASAPCryptoAlgorithms;
77
import net.sharksystem.utils.ASAPSerialization;

src/net/sharksystem/asap/protocol/ASAPExecTimeExceededException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44

55
public class ASAPExecTimeExceededException extends ASAPException {
66
public ASAPExecTimeExceededException() {

src/net/sharksystem/asap/protocol/ASAPPersistentConnection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44
import net.sharksystem.asap.internals.ASAPInternalPeer;
55
import net.sharksystem.asap.internals.ASAPUndecryptableMessageHandler;
66
import net.sharksystem.asap.internals.EngineSetting;

src/net/sharksystem/asap/protocol/ASAPProtocolEngine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
3+
import net.sharksystem.asap.ASAPException;
44
import net.sharksystem.asap.internals.ASAPUndecryptableMessageHandler;
55
import net.sharksystem.crypto.BasicKeyStore;
66

src/net/sharksystem/asap/protocol/ASAP_1_0.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
4-
import net.sharksystem.asap.internals.ASAPSecurityException;
3+
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.ASAPSecurityException;
55
import net.sharksystem.crypto.ASAPCommunicationCryptoSettings;
66

77
import java.io.IOException;

src/net/sharksystem/asap/protocol/ASAP_Modem_Impl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem.asap.protocol;
22

3-
import net.sharksystem.asap.internals.ASAPException;
4-
import net.sharksystem.asap.internals.ASAPSecurityException;
3+
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.ASAPSecurityException;
55
import net.sharksystem.asap.internals.ASAPUndecryptableMessageHandler;
66
import net.sharksystem.crypto.ASAPCryptoAlgorithms;
77
import net.sharksystem.crypto.BasicKeyStore;

0 commit comments

Comments
 (0)