Package org.objectweb.celtix.common.i18n

Examples of org.objectweb.celtix.common.i18n.Message


    }

    public int getInt(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            return ((Integer)obj).intValue();
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here


    }

    public float getFloat(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            return ((Float)obj).floatValue();
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here

    }

    public double getDouble(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            return ((Double)obj).doubleValue();
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here

    }

    public long getLong(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            return ((Long)obj).longValue();
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here

    }

    public String getString(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        if (!(obj instanceof String)) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
        return (String)obj;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public List<String> getStringList(String name) {
        Object obj = getObject(name);
        if (null == obj) {
            throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name));
        }
        try {
            Method method = obj.getClass().getMethod("getItem", new Class[0]);
            obj = method.invoke(obj, new Object[0]);

            return (List<String>)obj;
        } catch (ClassCastException ex) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (NoSuchMethodException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (IllegalAccessException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        } catch (InvocationTargetException e) {
            QName type = model.getDefinition(name).getType();
            throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type));
        }
    }
View Full Code Here

     * @throws ForkedCommandException if process execution fails for some reason
     *             or if the timeout has expired and the process was killed
     */
    public int execute(int timeout) {
        if (null == arguments || arguments.length == 0) {
            throw new ForkedCommandException(new Message("NO_ARGUMENTS_EXC", LOG));
        }
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Executing command: " + this);
        }
        try {
            Runtime rt = Runtime.getRuntime();
            if (environment == null) {
                proc = rt.exec(arguments);
            } else {
                StringBuffer msg = null;
                if (LOG.isLoggable(Level.FINE)) {
                    msg = new StringBuffer();
                    msg.append("Process environment: ");

                    for (int i = 0; i < environment.length; i++) {
                        msg.append(environment[i]);
                        msg.append(" ");
                    }
                    LOG.fine(msg.toString());
                }

                proc = rt.exec(arguments, environment);
            }
        } catch (IOException ex) {
            throw new ForkedCommandException(new Message("EXECUTE_EXC", LOG, this), ex);
        }

        // catch process stderr/stdout
        ForkedCommandStreamHandler cmdOut = new ForkedCommandStreamHandler(proc.getInputStream(),
                                                                           outputStream == null
                                                                               ? System.out : outputStream);
        ForkedCommandStreamHandler cmdErr = new ForkedCommandStreamHandler(proc.getErrorStream(),
                                                                           errorStream == null
                                                                               ? System.err : errorStream);
        cmdErr.start();
        cmdOut.start();

        // now wait for the process on our own thread
        start();

        // kill process after timeout
        try {
            if (timeout > 0) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("Waiting " + timeout + " seconds for process to complete");
                }
                join(timeout * 1000);
            } else {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("Waiting for process to complete");
                }
                join();
            }
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        } finally {
            if (completed) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("Process completed in time");
                }
            } else {
                proc.destroy();
                killed = true;
                LOG.fine("Process timed out and was killed");
            }

            // wait for the streams threads to finish if necessary
            if (joinErrOut) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.info("Waiting a further 10 seconds for process "
                                 + " stdout/stderr streams to be flushed");
                }
                try {
                    cmdErr.join(10 * 1000);
                    cmdOut.join(10 * 1000);
                } catch (InterruptedException ex) {
                    // silently ignore
                }
            }
        }

        if (killed) {
            throw new ForkedCommandException(new Message("TIMEOUT_EXC", LOG, timeout));
        }
        int exitVal = proc.exitValue();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Process exited with value: " + exitVal);
        }
View Full Code Here

        for (SourceType st : stList) {
            Service sourceService = wsdlModel.getService(st.getService());
            if (null == sourceService) {
                throw new WebServiceException(
                            new Message("UNDEFINED_SERVICE", LOG, st.getService()).toString());
            }
            Port sourcePort = sourceService.getPort(st.getPort());
           
            if (null == sourcePort) {
                throw new WebServiceException(
                            new Message("UNDEFINED_PORT", LOG, st.getPort()).toString());               
            }
            sourcePortMap.put(sourceService.getQName(), sourcePort);
        }
    }
View Full Code Here

        for (DestinationType dt : dtList) {
            Service destService = wsdlModel.getService(dt.getService());
            if (null == destService) {
                throw new WebServiceException(
                            new Message("UNDEFINED_SERVICE", LOG, dt.getService()).toString());
            }
            Port destPort = destService.getPort(dt.getPort());
           
            if (null == destPort) {
                throw new WebServiceException(
                            new Message("UNDEFINED_PORT", LOG, dt.getPort()).toString());               
            }
            destPortMap.put(destService.getQName(), destPort);
        }
    }
View Full Code Here

                }
            }
            i++;
        }
        if (!criteria1) {
            Message message = new Message("DOC_BARE_METHOD_CRITERIA1", LOG);
            throw new ToolException(message);
        }
        if (!criteria2) {
            Message message = new Message("DOC_BARE_METHOD_CRITERIA2", LOG);
            throw new ToolException(message);
        }
        criteria3 = nonHeaderParamCount <= 1 ? true : false;
        if (!criteria3) {
            Message message = new Message("DOC_BARE_METHOD_CRITERIA3", LOG);
            throw new ToolException(message);
        }
        return paras;
    }
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.common.i18n.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.