|
36 | 36 | import java.util.concurrent.Future;
|
37 | 37 | import java.util.concurrent.TimeUnit;
|
38 | 38 |
|
| 39 | +import javax.annotation.Nullable; |
39 | 40 | import javax.annotation.concurrent.ThreadSafe;
|
40 | 41 |
|
41 | 42 | import io.objectbox.annotation.apihint.Beta;
|
| 43 | +import io.objectbox.annotation.apihint.Experimental; |
42 | 44 | import io.objectbox.annotation.apihint.Internal;
|
43 | 45 | import io.objectbox.converter.PropertyConverter;
|
44 | 46 | import io.objectbox.exception.DbException;
|
@@ -129,12 +131,12 @@ static native void nativeRegisterCustomType(long store, int entityId, int proper
|
129 | 131 |
|
130 | 132 | static native int nativeCleanStaleReadTransactions(long store);
|
131 | 133 |
|
132 |
| - static native String startDataBrowser(long store, String urlPath, int port); |
| 134 | + static native String startObjectBrowser(long store, String urlPath, int port); |
133 | 135 |
|
134 |
| - public static native boolean isDataBrowserAvailable(); |
| 136 | + public static native boolean isObjectBrowserAvailable(); |
135 | 137 |
|
136 | 138 | public static String getVersion() {
|
137 |
| - return "1.0.2-2017-09-26"; |
| 139 | + return "1.1.0-2017-10-01"; |
138 | 140 | }
|
139 | 141 |
|
140 | 142 | private final File directory;
|
@@ -162,6 +164,8 @@ public static String getVersion() {
|
162 | 164 | // Not atomic because it is read most of the time
|
163 | 165 | volatile int commitCount;
|
164 | 166 |
|
| 167 | + private int objectBrowserPort; |
| 168 | + |
165 | 169 | BoxStore(BoxStoreBuilder builder) {
|
166 | 170 | NativeLibraryLoader.ensureLoaded();
|
167 | 171 |
|
@@ -664,8 +668,46 @@ public SubscriptionBuilder<Class> subscribe() {
|
664 | 668 | return new SubscriptionBuilder<>(objectClassPublisher, null, threadPool);
|
665 | 669 | }
|
666 | 670 |
|
667 |
| - public String startDataBrowser(int port) { |
668 |
| - return startDataBrowser(handle, null, port); |
| 671 | + @Experimental |
| 672 | + @Nullable |
| 673 | + public String startObjectBrowser() { |
| 674 | + verifyObjectBrowserNotRunning(); |
| 675 | + final int basePort = 8090; |
| 676 | + for (int port = basePort; port < basePort + 10; port++) { |
| 677 | + try { |
| 678 | + String url = startObjectBrowser(port); |
| 679 | + if (url != null) { |
| 680 | + return url; |
| 681 | + } |
| 682 | + } catch (DbException e) { |
| 683 | + if (e.getMessage() == null || !e.getMessage().contains("port")) { |
| 684 | + throw e; |
| 685 | + } |
| 686 | + } |
| 687 | + } |
| 688 | + return null; |
| 689 | + } |
| 690 | + |
| 691 | + @Experimental |
| 692 | + @Nullable |
| 693 | + public String startObjectBrowser(int port) { |
| 694 | + verifyObjectBrowserNotRunning(); |
| 695 | + String url = startObjectBrowser(handle, null, port); |
| 696 | + if (url != null) { |
| 697 | + objectBrowserPort = port; |
| 698 | + } |
| 699 | + return url; |
| 700 | + } |
| 701 | + |
| 702 | + @Experimental |
| 703 | + public int getObjectBrowserPort() { |
| 704 | + return objectBrowserPort; |
| 705 | + } |
| 706 | + |
| 707 | + private void verifyObjectBrowserNotRunning() { |
| 708 | + if (objectBrowserPort != 0) { |
| 709 | + throw new DbException("ObjectBrowser is already running at port " + objectBrowserPort); |
| 710 | + } |
669 | 711 | }
|
670 | 712 |
|
671 | 713 | /**
|
|
0 commit comments