/** * This method should setup the flags/switches for the java command which will determine the * actual command to be executed. * * <p>Sets up flags like : * * <ul> * <li>-Dem.home * <li>-Dprocess.name * </ul> * * <br> * add computes the classpath. */ protected void updateFlags(ServerCommand serverCmd) { String bootDir = System.getProperty("em.home"); String appType = System.getProperty("appType"); String appInst = System.getProperty("appInst"); String javaClasspath = serverCmd.getClasspath(); String processName = getProcessNameForLog(); List jvmFlags = serverCmd.getJVMFlags(); int cpToken = -1; for (int i = 0; i < jvmFlags.size(); i++) { String token = (String) jvmFlags.get(i); if (token.startsWith("-classpath")) { cpToken = i; javaClasspath = null; } else if (token.startsWith("-Dem.home")) { bootDir = null; } else if (token.startsWith("-Dprocess.name")) { processName = null; } } List addonJVMFlags = new LinkedList(); if (bootDir != null) { addonJVMFlags.add("-Dem.home=" + bootDir); } if (processName != null) { addonJVMFlags.add("-Dprocess.name=" + processName); } if (!(appType == null || appType.trim().equals(""))) { addonJVMFlags.add("-DappType=" + appType); } if (!(appInst == null || appInst.trim().equals(""))) { addonJVMFlags.add("-DappInst=" + appInst); } if (cpToken != -1) { jvmFlags.remove(cpToken); String str = (String) jvmFlags.remove(cpToken); serverCmd.setClasspath(str); } jvmFlags.addAll(addonJVMFlags); }
/** * Deletes a meeting from the database * * <p>- Requires a cookie for the session user - Requires a meetingId request parameter for the * HTTP GET * * @param req The HTTP Request * @param res The HTTP Response */ public void deletemeetingAction(HttpServletRequest req, HttpServletResponse res) { // Ensure there is a cookie for the session user if (AccountController.redirectIfNoCookie(req, res)) return; if (req.getMethod() == HttpMethod.Get) { // Get the meeting int meetingId = Integer.parseInt(req.getParameter("meetingId")); MeetingManager meetingMan = new MeetingManager(); Meeting meeting = meetingMan.get(meetingId); meetingMan.deleteMeeting(meetingId); // Update the User Session to remove meeting HttpSession session = req.getSession(); Session userSession = (Session) session.getAttribute("userSession"); List<Meeting> adminMeetings = userSession.getUser().getMeetings(); for (int i = 0; i < adminMeetings.size(); i++) { Meeting m = adminMeetings.get(i); if (m.getId() == meeting.getId()) { adminMeetings.remove(i); break; } } redirectToLocal(req, res, "/home/dashboard"); return; } else if (req.getMethod() == HttpMethod.Post) { httpNotFound(req, res); } }
/** * Receives a <tt>DatagramPacket</tt> from a specific list of <tt>DatagramPacket</tt>s if it is * not empty or from the network if the specified list is empty. When this method returns, the * <tt>DatagramPacket</tt>'s buffer is filled with the data received. The datagram packet also * contains the sender's IP address, and the port number on the sender's machine. * * @param received the list of previously received <tt>DatagramPacket</tt> from which the first is * to be removed and returned if available * @param p the <tt>DatagramPacket</tt> into which to place the incoming data * @throws IOException if an I/O error occurs */ private void receive(List<DatagramPacket> received, DatagramPacket p) throws IOException { DatagramPacket r = null; do { boolean doReceive; synchronized (receiveSyncRoot) { if (received.isEmpty()) { if (inReceive) { doReceive = false; try { receiveSyncRoot.wait(); } catch (InterruptedException iex) { continue; } } else { doReceive = true; inReceive = true; } } else { doReceive = false; r = received.remove(0); } } if (doReceive) { try { super.receive(p); synchronized (receiveSyncRoot) { synchronized (socketsSyncRoot) { boolean accepted = false; for (MultiplexedDatagramSocket socket : sockets) if (socket.getFilter().accept(p)) { socket.received.add(clone(p)); accepted = true; /* * Emil: Don't break because we want all * filtering sockets to get this. */ // break; } if (!accepted) this.received.add(clone(p)); } } } finally { synchronized (receiveSyncRoot) { inReceive = false; receiveSyncRoot.notify(); } } } } while (r == null); copy(r, p); }
public void removeSchedulerListener(SchedulerListener schedulerListener) { if (schedulerListener != null) { List<SchedulerListener> l = listeners; if (l != null) { synchronized (l) { l.remove(schedulerListener); } } } }
/** Receive notification of the end of an element. */ @Override public void endElement(String uri, String l, String q) { /* * 1. If current element is a String, update its value from the string buffer. * 2. Add the element to parent. */ ElementInfo element = _stack.remove(_stack.size() - 1); _logger.fine("endElement " + element); if (element.type == null) { _logger.warning("Element " + element.name + " not created "); return; } else if (_chars.length() > 0) { try { injectProperty(element.data, String.class, _chars.toString(), null, null); } catch (Exception x) { if (!_lenient) { throw new BeanAssemblyException( "Failed to set characters to object " + element.type.getName(), x); } else { _logger.warning("Failed to set characters to parent " + element.data); } } } _chars.setLength(0); _logger.fine( "<<ElementInfo: " + element.type.getName() + " in " + element + "\n @as is " + element.inst.get("@as") + "\n @id is " + element.inst.get("@id")); if (List.class.isAssignableFrom(element.data.getClass()) && element.name.endsWith("...")) { List<?> list = (List<?>) element.data; Object array = Array.newInstance(element.type, list.size()); for (int i = 0; i < list.size(); ++i) { Array.set(array, i, list.get(i)); } element.data = array; } String id = element.inst.get("@id"); if (id != null) { // locally stored object - not added to the parent _local.put(id, element); } else if (!_stack.isEmpty()) { // inject into the parent as a property ElementInfo parent = _stack.get(_stack.size() - 1); _logger.fine("Parent is " + parent.data.getClass().getName()); try { String as = element.inst.get("@as"); if (as != null) { injectProperty( parent.data, element.type, element.data, Strings.toCamelCase(as, '-', false), element.args.complete()); } else { injectProperty(parent.data, element.type, element.data, null, element.args.complete()); } } catch (Exception x) { if (!_lenient) { throw new BeanAssemblyException( "Failed to set value " + element.data + " to parent " + parent.data, x); } else { _logger.log( Level.WARNING, "Failed to set value " + element.data + " to parent " + parent.data, x); } } } _top = element.data; }