CPD Results

The following document contains the results of PMD's CPD

Duplications

FileLine
org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java62
org/apache/geronimo/gbuild/agent/WriteIncludeFileExtension.java76
    public void start() throws StartingException {
        template = new StringTemplate(fileNameTemplate);
        directory = new File(resultsDirectory);
        directory.mkdirs();

        if (!directory.exists()) {
            throw new IllegalStateException("File specified does not exist. " + directory.getAbsolutePath());
        }

        if (!directory.isDirectory()) {
            throw new IllegalStateException("File specified is not a directory. " + directory.getAbsolutePath());
        }

        if (!directory.canWrite()) {
            throw new IllegalStateException("Directory specified is not writable. " + directory.getAbsolutePath());
        }

        getLogger().info("Include files will be written to " + directory.getAbsolutePath());
        dateFormatter = new SimpleDateFormat(dateFormat);
    }

    public void stop() throws StoppingException {
    }

    public void execute(Map context) throws Exception {

FileLine
org/apache/geronimo/gbuild/agent/FileIncludeExtension.java41
org/apache/geronimo/gbuild/agent/HeaderIncludeExtension.java32
    private String pattern;


    public void preProcess(Map build) {
    }

    public void postProcess(Map build, Map results) {
        getLogger().debug("Pattern '"+pattern+"'");

        Iterator keys = build.keySet().iterator();

        while (keys.hasNext()) {

            String key = (String) keys.next();

            if (key.matches(pattern)){
                getLogger().debug("Match '"+key+"'");
                include(key, build, results);
            } else {
                getLogger().debug("No Match '"+key+"'");
            }
        }
    }

    private void include(String header, Map build, Map results) {

FileLine
org/apache/geronimo/gbuild/agent/BuildActivityMonitor.java65
org/apache/geronimo/gbuild/agent/BuildResultsContinuumAgent.java54
                MessageConsumer resultsConsumer = createConsumer(session, buildResultsTopic);

                try {
                    consumeMessages(client, resultsConsumer);
                } catch (JMSException e) {
                    getLogger().error("Agent recieved JMS Exception. ("+e.getMessage()+")");
                }
            }

        } catch (Exception e) {
            getLogger().error("Agent failed.", e);
        }
    }

    private void consumeMessages(Client client, MessageConsumer resultsConsumer) throws JMSException {
        while (client.isConnected() && isRunning()) {
            // Wait for a message
            Message message = resultsConsumer.receive(1000);

            if (message == null){

                continue;

            } else if (message instanceof ObjectMessage) {

                try {
                    Connection connection = client.getConnection();
                    getLogger().info("Message Received "+ message.getJMSMessageID() +" on "+ connection.getClientID()+":"+buildResultsTopic);