Example usage for java.lang IllegalAccessException printStackTrace

List of usage examples for java.lang IllegalAccessException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalAccessException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.evosuite.setup.TestClusterGenerator.java

/**
 * All public methods defined directly in the SUT should be covered
 * //  ww w  .  j av  a2  s  . co  m
 * TODO: What if we use instrument_parent?
 * 
 * @param targetClass
 */
@SuppressWarnings("unchecked")
private void initializeTargetMethods() throws RuntimeException, ClassNotFoundException {

    logger.info("Analyzing target class");
    Class<?> targetClass = Properties.getTargetClass();

    TestCluster cluster = TestCluster.getInstance();

    Set<Class<?>> targetClasses = new LinkedHashSet<Class<?>>();
    if (targetClass == null) {
        throw new RuntimeException("Failed to load " + Properties.TARGET_CLASS);
    }
    targetClasses.add(targetClass);
    addDeclaredClasses(targetClasses, targetClass);
    if (Modifier.isAbstract(targetClass.getModifiers())) {
        logger.info("SUT is an abstract class");
        Set<Class<?>> subclasses = getConcreteClasses(targetClass, inheritanceTree);
        logger.info("Found {} concrete subclasses", subclasses.size());
        targetClasses.addAll(subclasses);
    }

    // To make sure we also have anonymous inner classes double check inner classes using ASM
    ClassNode targetClassNode = DependencyAnalysis.getClassNode(Properties.TARGET_CLASS);
    Queue<InnerClassNode> innerClasses = new LinkedList<InnerClassNode>();
    innerClasses.addAll(targetClassNode.innerClasses);
    while (!innerClasses.isEmpty()) {
        InnerClassNode icn = innerClasses.poll();
        try {
            logger.debug("Loading inner class: {}, {},{}", icn.innerName, icn.name, icn.outerName);
            String innerClassName = ResourceList.getClassNameFromResourcePath(icn.name);
            Class<?> innerClass = TestGenerationContext.getInstance().getClassLoaderForSUT()
                    .loadClass(innerClassName);
            //if (!canUse(innerClass))
            //   continue;

            // Sometimes strange things appear such as Map$Entry
            if (!targetClasses.contains(innerClass)) {
                //                  && !innerClassName.matches(".*\\$\\d+(\\$.*)?$")) {

                logger.info("Adding inner class {}", innerClassName);
                targetClasses.add(innerClass);
                ClassNode innerClassNode = DependencyAnalysis.getClassNode(innerClassName);
                innerClasses.addAll(innerClassNode.innerClasses);
            }

        } catch (Throwable t) {
            logger.error("Problem for {}. Error loading inner class: {}, {},{}: {}", Properties.TARGET_CLASS,
                    icn.innerName, icn.name, icn.outerName, t);
        }
    }

    for (Class<?> clazz : targetClasses) {
        logger.info("Current SUT class: {}", clazz);

        if (!canUse(clazz)) {
            logger.info("Cannot access SUT class: {}", clazz);
            continue;
        }

        // Add all constructors
        for (Constructor<?> constructor : getConstructors(clazz)) {
            logger.info("Checking target constructor {}", constructor);
            String name = "<init>" + org.objectweb.asm.Type.getConstructorDescriptor(constructor);

            if (Properties.TT) {
                String orig = name;
                name = BooleanTestabilityTransformation.getOriginalNameDesc(clazz.getName(), "<init>",
                        org.objectweb.asm.Type.getConstructorDescriptor(constructor));
                if (!orig.equals(name))
                    logger.info("TT name: {} -> {}", orig, name);

            }

            if (canUse(constructor)) {
                GenericConstructor genericConstructor = new GenericConstructor(constructor, clazz);
                cluster.addTestCall(genericConstructor);
                // TODO: Add types!
                cluster.addGenerator(new GenericClass(clazz).getWithWildcardTypes(), genericConstructor);
                addDependencies(genericConstructor, 1);
                logger.debug("Keeping track of {}.{}{}", constructor.getDeclaringClass().getName(),
                        constructor.getName(), Type.getConstructorDescriptor(constructor));
            } else {
                logger.debug("Constructor cannot be used: {}", constructor);
            }

        }

        // Add all methods
        for (Method method : getMethods(clazz)) {
            logger.info("Checking target method {}", method);
            String name = method.getName() + org.objectweb.asm.Type.getMethodDescriptor(method);

            if (Properties.TT) {
                String orig = name;
                name = BooleanTestabilityTransformation.getOriginalNameDesc(clazz.getName(), method.getName(),
                        org.objectweb.asm.Type.getMethodDescriptor(method));
                if (!orig.equals(name))
                    logger.info("TT name: {} -> {}", orig, name);
            }

            if (canUse(method, clazz)) {
                logger.debug("Adding method {}.{}{}", clazz.getName(), method.getName(),
                        Type.getMethodDescriptor(method));

                GenericMethod genericMethod = new GenericMethod(method, clazz);
                cluster.addTestCall(genericMethod);
                cluster.addModifier(new GenericClass(clazz).getWithWildcardTypes(), genericMethod);
                addDependencies(genericMethod, 1);
                GenericClass retClass = new GenericClass(method.getReturnType());

                if (!retClass.isPrimitive() && !retClass.isVoid() && !retClass.isObject())
                    cluster.addGenerator(retClass.getWithWildcardTypes(), genericMethod);
            } else {
                logger.debug("Method cannot be used: {}", method);
            }
        }

        for (Field field : getFields(clazz)) {
            logger.info("Checking target field {}", field);

            if (canUse(field, clazz)) {
                GenericField genericField = new GenericField(field, clazz);
                addDependencies(genericField, 1);
                cluster.addGenerator(new GenericClass(field.getGenericType()).getWithWildcardTypes(),
                        genericField);
                logger.debug("Adding field {}", field);
                if (!Modifier.isFinal(field.getModifiers())) {
                    logger.debug("Is not final");
                    cluster.addTestCall(new GenericField(field, clazz));
                } else {
                    logger.debug("Is final");
                    if (Modifier.isStatic(field.getModifiers()) && !field.getType().isPrimitive()) {
                        logger.debug("Is static non-primitive");
                        /* 
                         * With this we are trying to cover such cases:
                         * 
                        public static final DurationField INSTANCE = new MillisDurationField();
                                
                        private MillisDurationField() {
                        super();
                        }
                         */
                        try {
                            Object o = field.get(null);
                            if (o == null) {
                                logger.info("Field is not yet initialized: {}", field);
                            } else {
                                Class<?> actualClass = o.getClass();
                                logger.debug("Actual class is {}", actualClass);
                                if (!actualClass.isAssignableFrom(genericField.getRawGeneratedType())
                                        && genericField.getRawGeneratedType().isAssignableFrom(actualClass)) {
                                    GenericField superClassField = new GenericField(field, clazz);
                                    cluster.addGenerator(new GenericClass(actualClass), superClassField);
                                }
                            }
                        } catch (IllegalAccessException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

                    }
                }
            } else {
                logger.debug("Can't use field {}", field);
            }
        }
        analyzedClasses.add(clazz);
        // TODO: Set to generic type rather than class?
        cluster.getAnalyzedClasses().add(clazz);
    }
    if (Properties.INSTRUMENT_PARENT) {
        for (String superClass : inheritanceTree.getSuperclasses(Properties.TARGET_CLASS)) {
            try {
                Class<?> superClazz = TestGenerationContext.getInstance().getClassLoaderForSUT()
                        .loadClass(superClass);
                dependencies.add(new Pair(0, superClazz));
            } catch (ClassNotFoundException e) {
                logger.error("Problem for {}. Class not found: {}", Properties.TARGET_CLASS, superClass, e);
            }

        }
    }

    if (Properties.HANDLE_STATIC_FIELDS) {

        GetStaticGraph getStaticGraph = GetStaticGraphGenerator.generate(Properties.TARGET_CLASS);

        Map<String, Set<String>> staticFields = getStaticGraph.getStaticFields();
        for (String className : staticFields.keySet()) {
            logger.info("Adding static fields to cluster for class {}", className);

            Class<?> clazz;
            try {
                clazz = getClass(className);
            } catch (ExceptionInInitializerError ex) {
                logger.debug("Class class init caused exception {}", className);
                continue;
            }
            if (clazz == null) {
                logger.debug("Class not found {}", className);
                continue;
            }

            if (!canUse(clazz))
                continue;

            Set<String> fields = staticFields.get(className);
            for (Field field : getFields(clazz)) {
                if (!canUse(field, clazz))
                    continue;

                if (fields.contains(field.getName())) {
                    if (!Modifier.isFinal(field.getModifiers())) {
                        logger.debug("Is not final");
                        cluster.addTestCall(new GenericField(field, clazz));
                    }
                }
            }
        }

        PutStaticMethodCollector collector = new PutStaticMethodCollector(Properties.TARGET_CLASS,
                staticFields);

        Set<MethodIdentifier> methodIdentifiers = collector.collectMethods();

        for (MethodIdentifier methodId : methodIdentifiers) {

            Class<?> clazz = getClass(methodId.getClassName());
            if (clazz == null)
                continue;

            if (!canUse(clazz))
                continue;

            Method method = getMethod(clazz, methodId.getMethodName(), methodId.getDesc());

            if (method == null)
                continue;

            GenericMethod genericMethod = new GenericMethod(method, clazz);

            cluster.addTestCall(genericMethod);

        }
    }

    logger.info("Finished analyzing target class");
}

From source file:ec.gob.ceaaces.controller.FuncionarioController.java

public void guardar() {

    if (funcionarioSeleccionado == null) {
        return;//from  w w  w.  j  ava  2 s .  c  om
    }
    if (validarDatosPersonales() == false) {
        return;
    }

    funcionarioSeleccionado.setOrigenCarga(ORIGEN_CARGA);
    funcionarioSeleccionado.setIesDTO(this.iesSeleccionada);
    funcionarioSeleccionado.setFaseIesDTO(faseIesDTO);

    PersonaDTO perdoc = null;

    try {
        perdoc = new PersonaDTO();
        PropertyUtils.copyProperties(perdoc, funcionarioSeleccionado);
    } catch (IllegalAccessException e1) {
        e1.printStackTrace();
    } catch (InvocationTargetException e1) {
        e1.printStackTrace();
    } catch (NoSuchMethodException e1) {
        e1.printStackTrace();
    }

    personaFuncionario = perdoc;
    personaFuncionario.setIesDTO(this.iesSeleccionada);
    PaisDTO nac = new PaisDTO();
    nac.setId(idPais);
    this.personaFuncionario.setPaisOrigen(nac);
    this.personaFuncionario.setDiscapacidad(DiscapacidadEnum.parse(this.discapacidad));
    this.personaFuncionario.setSexo(GeneroEnum.parse(this.genero));
    this.funcionarioSeleccionado.setTipoFuncionario(TipoFuncionarioEnum.parse(this.tipoFunc));

    SedeIesDTO sid = new SedeIesDTO();
    sid.setId(this.idSedeSeleccionada);
    this.funcionarioSeleccionado.setSedeIesDTO(sid);

    personaFuncionario.setIesDTO(this.iesSeleccionada);
    FuncionarioDTO resultado = null;
    try {
        // if (pestania.equals("Datos Personales")) {

        if (funcionarioSeleccionado.getId() == null) {
            personaFuncionario.setActivo(true);
            personaFuncionario.setFaseIesDTO(faseIesDTO);
            funcionarioSeleccionado.setActivo(true);
            if (contrataciones.isEmpty()) {
                JsfUtil.msgAdvert("Ingrese los datos de contratacin.");
                indiceTab = 1;
                verTabContratacion = false;
            } else {
                funcionarioSeleccionado.setContratacionDTO(contrataciones);
                resultado = registroServicio.registrarFuncionario(personaFuncionario, funcionarioSeleccionado,
                        usuarioSistema);
                RequestContext.getCurrentInstance().execute("dlgwContrato.hide()");
                JsfUtil.msgInfo("Registro almacenado correctamente");
            }
        } else {
            resultado = registroServicio.registrarFuncionario(personaFuncionario, funcionarioSeleccionado,
                    usuarioSistema);
            JsfUtil.msgInfo("Registro almacenado correctamente");
        }

        // resultado = guardarPestania();

    } catch (Exception e) {

        JsfUtil.msgError("No se puede almacenar el registro.");

    }
    if (funcionarioSeleccionado.getId() != null) {
        activarTab();
    }
}

From source file:ec.gob.ceaaces.controller.FuncionarioController.java

private void nuevoRedirect() {
    if (funcionarioSeleccionado == null) {
        return;/*from   w  w  w  . j  a  va  2s .  c  om*/
    }

    this.contrataciones.clear();

    // cargarDatosIniciales();

    if (funcionarioSeleccionado.getId() == null) {
        funcionarioSeleccionado = new FuncionarioDTO();
        idPais = -99L;
    }

    if (this.funcionarioSeleccionado.getId() != null) {
        this.personaFuncionario = new PersonaDTO();

        try {
            PropertyUtils.copyProperties(personaFuncionario, funcionarioSeleccionado);
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (InvocationTargetException e1) {
            e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();
        }

        cargarPaises();

        if (funcionarioSeleccionado.getIesDTO() == null) {
            personaFuncionario.setIesDTO(this.iesSeleccionada);
            funcionarioSeleccionado.setIesDTO(this.iesSeleccionada);
        }

        if (funcionarioSeleccionado.getPaisOrigen() != null) {
            idPais = funcionarioSeleccionado.getPaisOrigen().getId();
        } else {
            idPais = -99L;
        }

        if (funcionarioSeleccionado.getSedeIesDTO() != null) {
            idSedeSeleccionada = funcionarioSeleccionado.getSedeIesDTO().getId();
        }

        if (funcionarioSeleccionado.getDiscapacidad() != null) {
            discapacidad = funcionarioSeleccionado.getDiscapacidad().getValue();
        } else {
            funcionarioSeleccionado.setDiscapacidad(DiscapacidadEnum.NINGUNA);
            discapacidad = funcionarioSeleccionado.getDiscapacidad().getValue();
        }

        if (funcionarioSeleccionado.getSexo() != null) {
            genero = funcionarioSeleccionado.getSexo().getValue();
        } else {
            genero = funcionarioSeleccionado.getSexo().getValue();
        }

        if (funcionarioSeleccionado.getTipoFuncionario() != null) {
            tipoFunc = funcionarioSeleccionado.getTipoFuncionario().getValue();
        }

        if (funcionarioSeleccionado.getContratacionDTO() != null) {

            for (int i = 0; i < funcionarioSeleccionado.getContratacionDTO().size(); i++) {
                if (funcionarioSeleccionado.getContratacionDTO().get(i).getActivo()) {
                    contrataciones.add(funcionarioSeleccionado.getContratacionDTO().get(i));
                }
            }
            contrataciones.removeAll(Collections.singleton(null));
        }

    }
    activarTab();
}

From source file:voldemort.performance.benchmark.Benchmark.java

@SuppressWarnings("cast")
public long runTests(boolean runBenchmark) throws Exception {

    int localOpsCounts = 0;
    String label = null;/*from   ww  w .  java  2 s  .c  o m*/
    if (runBenchmark) {
        localOpsCounts = this.opsCount;
        label = new String("benchmark");
    } else {
        localOpsCounts = this.recordCount;
        label = new String("warmup");
    }
    Vector<Thread> threads = new Vector<Thread>();

    for (int index = 0; index < this.numThreads; index++) {
        VoldemortWrapper db = new VoldemortWrapper(storeClient, this.verifyRead && this.warmUpCompleted,
                this.ignoreNulls, this.localMode);
        WorkloadPlugin plugin = null;
        if (this.pluginName != null && this.pluginName.length() > 0) {
            Class<?> cls = Class.forName(this.pluginName);
            try {
                plugin = (WorkloadPlugin) cls.newInstance();
            } catch (IllegalAccessException e) {
                System.err.println("Class not accessible ");
                System.exit(1);
            } catch (InstantiationException e) {
                System.err.println("Class not instantiable.");
                System.exit(1);
            }
            plugin.setDb(db);
        }

        int opsPerThread = localOpsCounts / this.numThreads;
        // Make the last thread handle the remainder.
        if (index == this.numThreads - 1) {
            opsPerThread += localOpsCounts % this.numThreads;
        }

        threads.add(new ClientThread(db, runBenchmark, this.workLoad, opsPerThread,
                this.perThreadThroughputPerMs, this.verbose, plugin));
    }

    long startRunBenchmark = System.currentTimeMillis();
    for (Thread currentThread : threads) {
        currentThread.start();
    }

    StatusThread statusThread = null;
    if (this.statusIntervalSec > 0) {
        statusThread = new StatusThread(threads, this.statusIntervalSec, startRunBenchmark);
        statusThread.start();
    }

    for (Thread currentThread : threads) {
        try {
            currentThread.join();
        } catch (InterruptedException e) {
            if (this.verbose)
                e.printStackTrace();
        }
    }
    long endRunBenchmark = System.currentTimeMillis();

    if (this.statusIntervalSec > 0) {
        statusThread.interrupt();
    }

    // Print the output
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(4);
    nf.setGroupingUsed(false);

    System.out.println("[" + label + "]\tRunTime(ms): " + nf.format((endRunBenchmark - startRunBenchmark)));
    double throughput = Time.MS_PER_SECOND * ((double) localOpsCounts)
            / ((double) (endRunBenchmark - startRunBenchmark));
    System.out.println("[" + label + "]\tThroughput(ops/sec): " + nf.format(throughput));

    if (runBenchmark) {
        Metrics.getInstance().printReport(System.out);
    }
    return (endRunBenchmark - startRunBenchmark);
}

From source file:com.mysql.stresstool.StressTool.java

protected StressTool(String[] args) {

    if (args == null || args.length < 1)
        StressTool.showHelp();//  w w  w  . j a  v a  2 s.  com

    /* TODO:
     * All the parameters need to be converted into one single map this is horrible.
     */
    java.util.Collections.sort(lParameters);

    if (args.length >= 1 && args[0].indexOf("defaults-file") > 0) {

        try {
            stressSettings = new Wini(new File((String) args[0].split("=")[1]));
            Map<String, String> mainSettings = stressSettings.get("main");

            for (int i = 0; i < lParameters.size(); i++)
                try {
                    String methodName = (String) lParameters.get(i);
                    methodName = methodName.substring(0, 1).toUpperCase()
                            + methodName.substring(1, methodName.length());
                    methodName = "set" + methodName;

                    String valueM = mainSettings.get(lParameters.get(i));
                    //                     System.out.println(methodName + " = " + valueM);

                    if (valueM != null) {
                        if (valueM.equals("true") || valueM.equals("false")) {
                            MethodUtils.invokeMethod(this, methodName, Boolean.parseBoolean(valueM));
                        } else if (Utils.isNumeric(valueM)) {

                            MethodUtils.invokeMethod(this, methodName, Integer.parseInt(valueM));
                        } else
                            //                        PropertyUtils.setProperty(this,methodName,valueM);
                            //                     MethodUtils.setCacheMethods(false);
                            MethodUtils.invokeMethod(this, methodName, valueM);
                    }

                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (NoSuchMethodException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }

    }

    if (args.length >= 2 && args[0].indexOf("defaults-file") > 0) {

        for (int i = 1; i < args.length; i++) {
            if (args.length >= 1 && args[0] != null && this.connUrl == null) {
                this.connUrl = args[0];
            }
            if (args[i] != null && args[i].indexOf("truncate") >= 0) {
                this.truncate = Boolean.parseBoolean(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("debug") >= 0) {
                this.debug = true;
            }
            if (args[i] != null && args[i].indexOf("droptable") >= 0) {
                this.droptable = Boolean.parseBoolean(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("createtable") >= 0) {
                this.createtable = Boolean.parseBoolean(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("poolNumber") >= 0) {
                this.poolNumber = Integer.parseInt(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("repeatNumber") >= 0) {
                this.repeatNumber = Integer.parseInt(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("tableEngine") >= 0) {
                this.tableEngine = args[i].split("=")[1];
            }

            if (args[i] != null && args[i].indexOf("sleepFor") >= 0) {
                this.sleepFor = Integer.parseInt(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("dbType") >= 0) {
                this.dbType = args[i].split("=")[1];
                this.setDbType(this.dbType);
            }

            if (args[i] != null && args[i].indexOf("operationShort") >= 0) {
                this.operationShort = Boolean.parseBoolean(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("doDelete") >= 0) {
                this.doDelete = Boolean.parseBoolean(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("doBatch") >= 0) {
                this.iBatchInsert = Integer.parseInt(args[i].split("=")[1]);
                if (iBatchInsert > 0)
                    this.doBatch = true;
            }

            if (args[i] != null && args[i].indexOf("dolog") >= 0) {
                this.dolog = Boolean.parseBoolean(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("pctInsert") >= 0) {
                this.pctInsert = Integer.parseInt(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("pctSelect") >= 0) {
                this.pctSelect = Integer.parseInt(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("pctDelete") >= 0) {
                this.pctDelete = Integer.parseInt(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("doReport") >= 0) {
                this.doReport = Boolean.parseBoolean(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("doSimplePk") >= 0) {
                this.doSimplePk = Boolean.parseBoolean(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("ignorebinlog") >= 0) {
                this.ignoreBinlog = Boolean.parseBoolean(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("InsertClass") >= 0) {
                if (args[i].split("=") != null && args[i].split("=")[1] != null
                        && args[i].split("=")[1].length() > 0) {
                    this.insertDefaultClass = args[i].split("=")[1];
                }
            }

            if (args[i] != null && args[i].indexOf("SelectClass") >= 0) {
                if (args[i].split("=") != null && args[i].split("=")[1] != null
                        && args[i].split("=")[1].length() > 0) {
                    this.selectDefaultClass = args[i].split("=")[1];
                }
            }

            if (args[i] != null && args[i].indexOf("DeleteClass") >= 0) {
                if (args[i].split("=") != null && args[i].split("=")[1] != null
                        && args[i].split("=")[1].length() > 0) {
                    this.deleteDefaultClass = args[i].split("=")[1];
                }
            }

            if (args[i] != null && args[i].indexOf("ConnectString") >= 0) {
                if (args[i].split("=") != null && args[i].split("=")[1] != null
                        && args[i].split("=")[1].length() > 0) {
                    this.connectString = args[i].split("=")[1];
                }
            }

            if (args[i] != null && args[i].indexOf("DataBase") >= 0) {
                if (args[i].split("=") != null && args[i].split("=")[1] != null
                        && args[i].split("=")[1].length() > 0) {
                    this.databaseDefault = args[i].split("=")[1];
                }
            }
            if (args[i] != null && args[i].indexOf("sleepWrite") >= 0) {
                this.sleepWrite = Integer.parseInt(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("sleepRead") >= 0) {
                this.sleepRead = Integer.parseInt(args[i].split("=")[1]);
            }
            if (args[i] != null && args[i].indexOf("sleepDelete") >= 0) {
                this.sleepDelete = Integer.parseInt(args[i].split("=")[1]);
            }

            if (args[i] != null && args[i].indexOf("sqlstring") >= 0) {
                this.sqlString = (String) (args[i].split("=")[1]);
            }

        }
    } else if (args.length < 1) {
        StressTool.showHelp();
        System.exit(1);
    }

    try {
        stressSettings = new Wini(new File((String) args[0].split("=")[1]));
        Map<String, String> mainSettings = stressSettings.get("main");
        System.out.println(" MAIN SECTION");
        System.out.println("==============");
        for (int i = 0; i < lParameters.size(); i++) {
            String methodName = (String) lParameters.get(i);
            methodName = methodName.substring(0, 1).toUpperCase()
                    + methodName.substring(1, methodName.length());
            //               methodName = "get"+methodName;

            //               String valueM = mainSettings.get(lParameters.get(i));
            String value = null;
            try {
                value = MethodUtils.invokeMethod(this, "get" + methodName, null).toString();
            } catch (Throwable th) {
            }
            if (value == null)
                try {
                    value = MethodUtils.invokeMethod(this, "is" + methodName, null).toString();
                } catch (Throwable th) {
                }
            if (value == null) {
                Map<String, String> mainSettingsA = stressSettings.get("actionClass");
                value = mainSettingsA.get(lParameters.get(i));

            }

            System.out.println(methodName + " = " + value);
        }

        System.out.println("\nAPPLICATION SECTION");
        System.out.println("====================");

        Map<String, String> appSettings = stressSettings.get("actionClass");
        Iterator it = appSettings.keySet().iterator();
        while (it.hasNext()) {
            String methodName = (String) it.next();
            String value = null;

            for (int i = 1; i < args.length; i++) {
                String parName = ((String) (args[i].split("=")[0])).replace("--", "");
                if (parName.equals(methodName)) {
                    methodName = methodName.substring(0, 1).toUpperCase()
                            + methodName.substring(1, methodName.length());
                    value = args[i].split("=")[1];

                    try {
                        value = MethodUtils.invokeMethod(this, "get" + methodName, null).toString();
                    } catch (Throwable th) {
                    }
                    if (value == null)
                        try {
                            value = MethodUtils.invokeMethod(this, "is" + methodName, null).toString();
                        } catch (Throwable th) {
                        }

                }

            }
            if (value == null)
                System.out.println(methodName + " = " + appSettings.get(methodName));
            else
                System.out.println(methodName + " = " + value);
            //      value = mainSettingsA.get(lParameters.get(i));
        }

        //           } catch (IllegalAccessException e) {
        //               // TODO Auto-generated catch block
        //               e.printStackTrace();
        //           } catch (InvocationTargetException e) {
        //               // TODO Auto-generated catch block
        //               e.printStackTrace();
        //           } catch (NoSuchMethodException e) {
        //               // TODO Auto-generated catch block
        //               e.printStackTrace();
        //           }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.exit(1);
    }

}

From source file:net.groupbuy.entity.Product.java

/**
 * ??/* w w w .  jav a2s .  c o  m*/
 * 
 * @param attribute
 *            ?
 * @return ?
 */
@Transient
public String getAttributeValue(Attribute attribute) {
    if (attribute != null && attribute.getPropertyIndex() != null) {
        try {
            String propertyName = ATTRIBUTE_VALUE_PROPERTY_NAME_PREFIX + attribute.getPropertyIndex();
            return (String) PropertyUtils.getProperty(this, propertyName);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:net.groupbuy.entity.Product.java

/**
 * ?//w w  w.j av  a  2  s.  c om
 * 
 * @param attribute
 *            ?
 * @param value
 *            ?
 */
@Transient
public void setAttributeValue(Attribute attribute, String value) {
    if (attribute != null && attribute.getPropertyIndex() != null) {
        if (StringUtils.isEmpty(value)) {
            value = null;
        }
        if (value == null || (attribute.getOptions() != null && attribute.getOptions().contains(value))) {
            try {
                String propertyName = ATTRIBUTE_VALUE_PROPERTY_NAME_PREFIX + attribute.getPropertyIndex();
                PropertyUtils.setProperty(this, propertyName, value);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.clt.sub.service.imp.ShipheadServiceImp.java

/**
 * //from   ww w  . jav a 2  s .co m
 * @Description: TODO(??)
 * @param msgstrs
 * @param driverID
 * @return
 * @author liuwu
 * @create_date 2015-7-8 ?1:44:22
 */
@SuppressWarnings("unchecked")
public String saveshipHead(String[] msgstrs, int driverID) {
    JSONObject msgobj = new JSONObject();
    msgobj.put("resultCode", "ok");
    msgobj.put("errorContent", "??");

    TUser user = (TUser) UserSession.get("user");
    String subno = subDao.get(user.getiArchive()).getVcSubno();
    // 
    TTruckDriver truckDriver = driverDao.get(driverID);
    TShiphead head = new TShiphead();
    head.setNShipType(0);
    head.setNEnable(0);
    head.setDtCreate(new Date());
    head.setVcSubno(subno);
    head.setVcShipno(getMaxShipNo());
    head.setITruckId(driverID);
    head.setVcTruckName(truckDriver.getVcCarNo());
    head.setVcDriverId(getDriverId(truckDriver));

    // ?ID? ???
    TDriver tDriver = findDriverLinkByTruckId(truckDriver.getId());
    String[] properties = { "IArchiveType", "iArchive", "NEnable" };
    Object[] mainValues = { SystemConstants.SYS_TARCHIVE_DRIVER, tDriver.getId(), SystemConstants.SYS_ENABLE };
    List<TUser> users = userDao.findByPropertys(properties, mainValues);
    shipheadDao.save(head);
    String caiStr = "";// ????
    for (int i = 0; i < msgstrs.length; i++) {
        String[] ords = msgstrs[i].split(",");
        TOrder order = orderDao.getOrderByOrderNo(ords[0]);

        if (order == null) {
            msgobj.put("resultCode", "no");
            msgobj.put("errorContent", "??" + ords[0] + "  ????");

            return msgobj.toString();
        }
        if (order.getnLoad() == 1) {
            msgobj.put("resultCode", "no");
            msgobj.put("errorContent", "?" + ords[0] + "?? ");

            return msgobj.toString();
        }

        int count = Integer.parseInt(ords[1]);
        if (count > order.getNTotalCar()) {
            System.out.println("?????");

            msgobj.put("resultCode", "no");
            msgobj.put("errorContent", "?????");

            return msgobj.toString();

        }
        String datestr = DateUtil.getDate("yyyy/MM/dd");
        // and to_char(ark.dtStart,'yyyy-MM-dd') between ? and ?
        String sql = " select getArkilomer('" + subno + "','" + order.getVcStartCity() + "','"
                + order.getVcDestCity() + "','" + datestr + "') nar from dual ";
        System.out.println("sql" + sql);

        /*float nKilometer = 0;
        try
        {
                   
           List artlist = arkilomerDao.getDateBySQL( sql , null );
           if ( CollectionUtils.isNotEmpty( artlist )
            && artlist.get( 0 ) != null )
           {
              nKilometer = Float.parseFloat( artlist.get( 0 ) + "" );
           }
           else
           {
              msgobj.put( "resultCode" , "ok" );
              msgobj.put( "errorContent" , order.getVcStartCity() + "  "
               + order.getVcDestCity() + " " );
                      
           }
        }
        catch ( Exception e )
        {
           e.printStackTrace();
           // ??? ? ??  
           msgobj.put( "resultCode" , "no" );
           msgobj.put( "errorContent" , " " + e.getMessage() );
           return msgobj.toString();
        }*/
        if (count < order.getNTotalCar())// ?(???????2??)
        {
            order.setNEnable(SystemConstants.SYS_DISABLE);// ?
            orderDao.saveOrUpdate(order);
            // shipheadDao.save( head );
            for (int i1 = 0; i1 < 2; i1++) {
                TOrder copyOrder = new TOrder();
                try {
                    BeanUtils.copyProperties(copyOrder, order);
                    copyOrder.setVcOrderno(copyOrder.getVcOrderno() + "_" + (i1 + 1));
                    copyOrder.setNShipedQty(count);
                    copyOrder.setNEnable(SystemConstants.SYS_ENABLE);
                    System.out.println(count + "--" + order.getNTotalCar());

                    float ratio1 = Float.parseFloat(count + "") / Float.parseFloat(order.getNTotalCar() + "");
                    System.out.println("ratio1 = " + ratio1);
                    if (order.getNTotalPrice() != null) {
                        copyOrder.setNTotalPrice(ratio1 * order.getNTotalPrice());
                    }
                    copyOrder.setnLoad(1);// ?
                    if (i1 == 1) {

                        copyOrder.setNShipedQty(order.getNTotalCar() - count);// ??

                        if (order.getNTotalPrice() != null) {
                            copyOrder.setNTotalPrice((1 - ratio1) * order.getNTotalPrice());

                        }
                        copyOrder.setnLoad(0);// ?
                    }
                    copyOrder.setNTotalCar(copyOrder.getNShipedQty());

                    orderDao.save(copyOrder);
                    if (i1 == 0) {
                        TShipline line = new TShipline();
                        line.setIOrderId(copyOrder.getId());
                        line.setIShiphead(head.getId());
                        line.setVcStartCity(copyOrder.getVcStartCity());
                        line.setVcDestCity(copyOrder.getVcDestCity());
                        line.setDtAdd(new Date());
                        // line.setNQty( count );
                        line.setnShipQty(copyOrder.getNShipedQty());
                        // line.setNApkilometer( nKilometer );
                        shiplineDao.save(line);
                        TShipStatus tShipStatus = new TShipStatus();
                        tShipStatus.setnOrderId(copyOrder.getId());
                        tShipStatus.setnLineId(line.getId());
                        tShipStatus.setVcAddUser(user.getVcAccount());
                        tShipStatus.setVcStatusNote(SystemConstants.VC_LOADING_TRUE);
                        tShipStatus.setVcStatusTag(SystemConstants.VC_LOADING_TRUE_TAG);
                        tShipStatus.setnHeadId(head.getId());
                        iShipStatusDao.saveOrUpdate(tShipStatus);

                        // ??
                        HashMap<String, String> map = new HashMap<String, String>();
                        map.put("vcLineId", line.getId() + "");
                        map.put("msgType", "6");
                        PushUtils pushUtils = new PushUtils("?",
                                "?" + user.getVcAccount() + "???", users,
                                "com.unlcn.driver.ordermanagement.DriverOrderArriveDialogActivity", map);
                        pushUtils.run();
                        for (TUser tUser : users) {
                            // ??
                            TMsgRecord tMsgRecord = new TMsgRecord();
                            tMsgRecord.setIUser(user.getId());// ID
                            tMsgRecord.setVcAdduser(user.getVcAccount());// ??
                            tMsgRecord.setIUserAccept(tUser.getId());// id
                            tMsgRecord.setNMsgType(1);// ??
                            tMsgRecord.setVcContent("?" + user.getVcAccount() + "???");
                            tMsgRecord.setVcTitle("??");
                            msgService.save(tMsgRecord);
                        }
                    }
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (Exception e) {
                    // TODO: handle exception
                    e.printStackTrace();
                }
            }
            caiStr += "?" + order.getVcOrderno() + "?? ";
        } else {
            // shipheadDao.save( head );
            // order.setNShipedQty( order.getNShipedQty() + count );
            order.setnLoad(1);// ???
            order.setNShipedQty(count);
            orderDao.saveOrUpdate(order);
            TShipline line = new TShipline();
            line.setIOrderId(order.getId());
            line.setIShiphead(head.getId());
            line.setVcStartCity(order.getVcStartCity());
            line.setVcDestCity(order.getVcDestCity());
            line.setDtAdd(new Date());
            // line.setNQty( count );
            line.setnShipQty(count);
            // line.setNApkilometer( nKilometer );
            shiplineDao.save(line);

            TShipStatus tShipStatus = new TShipStatus();
            tShipStatus.setnOrderId(order.getId());
            tShipStatus.setnLineId(line.getId());
            tShipStatus.setVcAddUser(user.getVcAccount());
            tShipStatus.setVcStatusNote(SystemConstants.VC_LOADING_TRUE);
            tShipStatus.setVcStatusTag(SystemConstants.VC_LOADING_TRUE_TAG);
            tShipStatus.setnHeadId(head.getId());
            iShipStatusDao.save(tShipStatus);

            // ??
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("vcLineId", line.getId() + "");
            map.put("msgType", "6");
            PushUtils pushUtils = new PushUtils("?",
                    "?" + user.getVcAccount() + "???", users,
                    "com.unlcn.driver.ordermanagement.DriverOrderArriveDialogActivity", map);
            pushUtils.run();
            for (TUser tUser : users) {
                // ??
                TMsgRecord tMsgRecord = new TMsgRecord();
                tMsgRecord.setIUser(user.getId());// ID
                tMsgRecord.setVcAdduser(user.getVcAccount());// ??
                tMsgRecord.setIUserAccept(tUser.getId());// id
                tMsgRecord.setNMsgType(1);// ??
                tMsgRecord.setVcContent("?" + user.getVcAccount() + "???");
                tMsgRecord.setVcTitle("??");
                msgService.save(tMsgRecord);
            }
        }
        truckDriver.setNStatus(1);// ????0
        // truckDriver.setVcShipNo( head.getVcShipno() );
        driverDao.saveOrUpdate(truckDriver);
    }
    if (caiStr != "") {
        msgobj.put("resultCode", "ok");
        msgobj.put("errorContent", caiStr);
    }

    return msgobj.toString();
}

From source file:org.jbuilt.componentTree.jsf.AbstractJsfComponentTreeBuilder.java

@SuppressWarnings("unchecked")
public SelectItem selectItems(Object... args) {
    SelectItem selectItemGroup = new SelectItemGroup();
    System.out.print("selectItemGroup");
    incrementIndent();/*from   w  w w .j  a  va 2  s .c  o  m*/
    System.out.println(" ");

    for (Object arg : args) {
        if (arg instanceof ComponentAttribute) {
            try {
                PropertyUtils.setProperty(selectItemGroup, ((ComponentAttribute<String, Object>) arg).getKey(),
                        ((ComponentAttribute<String, Object>) arg).getValue());
            } catch (IllegalAccessException e) {

                e.printStackTrace();
            } catch (InvocationTargetException e) {

                e.printStackTrace();
            } catch (NoSuchMethodException e) {

                e.printStackTrace();
            }
        } else {
            throw new IllegalArgumentException(
                    "selectItemGroup method can only accept ComponentAttributes as arguments");
        }
        decrementIndent();
        System.out.print("end_selectItemGroup\n");

    }
    return selectItemGroup;
}

From source file:org.jbuilt.componentTree.jsf.AbstractJsfComponentTreeBuilder.java

@SuppressWarnings("unchecked")
public SelectItem selectItem(Object... args) {
    SelectItem selectItem = new SelectItem();
    System.out.print("selectItem");
    incrementIndent();//w  ww. j a v  a  2  s.  c  o  m
    System.out.println(" ");

    for (Object arg : args) {
        if (arg instanceof ComponentAttribute) {
            try {
                PropertyUtils.setProperty(selectItem, ((ComponentAttribute<String, Object>) arg).getKey(),
                        ((ComponentAttribute<String, Object>) arg).getValue());
            } catch (IllegalAccessException e) {

                e.printStackTrace();
            } catch (InvocationTargetException e) {

                e.printStackTrace();
            } catch (NoSuchMethodException e) {

                e.printStackTrace();
            }
        } else {
            throw new IllegalArgumentException(
                    "selectItem method can only accept ComponentAttributes as arguments");
        }
        decrementIndent();
        System.out.print("end_selectItem\n");

    }
    return selectItem;
}