MCPcopy Index your code
hub / github.com/processing/processing / launch

Method launch

app/src/processing/app/WebServer.java:109–161  ·  view source on GitHub ↗
(String zipPath)

Source from the content-addressed store, hash-verified

107
108 //public static void main(String[] a) throws Exception {
109 static public int launch(String zipPath) throws IOException {
110 final ZipFile zip = new ZipFile(zipPath);
111 final Map<String, ZipEntry> entries = new HashMap<String, ZipEntry>();
112 Enumeration en = zip.entries();
113 while (en.hasMoreElements()) {
114 ZipEntry entry = (ZipEntry) en.nextElement();
115 entries.put(entry.getName(), entry);
116 }
117
118// if (a.length > 0) {
119// port = Integer.parseInt(a[0]);
120// }
121// loadProps();
122// printProps();
123 // start worker threads
124 for (int i = 0; i < workers; ++i) {
125 WebServerWorker w = new WebServerWorker(zip, entries);
126 Thread t = new Thread(w, "Web Server Worker #" + i);
127 t.start();
128 threads.addElement(w);
129 }
130
131 final int port = 8080;
132
133 //SwingUtilities.invokeLater(new Runnable() {
134 Runnable r = new Runnable() {
135 public void run() {
136 try {
137 ServerSocket ss = new ServerSocket(port);
138 while (true) {
139 Socket s = ss.accept();
140 WebServerWorker w = null;
141 synchronized (threads) {
142 if (threads.isEmpty()) {
143 WebServerWorker ws = new WebServerWorker(zip, entries);
144 ws.setSocket(s);
145 (new Thread(ws, "additional worker")).start();
146 } else {
147 w = (WebServerWorker) threads.elementAt(0);
148 threads.removeElementAt(0);
149 w.setSocket(s);
150 }
151 }
152 }
153 } catch (IOException e) {
154 e.printStackTrace();
155 }
156 }
157 };
158 new Thread(r).start();
159// });
160 return port;
161 }
162}
163
164

Callers

nothing calls this directly

Calls 4

entriesMethod · 0.45
putMethod · 0.45
getNameMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected