Skip to content

Commit 85d14a0

Browse files
committed
Create notebookserver instance manually
1 parent a7b82aa commit 85d14a0

File tree

5 files changed

+57
-69
lines changed

5 files changed

+57
-69
lines changed

zeppelin-server/pom.xml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@
9595
<version>${cxf.version}</version>
9696
</dependency>
9797

98-
<dependency>
99-
<groupId>org.java-websocket</groupId>
100-
<artifactId>Java-WebSocket</artifactId>
101-
<version>1.3.0</version>
102-
</dependency>
103-
10498
<!-- Swagger -->
10599
<dependency>
106100
<groupId>com.wordnik</groupId>
@@ -297,19 +291,9 @@
297291
</dependency>
298292

299293
<dependency>
300-
<groupId>org.atmosphere</groupId>
301-
<artifactId>atmosphere-jersey</artifactId>
302-
<version>2.2.0</version>
303-
<exclusions>
304-
<exclusion>
305-
<groupId>com.sun.jersey</groupId>
306-
<artifactId>jersey-server</artifactId>
307-
</exclusion>
308-
<exclusion>
309-
<groupId>javax.ws.rs</groupId>
310-
<artifactId>javax.ws.rs-api</artifactId>
311-
</exclusion>
312-
</exclusions>
294+
<groupId>com.sun.jersey</groupId>
295+
<artifactId>jersey-servlet</artifactId>
296+
<version>1.13</version>
313297
</dependency>
314298

315299
<dependency>

zeppelin-server/src/main/java/org/apache/zeppelin/server/AppScriptServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
8383
int endIndex = script.indexOf(endReplaceString, startIndex);
8484

8585
if (startIndex >= 0 && endIndex >= 0) {
86-
Server server = ZeppelinServer.jettyServer;
87-
String replaceString = "this.getPort=function(){return " + ZeppelinServer.jettyServer.getConnectors()[0].getLocalPort() + "};";
86+
String replaceString = "this.getPort=function(){return "
87+
+ ZeppelinServer.jettyServer.getConnectors()[0].getLocalPort() + "};";
8888
script.replace(startIndex, endIndex + endReplaceString.length(), replaceString);
8989
}
9090

zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import javax.net.ssl.SSLContext;
2828
import javax.servlet.DispatcherType;
29+
import javax.servlet.Servlet;
2930
import javax.ws.rs.core.Application;
3031

3132
import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
@@ -162,13 +163,14 @@ private static Server setupJettyServer(ZeppelinConfiguration conf)
162163
private static ServletContextHandler setupNotebookServer(ZeppelinConfiguration conf)
163164
throws Exception {
164165

165-
final ServletHolder notebookServer = new ServletHolder("ws", NotebookServer.class);
166+
notebookServer = new NotebookServer();
167+
final ServletHolder servletHolder = new ServletHolder(notebookServer);
166168

167169
final ServletContextHandler cxfContext = new ServletContextHandler(
168170
ServletContextHandler.SESSIONS);
169171
cxfContext.setSessionHandler(new SessionHandler());
170172
cxfContext.setContextPath("/");
171-
cxfContext.addServlet(notebookServer, "/ws/*");
173+
cxfContext.addServlet(servletHolder, "/ws/*");
172174
cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*",
173175
EnumSet.allOf(DispatcherType.class));
174176
return cxfContext;

zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -91,51 +91,51 @@ public void onMessage(NotebookSocket conn, String msg) {
9191
LOG.info("RECEIVE << " + messagereceived.op);
9292
/** Lets be elegant here */
9393
switch (messagereceived.op) {
94-
case LIST_NOTES:
95-
broadcastNoteList();
96-
break;
97-
case GET_NOTE:
98-
sendNote(conn, notebook, messagereceived);
99-
break;
100-
case NEW_NOTE:
101-
createNote(conn, notebook);
102-
break;
103-
case DEL_NOTE:
104-
removeNote(conn, notebook, messagereceived);
105-
break;
106-
case COMMIT_PARAGRAPH:
107-
updateParagraph(conn, notebook, messagereceived);
108-
break;
109-
case RUN_PARAGRAPH:
110-
runParagraph(conn, notebook, messagereceived);
111-
break;
112-
case CANCEL_PARAGRAPH:
113-
cancelParagraph(conn, notebook, messagereceived);
114-
break;
115-
case MOVE_PARAGRAPH:
116-
moveParagraph(conn, notebook, messagereceived);
117-
break;
118-
case INSERT_PARAGRAPH:
119-
insertParagraph(conn, notebook, messagereceived);
120-
break;
121-
case PARAGRAPH_REMOVE:
122-
removeParagraph(conn, notebook, messagereceived);
123-
break;
124-
case NOTE_UPDATE:
125-
updateNote(conn, notebook, messagereceived);
126-
break;
127-
case COMPLETION:
128-
completion(conn, notebook, messagereceived);
129-
break;
130-
case PING:
131-
pong();
132-
break;
133-
case ANGULAR_OBJECT_UPDATED:
134-
angularObjectUpdated(conn, notebook, messagereceived);
135-
break;
136-
default:
137-
broadcastNoteList();
138-
break;
94+
case LIST_NOTES:
95+
broadcastNoteList();
96+
break;
97+
case GET_NOTE:
98+
sendNote(conn, notebook, messagereceived);
99+
break;
100+
case NEW_NOTE:
101+
createNote(conn, notebook);
102+
break;
103+
case DEL_NOTE:
104+
removeNote(conn, notebook, messagereceived);
105+
break;
106+
case COMMIT_PARAGRAPH:
107+
updateParagraph(conn, notebook, messagereceived);
108+
break;
109+
case RUN_PARAGRAPH:
110+
runParagraph(conn, notebook, messagereceived);
111+
break;
112+
case CANCEL_PARAGRAPH:
113+
cancelParagraph(conn, notebook, messagereceived);
114+
break;
115+
case MOVE_PARAGRAPH:
116+
moveParagraph(conn, notebook, messagereceived);
117+
break;
118+
case INSERT_PARAGRAPH:
119+
insertParagraph(conn, notebook, messagereceived);
120+
break;
121+
case PARAGRAPH_REMOVE:
122+
removeParagraph(conn, notebook, messagereceived);
123+
break;
124+
case NOTE_UPDATE:
125+
updateNote(conn, notebook, messagereceived);
126+
break;
127+
case COMPLETION:
128+
completion(conn, notebook, messagereceived);
129+
break;
130+
case PING:
131+
pong();
132+
break;
133+
case ANGULAR_OBJECT_UPDATED:
134+
angularObjectUpdated(conn, notebook, messagereceived);
135+
break;
136+
default:
137+
broadcastNoteList();
138+
break;
139139
}
140140
} catch (Exception e) {
141141
LOG.error("Can't handle message", e);

zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookSocket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.apache.zeppelin.socket;
22

33
import java.io.IOException;
4-
import java.util.List;
54

65
import javax.servlet.http.HttpServletRequest;
76

87
import org.eclipse.jetty.websocket.WebSocket;
98

9+
/**
10+
* Notebook websocket
11+
*/
1012
public class NotebookSocket implements WebSocket.OnTextMessage{
1113

1214
private Connection connection;

0 commit comments

Comments
 (0)