Search in sources :

Example 86 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project OpenAM by OpenRock.

the class ApplicationManager method newApplication.

/**
     * Creates an application.
     *
     * @param name Name of application.
     * @param applicationType application type.
     * @throws EntitlementException if application class is not found.
     */
public static Application newApplication(String name, ApplicationType applicationType) throws EntitlementException {
    Class clazz = applicationType.getApplicationClass();
    Class[] parameterTypes = { String.class, ApplicationType.class };
    Constructor constructor;
    try {
        constructor = clazz.getConstructor(parameterTypes);
        Object[] parameters = { name, applicationType };
        return (Application) constructor.newInstance(parameters);
    } catch (NoSuchMethodException ex) {
        throw new EntitlementException(6, ex);
    } catch (SecurityException ex) {
        throw new EntitlementException(6, ex);
    } catch (InstantiationException ex) {
        throw new EntitlementException(6, ex);
    } catch (IllegalAccessException ex) {
        throw new EntitlementException(6, ex);
    } catch (IllegalArgumentException ex) {
        throw new EntitlementException(6, ex);
    } catch (InvocationTargetException ex) {
        throw new EntitlementException(6, ex);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 87 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project OpenAM by OpenRock.

the class ApplicationPrivilegeManager method getInstance.

/**
     * Returns an instance of application privilege manager.
     *
     * @param realm
     *         Realm name.
     * @param caller
     *         Administrator subject.
     *
     * @return an instance of application privilege manager.
     */
public static ApplicationPrivilegeManager getInstance(String realm, Subject caller) {
    try {
        final Class[] parameterTypes = { String.class, Subject.class, ResourceTypeService.class };
        final Constructor<? extends ApplicationPrivilegeManager> constructor = DEFAULT_IMPL.getConstructor(parameterTypes);
        final ResourceTypeService resourceTypeService = InjectorHolder.getInstance(ResourceTypeService.class);
        return constructor.newInstance(realm, caller, resourceTypeService);
    } catch (InstantiationException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    } catch (IllegalAccessException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    } catch (IllegalArgumentException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    } catch (InvocationTargetException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    } catch (NoSuchMethodException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    } catch (SecurityException ex) {
        PolicyConstants.DEBUG.error("ApplicationPrivilegeManager.getInstance", ex);
    }
    return null;
}
Also used : ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 88 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project OpenAM by OpenRock.

the class UmaEmailService method getMailServer.

private MailServer getMailServer(String realm) throws MessagingException {
    try {
        ServiceConfigManager mailmgr = new ServiceConfigManager(AccessController.doPrivileged(AdminTokenAction.getInstance()), MailServerImpl.SERVICE_NAME, MailServerImpl.SERVICE_VERSION);
        ServiceConfig mailscm = mailmgr.getOrganizationConfig(realm, null);
        if (!mailscm.exists()) {
            throw new MessagingException("EmailService is not configured for realm, " + realm);
        }
        Map<String, Set<String>> mailattrs = mailscm.getAttributes();
        String mailServerClass = mailattrs.get("forgerockMailServerImplClassName").iterator().next();
        return Class.forName(mailServerClass).asSubclass(MailServer.class).getDeclaredConstructor(String.class).newInstance(realm);
    } catch (IllegalAccessException | SSOException | InstantiationException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException | SMSException e) {
        throw new MessagingException("Failed to load mail server", e);
    }
}
Also used : Set(java.util.Set) MessagingException(javax.mail.MessagingException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 89 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project android_frameworks_base by ResurrectionRemix.

the class ViewDebug method capturedViewExportMethods.

private static String capturedViewExportMethods(Object obj, Class<?> klass, String prefix) {
    if (obj == null) {
        return "null";
    }
    StringBuilder sb = new StringBuilder();
    final Method[] methods = capturedViewGetPropertyMethods(klass);
    int count = methods.length;
    for (int i = 0; i < count; i++) {
        final Method method = methods[i];
        try {
            Object methodValue = method.invoke(obj, (Object[]) null);
            final Class<?> returnType = method.getReturnType();
            CapturedViewProperty property = method.getAnnotation(CapturedViewProperty.class);
            if (property.retrieveReturn()) {
                //we are interested in the second level data only
                sb.append(capturedViewExportMethods(methodValue, returnType, method.getName() + "#"));
            } else {
                sb.append(prefix);
                sb.append(method.getName());
                sb.append("()=");
                if (methodValue != null) {
                    final String value = methodValue.toString().replace("\n", "\\n");
                    sb.append(value);
                } else {
                    sb.append("null");
                }
                sb.append("; ");
            }
        } catch (IllegalAccessException e) {
        //Exception IllegalAccess, it is OK here
        //we simply ignore this method
        } catch (InvocationTargetException e) {
        //Exception InvocationTarget, it is OK here
        //we simply ignore this method
        }
    }
    return sb.toString();
}
Also used : AccessibleObject(java.lang.reflect.AccessibleObject) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 90 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project android_frameworks_base by ResurrectionRemix.

the class BitmapUtils method createVideoThumbnail.

public static Bitmap createVideoThumbnail(String filePath) {
    // MediaMetadataRetriever is available on API Level 8
    // but is hidden until API Level 10
    Class<?> clazz = null;
    Object instance = null;
    try {
        clazz = Class.forName("android.media.MediaMetadataRetriever");
        instance = clazz.newInstance();
        Method method = clazz.getMethod("setDataSource", String.class);
        method.invoke(instance, filePath);
        // The method name changes between API Level 9 and 10.
        if (Build.VERSION.SDK_INT <= 9) {
            return (Bitmap) clazz.getMethod("captureFrame").invoke(instance);
        } else {
            byte[] data = (byte[]) clazz.getMethod("getEmbeddedPicture").invoke(instance);
            if (data != null) {
                Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                if (bitmap != null)
                    return bitmap;
            }
            return (Bitmap) clazz.getMethod("getFrameAtTime").invoke(instance);
        }
    } catch (IllegalArgumentException ex) {
    // Assume this is a corrupt video file
    } catch (RuntimeException ex) {
    // Assume this is a corrupt video file.
    } catch (InstantiationException e) {
        Log.e(TAG, "createVideoThumbnail", e);
    } catch (InvocationTargetException e) {
        Log.e(TAG, "createVideoThumbnail", e);
    } catch (ClassNotFoundException e) {
        Log.e(TAG, "createVideoThumbnail", e);
    } catch (NoSuchMethodException e) {
        Log.e(TAG, "createVideoThumbnail", e);
    } catch (IllegalAccessException e) {
        Log.e(TAG, "createVideoThumbnail", e);
    } finally {
        try {
            if (instance != null) {
                clazz.getMethod("release").invoke(instance);
            }
        } catch (Exception ignored) {
        }
    }
    return null;
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Bitmap(android.graphics.Bitmap)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)4781 Method (java.lang.reflect.Method)2031 IOException (java.io.IOException)550 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)492 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)407 ArrayList (java.util.ArrayList)402 List (java.util.List)248 CoreException (org.eclipse.core.runtime.CoreException)247 File (java.io.File)238 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)236 Constructor (java.lang.reflect.Constructor)233 Field (java.lang.reflect.Field)220 Test (org.junit.Test)209 Map (java.util.Map)205 HashMap (java.util.HashMap)202 DBException (org.jkiss.dbeaver.DBException)169 IStatus (org.eclipse.core.runtime.IStatus)136 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)97 Arrays (java.util.Arrays)96 Status (org.eclipse.core.runtime.Status)94