<commit_before>/*
 * This code is subject to the HIEOS License, Version 1.0
 *
 * Copyright(c) 2008-2009 Vangent, Inc.  All rights reserved.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vangent.hieos.xlog.server;

import com.vangent.hieos.xutil.db.support.SQLConnectionWrapper;
import com.vangent.hieos.xutil.exception.XdsInternalException;
import com.vangent.hieos.xutil.xlog.client.XLogMessage;
import com.vangent.hieos.xutil.xlog.client.XLogMessage.XLogMessageNameValue;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.ObjectMessage;
import javax.jms.JMSException;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Vector;
import java.util.Set;
import java.util.Iterator;

import java.sql.Statement;
import java.sql.Connection;
import java.sql.Timestamp;
import java.sql.ResultSet;

/**
 *
 * @author <NAME>
 */
@MessageDriven(mappedName = "jms/XLogger", activationConfig = {
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class XLoggerBean implements MessageListener {

    /**
     *
     */
    public XLoggerBean() {
    }

    /**
     *
     * @param message
     */
    public void onMessage(Message message) {
        try {
            if (message instanceof ObjectMessage) {
                ObjectMessage m = (ObjectMessage) message;
                Object so = m.getObject();  // Serialized object.
                if (so instanceof XLogMessage) {
                    XLogMessage logMessage = (XLogMessage) so;
                    //System.out.println("******* XLogMessage RECEIVED *******");
                    this.persist(logMessage);
                }
            } else if (message instanceof TextMessage) {
                TextMessage m = (TextMessage) message;
                System.out.println("--- Received message ");
                System.out.println(m.getText());<commit_msg>Added more robust logging support (for debug).<commit_after>/*
 * This code is subject to the HIEOS License, Version 1.0
 *
 * Copyright(c) 2008-2009 Vangent, Inc.  All rights reserved.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vangent.hieos.xlog.server;

import com.vangent.hieos.xutil.db.support.SQLConnectionWrapper;
import com.vangent.hieos.xutil.exception.XdsInternalException;
import com.vangent.hieos.xutil.xlog.client.XLogMessage;
import com.vangent.hieos.xutil.xlog.client.XLogMessage.XLogMessageNameValue;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.ObjectMessage;
import javax.jms.JMSException;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Vector;
import java.util.Set;
import java.util.Iterator;

import java.sql.Statement;
import java.sql.Connection;
import java.sql.Timestamp;
import java.sql.ResultSet;

/**
 *
 * @author <NAME>
 */
@MessageDriven(mappedName = "jms/XLogger", activationConfig = {
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class XLoggerBean implements MessageListener {

    /**
     *
     */
    public XLoggerBean() {
    }

    /**
     *
     * @param message
     */
    public void onMessage(Message message) {
        try {
            if (message instanceof ObjectMessage) {
                ObjectMessage m = (ObjectMessage) message;
                Object so = m.getObject();  // Serialized object.
                if (so instanceof XLogMessage) {
                    XLogMessage logMessage = (XLogMessage) so;
                    this.persist(logMessage);
                }
            } else if (message instanceof TextMessage) {
                TextMessage m = (TextMessage) message;
                System.out.println("--- Received message ");
                System.out.println(m.getText());
{'fraction_non_alphanumeric': 0.10275158745430056, 'fraction_numerical': 0.0038483740619588225, 'mean_word_length': 3.185185185185185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2497510', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1465, 'n_words': 386}