List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.solace.ExceptionHandler.java
/** * Creates the target configuration//w w w. j av a 2 s . c o m * * @param logger * an instance of a Logger * @param t * an instance of a Target configuration * @return the class/IExceptionHandler map */ private static Map<Class<? extends Exception>, IExceptionHandler> createTargetConfiguration( final Class<?> clazz, final ExceptionHandlers.Target t) { // if we do let's build up an instance and add it to the // registry Map<Class<? extends Exception>, IExceptionHandler> handlers = new HashMap<Class<? extends Exception>, IExceptionHandler>(); // create each exception/handler combo and add it to the // previously // created map for (ExceptionHandlers.Target.Handler h : t.getHandler()) { Exception exception = null; IExceptionHandler handler = null; try { exception = ReflectionUtil.<Exception>createInstance(h.getException()); handler = ReflectionUtil.<IExceptionHandler>createInstance(h.getClazz()); handlers.put(exception.getClass(), handler); } catch (Exception e) { ExceptionHandler.getInstance(ExceptionHandler.class).handle(null, String.format("{} has an incorrect configuration", t.getClazz()), e); } } return handlers; }
From source file:com.feilong.tools.net.httpclient3.HttpClientUtil.java
/** * ()use httpState to create httpmethod. * // w w w.j a va 2 s . c o m * @param httpMethod * the http method * @param httpClientConfig * the http client config * @return the http method * @throws HttpClientException * ?HttpClientUtilException? */ private static HttpMethod executeMethod(HttpMethod httpMethod, HttpClientConfig httpClientConfig) throws HttpClientException { HttpClient httpClient = new HttpClient(); // ? setAuthentication(httpMethod, httpClientConfig, httpClient); // ? setProxy(httpClientConfig, httpClient); try { if (log.isDebugEnabled()) { // String[] excludes = new String[] { "defaults" }; // HttpClientParams httpClientParams = httpClient.getParams(); // // log.debug("[httpClient.getParams()]:{}", JsonUtil.format(httpClientParams, excludes)); // // HttpMethodParams httpMethodParams = httpMethod.getParams(); // log.debug("[httpMethod.getParams()]:{}", JsonUtil.format(httpMethodParams, excludes)); Map<String, Object> map = getHttpMethodRequestAttributeMapForLog(httpMethod); String[] excludes = new String[] { "values", "elements" // "rawAuthority", // "rawCurrentHierPath", // "rawPath", // "rawPathQuery", // "rawQuery", // "rawScheme", // "rawURI", // "rawURIReference", // "rawUserinfo", // "rawFragment", // "rawHost", // "rawName", // "protocol", // "defaults", // "class" }; log.debug(JsonUtil.format(map, excludes)); } // ???? // ????????? // ?GetMethod? int statusCode = httpClient.executeMethod(httpMethod); if (statusCode != HttpStatus.SC_OK) { log.warn("statusCode is:[{}]", statusCode); } } catch (Exception e) { //SSL? //PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed Map<String, Object> map = getHttpMethodResponseAttributeMapForLog(httpMethod, httpClientConfig); log.error(e.getClass().getName() + " HttpMethodResponseAttributeMapForLog:" + JsonUtil.format(map), e); throw new HttpClientException(e); } return httpMethod; }
From source file:net.java.sip.communicator.impl.protocol.sip.xcap.BaseHttpXCapClient.java
/** * Shows an error and a short description. * @param ex the exception/*w ww. j a va 2s . c o m*/ */ static void showError(Exception ex, String title, String message) { try { if (title == null) title = SipActivator.getResources().getI18NString("impl.protocol.sip.XCAP_ERROR_TITLE"); if (message == null) message = title + "\n" + ex.getClass().getName() + ": " + ex.getLocalizedMessage(); if (SipActivator.getUIService() != null) SipActivator.getUIService().getPopupDialog().showMessagePopupDialog(message, title, PopupDialog.ERROR_MESSAGE); } catch (Throwable t) { logger.error("Error for error dialog", t); } }
From source file:com.swingtech.commons.util.ClassUtil.java
public static Object instantiateObject(final Class inClass, final Object[] args) { Constructor constructor = null; if (inClass == null) { throw new IllegalArgumentException("inClass can not be null."); }/*from w ww. j av a 2 s . c o m*/ try { constructor = inClass.getDeclaredConstructor(getClassArrayFromObjectArray(args)); return constructor.newInstance(args); } catch (final Exception e) { throw new RuntimeException("Error trying to instatiate class, '" + inClass.getName() + "'. Error: " + e.getClass().getName() + ": " + e.getMessage() + "."); } }
From source file:com.revorg.goat.IndexManager.java
/** * Gets the Index Version.// ww w .j a v a 2 s . co m * * @param indexPath Directory that contains the Lucene Collection * @throws Exception * @return ActionResult */ public static String getIndexVersion(String indexPath) { try { IndexReader reader = IndexReader.open(indexPath); ActionResult = Long.toString(reader.getVersion()); reader.close(); return ActionResult; } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to optimize index: " + indexPath); } ActionResult = "Failure"; return ActionResult + ActionResultError; }
From source file:com.revorg.goat.IndexManager.java
/** * Optimizes the structure and contents of the collection for searching; recovers space. Causes collection to be taken offline, preventing searches and indexing. * * @param indexPath Directory that contains the Lucene Collection * @throws Exception//from ww w. j av a 2s . c o m * @return ActionResult */ public static String optimizeIndex(String indexPath) { try { //StandardAnalyzer new StandardAnalyzer() = new StandardAnalyzer(); //Initialize Class IndexWriter writer = new IndexWriter(indexPath, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); writer.optimize(); writer.close(); ActionResult = "Success"; return ActionResult; } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to optimize index: " + indexPath); } ActionResult = "Failure"; return ActionResult + ActionResultError; }
From source file:com.revorg.goat.IndexManager.java
/** * Counts the total number of documents in the index. * * @param indexPath Directory that contains the Lucene Collection * @throws Exception/* w w w . j a va 2 s .c o m*/ * @return ActionResult */ public static String getIndexCount(String indexPath) { try { //StandardAnalyzer new StandardAnalyzer() = new StandardAnalyzer(); //Initialize Class IndexWriter writer = new IndexWriter(indexPath, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); int totalInIndex = writer.maxDoc(); ActionResult = Integer.toString(totalInIndex); writer.commit(); writer.close(); return ActionResult; } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to count index: " + indexPath); } ActionResult = "Failure"; return ActionResult + ActionResultError; }
From source file:com.revorg.goat.IndexManager.java
/** * Checks to see whether an index is locked or not. * * @param indexPath Directory that contains the Lucene Collection * @throws Exception// w w w. j a v a2 s .co m * @return ActionResult */ public static String isIndexLocked(String indexPath) { try { IndexWriter writer = new IndexWriter(indexPath, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); boolean indexLocked = writer.isLocked(indexPath); writer.close(); //Close Writer if (indexLocked) { ActionResult = "Yes"; } else { ActionResult = "No"; } return ActionResult; } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to optimize index: " + indexPath); } ActionResult = "Failure"; return ActionResult + ActionResultError; }
From source file:com.revorg.goat.IndexManager.java
/** * deletes all of the documents in a collection. Causes the collection to be taken offline, preventing searches. * * @param indexPath Directory that contains the Lucene Collection * @throws Exception/*from w w w .ja v a2 s . co m*/ * @return ActionResult */ public static String purgeIndex(String indexPath) { try { String indexExists = isIndexExistant(indexPath); if (indexExists.equalsIgnoreCase("Yes")) { //StandardAnalyzer new StandardAnalyzer() = new StandardAnalyzer(); //Initialize Class IndexWriter writer = new IndexWriter(indexPath, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); writer.commit(); writer.close(); ActionResult = "Success"; return ActionResult; } else { throw new Exception("Unable to open index"); } } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to purge index: " + indexPath); } ActionResult = "Failure"; return ActionResult + ActionResultError; }
From source file:com.revorg.goat.IndexManager.java
/** * Merges two indexes together.//from ww w . j a va2 s . c o m * * @param primaryIndex The Primary Lucene Index * @param secondaryIndex The Secondary Lucene Index that should be merged * @throws Exception * @return ActionResult */ public static String mergeIndexes(String primaryIndex, String secondaryIndex) { try { //Writer Class IndexWriter writer = new IndexWriter(primaryIndex, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); //Merge Index #2 to Index #1 writer.addIndexesNoOptimize(new Directory[] { FSDirectory.getDirectory(secondaryIndex) }); writer.commit(); writer.optimize(); writer.close(); ActionResult = "Success"; return ActionResult; } catch (Exception e) { ActionResultError = " caught a " + e.getClass() + " with message: " + e.getMessage(); System.out.println("Failure to merge index: " + primaryIndex); System.out.println(ActionResultError); } ActionResult = "Failure"; return ActionResult + ActionResultError; }