public static synchronized void createLoggers(boolean reinit) { if (m_initialized == true && reinit == false) { return; } if (!m_initialized) { Logger.getLogger("").removeHandler(Logger.getLogger("").getHandlers()[0]); } if (m_initialized) { m_severeLogger.removeHandler(m_severeLogger.getHandlers()[0]); m_nonSevereLogger.removeHandler(m_nonSevereLogger.getHandlers()[0]); } Handler severeHandler = new AMyConsoleHandler(System.err); severeHandler.setFormatter(new SingleLineFormatter()); m_severeLogger.addHandler(severeHandler); m_severeLogger.setLevel(getLoggingLevel()); Handler nonSevereHandler = new AMyConsoleHandler(System.out); nonSevereHandler.setFormatter(new SingleLineFormatter()); m_nonSevereLogger.addHandler(nonSevereHandler); m_nonSevereLogger.setLevel(getLoggingLevel()); m_initialized = true; }
public void stop() { running = false; for (Handler handler : logger.getHandlers()) { handler.flush(); handler.close(); } }
private boolean handleFault(int i) { Handler handler = _chain.get(i); boolean success = false; _invoked[i] = true; try { if (handler instanceof LogicalHandler) { _logicalContext.getMessage().setPayload(_source); success = handler.handleFault(_logicalContext); _source = _logicalContext.getMessage().getPayload(); } else if (handler instanceof SOAPHandler) { try { _soapContext.setMessage(_source); success = handler.handleFault(_soapContext); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException e) { throw new WebServiceException(e); } } else { throw new WebServiceException( L.l("Unsupported Handler type: {0}", handler.getClass().getName())); } _protocolException = null; } catch (ProtocolException e) { _protocolException = e; serializeProtocolException(); } catch (RuntimeException e) { _runtimeException = e; serializeRuntimeException(); } return success; }
public void preprocess(Run run) { File logFile = new File(getRunDir(run), "genetik.log"); try { SimpleFileHandler fh = new SimpleFileHandler(logFile); fh.setFormatter(new CompactFormatter()); Logger logger = Logger.getLogger(GenetikConstants.LOGGER); logger.setLevel(Level.INFO); logger.setUseParentHandlers(false); Handler handlers[] = logger.getHandlers(); logger.addHandler(fh); for (Handler h : handlers) { logger.removeHandler(h); if (h instanceof SimpleFileHandler) h.close(); // close our old one } } catch (Exception exp) { throw new IllegalArgumentException( "Unable to create log file at " + logFile.getAbsolutePath()); } super.preprocess(run); }
public void startFile(String logfile) { File parent = new File(logfile).getParentFile(); if (!parent.isDirectory() && !parent.mkdirs()) { logger.warning("Could not create log folder: " + parent); } Handler fileHandler = new RotatingFileHandler(logfile); fileHandler.setFormatter(new DateOutputFormatter(FILE_DATE, false)); logger.addHandler(fileHandler); }
private void dispatch() throws IOException { sel.select(); for (Iterator i = sel.selectedKeys().iterator(); i.hasNext(); ) { SelectionKey sk = (SelectionKey) i.next(); i.remove(); Handler h = (Handler) sk.attachment(); h.handle(sk); } }
public String toString() { StringBuilder sb = new StringBuilder("HandlerChainInvoker[\n"); for (Handler handler : _chain) { sb.append(handler.toString()); sb.append('\n'); } sb.append(']'); return sb.toString(); }
/** Cancel loading of a drawable for a certain ImageView. */ public void cancelLoad(ImageView view) { String fso = mRequests.get(view); if (fso != null && mWorkerHandler != null) { mWorkerHandler.removeMessages(MSG_LOAD, fso); } mRequests.remove(view); }
@Override public int hashCode() { int result = methodMatcher.hashCode(); result = 31 * result + handler.hashCode(); result = 31 * result + attributeAppenderFactory.hashCode(); result = 31 * result + methodTransformer.hashCode(); return result; }
@Override public int hashCode() { int result = handler.hashCode(); result = 31 * result + attributeAppenderFactory.hashCode(); result = 31 * result + methodDescription.hashCode(); result = 31 * result + typeTokens.hashCode(); return result; }
public static void start() { // ChumbyLog.i("NotificationEvents.start()"); final Handler handler = new Handler() { public void handleMessage(Message message) { switch (message.what) { case POLL_NOTIFICATIONS: NotificationEvents.getInstance().fetch(); break; default: super.handleMessage(message); } this.sendMessageDelayed(Message.obtain(this, POLL_NOTIFICATIONS), POLL_INTERVAL); } }; handler.sendMessageDelayed(Message.obtain(handler, POLL_NOTIFICATIONS), POLL_INTERVAL); }
@Override public boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; Entry entry = (Entry) other; return methodMatcher.equals(entry.methodMatcher) && handler.equals(entry.handler) && attributeAppenderFactory.equals(entry.attributeAppenderFactory) && methodTransformer.equals(entry.methodTransformer); }
public void deployModuleFromZip( String zipFileName, JsonObject config, int instances, Handler<String> doneHandler) { final String modName = zipFileName.substring(0, zipFileName.length() - 4); ModuleIdentifier modID = new ModuleIdentifier("__vertx_tmp#" + modName + "#__vertx_tmp"); if (unzipModule(modID, new ModuleZipInfo(false, zipFileName), false)) { deployModule(modID.toString(), config, instances, doneHandler); } else { doneHandler.handle(null); } }
@Override public boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; Entry entry = (Entry) other; return handler.equals(entry.handler) && attributeAppenderFactory.equals(entry.attributeAppenderFactory) && methodDescription.equals(entry.methodDescription) && typeTokens.equals(entry.typeTokens); }
private void close(int i) { Handler handler = _chain.get(i); if (!_invoked[i]) return; _invoked[i] = false; if (handler instanceof LogicalHandler) { _logicalContext.getMessage().setPayload(_source); handler.close(_logicalContext); _source = _logicalContext.getMessage().getPayload(); } else if (handler instanceof SOAPHandler) { try { _soapContext.setMessage(_source); handler.close(_soapContext); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException e) { throw new WebServiceException(e); } } }
// Private method to reset an invidual target logger. private void resetLogger(String name) { Logger logger = getLogger(name); if (logger == null) { return; } // Close all the Logger's handlers. Handler[] targets = logger.getHandlers(); for (int i = 0; i < targets.length; i++) { Handler h = targets[i]; logger.removeHandler(h); try { h.close(); } catch (Exception ex) { // Problems closing a handler? Keep going... } } if (name != null && name.equals("")) { // This is the root logger. logger.setLevel(defaultLevel); } else { logger.setLevel(null); } }
public void handleMessage(Message msg) { Ball B; for (int idx = 0; idx < arBall.size(); idx++) { B = arBall.get(idx); B.Move(getWidth(), getHeight()); if (B.count > 4) { arBall.remove(idx); idx--; } } invalidate(); mHandler.sendEmptyMessageDelayed(0, DELAY); }
public void getFilesFromFolder(List filesAndFolders, String savePath) { // create a File object for the parent directory File downloadsDirectory = new File(savePath); // create the folder if needed. downloadsDirectory.mkdir(); for (int i = 0; i < filesAndFolders.size(); i++) { Object links = filesAndFolders.get(i); List linksArray = (ArrayList) links; if (i == 0) { for (int j = 0; j < linksArray.size(); j += 2) { // We've got an array of file urls so download each one to a directory with the folder // name String fileURL = linksArray.get(j).toString(); String fileName = linksArray.get(j + 1).toString(); downloadFile(fileURL, savePath, fileName); progress++; Message msg = mHandler.obtainMessage(); msg.arg1 = progress; mHandler.sendMessage(msg); } } else if (i == 1) { // we've got an array of folders so recurse down the levels, extracting subfolders and files // until we've downloaded everything. for (int j = 0; j < linksArray.size(); j += 2) { String folderURL = linksArray.get(j).toString(); String folderName = linksArray.get(j + 1).toString(); String page = getData(folderURL); List newFilesAndFolders = parsePage(page); String dlDirPath = savePath + folderName + "/"; getFilesFromFolder(newFilesAndFolders, dlDirPath); } } } }
public static Logger initLogger() { Logger initlogger = Logger.getLogger(settings.getMainClass()); initlogger.setLevel(settings.getLogLevel()); boolean addconsole = false; if (settings.getLogToFile()) { try { Handler handler = new FileHandler(settings.getLogFile(), true); handler.setFormatter(new SimpleFormatter()); initlogger.addHandler(handler); } catch (Exception e) { Logger().warning("Could not set logfile " + settings.getLogFile() + ": " + e.getMessage()); addconsole = true; } } addconsole = settings.getLogToConsole() || addconsole; if (addconsole) { initlogger.addHandler(new ConsoleHandler()); } // restore original log state logger.setLevel(templevel); templevel = null; return initlogger; }
@Override protected void onNewIntent(Intent intent) { if (checkLaunchState(LaunchState.GeckoExiting)) { // We're exiting and shouldn't try to do anything else just incase // we're hung for some reason we'll force the process to exit System.exit(0); return; } final String action = intent.getAction(); if (ACTION_DEBUG.equals(action) && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) { mMainHandler.postDelayed( new Runnable() { public void run() { Log.i(LOG_FILE_NAME, "Launching from debug intent after 5s wait"); setLaunchState(LaunchState.Launching); launch(null); } }, 1000 * 5 /* 5 seconds */); Log.i(LOG_FILE_NAME, "Intent : ACTION_DEBUG - waiting 5s before launching"); return; } if (checkLaunchState(LaunchState.WaitForDebugger) || launch(intent)) return; if (Intent.ACTION_MAIN.equals(action)) { Log.i(LOG_FILE_NAME, "Intent : ACTION_MAIN"); GeckoAppShell.sendEventToGecko(new GeckoEvent("")); } else if (Intent.ACTION_VIEW.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(new GeckoEvent(uri)); Log.i(LOG_FILE_NAME, "onNewIntent: " + uri); } else if (ACTION_WEBAPP.equals(action)) { String uri = intent.getStringExtra("args"); GeckoAppShell.sendEventToGecko(new GeckoEvent(uri)); Log.i(LOG_FILE_NAME, "Intent : WEBAPP - " + uri); } else if (ACTION_BOOKMARK.equals(action)) { String args = intent.getStringExtra("args"); GeckoAppShell.sendEventToGecko(new GeckoEvent(args)); Log.i(LOG_FILE_NAME, "Intent : BOOKMARK - " + args); } }
@Override public void handleDownloadThreadUpdate() { handler.post( new Runnable() { @Override public void run() { // total_files_to_download = downloadThread.getTotalQueued(); total_files_to_download = links.size(); if (downloadThread != null) { completed_downloads = downloadThread.getTotalCompleted() + initial_value; } else { completed_downloads = readProgress()[0]; } progress_download.setMax(links.size()); // progress_download.incrementProgressBy(1); progress_download.setProgress(0); // need to do it due to a ProgressBar bug progress_download.setProgress(completed_downloads); progress_text.setText( "Downloading " + Integer.toString(completed_downloads + 1) + " of " + Integer.toString(links.size()) + "."); // writeProgress(completed_downloads,total_files_to_download); if (completed_downloads == total_files_to_download) { completed = true; writeProgress(completed_downloads, total_files_to_download); if (resume_pause.VISIBLE != View.GONE) resume_pause.setVisibility(View.GONE); downloadThread.requestStop(); progress_text.setText("Completed."); } } }); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { mAppContext = this; mMainHandler = new Handler(); if (!sTryCatchAttached) { sTryCatchAttached = true; mMainHandler.post( new Runnable() { public void run() { try { Looper.loop(); } catch (Exception e) { Log.e(LOG_FILE_NAME, "top level exception", e); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); pw.flush(); GeckoAppShell.reportJavaCrash(sw.toString()); } // resetting this is kinda pointless, but oh well sTryCatchAttached = false; } }); } SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE); String localeCode = settings.getString(getPackageName() + ".locale", ""); if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode); Log.i(LOG_FILE_NAME, "create"); super.onCreate(savedInstanceState); if (sGREDir == null) sGREDir = new File(this.getApplicationInfo().dataDir); getWindow() .setFlags( mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (cameraView == null) { cameraView = new SurfaceView(this); cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } if (surfaceView == null) surfaceView = new GeckoSurfaceView(this); else mainLayout.removeAllViews(); mainLayout = new AbsoluteLayout(this); mainLayout.addView( surfaceView, new AbsoluteLayout.LayoutParams( AbsoluteLayout.LayoutParams.MATCH_PARENT, // level 8 AbsoluteLayout.LayoutParams.MATCH_PARENT, 0, 0)); setContentView( mainLayout, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); mConnectivityFilter = new IntentFilter(); mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); mConnectivityReceiver = new GeckoConnectivityReceiver(); IntentFilter batteryFilter = new IntentFilter(); batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED); mBatteryReceiver = new GeckoBatteryManager(); registerReceiver(mBatteryReceiver, batteryFilter); if (SmsManager.getInstance() != null) { SmsManager.getInstance().start(); } GeckoNetworkManager.getInstance().init(); if (!checkAndSetLaunchState(LaunchState.PreLaunch, LaunchState.Launching)) return; checkAndLaunchUpdate(); mLibLoadThread = new Thread( new Runnable() { public void run() { // At some point while loading the gecko libs our default locale gets set // so just save it to locale here and reset it as default after the join Locale locale = Locale.getDefault(); GeckoAppShell.loadGeckoLibs(getApplication().getPackageResourcePath()); Locale.setDefault(locale); Resources res = getBaseContext().getResources(); Configuration config = res.getConfiguration(); config.locale = locale; res.updateConfiguration(config, res.getDisplayMetrics()); } }); mLibLoadThread.start(); }
public void actionPerformed(ActionEvent ae) { if (paths != null && paths.size() > 0) { dialog = new LockDialog(getView(), paths, false, remote); GUIUtils.center(getView(), dialog); dialog.setVisible(true); final CommitData data = dialog.getData(); if (data == null) { return; // null means user canceled } if (getUsername() == null) { verifyLogin(data.getPaths() == null ? null : data.getPaths().get(0)); if (isCanceled()) { return; } } data.setUsername(getUsername()); data.setPassword(getPassword()); data.setOut(new ConsolePrintStream(getView())); getView().getDockableWindowManager().showDockableWindow("subversion"); final OutputPanel panel = SVNPlugin.getOutputPanel(getView()); panel.showConsole(); final Logger logger = panel.getLogger(); logger.log(Level.INFO, jEdit.getProperty("ips.Unlocking_...", "Unlocking ...")); for (Handler handler : logger.getHandlers()) { handler.flush(); } class Runner extends SwingWorker<LockResults, Object> { @Override public LockResults doInBackground() { try { Lock lock = new Lock(); return lock.unlock(data); } catch (Exception e) { data.getOut().printError(e.getMessage()); } finally { data.getOut().close(); } return null; } @Override public boolean cancel(boolean mayInterruptIfRunning) { boolean cancelled = super.cancel(mayInterruptIfRunning); if (cancelled) { data.getOut().printError("Stopped 'Unlock' action."); data.getOut().close(); } else { data.getOut().printError("Unable to stop 'Unlock' action."); } return cancelled; } @Override protected void done() { if (isCancelled()) { return; } try { JPanel results_panel = new AddResultsPanel( get(), AddResultsPanel.UNLOCK, getView(), getUsername(), getPassword()); panel.addTab(jEdit.getProperty("ips.Unlocked", "Unlocked"), results_panel); } catch (Exception e) { // NOPMD // ignored } } } Runner runner = new Runner(); panel.addWorker("Unlock", runner); runner.execute(); } }
/** * The JList used for representing the files is created by subclasses, but the selection is * monitored in this class. The TransferHandler installed in the JFileChooser is also installed * in the file list as it is used as the actual transfer source. The list is updated on a mouse * enter to reflect the current data transfer state of the file chooser. */ public void mouseEntered(MouseEvent e) { handler.mouseEntered(e); }
public void mouseClicked(MouseEvent e) { handler.mouseClicked(e); }
/** Cleanup the axis2 environment and stop the synapse environment. */ public void stop() { try { // stop tasks SynapseTaskManager synapseTaskManager = synapseEnvironment.getTaskManager(); if (synapseTaskManager.isInitialized()) { synapseTaskManager.cleanup(); } EnterpriseBeanstalkManager manager = (EnterpriseBeanstalkManager) serverContextInformation.getProperty( EnterpriseBeanstalkConstants.BEANSTALK_MANAGER_PROP_NAME); if (manager != null) { manager.destroy(); } // stop the listener manager if (listenerManager != null) { listenerManager.stop(); } // detach the synapse handlers if (configurationContext != null) { List<Phase> inflowPhases = configurationContext.getAxisConfiguration().getInFlowPhases(); for (Phase inPhase : inflowPhases) { // we are interested about the Dispatch phase in the inflow if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) { List<HandlerDescription> synapseHandlers = new ArrayList<HandlerDescription>(); for (Handler handler : inPhase.getHandlers()) { if (SynapseDispatcher.NAME.equals(handler.getName()) || SynapseMustUnderstandHandler.NAME.equals(handler.getName())) { synapseHandlers.add(handler.getHandlerDesc()); } } for (HandlerDescription handlerMD : synapseHandlers) { inPhase.removeHandler(handlerMD); } } } } else { handleException( "Couldn't detach the Synapse handlers, " + "ConfigurationContext not found."); } // continue stopping the axis2 environment if we created it if (serverConfigurationInformation.isCreateNewInstance() && configurationContext != null && configurationContext.getAxisConfiguration() != null) { Map<String, AxisService> serviceMap = configurationContext.getAxisConfiguration().getServices(); for (AxisService svc : serviceMap.values()) { svc.setActive(false); } // stop all modules Map<String, AxisModule> moduleMap = configurationContext.getAxisConfiguration().getModules(); for (AxisModule mod : moduleMap.values()) { if (mod.getModule() != null && !"synapse".equals(mod.getName())) { mod.getModule().shutdown(configurationContext); } } } } catch (AxisFault e) { log.error("Error stopping the Axis2 Environment"); } }
@Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); ßløødy_ßadßøy_Handler.removeCallbacks(Arpan_Bløødy_ßãdboy); }
@Override public void startCoverAnimation() { ßløødy_ßadßøy_Handler.post(Arpan_Bløødy_ßãdboy); }
/** * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, * java.lang.String) */ public void endElement(String uri, String localName, String qName) throws SAXException { Handler thisAction = (Handler) stack.pop(); ((Handler) stack.peek()).keep(thisAction.create(gf)); }
void process(MessageContext synCtx) { if (log.isDebugEnabled()) { log.debug( "Processing message with ID: " + synCtx.getMessageID() + " through the " + "API: " + name); } synCtx.setProperty(RESTConstants.SYNAPSE_REST_API, getName()); synCtx.setProperty(RESTConstants.SYNAPSE_REST_API_VERSION, versionStrategy.getVersion()); synCtx.setProperty(RESTConstants.REST_API_CONTEXT, context); // Remove the API context part from the REST_URL_POSTFIX String restURLPostfix = (String) ((Axis2MessageContext) synCtx) .getAxis2MessageContext() .getProperty(NhttpConstants.REST_URL_POSTFIX); if (restURLPostfix != null) { if (!restURLPostfix.startsWith("/")) { restURLPostfix = "/" + restURLPostfix; } if (restURLPostfix.startsWith(context)) { restURLPostfix = restURLPostfix.substring(context.length()); if (versionStrategy instanceof URLBasedVersionStrategy) { String version = versionStrategy.getVersion(); if (restURLPostfix.startsWith(version)) { restURLPostfix = restURLPostfix.substring(version.length()); } else if (restURLPostfix.startsWith("/" + version)) { restURLPostfix = restURLPostfix.substring(version.length() + 1); } } ((Axis2MessageContext) synCtx) .getAxis2MessageContext() .setProperty(NhttpConstants.REST_URL_POSTFIX, restURLPostfix); } } for (Handler handler : handlers) { if (log.isDebugEnabled()) { log.debug( "Processing message with ID: " + synCtx.getMessageID() + " through " + "handler: " + handler.getClass().getName()); } boolean proceed; if (synCtx.isResponse()) { proceed = handler.handleResponse(synCtx); } else { proceed = handler.handleRequest(synCtx); } if (!proceed) { return; } } if (synCtx.isResponse()) { String resourceName = (String) synCtx.getProperty(RESTConstants.SYNAPSE_RESOURCE); if (resourceName != null) { Resource resource = resources.get(resourceName); if (resource != null) { resource.process(synCtx); } } else if (log.isDebugEnabled()) { log.debug("No resource information on the response: " + synCtx.getMessageID()); } return; } String path = RESTUtils.getFullRequestPath(synCtx); String subPath; if (versionStrategy.getVersionType().equals(VersionStrategyFactory.TYPE_URL)) { // for URL based // request --> http://{host:port}/context/version/path/to/resource subPath = path.substring(context.length() + versionStrategy.getVersion().length() + 1); } else { subPath = path.substring(context.length()); } if ("".equals(subPath)) { subPath = "/"; } synCtx.setProperty(RESTConstants.REST_SUB_REQUEST_PATH, subPath); org.apache.axis2.context.MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); String hostHeader = getHostHeader(msgCtx); if (hostHeader != null) { synCtx.setProperty( RESTConstants.REST_URL_PREFIX, msgCtx.getIncomingTransportName() + "://" + hostHeader); } Set<Resource> acceptableResources = new HashSet<Resource>(); for (Resource r : resources.values()) { if (r.canProcess(synCtx)) { acceptableResources.add(r); } } boolean processed = false; if (!acceptableResources.isEmpty()) { for (RESTDispatcher dispatcher : RESTUtils.getDispatchers()) { Resource resource = dispatcher.findResource(synCtx, acceptableResources); if (resource != null) { resource.process(synCtx); processed = true; break; } } } if (!processed) { if (log.isDebugEnabled()) { log.debug("No matching resource was found for the request: " + synCtx.getMessageID()); } Mediator sequence = synCtx.getSequence(RESTConstants.NO_MATCHING_RESOURCE_HANDLER); if (sequence != null) { sequence.mediate(synCtx); } } }