List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.initiativaromania.hartabanilorpublici.IRUserInterface.map.IRLocationListener.java
public void pauseGPSListener() { try {/*ww w. j av a2s . c o m*/ if (this.locationManager != null) this.locationManager.removeUpdates(this); } catch (SecurityException e) { e.printStackTrace(); } }
From source file:de.anhquan.config4j.internal.ConfigHandler.java
private Object invokeGetter(Object proxy, Method method) { @SuppressWarnings("unchecked") Class clsReturnType = method.getReturnType(); String strReturnType = StringUtils.capitalize(ClassUtils.getShortClassName(clsReturnType)); String configMethodName = "get" + strReturnType; String propName = findPropertyName(method); try {/*from ww w . j ava2s . c o m*/ Method getter = Configuration.class.getMethod(configMethodName, String.class); //String.class is for propName return getter.invoke(configuration, propName); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { return findDefaultValue(method, clsReturnType); } return null; }
From source file:fr.ippon.wip.util.WIPLogging.java
private WIPLogging() { try {//ww w.j av a2 s .c o m // FileHandler launch an exception if parent path doesn't exist, so // we make sure it exists File logDirectory = new File(HOME + "/wip"); if (!logDirectory.exists() || !logDirectory.isDirectory()) logDirectory.mkdirs(); accessFileHandler = new FileHandler("%h/wip/access.log", true); accessFileHandler.setLevel(Level.INFO); accessFileHandler.setFormatter(new SimpleFormatter()); Logger.getLogger("fr.ippon.wip.http.hc.HttpClientExecutor.AccessLog").addHandler(accessFileHandler); ConsoleHandler consoleHandler = new ConsoleHandler(); consoleHandler.setFilter(new Filter() { public boolean isLoggable(LogRecord record) { return !record.getLoggerName().equals("fr.ippon.wip.http.hc.HttpClientExecutor.AccessLog"); } }); Logger.getLogger("fr.ippon.wip").addHandler(consoleHandler); // For HttpClient debugging // FileHandler fileHandler = new // FileHandler("%h/wip/httpclient.log", true); // fileHandler.setLevel(Level.ALL); // Logger.getLogger("org.apache.http.headers").addHandler(fileHandler); // Logger.getLogger("org.apache.http.headers").setLevel(Level.ALL); } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.runnerup.tracker.component.TrackerGPS.java
@Override public ResultCode onEnd(Callback callback, Context context) { if (!mWithoutGps) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); try {/*w ww .j ava 2 s . c om*/ lm.removeUpdates(tracker); } catch (SecurityException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } if (mGpsStatus != null) { mGpsStatus.stop(this); } mGpsStatus = null; mConnectCallback = null; } return ResultCode.RESULT_OK; }
From source file:org.apache.tomcat.util.IntrospectionUtils.java
/** * Find a method with the right name If found, call the method ( if param is * int or boolean we'll convert value to the right type before) - that means * you can have setDebug(1).// w ww . j a v a 2s. c om */ public static void setProperty(Object o, String name, String value) { if (dbg > 1) d("setProperty(" + o.getClass() + " " + name + "=" + value + ")"); String setter = "set" + capitalize(name); try { Method methods[] = findMethods(o.getClass()); Method setPropertyMethod = null; // First, the ideal case - a setFoo( String ) method for (int i = 0; i < methods.length; i++) { Class paramT[] = methods[i].getParameterTypes(); if (setter.equals(methods[i].getName()) && paramT.length == 1 && "java.lang.String".equals(paramT[0].getName())) { methods[i].invoke(o, new Object[] { value }); return; } } // Try a setFoo ( int ) or ( boolean ) for (int i = 0; i < methods.length; i++) { boolean ok = true; if (setter.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1) { // match - find the type and invoke it Class paramType = methods[i].getParameterTypes()[0]; Object params[] = new Object[1]; // Try a setFoo ( int ) if ("java.lang.Integer".equals(paramType.getName()) || "int".equals(paramType.getName())) { try { params[0] = new Integer(value); } catch (NumberFormatException ex) { ok = false; } // Try a setFoo ( long ) } else if ("java.lang.Long".equals(paramType.getName()) || "long".equals(paramType.getName())) { try { params[0] = new Long(value); } catch (NumberFormatException ex) { ok = false; } // Try a setFoo ( boolean ) } else if ("java.lang.Boolean".equals(paramType.getName()) || "boolean".equals(paramType.getName())) { params[0] = new Boolean(value); // Try a setFoo ( InetAddress ) } else if ("java.net.InetAddress".equals(paramType.getName())) { try { params[0] = InetAddress.getByName(value); } catch (UnknownHostException exc) { d("Unable to resolve host name:" + value); ok = false; } // Unknown type } else { d("Unknown type " + paramType.getName()); } if (ok) { methods[i].invoke(o, params); return; } } // save "setProperty" for later if ("setProperty".equals(methods[i].getName())) { setPropertyMethod = methods[i]; } } // Ok, no setXXX found, try a setProperty("name", "value") if (setPropertyMethod != null) { Object params[] = new Object[2]; params[0] = name; params[1] = value; setPropertyMethod.invoke(o, params); } } catch (IllegalArgumentException ex2) { log.warn("IAE " + o + " " + name + " " + value, ex2); } catch (SecurityException ex1) { if (dbg > 0) d("SecurityException for " + o.getClass() + " " + name + "=" + value + ")"); if (dbg > 1) ex1.printStackTrace(); } catch (IllegalAccessException iae) { if (dbg > 0) d("IllegalAccessException for " + o.getClass() + " " + name + "=" + value + ")"); if (dbg > 1) iae.printStackTrace(); } catch (InvocationTargetException ie) { if (dbg > 0) d("InvocationTargetException for " + o.getClass() + " " + name + "=" + value + ")"); if (dbg > 1) ie.printStackTrace(); } }
From source file:org.exolab.castor.jdo.engine.jdo_descriptors.AddressJDODescriptor.java
/** * @param choice//w w w . j a va2 s.co m * @return jdo field descriptor for id */ private FieldDescriptor initId(final ClassChoice choice) { String idFieldName = "id"; FieldDescriptorImpl idFieldDescr; FieldMapping idFM = new FieldMapping(); TypeInfo idType = new TypeInfo(java.lang.Integer.class); // Set columns required (=not null) idType.setRequired(true); FieldHandler idHandler; try { idHandler = new FieldHandlerImpl(idFieldName, null, null, Address.class.getMethod("getId"), Address.class.getMethod("setId", new Class[] { int.class }), idType); } catch (SecurityException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } catch (MappingException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } catch (NoSuchMethodException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } // Instantiate title field descriptor idFieldDescr = new FieldDescriptorImpl(idFieldName, idType, idHandler, false); idFieldDescr.addNature(FieldDescriptorJDONature.class.getName()); FieldDescriptorJDONature idJdoNature = new FieldDescriptorJDONature(idFieldDescr); idJdoNature.setSQLName(new String[] { idFieldName }); idJdoNature.setSQLType(new int[] { SQLTypeInfos.javaType2sqlTypeNum(java.lang.Integer.class) }); idJdoNature.setManyKey(null); idJdoNature.setDirtyCheck(false); idJdoNature.setReadOnly(false); // Set parent class descriptor idFieldDescr.setContainingClassDescriptor(this); idFieldDescr.setClassDescriptor(this); idFieldDescr.setIdentity(true); idFM.setIdentity(true); idFM.setDirect(false); idFM.setName("id"); idFM.setRequired(true); idFM.setSetMethod("setId"); idFM.setGetMethod("getId"); idFM.setType("integer"); Sql idSql = new Sql(); idSql.addName("id"); idSql.setType("integer"); idFM.setSql(idSql); // Add field mappings choice.addFieldMapping(idFM); return idFieldDescr; }
From source file:org.castor.jaxb.reflection.JAXBFieldHandlerTest.java
private void setMethodsIntoFieldHandler(final JAXBFieldHandlerImpl fh) { Method getMethod = null;/*from w ww .jav a2s .c o m*/ Method setMethod = null; try { getMethod = Song.class.getMethod("getArtist", new Class<?>[] {}); setMethod = Song.class.getMethod("setArtist", new Class<?>[] { Artist.class }); } catch (SecurityException e) { e.printStackTrace(); throw new RuntimeException(); } catch (NoSuchMethodException e) { e.printStackTrace(); throw new RuntimeException(); } fh.setMethods(getMethod, setMethod); }
From source file:org.sakaiproject.poll.logic.test.PollListManagerTest.java
@Test public void testGetPollById() { externalLogicStubb.currentUserId = TestDataPreload.USER_UPDATE; //we shouldNot find this poll Poll pollFail = pollListManager.getPollById(Long.valueOf(9999999)); Assert.assertNull(pollFail);/*from w ww . j a v a2 s . c o m*/ //this one should exist -- the preload saves one poll and remembers its ID externalLogicStubb.currentUserId = TestDataPreload.USER_UPDATE; Poll poll1 = pollListManager.getPollById(tdp.getFirstPollId()); Assert.assertNotNull(poll1); //it should have options Assert.assertNotNull(poll1.getPollOptions()); Assert.assertTrue(poll1.getPollOptions().size() > 0); //we expect this one to fails externalLogicStubb.currentUserId = TestDataPreload.USER_NO_ACCEESS; try { Poll poll2 = pollListManager.getPollById(tdp.getFirstPollId()); Assert.fail("should not be allowed to read this poll"); } catch (SecurityException e) { e.printStackTrace(); } }
From source file:survivingwithandroid.com.uvindex.MainActivity.java
private void getUVIndex() { System.out.println("Get UV Index"); if (!googleClient.isConnected()) { // Try to connect again googleClient.connect();/*from w w w. j ava 2s .c om*/ } if (!googleClient.isConnected()) { showErrorMessage(); return; } try { Location loc = getLocation(); LocationRequest req = new LocationRequest(); req.setInterval(5 * 1000); req.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); LocationServices.FusedLocationApi.requestLocationUpdates(googleClient, req, this); } catch (SecurityException t) { t.printStackTrace(); } }
From source file:org.atomspace.pi2c.runtime.Server.java
/** * Run the Server Thread/*from w w w.j av a 2s. c om*/ */ @Override public void run() { location = Server.class.getProtectionDomain().getCodeSource().getLocation(); System.err.println("::: " + new Date() + " ::: loading from '" + location + "' :::"); //GET Lookup Enviroment if (location.toString().endsWith("jar")) { runmode = RUNMODE_JAR; System.err.println("::: " + new Date() + " ::: Starting in JAR-MODE :::"); } else { runmode = RUNMODE_ENV; System.err.println("::: " + new Date() + " ::: Starting in existing ENVIROMENT-MODE :::"); } // Adding a Shutdownhook for graceful camel context stop ServerShutdownHook shutdownHook = new ServerShutdownHook(); Thread shutdownHookThread = new Thread(shutdownHook); Runtime.getRuntime().addShutdownHook(shutdownHookThread); // Extract and Loading Jars with Classloader try { if (runmode == RUNMODE_JAR) this.loadingJars(); this.startSpringContext(); status = STATUS_RUNNING; } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }